Class: Gem::Commands::BuildCommand

Inherits:
Gem::Command show all
Includes:
VersionOption
Defined in:
lib/rubygems/commands/build_command.rb

Instance Attribute Summary

Attributes inherited from Gem::Command

#command, #defaults, #options, #program_name, #summary

Instance Method Summary collapse

Methods included from VersionOption

#add_platform_option, #add_prerelease_option, #add_version_option, #get_platform_from_requirements

Methods inherited from Gem::Command

add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #begins?, build_args, build_args=, #check_deprecated_options, common_options, #defaults_str, #deprecate_option, #deprecated?, extra_args, extra_args=, #get_all_gem_names, #get_all_gem_names_and_versions, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #invoke_with_build_args, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, specific_extra_args_hash=, #when_invoked

Methods included from UserInteraction

#alert, #alert_error, #alert_warning, #ask, #ask_for_password, #ask_yes_no, #choose_from_list, #say, #terminate_interaction, #verbose

Methods included from DefaultUserInteraction

ui, #ui, ui=, #ui=, use_ui, #use_ui

Methods included from Text

#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text

Constructor Details

#initializeBuildCommand

Returns a new instance of BuildCommand.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubygems/commands/build_command.rb', line 9

def initialize
  super 'build', 'Build a gem from a gemspec'

  add_platform_option

  add_option '--force', 'skip validation of the spec' do |value, options|
    options[:force] = true
  end

  add_option '--strict', 'consider warnings as errors when validating the spec' do |value, options|
    options[:strict] = true
  end

  add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
    options[:output] = value
  end

  add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
    options[:build_path] = value
  end
end

Instance Method Details

#argumentsObject

:nodoc:



31
32
33
# File 'lib/rubygems/commands/build_command.rb', line 31

def arguments # :nodoc:
  "GEMSPEC_FILE  gemspec file name to build a gem for"
end

#descriptionObject

:nodoc:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rubygems/commands/build_command.rb', line 35

def description # :nodoc:
  <<-EOF
The build command allows you to create a gem from a ruby gemspec.

The best way to build a gem is to use a Rakefile and the Gem::PackageTask
which ships with RubyGems.

The gemspec can either be created by hand or extracted from an existing gem
with gem spec:

$ gem unpack my_gem-1.0.gem
Unpacked gem: '.../my_gem-1.0'
$ gem spec my_gem-1.0.gem --ruby > my_gem-1.0/my_gem-1.0.gemspec
$ cd my_gem-1.0
[edit gem contents]
$ gem build my_gem-1.0.gemspec

Gems can be saved to a specified filename with the output option:

$ gem build my_gem-1.0.gemspec --output=release.gem

  EOF
end

#executeObject



63
64
65
66
67
68
69
70
# File 'lib/rubygems/commands/build_command.rb', line 63

def execute
  if build_path = options[:build_path]
    Dir.chdir(build_path) { build_gem }
    return
  end

  build_gem
end

#usageObject

:nodoc:



59
60
61
# File 'lib/rubygems/commands/build_command.rb', line 59

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