PHP 8.2.31
Preview: local_remote_options.rb Size: 3.36 KB
//proc/thread-self/root/opt/alt/ruby21/lib64/ruby/2.1.0/rubygems/local_remote_options.rb

#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++

require 'uri'
require 'rubygems'

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

module Gem::LocalRemoteOptions

  ##
  # Allows OptionParser to handle HTTP URIs.

  def accept_uri_http
    OptionParser.accept URI::HTTP do |value|
      begin
        uri = URI.parse value
      rescue URI::InvalidURIError
        raise OptionParser::InvalidArgument, value
      end

      unless ['http', 'https', 'file'].include?(uri.scheme)
         raise OptionParser::InvalidArgument, value
      end

      value
    end
  end

  ##
  # Add local/remote options to the command line parser.

  def add_local_remote_options
    add_option(:"Local/Remote", '-l', '--local',
               'Restrict operations to the LOCAL domain') do |value, options|
      options[:domain] = :local
    end

    add_option(:"Local/Remote", '-r', '--remote',
      'Restrict operations to the REMOTE domain') do |value, options|
      options[:domain] = :remote
    end

    add_option(:"Local/Remote", '-b', '--both',
               'Allow LOCAL and REMOTE operations') do |value, options|
      options[:domain] = :both
    end

    add_bulk_threshold_option
    add_clear_sources_option
    add_source_option
    add_proxy_option
    add_update_sources_option
  end

  ##
  # Add the --bulk-threshold option

  def add_bulk_threshold_option
    add_option(:"Local/Remote", '-B', '--bulk-threshold COUNT',
               "Threshold for switching to bulk",
               "synchronization (default #{Gem.configuration.bulk_threshold})") do
      |value, options|
      Gem.configuration.bulk_threshold = value.to_i
    end
  end

  ##
  # Add the --clear-sources option

  def add_clear_sources_option
    add_option(:"Local/Remote", '--clear-sources',
               'Clear the gem sources') do |value, options|

      Gem.sources = nil
      options[:sources_cleared] = true
    end
  end

  ##
  # Add the --http-proxy option

  def add_proxy_option
    accept_uri_http

    add_option(:"Local/Remote", '-p', '--[no-]http-proxy [URL]', URI::HTTP,
               'Use HTTP proxy for remote operations') do |value, options|
      options[:http_proxy] = (value == false) ? :no_proxy : value
      Gem.configuration[:http_proxy] = options[:http_proxy]
    end
  end

  ##
  # Add the --source option

  def add_source_option
    accept_uri_http

    add_option(:"Local/Remote", '--source URL', URI::HTTP,
               'Add URL as a remote source for gems') do |source, options|

      source << '/' if source !~ /\/\z/

      if options.delete :sources_cleared then
        Gem.sources = [source]
      else
        Gem.sources << source unless Gem.sources.include?(source)
      end
    end
  end

  ##
  # Add the --update-sources option

  def add_update_sources_option
    add_option(:Deprecated, '-u', '--[no-]update-sources',
               'Update local source cache') do |value, options|
      Gem.configuration.update_sources = value
    end
  end

  ##
  # Is fetching of local and remote information enabled?

  def both?
    options[:domain] == :both
  end

  ##
  # Is local fetching enabled?

  def local?
    options[:domain] == :local || options[:domain] == :both
  end

  ##
  # Is remote fetching enabled?

  def remote?
    options[:domain] == :remote || options[:domain] == :both
  end

end

Directory Contents

Dirs: 10 × Files: 59

Name Size Perms Modified Actions
commands DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
core_ext DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
ext DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
package DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
resolver DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
security DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
source DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
ssl_certs DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
util DIR
- drwxr-xr-x 2024-03-03 22:43:11
Edit Download
3.00 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
5.65 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
13.43 KB lrw-r--r-- 2012-11-30 16:27:52
Edit Download
4.62 KB lrw-r--r-- 2013-09-14 08:59:02
Edit Download
1.67 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
12.23 KB lrw-r--r-- 2023-07-26 14:19:40
Edit Download
3.64 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
7.77 KB lrw-r--r-- 2013-09-14 08:59:02
Edit Download
12.64 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
5.53 KB lrw-r--r-- 2013-02-27 23:20:57
Edit Download
1.70 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
3.04 KB lrw-r--r-- 2013-11-21 23:27:30
Edit Download
2.42 KB lrw-r--r-- 2013-11-19 00:34:13
Edit Download
5.87 KB lrw-r--r-- 2013-11-21 23:27:30
Edit Download
431 B lrw-r--r-- 2013-10-16 06:00:39
Edit Download
3.97 KB lrw-r--r-- 2013-09-18 21:29:41
Edit Download
1.96 KB lrw-r--r-- 2013-09-14 08:59:02
Edit Download
13.03 KB lrw-r--r-- 2013-10-16 00:14:16
Edit Download
21.42 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
4.20 KB lrw-r--r-- 2023-07-26 14:19:40
Edit Download
307 B lrw-r--r-- 2013-07-09 23:21:36
Edit Download
281 B lrw-r--r-- 2012-11-29 06:52:18
Edit Download
5.21 KB lrw-r--r-- 2013-09-14 08:59:02
Edit Download
3.36 KB lrw-r--r-- 2011-07-27 01:40:07
Edit Download
1.35 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
2.23 KB lrw-r--r-- 2013-09-14 08:59:02
Edit Download
14.25 KB lrw-r--r-- 2023-07-26 14:19:40
Edit Download
3.77 KB lrw-r--r-- 2013-08-26 20:24:51
Edit Download
1.82 KB lrw-r--r-- 2013-09-14 08:59:02
Edit Download
6.05 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
269 B lrw-r--r-- 2013-10-20 01:33:19
Edit Download
763 B lrw-r--r-- 2013-07-09 22:34:58
Edit Download
7.75 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
9.46 KB lrw-r--r-- 2015-08-18 12:56:58
Edit Download
7.53 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
6.94 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
6.10 KB lrw-r--r-- 2013-12-08 01:22:39
Edit Download
12.46 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
1.11 KB lrw-r--r-- 2023-07-26 14:19:40
Edit Download
20.96 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
21.69 KB lrw-r--r-- 2013-11-10 17:51:40
Edit Download
4.90 KB lrw-r--r-- 2013-12-08 01:22:39
Edit Download
2.47 KB lrw-r--r-- 2013-11-19 00:34:13
Edit Download
111 B lrw-r--r-- 2013-09-14 08:59:02
Edit Download
93 B lrw-r--r-- 2013-09-14 08:59:02
Edit Download
70.80 KB lrw-r--r-- 2023-07-26 14:19:40
Edit Download
6.40 KB lrw-r--r-- 2013-11-19 00:34:13
Edit Download
3.10 KB lrw-r--r-- 2013-10-18 21:56:18
Edit Download
2.09 KB lrw-r--r-- 2013-12-19 22:09:19
Edit Download
35.62 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
8.37 KB lrw-r--r-- 2013-12-08 01:22:39
Edit Download
1.23 KB lrw-r--r-- 2011-07-27 01:40:07
Edit Download
8.69 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
762 B lrw-r--r-- 2013-10-20 01:33:19
Edit Download
14.40 KB lrw-r--r-- 2013-12-13 00:51:04
Edit Download
2.26 KB lrw-r--r-- 2013-11-25 19:14:49
Edit Download
4.18 KB lrw-r--r-- 2013-11-30 23:27:52
Edit Download
10.78 KB lrw-r--r-- 2014-02-06 02:59:36
Edit Download
1.83 KB lrw-r--r-- 2013-09-14 08:59:02
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).