Skip to content

Instantly share code, notes, and snippets.

@snusnu
Created April 9, 2010 17:45
Show Gist options
  • Save snusnu/361389 to your computer and use it in GitHub Desktop.
Save snusnu/361389 to your computer and use it in GitHub Desktop.
desc "Support bundling from a typical datamapper dev checkout (allows BUNDLE_GEMFILE=Gemfile.local bundle exec foo)"
task :create_local_gemfile do |t|
datamapper = ENV['DATAMAPPER'] || File.expand_path('../..', __FILE__)
excluded_adapters = (ENV['EXCLUDED_ADAPTERS'] || '').split(',')
regex = /:git => \"#\{datamapper\}\/(.*?)(\.git|\")/
File.open(File.expand_path('../Gemfile.local', __FILE__), 'w') do |f|
File.open(File.expand_path('../Gemfile', __FILE__), 'r').each do |line|
new_line = (line =~ regex) ? line.gsub(regex, ":path => \"#{datamapper}/#{$1}") : line
new_line = "##{new_line}" if excluded_adapters.any? { |name| line =~ /#{name}/ }
f.puts new_line
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment