lib/gemirro/utils.rb in gemirro-1.2.0 vs lib/gemirro/utils.rb in gemirro-1.3.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Gemirro ## # The Utils class is responsible for executing specific traitments # that are located at least on two other files # @@ -14,10 +16,11 @@ attr_reader(:cache, :versions_fetcher, :gems_fetcher, :gems_collection, :stored_gems) + ## # Cache class to store marshal and data into files # # @return [Gemirro::Cache] # @@ -42,19 +45,21 @@ file_paths = specs_files_paths(orig) has_file_changed = false 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 data[:values] if !has_file_changed && !data[:values].nil? gems = [] 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 collection = GemVersionCollection.new(gems) @@ -73,10 +78,10 @@ marshal_version = Gemirro::Configuration.marshal_version 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('.')) + "gz#{orig ? '.orig' : ''}"].join('.')) end end ## # Return specs fils types