Module: Gem::Molinillo::UI

Included in:
Resolver
Defined in:
lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb

Overview

Conveys information about the resolution process to a user.

Instance Method Summary collapse

Instance Method Details

#after_resolutionvoid

This method returns an undefined value.

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



40
41
42
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb', line 40

def after_resolution
  output.puts
end

#before_resolutionvoid

This method returns an undefined value.

Called before resolution begins.



32
33
34
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb', line 32

def before_resolution
  output.print 'Resolving dependencies...'
end

#debug(depth = 0) ⇒ void

This method returns an undefined value.

Conveys debug information to the user.

Parameters:

  • depth (Integer) (defaults to: 0)

    the current depth of the resolution process.



48
49
50
51
52
53
54
55
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb', line 48

def debug(depth = 0)
  if debug?
    debug_info = yield
    debug_info = debug_info.inspect unless debug_info.is_a?(String)
    debug_info = debug_info.split("\n").map { |s| ":#{depth.to_s.rjust 4}: #{s}" }
    output.puts debug_info
  end
end

#debug?Boolean

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

Returns:

  • (Boolean)


62
63
64
65
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb', line 62

def debug?
  return @debug_mode if defined?(@debug_mode)
  @debug_mode = ENV['MOLINILLO_DEBUG']
end

#indicate_progressvoid

This method returns an undefined value.

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



17
18
19
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb', line 17

def indicate_progress
  output.print '.' unless debug?
end

#outputIO

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

Returns:

  • (IO)


9
10
11
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb', line 9

def output
  STDOUT
end

#progress_rateFloat

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

Returns:

  • (Float)


25
26
27
# File 'lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb', line 25

def progress_rate
  0.33
end