PHP 8.2.31
Preview: local_remote_options.rb Size: 3.36 KB
/proc/thread-self/root/opt/alt/ruby20/lib64/ruby/2.0.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: 6 × Files: 53

Name Size Perms Modified Actions
commands DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
core_ext DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
ext DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
package DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
security DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
ssl_certs DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
1.56 KB lrw-r--r-- 2013-03-17 14:51:53
Edit Download
13.43 KB lrw-r--r-- 2012-11-30 16:27:52
Edit Download
5.27 KB lrw-r--r-- 2012-12-06 05:26:46
Edit Download
1.58 KB lrw-r--r-- 2013-02-05 21:06:14
Edit Download
11.82 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
2.76 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
7.74 KB lrw-r--r-- 2012-12-23 00:35:09
Edit Download
12.36 KB lrw-r--r-- 2013-11-13 02:59:08
Edit Download
5.53 KB lrw-r--r-- 2013-03-17 14:51:53
Edit Download
14.97 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
1.73 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
2.86 KB lrw-r--r-- 2013-01-04 07:31:57
Edit Download
2.14 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
2.70 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
416 B lrw-r--r-- 2012-12-10 00:40:39
Edit Download
2.84 KB lrw-r--r-- 2013-09-15 14:23:26
Edit Download
1.98 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
12.89 KB lrw-r--r-- 2012-12-06 05:26:46
Edit Download
22.19 KB lrw-r--r-- 2013-08-16 15:35:06
Edit Download
4.28 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
281 B lrw-r--r-- 2012-11-29 06:52:18
Edit Download
5.09 KB lrw-r--r-- 2012-11-29 06:52:18
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
1.96 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
13.22 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
3.77 KB lrw-r--r-- 2013-08-16 15:35:06
Edit Download
1.58 KB lrw-r--r-- 2012-11-30 00:23:15
Edit Download
5.63 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
249 B lrw-r--r-- 2013-07-25 15:42:22
Edit Download
763 B lrw-r--r-- 2013-07-22 16:33:18
Edit Download
7.75 KB lrw-r--r-- 2013-03-17 14:51:53
Edit Download
15.99 KB lrw-r--r-- 2015-08-18 13:01:02
Edit Download
3.67 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
6.02 KB lrw-r--r-- 2012-11-30 16:27:52
Edit Download
1.11 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
20.56 KB lrw-r--r-- 2013-03-17 15:01:47
Edit Download
21.69 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
3.12 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
1.22 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
1.88 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
552 B lrw-r--r-- 2012-11-29 06:52:18
Edit Download
66.90 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
5.17 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
2.07 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
28.09 KB lrw-r--r-- 2013-07-25 15:42:22
Edit Download
4.03 KB lrw-r--r-- 2013-03-17 15:07:00
Edit Download
1.23 KB lrw-r--r-- 2011-07-27 01:40:07
Edit Download
8.29 KB lrw-r--r-- 2012-12-19 07:19:10
Edit Download
11.44 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
4.08 KB lrw-r--r-- 2012-12-23 00:35:09
Edit Download
10.50 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
1.59 KB lrw-r--r-- 2011-07-27 01:40:07
Edit Download

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