Module Gem::LocalRemoteOptions
In: lib/rubygems/local_remote_options.rb

Mixin methods for local and remote Gem::Command options.

Methods

Public Instance methods

Allows OptionParser to handle HTTP URIs.

[Source]

    # File lib/rubygems/local_remote_options.rb, line 18
18:   def accept_uri_http
19:     OptionParser.accept URI::HTTP do |value|
20:       begin
21:         uri = URI.parse value
22:       rescue URI::InvalidURIError
23:         raise OptionParser::InvalidArgument, value
24:       end
25: 
26:       raise OptionParser::InvalidArgument, value unless uri.scheme == 'http'
27: 
28:       value
29:     end
30:   end

Add the —bulk-threshold option

[Source]

    # File lib/rubygems/local_remote_options.rb, line 60
60:   def add_bulk_threshold_option
61:     add_option("Local/Remote""Local/Remote", '-B', '--bulk-threshold COUNT',
62:                "Threshold for switching to bulk",
63:                "synchronization (default #{Gem.configuration.bulk_threshold})") do
64:       |value, options|
65:       Gem.configuration.bulk_threshold = value.to_i
66:     end
67:   end

Add local/remote options to the command line parser.

[Source]

    # File lib/rubygems/local_remote_options.rb, line 35
35:   def add_local_remote_options
36:     add_option("Local/Remote""Local/Remote", '-l', '--local',
37:                'Restrict operations to the LOCAL domain') do |value, options|
38:       options[:domain] = :local
39:     end
40: 
41:     add_option("Local/Remote""Local/Remote", '-r', '--remote',
42:       'Restrict operations to the REMOTE domain') do |value, options|
43:       options[:domain] = :remote
44:     end
45: 
46:     add_option("Local/Remote""Local/Remote", '-b', '--both',
47:                'Allow LOCAL and REMOTE operations') do |value, options|
48:       options[:domain] = :both
49:     end
50: 
51:     add_bulk_threshold_option
52:     add_source_option
53:     add_proxy_option
54:     add_update_sources_option
55:   end

Add the —http-proxy option

[Source]

    # File lib/rubygems/local_remote_options.rb, line 72
72:   def add_proxy_option
73:     accept_uri_http
74: 
75:     add_option("Local/Remote""Local/Remote", '-p', '--[no-]http-proxy [URL]', URI::HTTP,
76:                'Use HTTP proxy for remote operations') do |value, options|
77:       options[:http_proxy] = (value == false) ? :no_proxy : value
78:       Gem.configuration[:http_proxy] = options[:http_proxy]
79:     end
80:   end

Add the —source option

[Source]

    # File lib/rubygems/local_remote_options.rb, line 85
85:   def add_source_option
86:     accept_uri_http
87: 
88:     add_option("Local/Remote""Local/Remote", '--source URL', URI::HTTP,
89:                'Use URL as the remote source for gems') do |source, options|
90:       source << '/' if source !~ /\/\z/
91: 
92:       if options[:added_source] then
93:         Gem.sources << source
94:       else
95:         options[:added_source] = true
96:         Gem.sources.replace [source]
97:       end
98:     end
99:   end

Add the —source option

[Source]

     # File lib/rubygems/local_remote_options.rb, line 104
104:   def add_update_sources_option
105: 
106:     add_option("Local/Remote""Local/Remote", '-u', '--[no-]update-sources',
107:                'Update local source cache') do |value, options|
108:       Gem.configuration.update_sources = value
109:     end
110:   end

Is fetching of local and remote information enabled?

[Source]

     # File lib/rubygems/local_remote_options.rb, line 115
115:   def both?
116:     options[:domain] == :both
117:   end

Is local fetching enabled?

[Source]

     # File lib/rubygems/local_remote_options.rb, line 122
122:   def local?
123:     options[:domain] == :local || options[:domain] == :both
124:   end

Is remote fetching enabled?

[Source]

     # File lib/rubygems/local_remote_options.rb, line 129
129:   def remote?
130:     options[:domain] == :remote || options[:domain] == :both
131:   end

[Validate]