Sha256: c5f994a27a7bf6af40393d6ce7dc9d0017d21f9c59455c727ba1bf8d76c4f499

Contents?: true

Size: 763 Bytes

Versions: 10

Compression:

Stored size: 763 Bytes

Contents

module Licensee
  class Project
    class File
      attr_reader :content, :filename

      ENCODING = Encoding::UTF_8
      ENCODING_OPTIONS = {
        invalid: :replace,
        undef:   :replace,
        replace: ''
      }.freeze

      def initialize(content, filename = nil)
        @content = content
        @content.encode!(ENCODING, ENCODING_OPTIONS)
        @filename = filename
      end

      def matcher
        @matcher ||= possible_matchers.map { |m| m.new(self) }.find(&:match)
      end

      # Returns the percent confident with the match
      def confidence
        matcher && matcher.confidence
      end

      def license
        matcher && matcher.match
      end

      alias match license
      alias path filename
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
licensee-8.9.0 lib/licensee/project_file.rb
licensee-8.8.5 lib/licensee/project_file.rb
licensee-8.8.4 lib/licensee/project_file.rb
licensee-8.8.3 lib/licensee/project_file.rb
licensee-8.8.2 lib/licensee/project_file.rb
licensee-8.8.1 lib/licensee/project_file.rb
licensee-8.8.0 lib/licensee/project_file.rb
licensee-8.7.0 lib/licensee/project_file.rb
licensee-8.6.1 lib/licensee/project_file.rb
licensee-8.6.0 lib/licensee/project_file.rb