Class: Gem::Commands::SpecificInstallCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::SpecificInstallCommand
- Defined in:
- lib/rubygems/commands/specific_install_command.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #arguments ⇒ Object
- #description ⇒ Object
- #execute ⇒ Object
-
#initialize(output = STDOUT) ⇒ SpecificInstallCommand
constructor
A new instance of SpecificInstallCommand.
- #usage ⇒ Object
Constructor Details
#initialize(output = STDOUT) ⇒ SpecificInstallCommand
Returns a new instance of SpecificInstallCommand.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubygems/commands/specific_install_command.rb', line 11 def initialize(output=STDOUT) super 'specific_install', description @output = output add_option('-l', '--location LOCATION', arguments) do |location, | [:location] = location end add_option('-b', '--branch BRANCH', arguments) do |branch, | [:branch] = branch end add_option('-d', '--directory DIRECTORY', arguments) do |directory, | [:directory] = directory end add_option('-r', '--ref COMMIT-ISH', arguments) do |ref, | [:ref] = ref end add_option('-t', '--tag TAG', arguments) do |tag, | [:tag] = tag end add_option('-u', '--user-install', arguments) do |userinstall, | [:userinstall] = userinstall end end |
Instance Attribute Details
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/rubygems/commands/specific_install_command.rb', line 5 def output @output end |
Instance Method Details
#arguments ⇒ Object
40 41 42 43 44 |
# File 'lib/rubygems/commands/specific_install_command.rb', line 40 def arguments "LOCATION like http://github.com/rdp/ruby_tutorials_core or git://github.com/rdp/ruby_tutorials_core.git or http://host/gem_name.gem\n" + "BRANCH (optional) like beta, or new-feature\n" + "DIRECTORY (optional) This will change the directory in the downloaded source directory before building the gem." end |
#description ⇒ Object
7 8 9 |
# File 'lib/rubygems/commands/specific_install_command.rb', line 7 def description "Allows you to install an 'edge' gem straight from its github repository or from a web site" end |
#execute ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rubygems/commands/specific_install_command.rb', line 50 def execute @loc ||= set_location @branch ||= set_branch if set_branch @ref ||= set_ref @tag ||= set_tag if @loc.nil? raise ArgumentError, "No location received. Use like `gem specific_install -l http://example.com/rdp/specific_install`" end require 'tempfile' if not defined?(Tempfile) Dir.mktmpdir do |dir| if subdir = [:directory] abort("Subdir '#{subdir}' is not a valid directory") unless valid_subdir?(subdir) @top_dir = dir @src_dir = File.join(dir, subdir) else @top_dir = @src_dir = dir end determine_source_and_install end end |
#usage ⇒ Object
46 47 48 |
# File 'lib/rubygems/commands/specific_install_command.rb', line 46 def usage "#{program_name} [LOCATION] [BRANCH] (or command line options for the same)" end |