Sha256: 026a12d11da1acc62213c22cec0738a2eb3d9a56896a979c8e6fde42d062f862

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

class Licensee
  class GitMatcher < Matcher

    def match
      match_info[0] if match_info && match_info[1] >= Licensee.confidence_threshold
    end

    def confidence
      match_info[1] unless match_info.nil?
    end

    private

    def matches
      @matches ||= Licensee.licenses(:hidden => true).map { |l| [l, file.similarity(l)] }.select { |l,sim| sim > 0 }
    end

    # Pulled out for easier testing
    def match_info
      return @match_info if defined? @match_info
      @match_info = begin
        match = matches.max_by { |license, similarity| similarity }
        match if match
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
licensee-5.0.0 lib/licensee/matchers/git_matcher.rb