Skip to content

Commit 8acf0d7

Browse files
cllnshsbt
authored andcommitted
[rubygems/rubygems] Use shorthand hash syntax for bundle add
ruby/rubygems@9691097036
1 parent afbc664 commit 8acf0d7

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

lib/bundler/injector.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ def build_gem_lines(conservative_versioning)
108108
end
109109

110110
if d.groups != Array(:default)
111-
group = d.groups.size == 1 ? ", :group => #{d.groups.first.inspect}" : ", :groups => #{d.groups.inspect}"
111+
group = d.groups.size == 1 ? ", group: #{d.groups.first.inspect}" : ", groups: #{d.groups.inspect}"
112112
end
113113

114-
source = ", :source => \"#{d.source}\"" unless d.source.nil?
115-
path = ", :path => \"#{d.path}\"" unless d.path.nil?
116-
git = ", :git => \"#{d.git}\"" unless d.git.nil?
117-
github = ", :github => \"#{d.github}\"" unless d.github.nil?
118-
branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
119-
ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
120-
glob = ", :glob => \"#{d.glob}\"" unless d.glob.nil?
121-
require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
114+
source = ", source: \"#{d.source}\"" unless d.source.nil?
115+
path = ", path: \"#{d.path}\"" unless d.path.nil?
116+
git = ", git: \"#{d.git}\"" unless d.git.nil?
117+
github = ", github: \"#{d.github}\"" unless d.github.nil?
118+
branch = ", branch: \"#{d.branch}\"" unless d.branch.nil?
119+
ref = ", ref: \"#{d.ref}\"" unless d.ref.nil?
120+
glob = ", glob: \"#{d.glob}\"" unless d.glob.nil?
121+
require_path = ", require: #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
122122

123123
%(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{glob}#{require_path})
124124
end.join("\n")

spec/bundler/commands/add_spec.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,25 @@
8888
describe "with --require" do
8989
it "adds the require param for the gem" do
9090
bundle "add 'foo' --require=foo/engine"
91-
expect(bundled_app_gemfile.read).to match(%r{gem "foo",(?: .*,) :require => "foo\/engine"})
91+
expect(bundled_app_gemfile.read).to match(%r{gem "foo",(?: .*,) require: "foo\/engine"})
9292
end
9393

9494
it "converts false to a boolean" do
9595
bundle "add 'foo' --require=false"
96-
expect(bundled_app_gemfile.read).to match(/gem "foo",(?: .*,) :require => false/)
96+
expect(bundled_app_gemfile.read).to match(/gem "foo",(?: .*,) require: false/)
9797
end
9898
end
9999

100100
describe "with --group" do
101101
it "adds dependency for the specified group" do
102102
bundle "add 'foo' --group='development'"
103-
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :group => :development/)
103+
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", group: :development/)
104104
expect(the_bundle).to include_gems "foo 2.0"
105105
end
106106

107107
it "adds dependency to more than one group" do
108108
bundle "add 'foo' --group='development, test'"
109-
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :groups => \[:development, :test\]/)
109+
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", groups: \[:development, :test\]/)
110110
expect(the_bundle).to include_gems "foo 2.0"
111111
end
112112
end
@@ -115,7 +115,7 @@
115115
it "adds dependency with specified source" do
116116
bundle "add 'foo' --source='https://gem.repo2'"
117117

118-
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", :source => "https://gem.repo2"})
118+
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", source: "https://gem.repo2"})
119119
expect(the_bundle).to include_gems "foo 2.0"
120120
end
121121
end
@@ -124,7 +124,7 @@
124124
it "adds dependency with specified path" do
125125
bundle "add 'foo' --path='#{lib_path("foo-2.0")}'"
126126

127-
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :path => "#{lib_path("foo-2.0")}"/)
127+
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", path: "#{lib_path("foo-2.0")}"/)
128128
expect(the_bundle).to include_gems "foo 2.0"
129129
end
130130
end
@@ -133,7 +133,7 @@
133133
it "adds dependency with specified git source" do
134134
bundle "add foo --git=#{lib_path("foo-2.0")}"
135135

136-
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/)
136+
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}"/)
137137
expect(the_bundle).to include_gems "foo 2.0"
138138
end
139139
end
@@ -146,7 +146,7 @@
146146
it "adds dependency with specified git source and branch" do
147147
bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test"
148148

149-
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/)
149+
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", branch: "test"/)
150150
expect(the_bundle).to include_gems "foo 2.0"
151151
end
152152
end
@@ -155,7 +155,7 @@
155155
it "adds dependency with specified git source and branch" do
156156
bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))}"
157157

158-
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2\.0", :git => "#{lib_path("foo-2.0")}", :ref => "#{revision_for(lib_path("foo-2.0"))}"/)
158+
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}"/)
159159
expect(the_bundle).to include_gems "foo 2.0"
160160
end
161161
end
@@ -164,31 +164,31 @@
164164
it "adds dependency with specified github source" do
165165
bundle "add rake --github=ruby/rake"
166166

167-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake"})
167+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake"})
168168
end
169169
end
170170

171171
describe "with --github and --branch" do
172172
it "adds dependency with specified github source and branch" do
173173
bundle "add rake --github=ruby/rake --branch=master"
174174

175-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :branch => "master"})
175+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", branch: "master"})
176176
end
177177
end
178178

179179
describe "with --github and --ref" do
180180
it "adds dependency with specified github source and ref" do
181181
bundle "add rake --github=ruby/rake --ref=5c60da8"
182182

183-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :ref => "5c60da8"})
183+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", ref: "5c60da8"})
184184
end
185185
end
186186

187187
describe "with --git and --glob" do
188188
it "adds dependency with specified git source" do
189189
bundle "add foo --git=#{lib_path("foo-2.0")} --glob='./*.gemspec'"
190190

191-
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :glob => "\./\*\.gemspec"})
191+
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", glob: "\./\*\.gemspec"})
192192
expect(the_bundle).to include_gems "foo 2.0"
193193
end
194194
end
@@ -201,7 +201,7 @@
201201
it "adds dependency with specified git source and branch" do
202202
bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test --glob='./*.gemspec'"
203203

204-
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test", :glob => "\./\*\.gemspec"})
204+
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", branch: "test", glob: "\./\*\.gemspec"})
205205
expect(the_bundle).to include_gems "foo 2.0"
206206
end
207207
end
@@ -210,7 +210,7 @@
210210
it "adds dependency with specified git source and branch" do
211211
bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))} --glob='./*.gemspec'"
212212

213-
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2\.0", :git => "#{lib_path("foo-2.0")}", :ref => "#{revision_for(lib_path("foo-2.0"))}", :glob => "\./\*\.gemspec"})
213+
expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}", glob: "\./\*\.gemspec"})
214214
expect(the_bundle).to include_gems "foo 2.0"
215215
end
216216
end
@@ -219,23 +219,23 @@
219219
it "adds dependency with specified github source" do
220220
bundle "add rake --github=ruby/rake --glob='./*.gemspec'"
221221

222-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :glob => "\.\/\*\.gemspec"})
222+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", glob: "\.\/\*\.gemspec"})
223223
end
224224
end
225225

226226
describe "with --github and --branch --and glob" do
227227
it "adds dependency with specified github source and branch" do
228228
bundle "add rake --github=ruby/rake --branch=master --glob='./*.gemspec'"
229229

230-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :branch => "master", :glob => "\.\/\*\.gemspec"})
230+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", branch: "master", glob: "\.\/\*\.gemspec"})
231231
end
232232
end
233233

234234
describe "with --github and --ref and --glob" do
235235
it "adds dependency with specified github source and ref" do
236236
bundle "add rake --github=ruby/rake --ref=5c60da8 --glob='./*.gemspec'"
237237

238-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :ref => "5c60da8", :glob => "\.\/\*\.gemspec"})
238+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", ref: "5c60da8", glob: "\.\/\*\.gemspec"})
239239
end
240240
end
241241

@@ -250,7 +250,7 @@
250250

251251
it "using combination of short form options works like long form" do
252252
bundle "add 'foo' -s='https://gem.repo2' -g='development' -v='~>1.0'"
253-
expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 1.0", :group => :development, :source => "https://gem.repo2")
253+
expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 1.0", group: :development, source: "https://gem.repo2")
254254
expect(the_bundle).to include_gems "foo 1.1"
255255
end
256256

0 commit comments

Comments
 (0)