mirror of https://github.com/licensee/licensee.git
use parallel
This commit is contained in:
parent
ae2464a7cf
commit
084175819f
|
@ -1,6 +1,7 @@
|
|||
require 'fuzzystringmatch'
|
||||
require 'yaml'
|
||||
require 'diffy'
|
||||
require 'parallel'
|
||||
|
||||
require_relative "licensee/license"
|
||||
require_relative "licensee/licenses"
|
||||
|
|
|
@ -59,8 +59,9 @@ class Licensee
|
|||
|
||||
def matches
|
||||
@matches ||= begin
|
||||
licenses_sorted.each { |l| l.match = distance(l) }
|
||||
licenses_sorted.sort_by { |l| l.match }.select { |l| l.match > 0}.reverse
|
||||
results = Parallel.map_with_index(potential_licenses) { |l,index| [distance(l), index] }
|
||||
results.each { |distance,index| potential_licenses[index].match = distance }
|
||||
potential_licenses.sort_by { |l| l.match }.reverse
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_dependency('levenshtein-ffi', '~> 1.1')
|
||||
gem.add_dependency('fuzzy-string-match', '~> 0.9')
|
||||
gem.add_dependency('diffy', '~> 3.0')
|
||||
gem.add_dependency('parallel')
|
||||
gem.add_development_dependency('pry', '~> 0.9')
|
||||
gem.add_development_dependency('shoulda', '~> 3.5')
|
||||
gem.add_development_dependency('rake', '~> 10.3')
|
||||
|
|
Loading…
Reference in New Issue