Class: Gem::Commands::SpecificInstallCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/specific_install_command.rb

Direct Known Subclasses

GitInstallCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options|
    options[:location] = location
  end

  add_option('-b', '--branch BRANCH', arguments) do |branch, options|
    options[:branch] = branch
  end

  add_option('-d', '--directory DIRECTORY', arguments) do |directory, options|
    options[:directory] = directory
  end

  add_option('-r', '--ref COMMIT-ISH', arguments) do |ref, options|
    options[:ref] = ref
  end

  add_option('-t', '--tag TAG', arguments) do |tag, options|
    options[:tag] = tag
  end

  add_option('-u', '--user-install', arguments) do |userinstall, options|
    options[:userinstall] = userinstall
  end
end

Instance Attribute Details

#outputObject

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

#argumentsObject



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

#descriptionObject



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

#executeObject



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 = options[: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

#usageObject



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