use parallel

This commit is contained in:
Ben Balter 2014-09-28 14:19:29 -05:00
parent ae2464a7cf
commit 084175819f
3 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,7 @@
require 'fuzzystringmatch'
require 'yaml'
require 'diffy'
require 'parallel'
require_relative "licensee/license"
require_relative "licensee/licenses"

View File

@ -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

View File

@ -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')