Module | Gem::VersionOption |
In: |
lib/rubygems/version_option.rb
|
Mixin methods for —version and —platform Gem::Command options.
Add the —platform option to the option parser.
# File lib/rubygems/version_option.rb, line 13 13: def add_platform_option(task = command, *wrap) 14: OptionParser.accept Gem::Platform do |value| 15: if value == Gem::Platform::RUBY then 16: value 17: else 18: Gem::Platform.new value 19: end 20: end 21: 22: add_option('--platform PLATFORM', Gem::Platform, 23: "Specify the platform of gem to #{task}", *wrap) do 24: |value, options| 25: unless options[:added_platform] then 26: Gem.platforms = [Gem::Platform::RUBY] 27: options[:added_platform] = true 28: end 29: 30: Gem.platforms << value unless Gem.platforms.include? value 31: end 32: end
Add the —version option to the option parser.
# File lib/rubygems/version_option.rb, line 35 35: def add_version_option(task = command, *wrap) 36: OptionParser.accept Gem::Requirement do |value| 37: Gem::Requirement.new value 38: end 39: 40: add_option('-v', '--version VERSION', Gem::Requirement, 41: "Specify version of gem to #{task}", *wrap) do 42: |value, options| 43: options[:version] = value 44: options[:prerelease] = true if value.prerelease? 45: end 46: end