Class: Gem::Release::GemCommand::Setup
- Inherits:
-
Struct
- Object
- Struct
- Gem::Release::GemCommand::Setup
- Defined in:
- lib/gem/release/support/gem_command.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd
6 7 8 |
# File 'lib/gem/release/support/gem_command.rb', line 6 def cmd @cmd end |
#name ⇒ Object
Returns the value of attribute name
6 7 8 |
# File 'lib/gem/release/support/gem_command.rb', line 6 def name @name end |
Instance Method Details
#arguments ⇒ Object
34 35 36 37 38 |
# File 'lib/gem/release/support/gem_command.rb', line 34 def arguments arg = const.args.map(&:first).max_by(&:size) args = const.args.map { |name, summary| [name.to_s.ljust(arg.size), summary] } args.map { |pair| pair.join(' - ') }.join("\n") end |
#const ⇒ Object
25 26 27 |
# File 'lib/gem/release/support/gem_command.rb', line 25 def const Cmds[name] || raise("Unknown command #{name}") end |
#opts ⇒ Object
21 22 23 |
# File 'lib/gem/release/support/gem_command.rb', line 21 def opts const.opts + Cmds::Base.opts end |
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gem/release/support/gem_command.rb', line 7 def run cmd.summary = const.summary cmd.description = const.description cmd.usage = usage cmd.arguments = arguments cmd.defaults_str = '' opts.each do |args| cmd.add_option(*args.first) do |*a| cmd.instance_exec(*a, &args.last) end end end |
#usage ⇒ Object
29 30 31 32 |
# File 'lib/gem/release/support/gem_command.rb', line 29 def usage args = const.args.map(&:first) [:gem, name, args.map { |arg| "[#{arg}]" }.join(' ')].join(' ') end |