Class: Runfile::Action
- Inherits:
-
Object
- Object
- Runfile::Action
- Includes:
- Inspectable
- Defined in:
- lib/runfile/action.rb
Overview
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#help ⇒ Object
Returns the value of attribute help.
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#shortcut ⇒ Object
Returns the value of attribute shortcut.
Instance Method Summary collapse
- #command_string ⇒ Object
- #implicit_usages ⇒ Object
- #inspectable ⇒ Object
- #prefix ⇒ Object
- #run(args = {}) ⇒ Object
- #usage_string ⇒ Object
- #usages ⇒ Object
Methods included from Inspectable
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
9 10 11 |
# File 'lib/runfile/action.rb', line 9 def block @block end |
#help ⇒ Object
Returns the value of attribute help.
9 10 11 |
# File 'lib/runfile/action.rb', line 9 def help @help end |
#host ⇒ Object
Returns the value of attribute host.
9 10 11 |
# File 'lib/runfile/action.rb', line 9 def host @host end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/runfile/action.rb', line 8 def name @name end |
#shortcut ⇒ Object
Returns the value of attribute shortcut.
8 9 10 |
# File 'lib/runfile/action.rb', line 8 def shortcut @shortcut end |
Instance Method Details
#command_string ⇒ Object
11 12 13 14 |
# File 'lib/runfile/action.rb', line 11 def command_string result = names.join(', ') result.empty? ? '(default)' : result end |
#implicit_usages ⇒ Object
16 17 18 |
# File 'lib/runfile/action.rb', line 16 def implicit_usages usages.empty? ? [usage_string] : usages end |
#inspectable ⇒ Object
20 21 22 |
# File 'lib/runfile/action.rb', line 20 def inspectable { name: name, prefix: prefix, 'host.path': host&.path } end |
#prefix ⇒ Object
37 38 39 |
# File 'lib/runfile/action.rb', line 37 def prefix host&.full_name end |
#run(args = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/runfile/action.rb', line 24 def run(args = {}) validate_context instance_eval do host.helpers.each { |b| b.call args } block.call args if block end end |
#usage_string ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/runfile/action.rb', line 45 def usage_string @usage_string ||= if shortcut "#{prefix} (#{name} | #{shortcut})".strip else "#{prefix} #{name}".strip end end |
#usages ⇒ Object
53 54 55 |
# File 'lib/runfile/action.rb', line 53 def usages @usages ||= [] end |