Sha256: 033bf195a302931ba2c1544a1d4577405fe87ba7c2bc69574bc25d6da653d64f

Contents?: true

Size: 567 Bytes

Versions: 10

Compression:

Stored size: 567 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, file.similarity(l)] }.select { |l,sim| sim > 0 }
    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

10 entries across 10 versions & 1 rubygems

Version Path
licensee-4.7.4 lib/licensee/matchers/git_matcher.rb
licensee-4.7.3 lib/licensee/matchers/git_matcher.rb
licensee-4.7.2 lib/licensee/matchers/git_matcher.rb
licensee-4.7.1 lib/licensee/matchers/git_matcher.rb
licensee-4.7.0 lib/licensee/matchers/git_matcher.rb
licensee-4.6.0 lib/licensee/matchers/git_matcher.rb
licensee-4.5.0 lib/licensee/matchers/git_matcher.rb
licensee-4.4.2 lib/licensee/matchers/git_matcher.rb
licensee-4.4.1 lib/licensee/matchers/git_matcher.rb
licensee-4.4.0 lib/licensee/matchers/git_matcher.rb