lib/drg/tasks/active_pinner.rb in drg-0.9.2 vs lib/drg/tasks/active_pinner.rb in drg-0.9.3

- old
+ new

@@ -1,19 +1,18 @@ module DRG module Tasks class ActivePinnner include Log - attr_reader :gemfile, :type, :updated_gems + attr_reader :gemfile, :type attr_writer :versions # @param [Symbol] type of pin to perform. Available options are [:available, :minor, :patch] def initialize(type = :patch) @type = type @gemfile = Gemfile.new @versions = {} - @updated_gems = Set.new end def perform(gem_name = nil) if gem_name update gem_name @@ -21,12 +20,15 @@ Updater.new.perform do |gems| load_versions gems gems.each &method(:update) end end - gemfile.write if gemfile.saved_lines.any? - log %Q(Done.#{' You may want run `bundle update`' if updated_gems.any?}) + log %Q(Done) + if gemfile.saved_lines.any? + gemfile.write + log %Q(You may want run `bundle update`) + end end # @note calls #latest_minor_version and #latest_patch_version def update(gem_name) spec = ::Bundler.locked_gems.specs.find { |spec| spec.name == gem_name } @@ -34,11 +36,10 @@ if gem latest_version = public_send("latest_#{type}_version", spec.name, spec.version) if latest_version log %Q(Updating "#{spec.name}" from #{spec.version.to_s} to #{latest_version}) gemfile.update gem, latest_version - updated_gems << gem.name else log %Q(No newer #{type} versions found) end end end @@ -93,10 +94,10 @@ @versions[gem_name] = versions.to_s.split(', ') end end def load_gem_versions(gems) - log %Q(Searching for latest #{type} versions of #{gems.join(' ')} ...) + log %Q(Searching for latest #{type} version of #{gems.join(' ')} ...) `gem query -ra #{gems.join(' ')}` end # @param [Array] list of a gem version's segments # @param [Array] other_list of another gem version's segments