Sha256: 50ab5970aac97c09302b8659f4932221f5c201cae06d60d0c855df11179060b8
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
class Licensee class LicenseFile attr_reader :blob, :path def initialize(blob, options={}) @blob = blob @path = options[:path] end def similarity(other) blob.hashsig(Rugged::Blob::HashSignature::WHITESPACE_SMART) other.hashsig ? blob.similarity(other.hashsig) : 0 rescue Rugged::InvalidError 0 end # Raw file contents def content @contents ||= begin blob.content end end alias_method :to_s, :content alias_method :contents, :content # File content with all whitespace replaced with a single space def content_normalized @content_normalized ||= content.downcase.gsub(/\s+/, " ").strip end # Comptutes a diff between known license and project license def diff(options={}) options = options.merge(:reverse => true) blob.diff(match.body, options).to_s if match end # Determines which matching strategy to use, returns an instane of that matcher def matcher @matcher ||= Licensee.matchers.map { |m| m.new(self) }.find { |m| m.match } end # Returns an Licensee::License instance of the matches license def match @match ||= matcher.match if matcher end # Returns the percent confident with the match def confidence @condience ||= matcher.confidence if matcher end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
licensee-4.7.2 | lib/licensee/license_file.rb |
licensee-4.7.1 | lib/licensee/license_file.rb |
licensee-4.7.0 | lib/licensee/license_file.rb |
licensee-4.6.0 | lib/licensee/license_file.rb |