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.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubygems/commands/compile_command.rb', line 5

def initialize
	super 'compile', 'Create binary gems from gems with extensions',
		:platform => Gem::Platform::CURRENT,
		:fat => ""

	add_option('-p', '--platform PLATFORM', 'Output platform name') do |value, options|
		options[:platform] = value
	end

	add_option('-f', '--fat VERSION:RUBY,...', 'Create fat binary (e.g. --fat 1.8:ruby,1.9:ruby19)') do |value, options|
		options[:fat] = value
	end
end

Instance Method Details

#argumentsObject

:nodoc:



19
20
21
# File 'lib/rubygems/commands/compile_command.rb', line 19

def arguments # :nodoc:
	"GEMFILE       name of gem to compile"
end

#executeObject



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

def execute
   gem = options[:args].shift

   unless gem then
		raise Gem::CommandLineError,
					"Please specify a gem name or file on the command line"
   end

	fat_commands = {}
	options[:fat].split(',').each do |ver_cmd|
		ver, cmd = ver_cmd.split(':', 2)
		unless ver =~ /^\d+\.\d+$/ then
			raise Gem::CommandLineError,
						"Invalid version string #{ver.dump}"
		end
		fat_commands[ver] = cmd
	end

	Gem::Compiler.compile(gem, options[:platform], fat_commands)
end

#usageObject

:nodoc:



23
24
25
# File 'lib/rubygems/commands/compile_command.rb', line 23

def usage # :nodoc:
	"#{program_name} GEMFILE"
end