Sha256: 336fade804a530bb76a88e6b02fd188034f64147fa022c63bd177a496e9288cf

Contents?: true

Size: 1.83 KB

Versions: 100

Compression:

Stored size: 1.83 KB

Contents

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

require 'rubygems'

##
# Mixin methods for --version and --platform Gem::Command options.

module Gem::VersionOption

  ##
  # Add the --platform option to the option parser.

  def add_platform_option(task = command, *wrap)
    OptionParser.accept Gem::Platform do |value|
      if value == Gem::Platform::RUBY then
        value
      else
        Gem::Platform.new value
      end
    end

    add_option('--platform PLATFORM', Gem::Platform,
               "Specify the platform of gem to #{task}", *wrap) do
                 |value, options|
      unless options[:added_platform] then
        Gem.platforms = [Gem::Platform::RUBY]
        options[:added_platform] = true
      end

      Gem.platforms << value unless Gem.platforms.include? value
    end
  end

  ##
  # Add the --prerelease option to the option parser.

  def add_prerelease_option(*wrap)
    add_option("--[no-]prerelease",
               "Allow prerelease versions of a gem", *wrap) do |value, options|
      options[:prerelease] = value
      options[:explicit_prerelease] = true
    end
  end

  ##
  # Add the --version option to the option parser.

  def add_version_option(task = command, *wrap)
    OptionParser.accept Gem::Requirement do |value|
      Gem::Requirement.new(*value.split(/\s*,\s*/))
    end

    add_option('-v', '--version VERSION', Gem::Requirement,
               "Specify version of gem to #{task}", *wrap) do
                 |value, options|
      options[:version] = value

      explicit_prerelease_set = !options[:explicit_prerelease].nil?
      options[:explicit_prerelease] = false unless explicit_prerelease_set

      options[:prerelease] = value.prerelease? unless
        options[:explicit_prerelease]
    end
  end

end

Version data entries

100 entries across 72 versions & 4 rubygems

Version Path
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/l64/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.3.0 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.3.0 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.3.0 bin/traveling-ruby-2.2.2/l64/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.3.0 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.5 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.5 bin/traveling-ruby-2.2.2/l64/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.5 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.5 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.4 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.4 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.4 bin/traveling-ruby-2.2.2/l64/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.4 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.3 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.3 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.3 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/rubygems/version_option.rb
rb2exe-0.2.3 bin/traveling-ruby-2.2.2/l64/lib/ruby/2.2.0/rubygems/version_option.rb