Class: Ing::Commands::List
- Inherits:
-
Object
- Object
- Ing::Commands::List
- Includes:
- Ing::CommonOptions
- Defined in:
- lib/ing/commands/list.rb
Constant Summary collapse
- DEFAULTS =
{ namespace: 'ing:commands', ing_file: 'ing.rb' }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
- #shell ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
-
#before ⇒ Object
Require each passed file or library before running and require the ing file if it exists.
- #call(ns = nil) ⇒ Object
-
#initialize(options) ⇒ List
constructor
A new instance of List.
Methods included from Ing::CommonOptions
#debug, #debug?, included, #ing_file, #namespace, #require_ing_file, #require_libs, #requires
Constructor Details
#initialize(options) ⇒ List
Returns a new instance of List.
28 29 30 |
# File 'lib/ing/commands/list.rb', line 28 def initialize() self. = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
21 22 23 |
# File 'lib/ing/commands/list.rb', line 21 def end |
#shell ⇒ Object
24 25 26 |
# File 'lib/ing/commands/list.rb', line 24 def shell @shell ||= ::Ing.shell_class.new end |
Class Method Details
.specify_options(parser) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/ing/commands/list.rb', line 11 def self.(parser) parser. "List all tasks within specified namespace" parser.text "\nUsage:" parser.text " ing list # list all built-in ing commands" parser.text " ing list rspec # list all ing commands in rspec namespace, or" parser.text " ing list --namespace rspec" end |
Instance Method Details
#before ⇒ Object
Require each passed file or library before running and require the ing file if it exists
34 35 36 37 |
# File 'lib/ing/commands/list.rb', line 34 def before require_libs require_ing_file end |
#call(ns = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ing/commands/list.rb', line 39 def call(ns=nil) before mod = _namespace_class(ns) data = mod.constants.map do |c| klass = mod.const_get(c) desc = (Command.new(klass).describe || '')[/.+$/] [ "ing #{Ing::Util.encode_class(mod)}:#{Ing::Util.encode_class_names([c])}", (desc || '(no description)').chomp ] end.sort shell.say desc_lines(mod, data).join("\n") end |