Skip to content

Commit 0823e10

Browse files
author
Andre Medeiros
committed
Try to find gems.rb and gems.locked if Gemfile is not found
1 parent 8b5f39c commit 0823e10

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Features:
1010
- prevent whitespace in gem declarations with clear messaging
1111
- tries to find a `bundler-<command>` executable on your path for non-bundler commands (@andremedeiros)
1212
- generates a `.consolerc` file with new gems and tries to load it on `bundle console` (@andremedeiros)
13+
- tries to find `gems.rb` and it's new counterpart, `gems.locked` (@andremedeiros)
1314

1415
## 1.7.2 (2014-08-23)
1516

lib/bundler/shared_helpers.rb

+12-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ def default_gemfile
2626
end
2727

2828
def default_lockfile
29-
Pathname.new("#{default_gemfile}.lock")
29+
gemfile = default_gemfile
30+
31+
case gemfile.basename.to_s
32+
when 'Gemfile' then Pathname.new("#{gemfile}.lock")
33+
when 'gems.rb' then Pathname.new(gemfile.sub(/.rb$/, '.locked'))
34+
end
3035
end
3136

3237
def in_bundle?
@@ -86,8 +91,12 @@ def find_gemfile
8691
end
8792

8893
# otherwise return the Gemfile if it's there
89-
filename = File.join(current, 'Gemfile')
90-
return filename if File.file?(filename)
94+
filename = ['Gemfile', 'gems.rb'].find do |file|
95+
path = File.join(current, file)
96+
File.file?(path)
97+
end
98+
99+
return filename unless filename.nil?
91100
current, previous = File.expand_path("..", current), current
92101
end
93102
end

spec/runtime/load_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,23 @@
3434
Bundler.load
3535
}.not_to raise_error()
3636
end
37+
end
38+
39+
describe "with a gems.rb file" do
40+
before(:each) do
41+
create_file "gems.rb", <<-G
42+
source "file://#{gem_repo1}"
43+
gem "rack"
44+
G
45+
end
3746

47+
it "provides a list of the env dependencies" do
48+
expect(Bundler.load.dependencies).to have_dep("rack", ">= 0")
49+
end
50+
51+
it "provides a list of the resolved gems" do
52+
expect(Bundler.load.gems).to have_gem("rack-1.0.0", "bundler-#{Bundler::VERSION}")
53+
end
3854
end
3955

4056
describe "without a gemfile" do

0 commit comments

Comments
 (0)