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 Method Summary collapse
- #alias ⇒ Object
- #command ⇒ Object
-
#initialize(config, args, options) ⇒ Action
constructor
A new instance of Action.
- #load_secrets ⇒ Object
- #load_secrets? ⇒ Boolean
- #run ⇒ Object
- #secrets_file ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config, args, options) ⇒ Action
Returns a new instance of Action.
8 9 10 11 12 |
# File 'lib/action.rb', line 8 def initialize(config, args, ) @config = config @args = args = end |
Instance Method Details
#alias ⇒ Object
24 25 26 |
# File 'lib/action.rb', line 24 def alias @config["alias"] end |
#command ⇒ Object
28 29 30 |
# File 'lib/action.rb', line 28 def command @config["command"] end |
#load_secrets ⇒ Object
36 37 38 |
# File 'lib/action.rb', line 36 def load_secrets Secrets.new(secrets_file).load end |
#load_secrets? ⇒ Boolean
32 33 34 |
# File 'lib/action.rb', line 32 def load_secrets? @config["load_secrets"] end |
#run ⇒ Object
14 15 16 17 18 |
# File 'lib/action.rb', line 14 def run load_secrets if load_secrets? Kernel.exec(to_s) end |
#secrets_file ⇒ Object
40 41 42 |
# File 'lib/action.rb', line 40 def secrets_file `echo -n #{@options&.dig("secrets", "path")}` end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/action.rb', line 20 def to_s "#{command} #{@args.join(' ')}" end |