Permalink
Browse files

Make the rake update task re-bundle if the version changed.

  • Loading branch information...
1 parent 2edb7b6 commit 2f78467a9a36abc3d8980c292d29d8261518a52a @martinemde martinemde committed Sep 6, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 Rakefile
View
@@ -95,14 +95,16 @@ def update_serverside_adapter
gem_name = "engineyard-serverside-adapter"
specs = Gem::SpecFetcher.fetcher.fetch(Gem::Dependency.new(gem_name))
latest_adapter_version = specs.map {|spec,| spec.version}.sort.last.to_s
+ version_changed = false
gemspec_file = Pathname.new('engineyard.gemspec')
gemspec_file.open('r') do |read_gemfile|
gemspec_file.unlink
gemspec_file.open('w') do |write_gemfile|
read_gemfile.each_line do |line|
- if line =~ /s.add_dependency\('#{gem_name}',/
+ if line =~ /s.add_dependency\('#{gem_name}', '=([^']+)'/
+ version_changed = ($1 != latest_adapter_version)
puts "#{gem_name} (#{latest_adapter_version})"
write_gemfile.write(" s.add_dependency(\'#{gem_name}\', \'=#{latest_adapter_version}\') # This line maintained by rake; edits may be stomped on\n")
else
@@ -111,6 +113,14 @@ def update_serverside_adapter
end
end
end
+
+ # re-bundle if the version changed
+ if version_changed
+ puts "Bundled gem version changed. Running bundle install..."
+ Bundler.with_clean_env do
+ system('bundle install')
+ end
+ end
end
namespace :update do

0 comments on commit 2f78467

Please sign in to comment.