Class: SdlParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, contents) ⇒ SdlParser

Returns a new instance of SdlParser.



5
6
7
8
# File 'lib/sdl_parser.rb', line 5

def initialize(type, contents)
  @contents = contents
  @type = type || "runtime"
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



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

def contents
  @contents
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#dependenciesObject



10
11
12
13
14
15
16
17
18
# File 'lib/sdl_parser.rb', line 10

def dependencies
  parse.children("dependency").inject([]) do |deps, dep|
    deps.push(Bibliothecary::Dependency.new(
      name: dep.value,
      requirement: dep.attribute("version") || ">= 0",
      type: type,
    ))
  end.uniq
end

#parseObject



20
21
22
# File 'lib/sdl_parser.rb', line 20

def parse
  SDL4R::read(contents)
end