Class: Librarian::Lockfile::Parser
- Inherits:
-
Object
- Object
- Librarian::Lockfile::Parser
- Defined in:
- lib/ext/librarian/lockfile/parser.rb
Instance Method Summary collapse
- #extract_and_parse_dependencies(lines, manifests_index) ⇒ Object
- #extract_and_parse_sources(lines) ⇒ Object
Instance Method Details
#extract_and_parse_dependencies(lines, manifests_index) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/ext/librarian/lockfile/parser.rb', line 39 def extract_and_parse_dependencies(lines, manifests_index) dependencies = [] while lines.first =~ /^ {2}([.\w-]+)(?: \((.*)\))?$/ lines.shift name, requirement = $1, $2.split(/,\s*/) dependencies << Dependency.new(name, requirement, manifests_index[name].source) end dependencies end |
#extract_and_parse_sources(lines) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ext/librarian/lockfile/parser.rb', line 10 def extract_and_parse_sources(lines) sources = [] while source_type_names.include?(lines.first) source = {} source_type_name = lines.shift source[:type] = source_type_names_map[source_type_name] = {} while lines.first =~ /^ {2}([\w-]+):\s+(.+)$/ lines.shift [$1.to_sym] = $2 end source[:options] = lines.shift # specs manifests = {} while lines.first =~ /^ {4}([.\w-]+) \((.*)\)$/ lines.shift name = $1 manifests[name] = {:version => $2, :dependencies => {}} while lines.first =~ /^ {6}([\w-]+) \((.*)\)$/ lines.shift manifests[name][:dependencies][$1] = $2.split(/,\s*/) end end source[:manifests] = manifests sources << source end sources end |