Sha256: 4cb49d68a40638403444165717199779e4452703ed4495fed1163ec7e53526a1

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 Bytes

Contents

class Licensee
  class Project
    private

    class File
      attr_reader :content, :filename

      def initialize(content, filename = nil)
        @content = content
        @content.encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace, :replace => "")
        @filename = filename
      end

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

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

      def license
        matcher && matcher.match
      end

      alias_method :match, :license
      alias_method :path, :filename
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
licensee-6.1.1 lib/licensee/project_file.rb
licensee-6.1.0 lib/licensee/project_file.rb