Class: Gemkeeper::ManifestReader

Inherits:
Object
  • Object
show all
Defined in:
lib/gemkeeper/manifest_reader.rb

Constant Summary collapse

DEFAULT_PATH =
File.expand_path("~/.config/gemkeeper/manifest.yml")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ManifestReader

Returns a new instance of ManifestReader.



15
16
17
18
19
20
# File 'lib/gemkeeper/manifest_reader.rb', line 15

def initialize(path)
  @path = path
  raise ManifestNotFoundError, manifest_not_found_message unless File.exist?(@path)

  parse_manifest
end

Instance Attribute Details

#gemsObject (readonly)

Returns the value of attribute gems.



9
10
11
# File 'lib/gemkeeper/manifest_reader.rb', line 9

def gems
  @gems
end

#source_urlObject (readonly)

Returns the value of attribute source_url.



9
10
11
# File 'lib/gemkeeper/manifest_reader.rb', line 9

def source_url
  @source_url
end

Class Method Details

.load(path = DEFAULT_PATH) ⇒ Object



11
12
13
# File 'lib/gemkeeper/manifest_reader.rb', line 11

def self.load(path = DEFAULT_PATH)
  new(path)
end

Instance Method Details

#find_by_name(name) ⇒ Object



26
27
28
# File 'lib/gemkeeper/manifest_reader.rb', line 26

def find_by_name(name)
  @gems.find { |gem_entry| gem_entry[:name] == name }
end

#gem_namesObject



22
23
24
# File 'lib/gemkeeper/manifest_reader.rb', line 22

def gem_names
  @gems.map { |gem_entry| gem_entry[:name] }
end