Class: Avm::EacRubyBase1::Rubygems::GemSearchParser

Inherits:
Aranha::Parsers::Base
  • Object
show all
Defined in:
lib/avm/eac_ruby_base1/rubygems/gem_search_parser.rb

Defined Under Namespace

Classes: GEM_STRUCT

Constant Summary collapse

LINE_PARSER =
/\A\s*(\S+)\s*\(([^)]+)\)\s*\z/.to_parser do |m|
  GEM_STRUCT.new(m[1], m[2].split(',').map(&:strip).reject(&:blank?))
end

Instance Method Summary collapse

Instance Method Details

#dataHash<String, Enumerable<String>]

Returns Hash<String, Enumerable<String>].

Returns:

  • (Hash<String, Enumerable<String>])

    Hash<String, Enumerable<String>]



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/avm/eac_ruby_base1/rubygems/gem_search_parser.rb', line 13

def data
  r = {}
  content.each_line do |line|
    parse_line(line).then do |line_parsed|
      next if line.blank?

      r[line_parsed.name] = line_parsed.versions
    end
  end
  r
end

#parse_line(line) ⇒ GEM_STRUCT

Parameters:

  • line (String)

Returns:



27
28
29
30
# File 'lib/avm/eac_ruby_base1/rubygems/gem_search_parser.rb', line 27

def parse_line(line)
  stripped_line = line.to_s.strip
  stripped_line.if_present(nil) { |v| LINE_PARSER.parse!(v) }
end