Sha256: ecef6a03d5cf96e4bfce684e783e1ff650294aebf97904f6503f0aa9bb62a206

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

require_relative 'licensee/version'
require 'forwardable'
require 'pathname'
require 'yaml'

module Licensee
  autoload :ContentHelper, 'licensee/content_helper'
  autoload :HashHelper, 'licensee/hash_helper'
  autoload :License, 'licensee/license'
  autoload :LicenseField, 'licensee/license_field'
  autoload :LicenseMeta, 'licensee/license_meta'
  autoload :LicenseRules, 'licensee/license_rules'
  autoload :Rule, 'licensee/rule'
  autoload :Matchers, 'licensee/matchers'
  autoload :Projects, 'licensee/projects'
  autoload :ProjectFiles, 'licensee/project_files'

  # Over which percent is a match considered a match by default
  CONFIDENCE_THRESHOLD = 98

  # Base domain from which to build license URLs
  DOMAIN = 'http://choosealicense.com'.freeze

  class << self
    attr_writer :confidence_threshold

    # Returns an array of Licensee::License instances
    def licenses(options = {})
      Licensee::License.all(options)
    end

    # Returns the license for a given path
    def license(path)
      Licensee.project(path).license
    end

    def project(path, **args)
      if path =~ %r{\Ahttps://github.com}
        Licensee::Projects::GitHubProject.new(path, args)
      else
        Licensee::Projects::GitProject.new(path, args)
      end
    rescue Licensee::Projects::GitProject::InvalidRepository
      Licensee::Projects::FSProject.new(path, args)
    end

    def confidence_threshold
      @confidence_threshold ||= CONFIDENCE_THRESHOLD
    end

    # Inverse of the confidence threshold, represented as a float
    # By default this will be 0.05
    def inverse_confidence_threshold
      @inverse_confidence_threshold ||=
        (1 - Licensee.confidence_threshold / 100.0).round(2)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
licensee-9.11.0 lib/licensee.rb
licensee-9.10.1 lib/licensee.rb
licensee-9.10.0 lib/licensee.rb
licensee-9.9.4 lib/licensee.rb
licensee-9.9.3 lib/licensee.rb
licensee-9.9.2 lib/licensee.rb