Sha256: fe1bb9181067371541d8f5b025de0a672f72d12c0a362892b4d34992cbc6ab89

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module LicenseFinder
  class NpmPackage < Package
    def initialize(node_module)
      @node_module = node_module
    end

    def name
      node_module["name"]
    end

    def version
      node_module["version"]
    end

    def summary
      node_module["description"]
    end

    def description
      node_module["readme"]
    end

    def homepage
      node_module["homepage"]
    end

    def children
      [] # no way to determine child deps from npm (maybe?)
    end

    def groups
      [] # no concept of dev/test groups in npm (maybe?)
    end

    private

    attr_reader :node_module

    def install_path
      node_module["path"]
    end

    def license_from_spec
      license = node_module.fetch("licenses", []).first

      if license
        license = license.fetch("type", nil)
      end

      if license.nil?
        license = node_module.fetch("license", nil)

        if license.is_a? Hash
          license = license.fetch("type", nil)
        end
      end

      license
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-0.9.5.1-java lib/license_finder/package_managers/npm_package.rb
license_finder-0.9.5.1 lib/license_finder/package_managers/npm_package.rb