Class: Librarian::Lockfile::Parser
- Inherits:
-
Object
- Object
- Librarian::Lockfile::Parser
- Defined in:
- lib/librarian/lockfile/parser.rb
Defined Under Namespace
Classes: ManifestPlaceholder
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
-
#initialize(environment) ⇒ Parser
constructor
A new instance of Parser.
- #parse(string) ⇒ Object
Constructor Details
#initialize(environment) ⇒ Parser
Returns a new instance of Parser.
19 20 21 |
# File 'lib/librarian/lockfile/parser.rb', line 19 def initialize(environment) self.environment = environment end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
16 17 18 |
# File 'lib/librarian/lockfile/parser.rb', line 16 def environment @environment end |
Instance Method Details
#parse(string) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/librarian/lockfile/parser.rb', line 23 def parse(string) lines = string.lines.map{|l| l.sub(/\s+\z/, '')}.reject(&:empty?) sources = extract_and_parse_sources(lines) manifests = compile(sources) manifests_index = Hash[manifests.map{|m| [m.name, m]}] raise StandardError, "Expected DEPENDENCIES topic!" unless lines.shift == "DEPENDENCIES" dependencies = extract_and_parse_dependencies(lines, manifests_index) Resolution.new(dependencies, manifests) end |