module Gem::Resolver::Molinillo::UI

Conveys information about the resolution process to a user.

Public Instance Methods

after_resolution() click to toggle source

Called after resolution ends (either successfully or with an error). By default, prints a newline.

@return [void]

# File lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb, line 38
def after_resolution
  output.puts
end
before_resolution() click to toggle source

Called before resolution begins.

@return [void]

# File lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb, line 30
def before_resolution
  output.print 'Resolving dependencies...'
end
debug(depth = 0) { || ... } click to toggle source

Conveys debug information to the user.

@param [Integer] depth the current depth of the resolution process. @return [void]

# File lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb, line 46
def debug(depth = 0)
  if debug?
    debug_info = yield
    debug_info = debug_info.inspect unless debug_info.is_a?(String)
    output.puts debug_info.split("\n").map { |s| ' ' * depth + s }
  end
end
debug?() click to toggle source

Whether or not debug messages should be printed. By default, whether or not the `MOLINILLO_DEBUG` environment variable is set.

@return [Boolean]

# File lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb, line 59
def debug?
  return @debug_mode if defined?(@debug_mode)
  @debug_mode = ENV['MOLINILLO_DEBUG']
end
indicate_progress() click to toggle source

Called roughly every {#progress_rate}, this method should convey progress to the user.

@return [void]

# File lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb, line 15
def indicate_progress
  output.print '.' unless debug?
end
output() click to toggle source

The {IO} object that should be used to print output. `STDOUT`, by default.

@return [IO]

# File lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb, line 7
def output
  STDOUT
end
progress_rate() click to toggle source

How often progress should be conveyed to the user via {#indicate_progress}, in seconds. A third of a second, by default.

@return [Float]

# File lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb, line 23
def progress_rate
  0.33
end