Class: Whally::GemsExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/whally/gems_extractor.rb

Overview

Extract gems from a gemfile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pathfile) ⇒ GemsExtractor

Returns a new instance of GemsExtractor.



6
7
8
9
10
11
# File 'lib/whally/gems_extractor.rb', line 6

def initialize(pathfile)
  @pathfile = pathfile
  @collect = []

  gems
end

Instance Attribute Details

#collectObject (readonly)

Returns the value of attribute collect.



4
5
6
# File 'lib/whally/gems_extractor.rb', line 4

def collect
  @collect
end

Instance Method Details

#gemsObject



13
14
15
16
17
18
19
20
21
# File 'lib/whally/gems_extractor.rb', line 13

def gems
  normalize_pathfile

  file = File.open(@pathfile, 'r')

  file.each_line do |line|
    @collect << Whally::Gemline.new(line).to_gem
  end
end

#normalize_pathfileObject



23
24
25
# File 'lib/whally/gems_extractor.rb', line 23

def normalize_pathfile
  @pathfile += '/Gemfile' unless @pathfile.include? 'Gemfile'
end