lib/hoe/bundler.rb in hoe-bundler-1.1.0 vs lib/hoe/bundler.rb in hoe-bundler-1.2.0

- old
+ new

@@ -3,33 +3,51 @@ # Rake task to generate a bundler Gemfile based on your declared hoe dependencies. # # * <tt>bundler:gemfile</tt> # module Bundler - VERSION = "1.1.0" #:nodoc: + VERSION = "1.2.0" #:nodoc: def define_bundler_tasks desc "generate a bundler Gemfile from your Hoe.spec dependencies" task "bundler:gemfile" do File.open("Gemfile","w") do |gemfile| - gemfile.puts "# -*- ruby -*-" - gemfile.puts - gemfile.puts "# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`." - gemfile.puts - gemfile.puts "source :gemcutter" - gemfile.puts - self.extra_deps.each do |name, version| - version ||= ">=0" - gemfile.puts %Q{gem "#{name}", "#{version.gsub(/ /,'')}"} - end - gemfile.puts - self.extra_dev_deps.each do |name, version| - version ||= ">=0" - gemfile.puts %Q{gem "#{name}", "#{version.gsub(/ /,'')}", :group => [:development, :test]} - end - gemfile.puts - gemfile.puts "# vim: syntax=ruby" + gemfile.print hoe_bundler_contents end end + end + + def hoe_bundler_contents + gemfile = StringIO.new + gemfile.puts "# -*- ruby -*-" + gemfile.puts + gemfile.puts "# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`." + gemfile.puts + gemfile.puts "source \"https://rubygems.org/\"" + gemfile.puts + + extra_deps = {} + self.extra_deps.each do |name, version| + version ||= ">=0" + extra_deps[name] = version unless extra_deps.key?(name) + end + extra_deps.each do |name, version| + gemfile.puts %Q{gem "#{name}", "#{version.gsub(/ /,'')}"} + end + gemfile.puts + + extra_dev_deps = {} + self.extra_dev_deps.each do |name, version| + version ||= ">=0" + extra_dev_deps[name] = version unless extra_dev_deps.key?(name) + end + extra_dev_deps.each do |name, version| + gemfile.puts %Q{gem "#{name}", "#{version.gsub(/ /,'')}", :group => [:development, :test]} + end + gemfile.puts + gemfile.puts "# vim: syntax=ruby" + + gemfile.rewind + gemfile.read end end end