Class: Action
- Inherits:
-
Object
- Object
- Action
- Defined in:
- lib/action.rb
Overview
represents one action to be performed in the shell can assemble a command line from a command and args
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #alias ⇒ Object
- #allowed_in_env?(env) ⇒ Boolean
- #command ⇒ Object
- #config_errors ⇒ Object
- #config_valid? ⇒ Boolean
- #description ⇒ Object
- #execute_in_env?(env) ⇒ Boolean
-
#initialize(name, config, args) ⇒ Action
constructor
A new instance of Action.
- #load_secrets? ⇒ Boolean
- #run ⇒ Object
- #skip_hooks?(name) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, config, args) ⇒ Action
Returns a new instance of Action.
10 11 12 13 14 |
# File 'lib/action.rb', line 10 def initialize(name, config, args) @name = name @config = config @args = args end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/action.rb', line 8 def name @name end |
Instance Method Details
#alias ⇒ Object
28 29 30 |
# File 'lib/action.rb', line 28 def alias @config["alias"] end |
#allowed_in_env?(env) ⇒ Boolean
66 67 68 69 70 71 72 |
# File 'lib/action.rb', line 66 def allowed_in_env?(env) return false if not_in_envs.include?(env) return false if in_envs.any? && !in_envs.include?(env) true end |
#command ⇒ Object
32 33 34 |
# File 'lib/action.rb', line 32 def command @config["command"] end |
#config_errors ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/action.rb', line 48 def config_errors @config_errors ||= begin errors = [] errors << "No 'command' specified in 'action'." unless @config['command'] errors end end |
#config_valid? ⇒ Boolean
44 45 46 |
# File 'lib/action.rb', line 44 def config_valid? config_errors.empty? end |
#description ⇒ Object
36 37 38 |
# File 'lib/action.rb', line 36 def description @config["description"] end |
#execute_in_env?(env) ⇒ Boolean
62 63 64 |
# File 'lib/action.rb', line 62 def execute_in_env?(env) !skip_in_envs.include?(env) end |
#load_secrets? ⇒ Boolean
58 59 60 |
# File 'lib/action.rb', line 58 def load_secrets? @config["load_secrets"].nil? ? false : @config["load_secrets"] end |
#run ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/action.rb', line 16 def run if perform_shell_expansion? Kernel.exec(to_s) else Kernel.exec(*to_a) end end |
#skip_hooks?(name) ⇒ Boolean
40 41 42 |
# File 'lib/action.rb', line 40 def skip_hooks?(name) @config["skip_#{name}_hooks"] end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/action.rb', line 24 def to_s "#{command} #{@args.join(' ')}".strip end |