Sha256: cf3c29e6f661d523456af33324be68b1f66ab6d7615eddcf9792f27d16f1527d

Contents?: true

Size: 736 Bytes

Versions: 7

Compression:

Stored size: 736 Bytes

Contents

require 'json'

module Bibliothecary
  module Parsers
    class Bower
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^bower\.json$/ => {
            kind: 'manifest',
            parser: :parse_manifest
          }
        }
      end

      def self.parse_manifest(manifest)
        json = JSON.parse(manifest)
        map_dependencies(json, 'dependencies', 'runtime') +
        map_dependencies(json, 'devDependencies', 'development')
      end

      def self.map_dependencies(hash, key, type)
        hash.fetch(key,[]).map do |name, requirement|
          {
            name: name,
            requirement: requirement,
            type: type
          }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bibliothecary-5.3.4 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.3.3 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.3.2 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.3.1 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.3.0 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.2.0 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.1.0 lib/bibliothecary/parsers/bower.rb