rubygems-update 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (96) hide show
  1. data/ChangeLog +2335 -0
  2. data/README +54 -0
  3. data/Rakefile +293 -0
  4. data/Releases +98 -0
  5. data/TODO +7 -0
  6. data/bin/gem +11 -0
  7. data/bin/gem_server +111 -0
  8. data/bin/generate_yaml_index.rb +58 -0
  9. data/bin/update_rubygems +18 -0
  10. data/doc/doc.css +73 -0
  11. data/doc/makedoc.rb +4 -0
  12. data/examples/application/an-app.gemspec +26 -0
  13. data/examples/application/bin/myapp +3 -0
  14. data/examples/application/lib/somefunctionality.rb +3 -0
  15. data/gemspecs/README +4 -0
  16. data/gemspecs/cgikit-1.1.0.gemspec +18 -0
  17. data/gemspecs/jabber4r.gemspec +26 -0
  18. data/gemspecs/linguistics.gemspec +22 -0
  19. data/gemspecs/ook.gemspec +21 -0
  20. data/gemspecs/progressbar.gemspec +22 -0
  21. data/gemspecs/redcloth.gemspec +22 -0
  22. data/gemspecs/rublog.gemspec +23 -0
  23. data/gemspecs/ruby-doom.gemspec +21 -0
  24. data/gemspecs/rubyjdwp.gemspec +21 -0
  25. data/gemspecs/statistics.gemspec +21 -0
  26. data/lib/rubygems.rb +353 -0
  27. data/lib/rubygems/builder.rb +54 -0
  28. data/lib/rubygems/cmd_manager.rb +127 -0
  29. data/lib/rubygems/command.rb +191 -0
  30. data/lib/rubygems/config_file.rb +57 -0
  31. data/lib/rubygems/doc_manager.rb +94 -0
  32. data/lib/rubygems/format.rb +65 -0
  33. data/lib/rubygems/gem_commands.rb +925 -0
  34. data/lib/rubygems/gem_runner.rb +23 -0
  35. data/lib/rubygems/installer.rb +621 -0
  36. data/lib/rubygems/loadpath_manager.rb +108 -0
  37. data/lib/rubygems/old_format.rb +150 -0
  38. data/lib/rubygems/open-uri.rb +604 -0
  39. data/lib/rubygems/package.rb +740 -0
  40. data/lib/rubygems/remote_installer.rb +499 -0
  41. data/lib/rubygems/rubygems_version.rb +6 -0
  42. data/lib/rubygems/source_index.rb +130 -0
  43. data/lib/rubygems/specification.rb +613 -0
  44. data/lib/rubygems/user_interaction.rb +176 -0
  45. data/lib/rubygems/validator.rb +148 -0
  46. data/lib/rubygems/version.rb +279 -0
  47. data/lib/ubygems.rb +4 -0
  48. data/pkgs/sources/lib/sources.rb +6 -0
  49. data/pkgs/sources/sources.gemspec +14 -0
  50. data/post-install.rb +75 -0
  51. data/redist/session.gem +433 -0
  52. data/scripts/buildtests.rb +25 -0
  53. data/scripts/gemdoc.rb +62 -0
  54. data/scripts/runtest.rb +17 -0
  55. data/scripts/specdoc.rb +164 -0
  56. data/setup.rb +1360 -0
  57. data/test/bogussources.rb +5 -0
  58. data/test/data/legacy/keyedlist-0.4.0.ruby +11 -0
  59. data/test/data/legacy/keyedlist-0.4.0.yaml +16 -0
  60. data/test/data/lib/code.rb +1 -0
  61. data/test/data/one/README.one +1 -0
  62. data/test/data/one/lib/one.rb +3 -0
  63. data/test/data/one/one.gemspec +17 -0
  64. data/test/data/one/one.yaml +40 -0
  65. data/test/functional.rb +145 -0
  66. data/test/gemenvironment.rb +45 -0
  67. data/test/gemutilities.rb +18 -0
  68. data/test/insure_session.rb +46 -0
  69. data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +5 -0
  70. data/test/mock/gems/specifications/sources-0.0.1.gemspec +8 -0
  71. data/test/mockgemui.rb +45 -0
  72. data/test/onegem.rb +23 -0
  73. data/test/simple_gem.rb +66 -0
  74. data/test/test_builder.rb +13 -0
  75. data/test/test_cached_fetcher.rb +60 -0
  76. data/test/test_check_command.rb +28 -0
  77. data/test/test_command.rb +130 -0
  78. data/test/test_configfile.rb +36 -0
  79. data/test/test_format.rb +70 -0
  80. data/test/test_gemloadpaths.rb +45 -0
  81. data/test/test_gempaths.rb +115 -0
  82. data/test/test_loadmanager.rb +40 -0
  83. data/test/test_local_cache.rb +157 -0
  84. data/test/test_package.rb +600 -0
  85. data/test/test_parse_commands.rb +179 -0
  86. data/test/test_process_commands.rb +21 -0
  87. data/test/test_remote_fetcher.rb +162 -0
  88. data/test/test_remote_installer.rb +154 -0
  89. data/test/test_source_index.rb +58 -0
  90. data/test/test_specification.rb +286 -0
  91. data/test/test_validator.rb +53 -0
  92. data/test/test_version_comparison.rb +204 -0
  93. data/test/testgem.rc +6 -0
  94. data/test/user_capture.rb +1 -0
  95. data/test/yaml_data.rb +59 -0
  96. metadata +151 -0
@@ -0,0 +1,127 @@
1
+ require 'rubygems'
2
+ require 'rubygems/command'
3
+ require 'rubygems/user_interaction'
4
+ require 'rubygems/gem_commands'
5
+
6
+ module Gem
7
+
8
+ # Signals that local installation will not proceed, not that it has
9
+ # been tried and failed. TODO: better name.
10
+ class LocalInstallationError < Gem::Exception; end
11
+
12
+ class FilePermissionError < Gem::Exception
13
+ def initialize(path)
14
+ super("You don't have write permissions into the #{path} directory.")
15
+ end
16
+ end
17
+
18
+ # Signals that a remote operation cannot be conducted, probably due to not being
19
+ # connected (or just not finding host).
20
+ #
21
+ # TODO: create a method that tests connection to the preferred gems server. All code
22
+ # dealing with remote operations will want this. Failure in that method should raise
23
+ # this error.
24
+ class RemoteError < Gem::Exception; end
25
+
26
+ class CommandManager
27
+ include UserInteraction
28
+
29
+ def self.instance
30
+ @cmd_manager ||= CommandManager.new
31
+ end
32
+
33
+ def initialize
34
+ @commands = {}
35
+ register_command HelpCommand.new
36
+ register_command InstallCommand.new
37
+ register_command UninstallCommand.new
38
+ register_command CheckCommand.new
39
+ register_command BuildCommand.new
40
+ register_command QueryCommand.new
41
+ register_command ListCommand.new
42
+ register_command SearchCommand.new
43
+ register_command UpdateCommand.new
44
+ register_command RDocCommand.new
45
+ register_command EnvironmentCommand.new
46
+ register_command SpecificationCommand.new
47
+ register_command UnpackCommand.new
48
+ end
49
+
50
+ def register_command(command)
51
+ @commands[command.command.intern] = command
52
+ end
53
+
54
+ def [](command_name)
55
+ @commands[command_name.intern]
56
+ end
57
+
58
+ def command_names
59
+ @commands.keys.collect {|key| key.to_s}.sort
60
+ end
61
+
62
+ def run(cfg)
63
+ process_args(cfg.args)
64
+ rescue StandardError => ex
65
+ alert_error "While executing gem ... (#{ex.class})\n #{ex.to_s}"
66
+ puts ex.backtrace if cfg.backtrace
67
+ terminate_interaction(1)
68
+ end
69
+
70
+ def process_args(args)
71
+ args = args.to_str.split(/\s/) if args.respond_to?(:to_str)
72
+ if args.size == 0
73
+ say Gem::HELP
74
+ terminate_interaction(1)
75
+ end
76
+ case args[0]
77
+ when '-h', '--help'
78
+ say Gem::HELP
79
+ terminate_interaction(0)
80
+ when '-v', '--version'
81
+ say Gem::RubyGemsPackageVersion
82
+ terminate_interaction(0)
83
+ when /^-/
84
+ alert_error "Invalid option: #{args[0]}. See 'gem --help'."
85
+ terminate_interaction(1)
86
+ else
87
+ cmd_name = args.shift.downcase
88
+ cmd = find_command(cmd_name)
89
+ #load_config_file_options(args)
90
+ cmd.invoke(*args)
91
+ end
92
+ end
93
+
94
+ def find_command(cmd_name)
95
+ possibilities = find_command_possibilities(cmd_name)
96
+ if possibilities.size > 1
97
+ raise "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
98
+ end
99
+ if possibilities.size < 1
100
+ raise "Unknown command #{cmd_name}"
101
+ end
102
+ self[possibilities.first]
103
+ end
104
+
105
+ def find_command_possibilities(cmd_name)
106
+ len = cmd_name.length
107
+ self.command_names.select { |n| cmd_name == n[0,len] }
108
+ end
109
+
110
+ # - a config file may be specified on the command line
111
+ # - if it's specified multiple times, the first one wins
112
+ # - there is a default config file location HOME/.gemrc
113
+ def load_config_file_options(args)
114
+ config_file = File.join(ENV['HOME'], ".gemrc")
115
+ if args.index("--config-file")
116
+ config_file = args[args.index("--config-file")+1]
117
+ end
118
+ if File.exist?(config_file)
119
+ @config_file_options = YAML.load(File.read(config_file))
120
+ else
121
+ alert_error "Config file #{config_file} not found" if options[:config_file]
122
+ terminate_interaction!if options[:config_file]
123
+ end
124
+ end
125
+
126
+ end
127
+ end
@@ -0,0 +1,191 @@
1
+ require 'rubygems/user_interaction'
2
+
3
+ module Gem
4
+ class Command
5
+ include UserInteraction
6
+
7
+ Option = Struct.new(:short, :long, :description, :handler)
8
+
9
+ attr_reader :command, :options
10
+ attr_accessor :summary, :defaults, :program_name
11
+
12
+ def initialize(command, summary=nil, defaults={})
13
+ @command = command
14
+ @summary = summary
15
+ @program_name = "gem #{command}"
16
+ @defaults = defaults
17
+ @options = defaults.dup
18
+ @option_list = []
19
+ @parser = nil
20
+ end
21
+
22
+ def show_help
23
+ parser.program_name = usage
24
+ say parser
25
+ end
26
+
27
+ def usage
28
+ "#{program_name}"
29
+ end
30
+
31
+ # Override this method to provide details of the arguments a command takes. It should
32
+ # return a left-justified string, one argument per line.
33
+ def arguments
34
+ ""
35
+ end
36
+
37
+ # This is just like the 'arguments' method, except it describes the default options used.
38
+ def defaults_str
39
+ ""
40
+ end
41
+
42
+ def invoke(*args)
43
+ handle_options(args)
44
+ if options[:help]
45
+ show_help
46
+ elsif @when_invoked
47
+ @when_invoked.call(options)
48
+ else
49
+ execute
50
+ end
51
+ end
52
+
53
+ def when_invoked(&block)
54
+ @when_invoked = block
55
+ end
56
+
57
+ def add_option(*args, &handler)
58
+ @option_list << [args, handler]
59
+ end
60
+
61
+ def remove_option(name)
62
+ @option_list.reject! { |args, handler| args.any? { |x| x =~ /^#{name}/ } }
63
+ end
64
+
65
+ def merge_options(new_options)
66
+ @options = @defaults.clone
67
+ new_options.each do |k,v| @options[k] = v end
68
+ end
69
+
70
+ def handles?(args)
71
+ begin
72
+ parser.parse!(args.dup)
73
+ return true
74
+ rescue
75
+ return false
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def handle_options(args)
82
+ args = add_extra_args(args)
83
+ @options = @defaults.clone
84
+ parser.parse!(args)
85
+ @options[:args] = args
86
+ end
87
+
88
+ def add_extra_args(args)
89
+ result = []
90
+ extra = Command.extra_args.dup
91
+ while ! extra.empty?
92
+ ex = []
93
+ ex << extra.shift
94
+ ex << extra.shift if extra.first.to_s =~ /^[^-]/
95
+ result << ex if handles?(ex)
96
+ end
97
+ result.flatten!
98
+ result.concat(args)
99
+ result
100
+ end
101
+
102
+ # Create on demand parser.
103
+ def parser
104
+ create_option_parser if @parser.nil?
105
+ @parser
106
+ end
107
+
108
+ def create_option_parser
109
+ require 'optparse'
110
+ @parser = OptionParser.new
111
+ option_names = {}
112
+ @parser.separator("")
113
+ unless @option_list.empty?
114
+ @parser.separator(" Options:")
115
+ configure_options(@option_list, option_names)
116
+ @parser.separator("")
117
+ end
118
+ @parser.separator(" Common Options:")
119
+ configure_options(Command.common_options, option_names)
120
+ @parser.separator("")
121
+ unless arguments.empty?
122
+ @parser.separator(" Arguments:")
123
+ arguments.split(/\n/).each do |arg_desc|
124
+ @parser.separator(" #{arg_desc}")
125
+ end
126
+ @parser.separator("")
127
+ end
128
+ @parser.separator(" Summary:")
129
+ @parser.separator(" #@summary")
130
+ unless defaults_str.empty?
131
+ @parser.separator("")
132
+ @parser.separator(" Defaults:")
133
+ defaults_str.split(/\n/).each do |line|
134
+ @parser.separator(" #{line}")
135
+ end
136
+ end
137
+ end
138
+
139
+ def configure_options(option_list, option_names)
140
+ option_list.each do |args, handler|
141
+ dashes = args.select { |arg| arg =~ /^-/ }
142
+ next if dashes.any? { |arg| option_names[arg] }
143
+ @parser.on(*args) do |value|
144
+ handler.call(value, @options)
145
+ end
146
+ dashes.each do |arg| option_names[arg] = true end
147
+ end
148
+ end
149
+
150
+ class << self
151
+ def common_options
152
+ @common_options ||= []
153
+ end
154
+
155
+ def add_common_option(*args, &handler)
156
+ Gem::Command.common_options << [args, handler]
157
+ end
158
+
159
+ def extra_args
160
+ @extra_args ||= []
161
+ end
162
+
163
+ def extra_args=(value)
164
+ case value
165
+ when Array
166
+ @extra_args = value
167
+ when String
168
+ @extra_args = value.split
169
+ end
170
+ end
171
+ end
172
+
173
+ add_common_option('--source URL', 'Use URL as the remote source for gems') do |value, options|
174
+ require_gem("sources")
175
+ Gem.sources.clear
176
+ Gem.sources << value
177
+ end
178
+ add_common_option('-p', '--[no-]http-proxy [URL]', 'Use HTTP proxy for remote operations') do |value, options|
179
+ options[:http_proxy] = (value == false) ? :no_proxy : value
180
+ end
181
+ add_common_option('-h', '--help', 'Get help on this command') do |value, options|
182
+ options[:help] = true
183
+ end
184
+ # Backtrace and config-file are added so they show up in the help
185
+ # commands. Both options are actually handled before the other
186
+ # options get parsed.
187
+ add_common_option('--config-file FILE', "Use this config file instead of default") do end
188
+ add_common_option('--backtrace', 'Show stack backtrace on errors') do end
189
+ add_common_option('--debug', 'Turn on Ruby debugging') do end
190
+ end # class
191
+ end # module
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+
5
+ module Gem
6
+ class ConfigFile
7
+ attr_reader :backtrace, :args
8
+
9
+ def initialize(arg_list)
10
+ handle_arguments(arg_list)
11
+ if File.exist?(config_file_name)
12
+ @hash = open(config_file_name) { |f| YAML.load(f) }
13
+ else
14
+ @hash = {}
15
+ end
16
+ end
17
+
18
+ def config_file_name
19
+ @config_file_name || default_config_file_name
20
+ end
21
+
22
+ def [](key)
23
+ @hash[key.to_s]
24
+ end
25
+
26
+ private
27
+
28
+ def handle_arguments(arg_list)
29
+ need_cfg_name = false
30
+ @args = []
31
+ arg_list.each do |arg|
32
+ if need_cfg_name
33
+ @config_file_name = arg
34
+ need_cfg_name = false
35
+ else
36
+ case arg
37
+ when /^--backtrace$/
38
+ @backtrace = true
39
+ when /^--debug$/
40
+ $DEBUG = true
41
+ when /^--config-file$/
42
+ need_cfg_name = true
43
+ when /^--config-file=(.+)$/
44
+ @config_file_name = $1
45
+ else
46
+ @args << arg
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ def default_config_file_name
53
+ File.join(ENV['HOME'], '.gemrc')
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,94 @@
1
+ module Gem
2
+
3
+ class DocumentError < Gem::Exception; end
4
+
5
+ class DocManager
6
+
7
+ include UserInteraction
8
+
9
+ #
10
+ # spec:: The Gem::Specification object representing the gem.
11
+ # rdoc_args:: Optional arguments for RDoc (template etc.) as a String.
12
+ #
13
+ def initialize(spec, rdoc_args="")
14
+ @spec = spec
15
+ @doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
16
+ Gem::FilePermissionError.new(spec.installation_path) unless File.writable?(spec.installation_path)
17
+ @rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
18
+ end
19
+
20
+ def rdoc_installed?
21
+ return File.exist?(File.join(@doc_dir, "rdoc"))
22
+ end
23
+
24
+ def install_doc(rdoc = true)
25
+ self.generate_rdoc if rdoc
26
+ require 'fileutils'
27
+ FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
28
+ end
29
+
30
+ ##
31
+ # Return Rdoc args as specified in gem spec. If args exist in gemspec,
32
+ # append any user-defined args. This behavior is open for a vote.
33
+ def rdoc_args_from_spec(non_spec_args)
34
+ @spec.rdoc_options << non_spec_args
35
+ end
36
+
37
+ def generate_rdoc
38
+ require 'fileutils'
39
+ Gem::FilePermissionError.new(@doc_dir) if File.exist?(@doc_dir) && !File.writable?(@doc_dir)
40
+ FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
41
+ begin
42
+ require 'rdoc/rdoc'
43
+ rescue LoadError => e
44
+ raise DocumentError, "ERROR: RDoc documentation generator not installed!"
45
+ end
46
+ say "Installing RDoc documentation for #{@spec.full_name}..."
47
+ say "WARNING: Generating RDoc on .gem that may not have RDoc." unless @spec.has_rdoc?
48
+ rdoc_dir = File.join(@doc_dir, "rdoc")
49
+ begin
50
+ source_dirs = @spec.require_paths.clone.concat(@spec.extra_rdoc_files)
51
+ current_dir = Dir.pwd
52
+ Dir.chdir(@spec.full_gem_path)
53
+ begin
54
+ @rdoc_args = rdoc_args_from_spec(@rdoc_args)
55
+ @rdoc_args.concat(DocManager.configured_args)
56
+ r = RDoc::RDoc.new
57
+ begin
58
+ r.document(['--quiet', '--op', rdoc_dir] + @rdoc_args.flatten + source_dirs)
59
+ rescue Errno::EACCES => e
60
+ raise Gem::FilePermissionError.new(File.dirname(e.message.split("-")[1].strip))
61
+ end
62
+ #TODO: Why is this throwing an error?
63
+ #ri = RDoc::RDoc.new
64
+ #ri.document(['-R'] + source_dirs)
65
+ ensure
66
+ Dir.chdir(current_dir)
67
+ end
68
+ rescue RDoc::RDocError => e
69
+ raise DocumentError, e.message
70
+ end
71
+ end
72
+
73
+ def uninstall_doc
74
+ doc_dir = File.join(@spec.installation_path, "doc", @spec.full_name)
75
+ FileUtils.rm_rf doc_dir
76
+ end
77
+
78
+ class << self
79
+ def configured_args
80
+ @configured_args ||= []
81
+ end
82
+
83
+ def configured_args=(args)
84
+ case args
85
+ when Array
86
+ @configured_args = args
87
+ when String
88
+ @configured_args = args.split
89
+ end
90
+ end
91
+ end
92
+
93
+ end
94
+ end