Sha256: 5eee09b61320352ac4d5704f78d8028facea7d323658cd1fd75ff8c831f3e48c

Contents?: true

Size: 513 Bytes

Versions: 27

Compression:

Stored size: 513 Bytes

Contents

require 'sdl4r'

class SdlParser
  attr_reader :contents, :type
  def initialize(type, contents)
    @contents = contents
    @type = type || 'runtime'
  end

  def to_json
    Oj.dump(dependencies, mode: :compat) unless contents.nil?
  end

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

  def parse
    SDL4R::read(contents)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
bibliothecary-4.0.4 lib/sdl_parser.rb
bibliothecary-4.0.3 lib/sdl_parser.rb
bibliothecary-4.0.2 lib/sdl_parser.rb
bibliothecary-4.0.1 lib/sdl_parser.rb
bibliothecary-4.0.0 lib/sdl_parser.rb
bibliothecary-3.0.1 lib/sdl_parser.rb
bibliothecary-3.0.0 lib/sdl_parser.rb
bibliothecary-2.0.1 lib/sdl_parser.rb
bibliothecary-2.0.0 lib/sdl_parser.rb
bibliothecary-1.4.2 lib/sdl_parser.rb
bibliothecary-1.4.1 lib/sdl_parser.rb
bibliothecary-1.4.0 lib/sdl_parser.rb
bibliothecary-1.3.0 lib/sdl_parser.rb
bibliothecary-1.2.1 lib/sdl_parser.rb
bibliothecary-1.2.0 lib/sdl_parser.rb
bibliothecary-1.1.0 lib/sdl_parser.rb
bibliothecary-1.0.0 lib/sdl_parser.rb
bibliothecary-0.16.1 lib/sdl_parser.rb
bibliothecary-0.16.0 lib/sdl_parser.rb
bibliothecary-0.15.2 lib/sdl_parser.rb