Sha256: 16896e3e9952e7a373f6c82811af76055654dc37aad3d9b27ad16a86edc7366e

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'json'

module Papers
  class BowerComponent < DependencySpecification
    def pretty_hash
      {
        name: name_without_version,
        license: license,
        license_url: @license_url,
        project_url: @project_url
      }
    end

    def self.introspected
      full_introspected_entries.map { |e| e['name'] }
    end

    def self.full_introspected_entries
      whitelisted_license = Papers.config.version_whitelisted_license
      bower_json_entries.map do |entry|
        name =
          if whitelisted_license != nil && whitelisted_license == entry['license']
            entry['name']
          else
            "#{entry['name']}-#{entry['_release']}"
          end
        {
          'name' => name,
          'homepage' => entry['homepage']
        }
      end
    end

    def self.bower_json_entries
      json_files = Dir["#{Papers.config.bower_components_path}/*/.bower.json"]
      json_files.map do |path|
        JSON.parse File.read(path)
      end
    end

    def self.manifest_key
      "bower_components"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
papers-2.1.0 lib/papers/dependency_specification/bower_component.rb
papers-2.0.0 lib/papers/dependency_specification/bower_component.rb