Class: Cbradeps::GemfileScraper

Inherits:
Object
  • Object
show all
Defined in:
lib/cobradeps/gemfile_scraper.rb

Defined Under Namespace

Classes: OptionParser

Instance Method Summary collapse

Constructor Details

#initialize(root_path) ⇒ GemfileScraper

Returns a new instance of GemfileScraper.



3
4
5
# File 'lib/cobradeps/gemfile_scraper.rb', line 3

def initialize(root_path)
  @root_path = root_path
end

Instance Method Details

#cobra_dependenciesObject



15
16
17
18
19
20
# File 'lib/cobradeps/gemfile_scraper.rb', line 15

def cobra_dependencies
  dirdep = direct_dependencies
  transitive_cobra_dependencies.select do |dep|
    dirdep.include?(dep[:name]) || dep[:options][:direct]
  end
end

#nameObject



7
8
9
# File 'lib/cobradeps/gemfile_scraper.rb', line 7

def name
  Pathname.new(@root_path).basename.to_s
end

#to_sObject



11
12
13
# File 'lib/cobradeps/gemfile_scraper.rb', line 11

def to_s
  cobra_dependencies
end

#transitive_cobra_dependenciesObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/cobradeps/gemfile_scraper.rb', line 22

def transitive_cobra_dependencies
  gem_dependencies.inject([]) do |memo, dep|
    if !!dep[:options][:path]
      absolute_dep = dep.clone
      absolute_dep[:options][:path] = File.expand_path(File.join(@root_path, dep[:options][:path]))
      memo << dep
    end
    memo
  end
end