Sha256: bfe7714872ff2844f363121c162be54613368c22a597be22142fab2db65f9ce1

Contents?: true

Size: 1003 Bytes

Versions: 21

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

require 'open-uri'

module LicenseFinder
  class BowerPackage < Package
    def initialize(bower_module, options = {})
      spec = bower_module.fetch('pkgMeta', {})

      if spec.empty?
        endpoint = bower_module.fetch('endpoint', {})
        name = endpoint['name']
        version = endpoint['target']
      else
        name = spec['name']
        version = spec['version']
      end

      super(
        name,
        version,
        options.merge(
          summary: spec['description'],
          description: spec['readme'],
          homepage: spec['homepage'],
          spec_licenses: Package.license_names_from_standard_spec(spec),
          install_path: bower_module['canonicalDir'],
          missing: bower_module['missing']
        )
      )
    end

    def package_manager
      'Bower'
    end

    def package_url
      meta = JSON.parse(open("https://registry.bower.io/packages/#{CGI.escape(name)}").read)
      meta['url']
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
license_finder-6.15.0 lib/license_finder/packages/bower_package.rb
gitlab-license_finder-6.14.2.1 lib/license_finder/packages/bower_package.rb
license_finder-6.14.2 lib/license_finder/packages/bower_package.rb
license_finder-6.14.1 lib/license_finder/packages/bower_package.rb
license_finder-6.13.0 lib/license_finder/packages/bower_package.rb
license_finder-6.12.2 lib/license_finder/packages/bower_package.rb
license_finder-6.12.1 lib/license_finder/packages/bower_package.rb
license_finder-6.12.0 lib/license_finder/packages/bower_package.rb
license_finder-6.11.0 lib/license_finder/packages/bower_package.rb
license_finder-6.10.1 lib/license_finder/packages/bower_package.rb
license_finder-6.10.0 lib/license_finder/packages/bower_package.rb
license_finder-6.9.0 lib/license_finder/packages/bower_package.rb
license_finder-6.8.2 lib/license_finder/packages/bower_package.rb
license_finder-6.8.1 lib/license_finder/packages/bower_package.rb
license_finder-6.8.0 lib/license_finder/packages/bower_package.rb
license_finder-6.7.0 lib/license_finder/packages/bower_package.rb
license_finder-6.6.2 lib/license_finder/packages/bower_package.rb
license_finder-6.6.1 lib/license_finder/packages/bower_package.rb
license_finder-6.6.0 lib/license_finder/packages/bower_package.rb
license_finder-6.5.0 lib/license_finder/packages/bower_package.rb