Class: Licensee::ProjectFiles::PackageManagerFile

Inherits:
ProjectFile
  • Object
show all
Defined in:
lib/licensee/project_files/package_manager_file.rb

Constant Summary collapse

MATCHERS_EXTENSIONS =

Hash of Extension => [possible matchers]

{
  '.gemspec' => [Matchers::Gemspec],
  '.json'    => [Matchers::NpmBower],
  '.cabal'   => [Matchers::Cabal],
  '.nuspec'  => [Matchers::NuGet]
}.freeze
FILENAMES_EXTENSIONS =

Hash of Filename => [possible matchers]

{
  'DESCRIPTION'  => [Matchers::Cran],
  'dist.ini'     => [Matchers::DistZilla],
  'LICENSE.spdx' => [Matchers::Spdx],
  'Cargo.toml'   => [Matchers::Cargo]
}.freeze
FILENAMES_SCORES =
{
  'package.json'     => 1.0,
  'LICENSE.spdx'     => 1.0,
  'Cargo.toml'       => 1.0,
  'DESCRIPTION'      => 0.9,
  'dist.ini'         => 0.8,
  'bower.json'       => 0.75,
  'elm-package.json' => 0.7
}.freeze

Constants inherited from ProjectFile

Licensee::ProjectFiles::ProjectFile::ENCODING, Licensee::ProjectFiles::ProjectFile::ENCODING_OPTIONS, Licensee::ProjectFiles::ProjectFile::HASH_METHODS

Instance Attribute Summary

Attributes inherited from ProjectFile

#content

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ProjectFile

#attribution, #confidence, #content_hash, #content_normalized, #copyright?, #directory, #filename, #initialize, #license, #matched_license, #matcher, #path_relative_to_root

Methods included from HashHelper

#to_h

Constructor Details

This class inherits a constructor from Licensee::ProjectFiles::ProjectFile

Class Method Details

.name_score(filename) ⇒ Object



36
37
38
39
40
# File 'lib/licensee/project_files/package_manager_file.rb', line 36

def self.name_score(filename)
  return 1.0 if ['.gemspec', '.cabal', '.nuspec'].include?(File.extname(filename))

  FILENAMES_SCORES[filename] || 0.0
end

Instance Method Details

#possible_matchersObject



32
33
34
# File 'lib/licensee/project_files/package_manager_file.rb', line 32

def possible_matchers
  MATCHERS_EXTENSIONS[extension] || FILENAMES_EXTENSIONS[filename] || []
end