Created
April 9, 2010 17:45
-
-
Save snusnu/361389 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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