Permalink
Browse files

Add Gem::Specification#add_bundler_dependencies for gemspecs

Use like this:

Gem::Specification.new do |s|
  [...the usual...]
  s.add_bundler_dependencies
end

The generated gemspec will contain dependencies on your bundler gems,
and gems in the bundler group :development will be added as dev deps.
  • Loading branch information...
1 parent 7a7628c commit 58a2244fb34a0fefd33f89f089e25e517669f828 @indirect indirect committed Mar 31, 2010
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/bundler/rubygems_ext.rb
@@ -31,6 +31,16 @@ def to_gemfile(path = nil)
gemfile << dependencies_to_gemfile(development_dependencies, :development)
end
+ def add_bundler_dependencies
+ Bundler.definition.dependencies.each do |dep|
+ if dep.groups.include?(:development)
+ self.add_development_dependency(dep.name, dep.requirement.to_s)
+ else
+ self.add_dependency(dep.name, dep.requirement.to_s)
+ end
+ end
+ end
+
private
def dependencies_to_gemfile(dependencies, group = nil)

0 comments on commit 58a2244

Please sign in to comment.