Skip to content
Browse files

refactor checking `really_verbose`

This commit tries to reduce the number of places in RubyGems where we
test `really_verbose`.
  • Loading branch information...
1 parent 3082aef commit 75821c744f0bfda185eac35b91810254bf9e2367 @tenderlove tenderlove committed Feb 5, 2014
View
4 lib/rubygems/commands/cleanup_command.rb
@@ -67,10 +67,10 @@ def execute
say "Clean Up Complete"
- if Gem.configuration.really_verbose then
+ verbose do
skipped = @default_gems.map { |spec| spec.full_name }
- say "Skipped default gems: #{skipped.join ', '}"
+ "Skipped default gems: #{skipped.join ', '}"
end
end
View
6 lib/rubygems/dependency_installer.rb
@@ -243,9 +243,9 @@ def find_gems_with_sources dep, best_only=false # :nodoc:
# FIX if there is a problem talking to the network, we either need to always tell
# the user (no really_verbose) or fail hard, not silently tell them that we just
# couldn't find their requested gem.
- if Gem.configuration.really_verbose then
- say "Error fetching remote data:\t\t#{e.message}"
- say "Falling back to local-only install"
+ verbose do
+ "Error fetching remote data:\t\t#{e.message}\n" \
+ "Falling back to local-only install"
end
@domain = :local
end
View
2 lib/rubygems/ext/builder.rb
@@ -161,7 +161,7 @@ def build_extension extension, dest_path # :nodoc:
results = builder.build(extension, @gem_dir, dest_path,
results, @build_args, lib_dir)
- say results.join("\n") if Gem.configuration.really_verbose
+ verbose { results.join("\n") }
end
end
View
4 lib/rubygems/installer.rb
@@ -382,7 +382,7 @@ def generate_windows_script(filename, bindir)
file.puts windows_stub_script(bindir, filename)
end
- say script_path if Gem.configuration.really_verbose
+ verbose script_path
end
end
@@ -433,7 +433,7 @@ def generate_bin_script(filename, bindir)
file.print app_script_text(filename)
end
- say bin_script_path if Gem.configuration.really_verbose
+ verbose bin_script_path
generate_windows_script filename, bindir
end
View
2 lib/rubygems/package.rb
@@ -370,7 +370,7 @@ def extract_tar_gz io, destination_dir, pattern = "*" # :nodoc:
out.write entry.read
end if entry.file?
- say destination if Gem.configuration.really_verbose
+ verbose destination
end
end
end
View
2 lib/rubygems/package/old.rb
@@ -83,7 +83,7 @@ def extract_files destination_dir
out.write file_data
end
- say destination if Gem.configuration.really_verbose
+ verbose destination
end
end
rescue Zlib::DataError
View
2 lib/rubygems/rdoc.rb
@@ -263,7 +263,7 @@ def legacy_rdoc *args
Gem::Requirement.new('>= 2.4.0') =~ self.class.rdoc_version
r = new_rdoc
- say "rdoc #{args.join ' '}" if Gem.configuration.really_verbose
+ verbose { "rdoc #{args.join ' '}" }
Dir.chdir @spec.full_gem_path do
begin
View
12 lib/rubygems/remote_fetcher.rb
@@ -157,8 +157,7 @@ def download(spec, source_uri, install_dir = Gem.dir)
when 'http', 'https' then
unless File.exist? local_gem_path then
begin
- say "Downloading gem #{gem_file_name}" if
- Gem.configuration.really_verbose
+ verbose "Downloading gem #{gem_file_name}"
remote_gem_path = source_uri + "gems/#{gem_file_name}"
@@ -168,8 +167,7 @@ def download(spec, source_uri, install_dir = Gem.dir)
alternate_name = "#{spec.original_name}.gem"
- say "Failed, downloading gem #{alternate_name}" if
- Gem.configuration.really_verbose
+ verbose "Failed, downloading gem #{alternate_name}"
remote_gem_path = source_uri + "gems/#{alternate_name}"
@@ -188,8 +186,7 @@ def download(spec, source_uri, install_dir = Gem.dir)
local_gem_path = source_uri.to_s
end
- say "Using local gem #{local_gem_path}" if
- Gem.configuration.really_verbose
+ verbose "Using local gem #{local_gem_path}"
when nil then # TODO test for local overriding cache
source_path = if Gem.win_platform? && source_uri.scheme &&
!source_uri.path.include?(':') then
@@ -207,8 +204,7 @@ def download(spec, source_uri, install_dir = Gem.dir)
local_gem_path = source_uri.to_s
end
- say "Using local gem #{local_gem_path}" if
- Gem.configuration.really_verbose
+ verbose "Using local gem #{local_gem_path}"
else
raise ArgumentError, "unsupported URI scheme #{source_uri.scheme}"
end
View
11 lib/rubygems/request.rb
@@ -127,8 +127,7 @@ def fetch
begin
@requests[connection.object_id] += 1
- say "#{request.method} #{@uri}" if
- Gem.configuration.really_verbose
+ verbose "#{request.method} #{@uri}"
file_name = File.basename(@uri.path)
# perform download progress reporter only for gems
@@ -157,11 +156,10 @@ def fetch
response = connection.request request
end
- say "#{response.code} #{response.message}" if
- Gem.configuration.really_verbose
+ verbose "#{response.code} #{response.message}"
rescue Net::HTTPBadResponse
- say "bad response" if Gem.configuration.really_verbose
+ verbose "bad response"
reset connection
@@ -176,8 +174,7 @@ def fetch
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
requests = @requests[connection.object_id]
- say "connection reset after #{requests} requests, retrying" if
- Gem.configuration.really_verbose
+ verbose "connection reset after #{requests} requests, retrying"
raise Gem::RemoteFetcher::FetchError.new('too many connection resets', @uri) if retried
View
8 lib/rubygems/user_interaction.rb
@@ -157,6 +157,14 @@ def say statement = ''
def terminate_interaction exit_code = 0
ui.terminate_interaction exit_code
end
+
+ ##
+ # Calls +say+ with +msg+ or the results of the block if really_verbose
+ # is true.
+
+ def verbose msg = nil
+ say(msg || yield) if Gem.configuration.really_verbose
+ end
end
##

0 comments on commit 75821c7

Please sign in to comment.
Something went wrong with that request. Please try again.