Sha256: 9448b6459dc66736019cae4c417f5e903dc374c0937cea33f077191ea63bfe48

Contents?: true

Size: 880 Bytes

Versions: 4

Compression:

Stored size: 880 Bytes

Contents

require 'json'

module Papers
  class NpmPackage < DependencySpecification
    def self.introspected
      full_introspected_entries.map {|e| "#{e['name']}-#{e['version']}"}
    end

    def self.full_introspected_entries
      packages = (package['dependencies'] || {}).merge((package['devDependencies'] || {}))
      packages.map do |name, version|
        version.sub!(/^\D+/, '')
        {
          'name' => name,
          'version' => version
        }
      end
    end

    def pretty_hash
      {
        name: name_without_version,
        license: license,
        license_url: @license_url,
        project_url: @project_url
      }
    end

    def self.manifest_key
      "npm_packages"
    end

    private

    def self.package
      pkg = File.read(Papers.config.npm_package_json_path)
      JSON.parse(pkg)
    rescue Errno::ENOENT
      {}
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
papers-2.1.0 lib/papers/dependency_specification/npm_package.rb
papers-2.0.0 lib/papers/dependency_specification/npm_package.rb
papers-1.4.0 lib/papers/dependency_specification/npm_package.rb
papers-1.3.2 lib/papers/dependency_specification/npm_package.rb