Browse files

Add TODO for various improvements to RubyGems.

Fix minor comment and whitespace issues
  • Loading branch information...
1 parent 72648d1 commit bb81071448ab9c4b0be2db3d0503ecb1f14a8302 @drbrain drbrain committed Dec 20, 2011
View
2 lib/rubygems/builder.rb
@@ -4,6 +4,8 @@
# See LICENSE.txt for permissions.
#++
+# TODO: Merge with Gem::Format
+
require 'rubygems'
require 'rubygems/user_interaction'
View
9 lib/rubygems/command_manager.rb
@@ -99,7 +99,7 @@ def unregister_command(command)
end
##
- # Return the registered command from the command name.
+ # Returns a Command instance for +command_name+
def [](command_name)
command_name = command_name.intern
@@ -108,14 +108,14 @@ def [](command_name)
end
##
- # Return a sorted list of all command names (as strings).
+ # Return a sorted list of all command names as strings.
def command_names
@commands.keys.collect {|key| key.to_s}.sort
end
##
- # Run the config specified by +args+.
+ # Run the command specified by +args+.
def run(args)
process_args(args)
@@ -165,7 +165,8 @@ def process_args(args)
def find_command(cmd_name)
possibilities = find_command_possibilities cmd_name
- if possibilities.size > 1 then
+ if possibilities.size > 1 then # TODO if there's an exact match, pick it
+ # TODO raise Gem::Exception subclass
raise "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
elsif possibilities.size < 1 then
raise "Unknown command #{cmd_name}"
View
19 lib/rubygems/config_file.rb
@@ -151,6 +151,8 @@ class Gem::ConfigFile
# <tt>--debug</tt>::
# Enable Ruby level debug messages. Handled early for the same reason as
# --backtrace.
+ #--
+ # TODO: parse options upstream, pass in options directly
def initialize(args)
@config_file_name = nil
@@ -187,14 +189,14 @@ def initialize(args)
@hash = @hash.merge user_config
# HACK these override command-line args, which is bad
- @backtrace = @hash[:backtrace] if @hash.key? :backtrace
- @benchmark = @hash[:benchmark] if @hash.key? :benchmark
- @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
- @home = @hash[:gemhome] if @hash.key? :gemhome
- @path = @hash[:gempath] if @hash.key? :gempath
- @update_sources = @hash[:update_sources] if @hash.key? :update_sources
- @verbose = @hash[:verbose] if @hash.key? :verbose
- @disable_default_gem_server = @hash[:verbose] if @hash.key? :disable_default_gem_server
+ @backtrace = @hash[:backtrace] if @hash.key? :backtrace
+ @benchmark = @hash[:benchmark] if @hash.key? :benchmark
+ @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
+ @home = @hash[:gemhome] if @hash.key? :gemhome
+ @path = @hash[:gempath] if @hash.key? :gempath
+ @update_sources = @hash[:update_sources] if @hash.key? :update_sources
+ @verbose = @hash[:verbose] if @hash.key? :verbose
+ @disable_default_gem_server = @hash[:verbose] if @hash.key? :disable_default_gem_server
load_api_keys
@@ -215,6 +217,7 @@ def load_api_keys
else
@hash
end
+
if @api_keys.key? :rubygems_api_key then
@rubygems_api_key = @api_keys[:rubygems_api_key]
@api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless @api_keys.key? :rubygems
View
2 lib/rubygems/custom_require.rb
@@ -42,6 +42,8 @@ def require path
# If +path+ is for a gem that has already been loaded, don't
# bother trying to find it in an unresolved gem, just go straight
# to normal require.
+ #--
+ # TODO request access to the C implementation of this to speed up RubyGems
spec = Gem::Specification.find { |s|
s.activated? and s.contains_requirable_file? path
View
6 lib/rubygems/dependency_list.rb
@@ -10,6 +10,10 @@
##
# Gem::DependencyList is used for installing and uninstalling gems in the
# correct order to avoid conflicts.
+#--
+# TODO: It appears that all but topo-sort functionality is being duplicated
+# (or is planned to be duplicated) elsewhere in rubygems. Is the majority of
+# this class necessary anymore? Especially #ok?, #why_not_ok?
class Gem::DependencyList
attr_reader :specs
@@ -33,6 +37,8 @@ def self.from_specs
##
# Creates a DependencyList from a Gem::SourceIndex +source_index+
+ #--
+ # TODO: delete per deprecation at bottom of file
def self.from_source_index(ignored=nil)
warn "NOTE: DependencyList.from_source_index ignores it's arg" if ignored
View
2 lib/rubygems/doc_manager.rb
@@ -4,6 +4,8 @@
# See LICENSE.txt for permissions.
#++
+# TODO delete, superseded by lib/rubygems/rdoc.rb
+
require 'rubygems'
##
View
13 lib/rubygems/errors.rb
@@ -1,10 +1,9 @@
-class Gem::ErrorReason; end
+class Gem::ErrorReason; end # TODO: remove, unnecessary superclass
-# Generated when trying to lookup a gem to indicate that the gem
-# was found, but that it isn't usable on the current platform.
-#
-# fetch and install read these and report them to the user to aid
-# in figuring out why a gem couldn't be installed.
+# TODO move to lib/rubygems/platform_mismatch.rb
+# TODO write tests
+#--
+# Generated when a gem is found that isn't usable on the current platform.
#
class Gem::PlatformMismatch < Gem::ErrorReason
@@ -22,6 +21,8 @@ def add_platform(platform)
@platforms << platform
end
+ #--
+ # Replace only "platforms", remove duplicate strings
def wordy
prefix = "Found #{@name} (#{@version})"
View
5 lib/rubygems/exceptions.rb
@@ -1,3 +1,8 @@
+# TODO: the documentation in here is terrible.
+#
+# Each exception needs a brief description and the scenarios where it is
+# likely to be raised
+
##
# Base exception class for RubyGems. All exception raised by RubyGems are a
# subclass of this one.
View
11 lib/rubygems/format.rb
@@ -4,11 +4,12 @@
# See LICENSE.txt for permissions.
#++
+# TODO: Merge with Gem::Builder as Gem::GemFile or something to read and write
+
require 'rubygems/package'
##
-# Gem::Format knows the guts of the RubyGem .gem file format and provides the
-# capability to read gem files
+# Gem::Format can read a .gem file
class Gem::Format
@@ -26,6 +27,8 @@ def initialize(gem_path)
##
# Reads the gem +file_path+ using +security_policy+ and returns a Format
# representing the data in the gem
+ #--
+ # TODO this method name is terrible, use ::read
def self.from_file_by_path(file_path, security_policy = nil)
unless File.file?(file_path)
@@ -41,6 +44,7 @@ def self.from_file_by_path(file_path, security_policy = nil)
Gem::OldFormat.from_file_by_path file_path
else
+ # TODO move to an instance method
begin
open file_path, Gem.binary_mode do |io|
from_io io, file_path, security_policy
@@ -59,6 +63,7 @@ def self.from_file_by_path(file_path, security_policy = nil)
def self.from_io(io, gem_path="(io)", security_policy = nil)
format = new gem_path
+ # TODO move to an instance method
Gem::Package.open io, 'r', security_policy do |pkg|
format.spec = pkg.metadata
format.file_entries = []
@@ -70,7 +75,7 @@ def self.from_io(io, gem_path="(io)", security_policy = nil)
format.file_entries << [{
"size" => size, "mode" => mode, "path" => entry.full_name,
},
- entry.read
+ entry.read # TODO does entry handle this so we can delete it? or seek instead?
]
end
end
View
1 lib/rubygems/gem_openssl.rb
@@ -46,6 +46,7 @@ def ensure_ssl_available
Gem.ssl_available = !!OpenSSL::Digest::SHA1
+ # TODO: isn't this available on 1.8.7+?
class OpenSSL::X509::Certificate
# Check the validity of this certificate.
def check_validity(issuer_cert = nil, time = Time.now)
View
2 lib/rubygems/gem_path_searcher.rb
@@ -4,6 +4,8 @@
##
# GemPathSearcher has the capability to find loadable files inside
# gems. It generates data up front to speed up searches later.
+#--
+# TODO: delete per deprecation in lib/rubygems.rb
class Gem::GemPathSearcher
View
2 lib/rubygems/gem_runner.rb
@@ -40,6 +40,7 @@ def run(args)
# We need to preserve the original ARGV to use for passing gem options
# to source gems. If there is a -- in the line, strip all options after
# it...its for the source building process.
+ # TODO use slice!
build_args = args[args.index("--") + 1...args.length]
args = args[0...args.index("--")]
end
@@ -63,6 +64,7 @@ def run(args)
cmd.run Gem.configuration.args
end_time = Time.now
+ # TODO: remove benchmark, time(1) is good enough
if Gem.configuration.benchmark then
printf "\nExecution time: %0.2f seconds.\n", end_time - start_time
puts "Press Enter to finish"
View
1 lib/rubygems/gemcutter_utilities.rb
@@ -1,6 +1,7 @@
require 'rubygems/remote_fetcher'
module Gem::GemcutterUtilities
+ # TODO: move to Gem::Command
OptionParser.accept Symbol do |value|
value.to_sym
end
View
2 lib/rubygems/indexer.rb
@@ -109,6 +109,8 @@ def initialize(directory, options = {})
# searching, downloading and related activities and do not need deployment
# specific information (e.g. list of files). So we abbreviate the spec,
# making it much smaller for quicker downloads.
+ #--
+ # TODO move to Gem::Specification
def abbreviate(spec)
spec.files = []
View
4 lib/rubygems/install_message.rb
@@ -1,6 +1,10 @@
require 'rubygems'
require 'rubygems/user_interaction'
+##
+# A default post-install hook that displays "Successfully installed
+# some_gem-1.0"
+
Gem.post_install do |installer|
ui = Gem::DefaultUserInteraction.ui
ui.say "Successfully installed #{installer.spec.full_name}"
View
1 lib/rubygems/install_update_options.rb
@@ -22,6 +22,7 @@ module Gem::InstallUpdateOptions
# Add the install/update options to the option parser.
def add_install_update_options
+ # TODO: use @parser.accept
OptionParser.accept Gem::Security::Policy do |value|
require 'rubygems/security'
View
2 lib/rubygems/installer_test_case.rb
@@ -61,6 +61,8 @@ class Gem::Installer
##
# A test case for Gem::Installer.
+#--
+# TODO document these utility methods
class Gem::InstallerTestCase < Gem::TestCase

0 comments on commit bb81071

Please sign in to comment.