class Gemnasium::Parser::Gemspec

Attributes

content[R]

Public Class Methods

new(content) click to toggle source
# File lib/gemnasium/parser/gemspec.rb, line 6
def initialize(content)
  @content = content
end

Public Instance Methods

dependencies() click to toggle source
# File lib/gemnasium/parser/gemspec.rb, line 10
def dependencies
  @dependencies ||= [].tap do |deps|
    runtime_matches.each do |match|
      dep = dependency(match)
      deps << dep
    end
  end
end

Private Instance Methods

dependency(match) click to toggle source
# File lib/gemnasium/parser/gemspec.rb, line 28
def dependency(match)
  name, reqs = match["name"], [match["req1"], match["req2"]].compact
  type = match["type"] =~ /development/ ? :development : :runtime
  Bundler::Dependency.new(name, reqs, "type" => type).tap do |dep|
    line = content.slice(0, match.begin(0)).count("\n") + 1
    dep.instance_variable_set(:@line, line)
  end
end
matches(pattern) click to toggle source
# File lib/gemnasium/parser/gemspec.rb, line 24
def matches(pattern)
  [].tap{|m| content.scan(pattern){ m << Regexp.last_match } }
end
runtime_matches() click to toggle source
# File lib/gemnasium/parser/gemspec.rb, line 20
def runtime_matches
  @runtime_matches ||= matches(Patterns::ADD_DEPENDENCY_CALL)
end