Method: Gonzui::LicenseDetector#detect

Defined in:
lib/gonzui/license.rb

#detectObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/gonzui/license.rb', line 80

def detect
  candidates = []
  LicenseRegistry.each {|license|
    if m = license.regexp.match(@chunk)
      if allow_later?
        license = license.clone
        license.allow_later
      end
      candidates.push([m[0].length, license])
    end
  }
  if candidates.empty?
    return OtherLicense
  else
    license_of_shortest_match = 
      candidates.min {|a, b| a.first <=> b.first }.last
    return license_of_shortest_match
  end
end