lib/gemirro/utils.rb in gemirro-0.13.5 vs lib/gemirro/utils.rb in gemirro-0.14.0
- old
+ new
@@ -1,7 +1,5 @@
-# -*- coding: utf-8 -*-
-
module Gemirro
##
# The Utils class is responsible for executing specific traitments
# that are located at least on two other files
#
@@ -41,21 +39,21 @@
data = @gems_collection[is_orig]
data = { files: {}, values: nil } if data.nil?
file_paths = specs_files_paths(orig)
has_file_changed = false
- file_paths.pmap do |file_path|
+ Parallel.map(file_paths, in_threads: 4) do |file_path|
next if data[:files].key?(file_path) &&
data[:files][file_path] == File.mtime(file_path)
has_file_changed = true
end
# Return result if no file changed
- return @gems_collection[is_orig][:values] unless has_file_changed
+ return data[:values] if !has_file_changed && !data[:values].nil?
gems = []
- file_paths.pmap do |file_path|
+ Parallel.map(file_paths, in_threads: 4) do |file_path|
next unless File.exist?(file_path)
gems.concat(Marshal.load(Zlib::GzipReader.open(file_path).read))
data[:files][file_path] = File.mtime(file_path)
end
@@ -71,11 +69,11 @@
# @param [TrueClass|FalseClass] orig Fetch orig files
# @return [Array]
#
def self.specs_files_paths(orig = true)
marshal_version = Gemirro::Configuration.marshal_version
- specs_file_types.pmap do |specs_file_type|
+ Parallel.map(specs_file_types, in_threads: 4) do |specs_file_type|
File.join(configuration.destination,
[specs_file_type,
marshal_version,
'gz' + (orig ? '.orig' : '')].join('.'))
end
@@ -85,10 +83,10 @@
# Return specs fils types
#
# @return [Array]
#
def self.specs_file_types
- [:specs, :prerelease_specs]
+ %i[specs prerelease_specs]
end
##
# @see Gemirro::Configuration#logger
# @return [Logger]