Class: LibGems::Commands::BuildCommand
- Inherits:
-
LibGems::Command
- Object
- LibGems::Command
- LibGems::Commands::BuildCommand
- Defined in:
- lib/libgems/commands/build_command.rb
Instance Attribute Summary
Attributes inherited from LibGems::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ BuildCommand
constructor
A new instance of BuildCommand.
- #load_gemspecs(filename) ⇒ Object
-
#usage ⇒ Object
:nodoc:.
- #yaml?(filename) ⇒ Boolean
Methods inherited from LibGems::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #begins?, build_args, build_args=, common_options, #defaults_str, #description, extra_args, extra_args=, #get_all_gem_names, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #when_invoked
Methods included from UserInteraction
Methods included from DefaultUserInteraction
ui, #ui, ui=, #ui=, use_ui, #use_ui
Constructor Details
#initialize ⇒ BuildCommand
Returns a new instance of BuildCommand.
6 7 8 |
# File 'lib/libgems/commands/build_command.rb', line 6 def initialize super('build', 'Build a gem from a gemspec') end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/libgems/commands/build_command.rb', line 10 def arguments # :nodoc: "GEMSPEC_FILE gemspec file name to build a gem for" end |
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/libgems/commands/build_command.rb', line 18 def execute gemspec = get_one_gem_name if File.exist?(gemspec) specs = load_gemspecs(gemspec) specs.each do |spec| LibGems::Builder.new(spec).build end else alert_error "Gemspec file not found: #{gemspec}" end end |
#load_gemspecs(filename) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/libgems/commands/build_command.rb', line 30 def load_gemspecs(filename) if yaml?(filename) result = [] open(filename) do |f| begin while not f.eof? and spec = LibGems::Specification.from_yaml(f) result << spec end rescue LibGems::EndOfYAMLException # OK end end else result = [LibGems::Specification.load(filename)] end result end |
#usage ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/libgems/commands/build_command.rb', line 14 def usage # :nodoc: "#{program_name} GEMSPEC_FILE" end |
#yaml?(filename) ⇒ Boolean
48 49 50 51 52 |
# File 'lib/libgems/commands/build_command.rb', line 48 def yaml?(filename) line = open(filename) { |f| line = f.gets } result = line =~ %r{!ruby/object:Gem::Specification} result end |