Sha256: ecac595ee66ecf535baed1fac3aff01207f428c7efb4aa7dbdde4dd388d11c92

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module Licensee
  module ProjectFiles
    class PackageManagerFile < Licensee::ProjectFiles::ProjectFile
      # Hash of Extension => [possible matchers]
      MATCHERS_EXTENSIONS = {
        '.gemspec' => [Matchers::Gemspec],
        '.json'    => [Matchers::NpmBower],
        '.cabal'   => [Matchers::Cabal]
      }.freeze

      # Hash of Filename => [possible matchers]
      FILENAMES_EXTENSIONS = {
        'DESCRIPTION' => [Matchers::Cran],
        'dist.ini'    => [Matchers::DistZilla]
      }.freeze

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

      def self.name_score(filename)
        return 1.0  if ['.gemspec', '.cabal'].include?(File.extname(filename))
        return 1.0  if filename == 'package.json'
        return 0.8  if filename == 'dist.ini'
        return 0.9  if filename == 'DESCRIPTION'
        return 0.75 if filename == 'bower.json'
        0.0
      end

      private

      def extension
        @extension ||= File.extname(filename)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
licensee-9.6.0 lib/licensee/project_files/package_manager_file.rb
licensee-9.5.0 lib/licensee/project_files/package_manager_file.rb
licensee-9.4.0 lib/licensee/project_files/package_manager_file.rb
licensee-9.3.1 lib/licensee/project_files/package_manager_file.rb
licensee-9.3.0 lib/licensee/project_files/package_manager_file.rb
licensee-9.2.1 lib/licensee/project_files/package_manager_file.rb
licensee-9.2.0 lib/licensee/project_files/package_manager_file.rb
licensee-9.1.0 lib/licensee/project_files/package_manager_file.rb
licensee-9.0.0 lib/licensee/project_files/package_manager_file.rb
licensee-9.0.0.beta.1 lib/licensee/project_files/package_manager_file.rb