rubygems-update 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (128) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +24 -0
  3. data/.document +4 -3
  4. data/ChangeLog +382 -1
  5. data/Manifest.txt +214 -0
  6. data/README +1 -49
  7. data/Rakefile +124 -191
  8. data/bin/gem +1 -4
  9. data/cruise_config.rb +22 -0
  10. data/doc/release_notes/rel_1_3_1.rdoc +3 -3
  11. data/doc/release_notes/rel_1_3_2.rdoc +119 -0
  12. data/lib/gauntlet_rubygems.rb +50 -0
  13. data/lib/rubygems.rb +250 -25
  14. data/lib/rubygems/builder.rb +62 -60
  15. data/lib/rubygems/command.rb +421 -319
  16. data/lib/rubygems/command_manager.rb +153 -125
  17. data/lib/rubygems/commands/check_command.rb +12 -7
  18. data/lib/rubygems/commands/cleanup_command.rb +11 -2
  19. data/lib/rubygems/commands/contents_command.rb +42 -18
  20. data/lib/rubygems/commands/generate_index_command.rb +91 -15
  21. data/lib/rubygems/commands/install_command.rb +33 -47
  22. data/lib/rubygems/commands/query_command.rb +36 -20
  23. data/lib/rubygems/commands/rdoc_command.rb +62 -68
  24. data/lib/rubygems/commands/search_command.rb +26 -32
  25. data/lib/rubygems/commands/setup_command.rb +353 -0
  26. data/lib/rubygems/commands/sources_command.rb +5 -0
  27. data/lib/rubygems/commands/specification_command.rb +23 -3
  28. data/lib/rubygems/commands/uninstall_command.rb +71 -61
  29. data/lib/rubygems/commands/unpack_command.rb +14 -12
  30. data/lib/rubygems/commands/update_command.rb +26 -5
  31. data/lib/rubygems/defaults.rb +16 -3
  32. data/lib/rubygems/dependency.rb +38 -7
  33. data/lib/rubygems/dependency_installer.rb +7 -4
  34. data/lib/rubygems/digest/digest_adapter.rb +42 -33
  35. data/lib/rubygems/digest/sha1.rb +6 -1
  36. data/lib/rubygems/digest/sha2.rb +5 -0
  37. data/lib/rubygems/doc_manager.rb +31 -11
  38. data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
  39. data/lib/rubygems/ext/rake_builder.rb +6 -2
  40. data/lib/rubygems/format.rb +63 -63
  41. data/lib/rubygems/gem_openssl.rb +14 -2
  42. data/lib/rubygems/gem_path_searcher.rb +7 -3
  43. data/lib/rubygems/gem_runner.rb +59 -39
  44. data/lib/rubygems/indexer.rb +450 -109
  45. data/lib/rubygems/install_update_options.rb +13 -1
  46. data/lib/rubygems/installer.rb +25 -22
  47. data/lib/rubygems/local_remote_options.rb +5 -3
  48. data/lib/rubygems/old_format.rb +124 -120
  49. data/lib/rubygems/package/tar_header.rb +25 -3
  50. data/lib/rubygems/package/tar_input.rb +5 -5
  51. data/lib/rubygems/package/tar_output.rb +2 -0
  52. data/lib/rubygems/package/tar_reader.rb +19 -0
  53. data/lib/rubygems/package/tar_reader/entry.rb +43 -0
  54. data/lib/rubygems/package/tar_writer.rb +65 -3
  55. data/lib/rubygems/package_task.rb +117 -0
  56. data/lib/rubygems/platform.rb +12 -8
  57. data/lib/rubygems/remote_fetcher.rb +43 -24
  58. data/lib/rubygems/require_paths_builder.rb +14 -12
  59. data/lib/rubygems/requirement.rb +15 -6
  60. data/lib/rubygems/rubygems_version.rb +14 -1
  61. data/lib/rubygems/source_index.rb +38 -16
  62. data/lib/rubygems/source_info_cache_entry.rb +2 -2
  63. data/lib/rubygems/spec_fetcher.rb +43 -20
  64. data/lib/rubygems/specification.rb +1122 -947
  65. data/lib/rubygems/text.rb +30 -0
  66. data/lib/rubygems/timer.rb +14 -11
  67. data/lib/rubygems/uninstaller.rb +25 -5
  68. data/lib/rubygems/user_interaction.rb +294 -264
  69. data/lib/rubygems/validator.rb +70 -36
  70. data/lib/rubygems/version.rb +97 -33
  71. data/lib/rubygems/version_option.rb +1 -0
  72. data/setup.rb +11 -306
  73. data/test/foo/discover.rb +0 -0
  74. data/test/gem_installer_test_case.rb +22 -11
  75. data/test/gem_package_tar_test_case.rb +0 -14
  76. data/test/gemutilities.rb +89 -8
  77. data/test/mockgemui.rb +2 -1
  78. data/test/rubygems_plugin.rb +16 -0
  79. data/test/test_gem.rb +107 -36
  80. data/test/test_gem_command.rb +3 -13
  81. data/test/test_gem_command_manager.rb +1 -14
  82. data/test/test_gem_commands_cert_command.rb +1 -1
  83. data/test/test_gem_commands_contents_command.rb +63 -0
  84. data/test/test_gem_commands_environment_command.rb +1 -1
  85. data/test/test_gem_commands_generate_index_command.rb +104 -1
  86. data/test/test_gem_commands_install_command.rb +95 -0
  87. data/test/test_gem_commands_pristine_command.rb +3 -3
  88. data/test/test_gem_commands_query_command.rb +46 -0
  89. data/test/test_gem_commands_sources_command.rb +9 -5
  90. data/test/test_gem_commands_specification_command.rb +31 -0
  91. data/test/test_gem_commands_uninstall_command.rb +3 -2
  92. data/test/test_gem_commands_unpack_command.rb +3 -2
  93. data/test/test_gem_commands_update_command.rb +12 -7
  94. data/test/test_gem_dependency.rb +62 -11
  95. data/test/test_gem_dependency_installer.rb +18 -5
  96. data/test/test_gem_dependency_list.rb +6 -6
  97. data/test/test_gem_doc_manager.rb +7 -1
  98. data/test/test_gem_ext_configure_builder.rb +8 -10
  99. data/test/test_gem_ext_ext_conf_builder.rb +14 -8
  100. data/test/test_gem_gem_path_searcher.rb +1 -1
  101. data/test/test_gem_gem_runner.rb +11 -0
  102. data/test/test_gem_indexer.rb +398 -21
  103. data/test/test_gem_install_update_options.rb +20 -6
  104. data/test/test_gem_installer.rb +22 -14
  105. data/test/test_gem_local_remote_options.rb +2 -1
  106. data/test/test_gem_package_tar_header.rb +3 -3
  107. data/test/test_gem_package_tar_input.rb +3 -3
  108. data/test/test_gem_package_tar_output.rb +2 -2
  109. data/test/test_gem_package_task.rb +70 -0
  110. data/test/test_gem_platform.rb +12 -6
  111. data/test/test_gem_remote_fetcher.rb +23 -1
  112. data/test/test_gem_source_index.rb +32 -21
  113. data/test/test_gem_spec_fetcher.rb +77 -5
  114. data/test/test_gem_specification.rb +274 -1
  115. data/test/test_gem_uninstaller.rb +34 -4
  116. data/test/test_gem_version.rb +94 -4
  117. data/test/test_gem_version_option.rb +13 -0
  118. data/test/test_kernel.rb +4 -4
  119. data/util/CL2notes +56 -0
  120. data/util/gem_prelude.rb.template +251 -0
  121. metadata +30 -20
  122. metadata.gz.sig +3 -4
  123. data/TODO +0 -1
  124. data/scripts/buildtests.rb +0 -31
  125. data/scripts/gemdoc.rb +0 -67
  126. data/scripts/runtest.rb +0 -40
  127. data/scripts/specdoc.rb +0 -171
  128. data/scripts/upload_gemdoc.rb +0 -140
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+
3
+ ##
4
+ # A collection of text-wrangling methods
5
+
6
+ module Gem::Text
7
+
8
+ ##
9
+ # Wraps +text+ to +wrap+ characters and optionally indents by +indent+
10
+ # characters
11
+
12
+ def format_text(text, wrap, indent=0)
13
+ result = []
14
+ work = text.dup
15
+
16
+ while work.length > wrap do
17
+ if work =~ /^(.{0,#{wrap}})[ \n]/ then
18
+ result << $1
19
+ work.slice!(0, $&.length)
20
+ else
21
+ result << work.slice!(0, wrap)
22
+ end
23
+ end
24
+
25
+ result << work if work.length.nonzero?
26
+ result.join("\n").gsub(/^/, " " * indent)
27
+ end
28
+
29
+ end
30
+
@@ -1,6 +1,6 @@
1
1
  #
2
- # This file defines a $log variable for logging, and a time() method for recording timing
3
- # information.
2
+ # This file defines a $log variable for logging, and a time() method for
3
+ # recording timing information.
4
4
  #
5
5
  #--
6
6
  # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
@@ -8,18 +8,21 @@
8
8
  # See LICENSE.txt for permissions.
9
9
  #++
10
10
 
11
+ require 'rubygems'
12
+
13
+ file, lineno = Gem.location_of_caller
14
+
15
+ warn "#{file}:#{lineno}:Warning: RubyGems' lib/rubygems/timer.rb deprecated and will be removed on or after June 2009."
11
16
 
12
17
  $log = Object.new
13
- def $log.debug(str)
14
- STDERR.puts str
18
+
19
+ # :stopdoc:
20
+ def $log.debug(message)
21
+ Gem.debug message
15
22
  end
16
23
 
17
- def time(msg, width=25)
18
- t = Time.now
19
- return_value = yield
20
- elapsed = Time.now.to_f - t.to_f
21
- elapsed = sprintf("%3.3f", elapsed)
22
- $log.debug "#{msg.ljust(width)}: #{elapsed}s"
23
- return_value
24
+ def time(msg, width=25, &block)
25
+ Gem.time(msg, width, &block)
24
26
  end
27
+ # :startdoc:
25
28
 
@@ -12,6 +12,11 @@ require 'rubygems/user_interaction'
12
12
 
13
13
  ##
14
14
  # An Uninstaller.
15
+ #
16
+ # The uninstaller fires pre and post uninstall hooks. Hooks can be added
17
+ # either through a rubygems_plugin.rb file in an installed gem or via a
18
+ # rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb
19
+ # file. See Gem.pre_uninstall and Gem.post_uninstall for details.
15
20
 
16
21
  class Gem::Uninstaller
17
22
 
@@ -46,8 +51,17 @@ class Gem::Uninstaller
46
51
  @force_ignore = options[:ignore]
47
52
  @bin_dir = options[:bin_dir]
48
53
 
54
+ # only add user directory if install_dir is not set
55
+ @user_install = false
56
+ @user_install = options[:user_install] unless options[:install_dir]
57
+
49
58
  spec_dir = File.join @gem_home, 'specifications'
50
59
  @source_index = Gem::SourceIndex.from_gems_in spec_dir
60
+
61
+ if @user_install then
62
+ user_dir = File.join Gem.user_dir, 'specifications'
63
+ @user_index = Gem::SourceIndex.from_gems_in user_dir
64
+ end
51
65
  end
52
66
 
53
67
  ##
@@ -56,9 +70,10 @@ class Gem::Uninstaller
56
70
 
57
71
  def uninstall
58
72
  list = @source_index.find_name @gem, @version
73
+ list += @user_index.find_name @gem, @version if @user_install
59
74
 
60
75
  if list.empty? then
61
- raise Gem::InstallError, "Unknown gem #{@gem} #{@version}"
76
+ raise Gem::InstallError, "cannot uninstall, check `gem list -d #{@gem}`"
62
77
 
63
78
  elsif list.size > 1 and @force_all then
64
79
  remove_all list.dup
@@ -169,7 +184,8 @@ class Gem::Uninstaller
169
184
  "Uninstallation aborted due to dependent gem(s)"
170
185
  end
171
186
 
172
- unless path_ok? spec then
187
+ unless path_ok?(@gem_home, spec) or
188
+ (@user_install and path_ok?(Gem.user_dir, spec)) then
173
189
  e = Gem::GemNotInHomeException.new \
174
190
  "Gem is not installed in directory #{@gem_home}"
175
191
  e.spec = spec
@@ -210,9 +226,12 @@ class Gem::Uninstaller
210
226
  list.delete spec
211
227
  end
212
228
 
213
- def path_ok?(spec)
214
- full_path = File.join @gem_home, 'gems', spec.full_name
215
- original_path = File.join @gem_home, 'gems', spec.original_name
229
+ ##
230
+ # Is +spec+ in +gem_dir+?
231
+
232
+ def path_ok?(gem_dir, spec)
233
+ full_path = File.join gem_dir, 'gems', spec.full_name
234
+ original_path = File.join gem_dir, 'gems', spec.original_name
216
235
 
217
236
  full_path == spec.full_gem_path || original_path == spec.full_gem_path
218
237
  end
@@ -221,6 +240,7 @@ class Gem::Uninstaller
221
240
  return true if @force_ignore
222
241
 
223
242
  deplist = Gem::DependencyList.from_source_index @source_index
243
+ deplist.add(*@user_index.gems.values) if @user_install
224
244
  deplist.ok_to_remove?(spec.full_name) || ask_if_ok(spec)
225
245
  end
226
246
 
@@ -4,357 +4,387 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- module Gem
7
+ ##
8
+ # Module that defines the default UserInteraction. Any class including this
9
+ # module will have access to the +ui+ method that returns the default UI.
8
10
 
9
- ##
10
- # Module that defines the default UserInteraction. Any class including this
11
- # module will have access to the +ui+ method that returns the default UI.
11
+ module Gem::DefaultUserInteraction
12
12
 
13
- module DefaultUserInteraction
13
+ ##
14
+ # The default UI is a class variable of the singleton class for this
15
+ # module.
14
16
 
15
- ##
16
- # The default UI is a class variable of the singleton class for this
17
- # module.
17
+ @ui = nil
18
18
 
19
- @ui = nil
19
+ ##
20
+ # Return the default UI.
20
21
 
21
- ##
22
- # Return the default UI.
22
+ def self.ui
23
+ @ui ||= Gem::ConsoleUI.new
24
+ end
23
25
 
24
- def self.ui
25
- @ui ||= Gem::ConsoleUI.new
26
- end
26
+ ##
27
+ # Set the default UI. If the default UI is never explicitly set, a simple
28
+ # console based UserInteraction will be used automatically.
27
29
 
28
- ##
29
- # Set the default UI. If the default UI is never explicitly set, a simple
30
- # console based UserInteraction will be used automatically.
30
+ def self.ui=(new_ui)
31
+ @ui = new_ui
32
+ end
31
33
 
32
- def self.ui=(new_ui)
33
- @ui = new_ui
34
- end
34
+ ##
35
+ # Use +new_ui+ for the duration of +block+.
36
+
37
+ def self.use_ui(new_ui)
38
+ old_ui = @ui
39
+ @ui = new_ui
40
+ yield
41
+ ensure
42
+ @ui = old_ui
43
+ end
35
44
 
36
- ##
37
- # Use +new_ui+ for the duration of +block+.
38
-
39
- def self.use_ui(new_ui)
40
- old_ui = @ui
41
- @ui = new_ui
42
- yield
43
- ensure
44
- @ui = old_ui
45
- end
45
+ ##
46
+ # See DefaultUserInteraction::ui
46
47
 
47
- ##
48
- # See DefaultUserInteraction::ui
48
+ def ui
49
+ Gem::DefaultUserInteraction.ui
50
+ end
49
51
 
50
- def ui
51
- DefaultUserInteraction.ui
52
- end
52
+ ##
53
+ # See DefaultUserInteraction::ui=
53
54
 
54
- ##
55
- # See DefaultUserInteraction::ui=
55
+ def ui=(new_ui)
56
+ Gem::DefaultUserInteraction.ui = new_ui
57
+ end
56
58
 
57
- def ui=(new_ui)
58
- DefaultUserInteraction.ui = new_ui
59
- end
59
+ ##
60
+ # See DefaultUserInteraction::use_ui
60
61
 
61
- ##
62
- # See DefaultUserInteraction::use_ui
62
+ def use_ui(new_ui, &block)
63
+ Gem::DefaultUserInteraction.use_ui(new_ui, &block)
64
+ end
63
65
 
64
- def use_ui(new_ui, &block)
65
- DefaultUserInteraction.use_ui(new_ui, &block)
66
- end
66
+ end
67
67
 
68
- end
68
+ ##
69
+ # Make the default UI accessable without the "ui." prefix. Classes
70
+ # including this module may use the interaction methods on the default UI
71
+ # directly. Classes may also reference the ui and ui= methods.
72
+ #
73
+ # Example:
74
+ #
75
+ # class X
76
+ # include Gem::UserInteraction
77
+ #
78
+ # def get_answer
79
+ # n = ask("What is the meaning of life?")
80
+ # end
81
+ # end
82
+
83
+ module Gem::UserInteraction
84
+
85
+ include Gem::DefaultUserInteraction
69
86
 
70
87
  ##
71
- # Make the default UI accessable without the "ui." prefix. Classes
72
- # including this module may use the interaction methods on the default UI
73
- # directly. Classes may also reference the ui and ui= methods.
74
- #
75
- # Example:
76
- #
77
- # class X
78
- # include Gem::UserInteraction
79
- #
80
- # def get_answer
81
- # n = ask("What is the meaning of life?")
82
- # end
83
- # end
84
-
85
- module UserInteraction
86
-
87
- include DefaultUserInteraction
88
-
89
- [:alert,
90
- :alert_error,
91
- :alert_warning,
92
- :ask,
93
- :ask_yes_no,
94
- :choose_from_list,
95
- :say,
96
- :terminate_interaction ].each do |methname|
97
- class_eval %{
98
- def #{methname}(*args)
99
- ui.#{methname}(*args)
100
- end
101
- }, __FILE__, __LINE__
102
- end
103
- end
88
+ # :method: alert
104
89
 
105
90
  ##
106
- # StreamUI implements a simple stream based user interface.
91
+ # :method: alert_error
107
92
 
108
- class StreamUI
93
+ ##
94
+ # :method: alert_warning
109
95
 
110
- attr_reader :ins, :outs, :errs
96
+ ##
97
+ # :method: ask
111
98
 
112
- def initialize(in_stream, out_stream, err_stream=STDERR)
113
- @ins = in_stream
114
- @outs = out_stream
115
- @errs = err_stream
116
- end
99
+ ##
100
+ # :method: ask_yes_no
117
101
 
118
- ##
119
- # Choose from a list of options. +question+ is a prompt displayed above
120
- # the list. +list+ is a list of option strings. Returns the pair
121
- # [option_name, option_index].
102
+ ##
103
+ # :method: choose_from_list
122
104
 
123
- def choose_from_list(question, list)
124
- @outs.puts question
105
+ ##
106
+ # :method: say
125
107
 
126
- list.each_with_index do |item, index|
127
- @outs.puts " #{index+1}. #{item}"
108
+ ##
109
+ # :method: terminate_interaction
110
+
111
+ [:alert,
112
+ :alert_error,
113
+ :alert_warning,
114
+ :ask,
115
+ :ask_yes_no,
116
+ :choose_from_list,
117
+ :say,
118
+ :terminate_interaction ].each do |methname|
119
+ class_eval %{
120
+ def #{methname}(*args)
121
+ ui.#{methname}(*args)
128
122
  end
123
+ }, __FILE__, __LINE__
124
+ end
125
+ end
126
+
127
+ ##
128
+ # Gem::StreamUI implements a simple stream based user interface.
129
+
130
+ class Gem::StreamUI
131
+
132
+ attr_reader :ins, :outs, :errs
129
133
 
130
- @outs.print "> "
131
- @outs.flush
134
+ def initialize(in_stream, out_stream, err_stream=STDERR)
135
+ @ins = in_stream
136
+ @outs = out_stream
137
+ @errs = err_stream
138
+ end
132
139
 
133
- result = @ins.gets
140
+ ##
141
+ # Choose from a list of options. +question+ is a prompt displayed above
142
+ # the list. +list+ is a list of option strings. Returns the pair
143
+ # [option_name, option_index].
134
144
 
135
- return nil, nil unless result
145
+ def choose_from_list(question, list)
146
+ @outs.puts question
136
147
 
137
- result = result.strip.to_i - 1
138
- return list[result], result
148
+ list.each_with_index do |item, index|
149
+ @outs.puts " #{index+1}. #{item}"
139
150
  end
140
151
 
141
- ##
142
- # Ask a question. Returns a true for yes, false for no. If not connected
143
- # to a tty, raises an exception if default is nil, otherwise returns
144
- # default.
145
-
146
- def ask_yes_no(question, default=nil)
147
- unless @ins.tty? then
148
- if default.nil? then
149
- raise Gem::OperationNotSupportedError,
150
- "Not connected to a tty and no default specified"
151
- else
152
- return default
153
- end
154
- end
152
+ @outs.print "> "
153
+ @outs.flush
155
154
 
156
- qstr = case default
157
- when nil
158
- 'yn'
159
- when true
160
- 'Yn'
161
- else
162
- 'yN'
163
- end
164
-
165
- result = nil
166
-
167
- while result.nil?
168
- result = ask("#{question} [#{qstr}]")
169
- result = case result
170
- when /^[Yy].*/
171
- true
172
- when /^[Nn].*/
173
- false
174
- when /^$/
175
- default
176
- else
177
- nil
178
- end
155
+ result = @ins.gets
156
+
157
+ return nil, nil unless result
158
+
159
+ result = result.strip.to_i - 1
160
+ return list[result], result
161
+ end
162
+
163
+ ##
164
+ # Ask a question. Returns a true for yes, false for no. If not connected
165
+ # to a tty, raises an exception if default is nil, otherwise returns
166
+ # default.
167
+
168
+ def ask_yes_no(question, default=nil)
169
+ unless @ins.tty? then
170
+ if default.nil? then
171
+ raise Gem::OperationNotSupportedError,
172
+ "Not connected to a tty and no default specified"
173
+ else
174
+ return default
179
175
  end
176
+ end
180
177
 
181
- return result
178
+ qstr = case default
179
+ when nil
180
+ 'yn'
181
+ when true
182
+ 'Yn'
183
+ else
184
+ 'yN'
185
+ end
186
+
187
+ result = nil
188
+
189
+ while result.nil?
190
+ result = ask("#{question} [#{qstr}]")
191
+ result = case result
192
+ when /^[Yy].*/
193
+ true
194
+ when /^[Nn].*/
195
+ false
196
+ when /^$/
197
+ default
198
+ else
199
+ nil
200
+ end
182
201
  end
183
202
 
184
- ##
185
- # Ask a question. Returns an answer if connected to a tty, nil otherwise.
203
+ return result
204
+ end
186
205
 
187
- def ask(question)
188
- return nil if not @ins.tty?
206
+ ##
207
+ # Ask a question. Returns an answer if connected to a tty, nil otherwise.
189
208
 
190
- @outs.print(question + " ")
191
- @outs.flush
209
+ def ask(question)
210
+ return nil if not @ins.tty?
192
211
 
193
- result = @ins.gets
194
- result.chomp! if result
195
- result
196
- end
212
+ @outs.print(question + " ")
213
+ @outs.flush
197
214
 
198
- ##
199
- # Display a statement.
215
+ result = @ins.gets
216
+ result.chomp! if result
217
+ result
218
+ end
200
219
 
201
- def say(statement="")
202
- @outs.puts statement
203
- end
220
+ ##
221
+ # Display a statement.
204
222
 
205
- ##
206
- # Display an informational alert. Will ask +question+ if it is not nil.
223
+ def say(statement="")
224
+ @outs.puts statement
225
+ end
207
226
 
208
- def alert(statement, question=nil)
209
- @outs.puts "INFO: #{statement}"
210
- ask(question) if question
211
- end
227
+ ##
228
+ # Display an informational alert. Will ask +question+ if it is not nil.
212
229
 
213
- ##
214
- # Display a warning in a location expected to get error messages. Will
215
- # ask +question+ if it is not nil.
230
+ def alert(statement, question=nil)
231
+ @outs.puts "INFO: #{statement}"
232
+ ask(question) if question
233
+ end
216
234
 
217
- def alert_warning(statement, question=nil)
218
- @errs.puts "WARNING: #{statement}"
219
- ask(question) if question
220
- end
235
+ ##
236
+ # Display a warning in a location expected to get error messages. Will
237
+ # ask +question+ if it is not nil.
221
238
 
222
- ##
223
- # Display an error message in a location expected to get error messages.
224
- # Will ask +question+ if it is not nil.
239
+ def alert_warning(statement, question=nil)
240
+ @errs.puts "WARNING: #{statement}"
241
+ ask(question) if question
242
+ end
225
243
 
226
- def alert_error(statement, question=nil)
227
- @errs.puts "ERROR: #{statement}"
228
- ask(question) if question
229
- end
244
+ ##
245
+ # Display an error message in a location expected to get error messages.
246
+ # Will ask +question+ if it is not nil.
230
247
 
231
- ##
232
- # Terminate the application with exit code +status+, running any exit
233
- # handlers that might have been defined.
248
+ def alert_error(statement, question=nil)
249
+ @errs.puts "ERROR: #{statement}"
250
+ ask(question) if question
251
+ end
234
252
 
235
- def terminate_interaction(status = 0)
236
- raise Gem::SystemExitException, status
237
- end
253
+ ##
254
+ # Display a debug message on the same location as error messages.
238
255
 
239
- ##
240
- # Return a progress reporter object chosen from the current verbosity.
241
-
242
- def progress_reporter(*args)
243
- case Gem.configuration.verbose
244
- when nil, false
245
- SilentProgressReporter.new(@outs, *args)
246
- when true
247
- SimpleProgressReporter.new(@outs, *args)
248
- else
249
- VerboseProgressReporter.new(@outs, *args)
250
- end
251
- end
256
+ def debug(statement)
257
+ @errs.puts statement
258
+ end
252
259
 
253
- ##
254
- # An absolutely silent progress reporter.
260
+ ##
261
+ # Terminate the application with exit code +status+, running any exit
262
+ # handlers that might have been defined.
255
263
 
256
- class SilentProgressReporter
257
- attr_reader :count
264
+ def terminate_interaction(status = 0)
265
+ raise Gem::SystemExitException, status
266
+ end
258
267
 
259
- def initialize(out_stream, size, initial_message, terminal_message = nil)
260
- end
268
+ ##
269
+ # Return a progress reporter object chosen from the current verbosity.
270
+
271
+ def progress_reporter(*args)
272
+ case Gem.configuration.verbose
273
+ when nil, false
274
+ SilentProgressReporter.new(@outs, *args)
275
+ when true
276
+ SimpleProgressReporter.new(@outs, *args)
277
+ else
278
+ VerboseProgressReporter.new(@outs, *args)
279
+ end
280
+ end
261
281
 
262
- def updated(message)
263
- end
282
+ ##
283
+ # An absolutely silent progress reporter.
264
284
 
265
- def done
266
- end
285
+ class SilentProgressReporter
286
+ attr_reader :count
287
+
288
+ def initialize(out_stream, size, initial_message, terminal_message = nil)
267
289
  end
268
290
 
269
- ##
270
- # A basic dotted progress reporter.
291
+ def updated(message)
292
+ end
271
293
 
272
- class SimpleProgressReporter
273
- include DefaultUserInteraction
294
+ def done
295
+ end
296
+ end
274
297
 
275
- attr_reader :count
298
+ ##
299
+ # A basic dotted progress reporter.
276
300
 
277
- def initialize(out_stream, size, initial_message,
278
- terminal_message = "complete")
279
- @out = out_stream
280
- @total = size
281
- @count = 0
282
- @terminal_message = terminal_message
301
+ class SimpleProgressReporter
283
302
 
284
- @out.puts initial_message
285
- end
303
+ include Gem::DefaultUserInteraction
286
304
 
287
- ##
288
- # Prints out a dot and ignores +message+.
305
+ attr_reader :count
289
306
 
290
- def updated(message)
291
- @count += 1
292
- @out.print "."
293
- @out.flush
294
- end
307
+ def initialize(out_stream, size, initial_message,
308
+ terminal_message = "complete")
309
+ @out = out_stream
310
+ @total = size
311
+ @count = 0
312
+ @terminal_message = terminal_message
295
313
 
296
- ##
297
- # Prints out the terminal message.
314
+ @out.puts initial_message
315
+ end
298
316
 
299
- def done
300
- @out.puts "\n#{@terminal_message}"
301
- end
317
+ ##
318
+ # Prints out a dot and ignores +message+.
302
319
 
320
+ def updated(message)
321
+ @count += 1
322
+ @out.print "."
323
+ @out.flush
303
324
  end
304
325
 
305
326
  ##
306
- # A progress reporter that prints out messages about the current progress.
327
+ # Prints out the terminal message.
307
328
 
308
- class VerboseProgressReporter
309
- include DefaultUserInteraction
329
+ def done
330
+ @out.puts "\n#{@terminal_message}"
331
+ end
310
332
 
311
- attr_reader :count
333
+ end
312
334
 
313
- def initialize(out_stream, size, initial_message,
314
- terminal_message = 'complete')
315
- @out = out_stream
316
- @total = size
317
- @count = 0
318
- @terminal_message = terminal_message
335
+ ##
336
+ # A progress reporter that prints out messages about the current progress.
319
337
 
320
- @out.puts initial_message
321
- end
338
+ class VerboseProgressReporter
322
339
 
323
- ##
324
- # Prints out the position relative to the total and the +message+.
340
+ include Gem::DefaultUserInteraction
325
341
 
326
- def updated(message)
327
- @count += 1
328
- @out.puts "#{@count}/#{@total}: #{message}"
329
- end
342
+ attr_reader :count
330
343
 
331
- ##
332
- # Prints out the terminal message.
344
+ def initialize(out_stream, size, initial_message,
345
+ terminal_message = 'complete')
346
+ @out = out_stream
347
+ @total = size
348
+ @count = 0
349
+ @terminal_message = terminal_message
333
350
 
334
- def done
335
- @out.puts @terminal_message
336
- end
351
+ @out.puts initial_message
337
352
  end
338
- end
339
353
 
340
- ##
341
- # Subclass of StreamUI that instantiates the user interaction using STDIN,
342
- # STDOUT, and STDERR.
354
+ ##
355
+ # Prints out the position relative to the total and the +message+.
343
356
 
344
- class ConsoleUI < StreamUI
345
- def initialize
346
- super(STDIN, STDOUT, STDERR)
357
+ def updated(message)
358
+ @count += 1
359
+ @out.puts "#{@count}/#{@total}: #{message}"
347
360
  end
348
- end
349
361
 
350
- ##
351
- # SilentUI is a UI choice that is absolutely silent.
362
+ ##
363
+ # Prints out the terminal message.
352
364
 
353
- class SilentUI
354
- def method_missing(sym, *args, &block)
355
- self
365
+ def done
366
+ @out.puts @terminal_message
356
367
  end
357
368
  end
358
369
 
359
370
  end
360
371
 
372
+ ##
373
+ # Subclass of StreamUI that instantiates the user interaction using STDIN,
374
+ # STDOUT, and STDERR.
375
+
376
+ class Gem::ConsoleUI < Gem::StreamUI
377
+ def initialize
378
+ super STDIN, STDOUT, STDERR
379
+ end
380
+ end
381
+
382
+ ##
383
+ # SilentUI is a UI choice that is absolutely silent.
384
+
385
+ class Gem::SilentUI
386
+ def method_missing(sym, *args, &block)
387
+ self
388
+ end
389
+ end
390
+