Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds support for gem bundle --only. Closes #46; Closes #81

  • Loading branch information...
commit d63bff1467508d11bbaca6b3e3e06c3d6338e3cd 1 parent 0fc4093
Yehuda Katz authored
View
5 lib/bundler/commands/bundle_command.rb
@@ -36,6 +36,11 @@ def initialize
options[:build_options] = YAML.load_file(option_file)
end
end
+
+ add_option('--only ENV', "Only expand the given environment. To specify multiple environments, use --only multiple times.") do |env, options|
+ options[:only] ||= []
+ options[:only] << env
+ end
end
def usage
View
7 lib/bundler/environment.rb
@@ -46,8 +46,15 @@ def initialize(filename)
end
def install(options = {})
+ if only_envs = options[:only]
+ dependencies.reject! { |d| !only_envs.any? {|env| d.in?(env) } }
+ end
+
no_bundle = dependencies.map { |dep| !dep.bundle && dep.name }.compact
+ update = options[:update]
+ cached = options[:cached]
+
repository.install(gem_dependencies, sources,
:rubygems => rubygems,
:system_gems => system_gems,
View
26 spec/bundler/cli_spec.rb
@@ -354,6 +354,32 @@
end
end
+ describe "bundling only given environments" do
+ before(:each) do
+ build_manifest <<-Gemfile
+ clear_sources
+ source "file://#{gem_repo1}"
+ gem "extlib"
+ gem "very-simple", :only => :server
+ gem "rack", :only => :test
+ Gemfile
+
+ %w(doc environment.rb gems specifications).each do |f|
+ FileUtils.rm_rf(tmp_gem_path.join(f))
+ end
+ end
+
+ it "install gems for environments specified in --only line" do
+ Dir.chdir(bundled_app) do
+ gem_command :bundle, "--only test"
+ bundled_app('vendor', 'gems', 'environment.rb').should have_load_paths(bundled_app("vendor", "gems"),
+ "extlib-0.9.12" => %w(lib),
+ "rack-0.9.1" => %w(bin lib)
+ )
+ end
+ end
+ end
+
describe "caching gems to the bundle" do
before(:each) do
build_manifest <<-Gemfile
View
26 spec/bundler/dsl_spec.rb
@@ -12,17 +12,17 @@
only :test do
gem "rspec", :require_as => "spec"
- gem "webrat"
+ gem "very-simple"
end
Gemfile
"default".should have_const("ActiveRecord")
"default".should_not have_const("Spec")
- "default".should_not have_const("Webrat")
+ "default".should_not have_const("VerySimpleForTests")
"test".should have_const("ActiveRecord")
"test".should have_const("Spec")
- "test".should have_const("Webrat")
+ "test".should have_const("VerySimpleForTests")
end
it "supports only blocks with multiple args" do
@@ -46,16 +46,16 @@
source "file://#{gem_repo2}"
only [:test, :staging] do
- gem "webrat"
+ gem "very-simple"
only :test do
gem "rspec", :require_as => "spec"
end
end
Gemfile
- "test".should have_const("Webrat")
+ "test".should have_const("VerySimpleForTests")
"test".should have_const("Spec")
- "staging".should have_const("Webrat")
+ "staging".should have_const("VerySimpleForTests")
"staging".should_not have_const("Spec")
end
@@ -69,17 +69,17 @@
except :test do
gem "rspec", :require_as => "spec"
- gem "webrat"
+ gem "very-simple"
end
Gemfile
"default".should have_const("ActiveRecord")
"default".should have_const("Spec")
- "default".should have_const("Webrat")
+ "default".should have_const("VerySimpleForTests")
"test".should have_const("ActiveRecord")
"test".should_not have_const("Spec")
- "test".should_not have_const("Webrat")
+ "test".should_not have_const("VerySimpleForTests")
end
it "supports except blocks with multiple args" do
@@ -103,7 +103,7 @@
source "file://#{gem_repo2}"
except [:test] do
- gem "webrat"
+ gem "very-simple"
except :omg do
gem "rspec", :require_as => "spec"
end
@@ -111,10 +111,10 @@
Gemfile
"default".should have_const("Spec")
- "default".should have_const("Webrat")
- "test".should_not have_const("Webrat")
+ "default".should have_const("VerySimpleForTests")
+ "test".should_not have_const("VerySimpleForTests")
"test".should_not have_const("Spec")
- "omg".should have_const("Webrat")
+ "omg".should have_const("VerySimpleForTests")
"omg".should_not have_const("Spec")
end
end
View
6 spec/bundler/installer_spec.rb
@@ -127,11 +127,11 @@ def setup
m = build_manifest <<-Gemfile
clear_sources
source "file://#{gem_repo1}"
- gem "webrat", "0.4.4.racktest"
+ gem "very-simple-prerelease", "1.0.pre"
Gemfile
m.install
- bundled_app("vendor", "gems").should have_cached_gem("webrat-0.4.4.racktest", "nokogiri-1.3.2")
- bundled_app("vendor", "gems").should have_installed_gem("webrat-0.4.4.racktest", "nokogiri-1.3.2")
+ bundled_app("vendor", "gems").should have_cached_gem("very-simple-prerelease-1.0.pre")
+ bundled_app("vendor", "gems").should have_installed_gem("very-simple-prerelease-1.0.pre")
end
it "outputs a logger message for each gem that is installed" do
Please sign in to comment.
Something went wrong with that request. Please try again.