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, source = nil) ⇒ SdlParser

Returns a new instance of SdlParser.



8
9
10
11
12
# File 'lib/sdl_parser.rb', line 8

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



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

def contents
  @contents
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#dependenciesObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/sdl_parser.rb', line 14

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

#parseObject



25
26
27
# File 'lib/sdl_parser.rb', line 25

def parse
  SDL4R.read(contents)
end