lib/appengine-tools/update_check.rb in appengine-tools-0.0.4 vs lib/appengine-tools/update_check.rb in appengine-tools-0.0.5

- old
+ new

@@ -44,17 +44,16 @@ 'dm-appengine' => find_gem_version('dm-appengine'), } end def find_gem_version(name) - specs = Dir.glob("#{@approot}/.gems/specifications/#{name}-*.gemspec") - versions = specs.map do |filename| - if filename =~ /-(\w+\.\w+.\w+).gemspec$/ - Gem::Version.new($1) + IO.foreach("#{@approot}/.gems/bundler_gems/environment.rb") do |line| + if line =~ %r(/gems/#{name}-(\w+\.\w+.\w+)[/"]) + return Gem::Version.new($1) end - end - versions.sort[-1] + end rescue nil + nil end def remote_versions versions = YAML.load(open(@url).read) versions.inject({}) do |versions, (name, version)| @@ -64,25 +63,25 @@ end def check_for_updates local = local_versions unless local['google-appengine'] - puts 'Skipping update check' + puts '=> Skipping update check' return end latest = remote_versions local.each do |name, version| current = latest[name] if version && version < current prefix = if name == 'google-appengine' - "sudo" + update_msg = "=> Please run sudo gem update google-appengine." else - "appcfg.rb" + update_msg = "=> Please update your Gemfile." end - puts "There is a new version of #{name}: #{current} " + + puts "=> There is a new version of #{name}: #{current} " + "(You have #{version})" - puts "Please run #{prefix} gem update #{name}." + puts update_msg end end end def parse_nag_file @@ -113,6 +112,6 @@ def can_nag? parse_nag_file['opt_in'] end end end -end \ No newline at end of file +end