Class: Gem::Commands::CompileCommand

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

Instance Method Summary collapse

Constructor Details

#initializeCompileCommand

Returns a new instance of CompileCommand.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubygems/commands/compile_command.rb', line 4

def initialize
  super "compile", "Create binary pre-compiled gem",
        output: Dir.pwd

  add_option "-O", "--output DIR", "Directory where binary will be stored" do |value, options|
    options[:output] = File.expand_path(value, Dir.pwd)
  end

  add_option "--include-shared-dir DIR", "Additional directory for shared libraries" do |value, options|
    options[:include_shared_dir] = value
  end

  add_option "--prune", "Clean non-existing files during re-packaging" do |value, options|
    options[:prune] = true
  end

  add_option "-N", "--no-abi-lock", "Do not lock compiled Gem to Ruby's ABI" do |value, options|
    options[:no_abi_lock] = true
  end
end

Instance Method Details

#argumentsObject



25
26
27
# File 'lib/rubygems/commands/compile_command.rb', line 25

def arguments
  "GEMFILE       path to the gem file to compile"
end

#executeObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rubygems/commands/compile_command.rb', line 33

def execute
  gemfile = options[:args].shift

  # no gem, no binary
  unless gemfile
    raise Gem::CommandLineError,
          "Please specify a gem file on the command line (e.g. #{program_name} foo-0.1.0.gem)"
  end

  require "rubygems/compiler"

  compiler = Gem::Compiler.new(gemfile, options)
  compiler.compile
end

#usageObject



29
30
31
# File 'lib/rubygems/commands/compile_command.rb', line 29

def usage
  "#{program_name} GEMFILE"
end