Sha256: 14b4413df643a04a8b4dc0f282da2b84e2ac2d30eea558c40582a571546d7ffe

Contents?: true

Size: 639 Bytes

Versions: 15

Compression:

Stored size: 639 Bytes

Contents

class Licensee
  class GitMatcher < Matcher

    def match
      match_info[0] unless match_info.nil?
    end

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

    private

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

    def similarity(other)
      file.blob.similarity(other.hashsig)
    end

    # Pulled out for easier testing
    def match_info
      @match_info ||= begin
        match = matches.max_by { |license, similarity| similarity }
        match if match && match[1] > Licensee::CONFIDENCE_THRESHOLD
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
licensee-4.3.3 lib/licensee/matchers/git_matcher.rb
licensee-4.3.2 lib/licensee/matchers/git_matcher.rb
licensee-4.3.1 lib/licensee/matchers/git_matcher.rb
licensee-4.3.0 lib/licensee/matchers/git_matcher.rb
licensee-4.2.4 lib/licensee/matchers/git_matcher.rb
licensee-4.2.3 lib/licensee/matchers/git_matcher.rb
licensee-4.2.2 lib/licensee/matchers/git_matcher.rb
licensee-4.2.1 lib/licensee/matchers/git_matcher.rb
licensee-4.2.0 lib/licensee/matchers/git_matcher.rb
licensee-4.1.2 lib/licensee/matchers/git_matcher.rb
licensee-4.1.1 lib/licensee/matchers/git_matcher.rb
licensee-4.1.0 lib/licensee/matchers/git_matcher.rb
licensee-4.0.1 lib/licensee/matchers/git_matcher.rb
licensee-4.0.0 lib/licensee/matchers/git_matcher.rb
licensee-3.0.0 lib/licensee/matchers/git_matcher.rb