Sha256: 0b74c1d6b2b7b07c723474cd926b13dff020c7d9439a14db4a51c2d3c1341955

Contents?: true

Size: 681 Bytes

Versions: 9

Compression:

Stored size: 681 Bytes

Contents

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

      def initialize(content, filename = nil)
        @content = content
        options = { invalid: :replace, undef: :replace, replace: '' }
        @content.encode!(Encoding::UTF_8, 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

9 entries across 9 versions & 1 rubygems

Version Path
licensee-8.5.0 lib/licensee/project_file.rb
licensee-8.4.0 lib/licensee/project_file.rb
licensee-8.3.1 lib/licensee/project_file.rb
licensee-8.3.0 lib/licensee/project_file.rb
licensee-8.2.0 lib/licensee/project_file.rb
licensee-8.1.0 lib/licensee/project_file.rb
licensee-8.0.0 lib/licensee/project_file.rb
licensee-7.0.1 lib/licensee/project_file.rb
licensee-7.0.0 lib/licensee/project_file.rb