Class: Gem::Commands::NewgemCommand

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

Instance Method Summary collapse

Constructor Details

#initializeNewgemCommand

Returns a new instance of NewgemCommand.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubygems/commands/newgem_command.rb', line 11

def initialize
  super('newgem', GemNewgem::SUMMARY)

  @config = GemNewgem::Newgem::Configuration.instance

  add_option('-t', '--template TEMPLATE_NAME', @config.option_template_desc) do |template, options|
    options[:template] = template
  end

  add_option('-s', '--summary "SUMMARY_TEXT"', @config.option_summary_desc) do |summary, options|
    options[:summary] = summary
  end
end

Instance Method Details

#argumentsObject



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

def arguments
  %Q|GEMNAME          name of the gem skeleton to generate.|
end

#defaults_strObject



33
34
35
# File 'lib/rubygems/commands/newgem_command.rb', line 33

def defaults_str
  %Q|--template #{@config.default_template} --summary "#{@config.default_summary}"|
end

#executeObject



37
38
39
40
41
42
43
44
45
# File 'lib/rubygems/commands/newgem_command.rb', line 37

def execute
  @newgem = GemNewgem::Newgem.new(
    get_one_optional_argument, options[:summary], options[:template]
  )

  @newgem.validate

  @newgem.generate!
end

#usageObject



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

def usage
  %Q|#{program_name} GEMNAME|
end