Sha256: 6b8791c063581f1b5f903ab97365bbfb0af98fdbc829596e6c14a9560c5d91a4

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

require 'json'

module Bibliothecary
  module Parsers
    class Bower
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^bower\.json$/ => :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

3 entries across 3 versions & 1 rubygems

Version Path
bibliothecary-5.0.2 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.0.1 lib/bibliothecary/parsers/bower.rb
bibliothecary-5.0.0 lib/bibliothecary/parsers/bower.rb