Skip to content

Commit 0775c23

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Let gem sources be more clear about which sources it's displaying
ruby/rubygems@2afefa4a48
1 parent cbd0de8 commit 0775c23

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

lib/rubygems/commands/sources_command.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def description # :nodoc:
128128
Without any arguments the sources lists your currently configured sources:
129129
130130
$ gem sources
131-
*** CURRENT SOURCES ***
131+
*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***
132132
133133
https://rubygems.org
134134
@@ -164,10 +164,18 @@ def description # :nodoc:
164164
end
165165

166166
def list # :nodoc:
167-
say "*** CURRENT SOURCES ***"
167+
if configured_sources
168+
header = "*** CURRENT SOURCES ***"
169+
list = configured_sources
170+
else
171+
header = "*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***"
172+
list = Gem.sources
173+
end
174+
175+
say header
168176
say
169177

170-
Gem.sources.each do |src|
178+
list.each do |src|
171179
say src
172180
end
173181
end
@@ -224,4 +232,10 @@ def remove_cache_file(desc, path) # :nodoc:
224232
say "*** Unable to remove #{desc} source cache ***"
225233
end
226234
end
235+
236+
private
237+
238+
def configured_sources
239+
Gem.configuration.sources
240+
end
227241
end

test/rubygems/test_gem_commands_sources_command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_execute
3232
end
3333

3434
expected = <<-EOF
35-
*** CURRENT SOURCES ***
35+
*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***
3636
3737
#{@gem_repo}
3838
EOF
@@ -476,7 +476,7 @@ def test_execute_list
476476
end
477477

478478
expected = <<-EOF
479-
*** CURRENT SOURCES ***
479+
*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***
480480
481481
#{@gem_repo}
482482
EOF

0 commit comments

Comments
 (0)