| 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 17
17: def add_platform_option(task = command, *wrap)
18: OptionParser.accept Gem::Platform do |value|
19: if value == Gem::Platform::RUBY then
20: value
21: else
22: Gem::Platform.new value
23: end
24: end
25:
26: add_option('--platform PLATFORM', Gem::Platform,
27: "Specify the platform of gem to #{task}", *wrap) do
28: |value, options|
29: unless options[:added_platform] then
30: Gem.platforms = [Gem::Platform::RUBY]
31: options[:added_platform] = true
32: end
33:
34: Gem.platforms << value unless Gem.platforms.include? value
35: end
36: end
Add the —prerelease option to the option parser.
# File lib/rubygems/version_option.rb, line 41
41: def add_prerelease_option(*wrap)
42: add_option("--[no-]prerelease",
43: "Allow prerelease versions of a gem", *wrap) do |value, options|
44: options[:prerelease] = value
45: end
46: end
Add the —version option to the option parser.
# File lib/rubygems/version_option.rb, line 51
51: def add_version_option(task = command, *wrap)
52: OptionParser.accept Gem::Requirement do |value|
53: Gem::Requirement.new value
54: end
55:
56: add_option('-v', '--version VERSION', Gem::Requirement,
57: "Specify version of gem to #{task}", *wrap) do
58: |value, options|
59: options[:version] = value
60: options[:prerelease] = true if value.prerelease?
61: end
62: end