Class: SimpleScriptRecord
- Inherits:
-
SSHKit::Backend::Printer
- Object
- SSHKit::Backend::Printer
- SimpleScriptRecord
- Defined in:
- lib/capsum/sidekiq.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #command(*args) ⇒ Object
- #execute(*args) ⇒ Object
-
#initialize(&block) ⇒ SimpleScriptRecord
constructor
A new instance of SimpleScriptRecord.
- #test(*args) ⇒ Object
- #to_bash ⇒ Object
- #within(directory, &block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ SimpleScriptRecord
Returns a new instance of SimpleScriptRecord.
59 60 61 62 63 |
# File 'lib/capsum/sidekiq.rb', line 59 def initialize(&block) @result = [] @block = block self.run end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
57 58 59 |
# File 'lib/capsum/sidekiq.rb', line 57 def result @result end |
Instance Method Details
#command(*args) ⇒ Object
93 94 95 |
# File 'lib/capsum/sidekiq.rb', line 93 def command(*args) raise SSHKit::Backend::MethodUnavailableError end |
#execute(*args) ⇒ Object
83 84 85 86 87 |
# File 'lib/capsum/sidekiq.rb', line 83 def execute(*args) = args. .merge!(in: @pwd.nil? ? nil : File.join(@pwd), env: @env, host: @host, user: @user, group: @group) @result << [ *args, ] end |
#test(*args) ⇒ Object
89 90 91 |
# File 'lib/capsum/sidekiq.rb', line 89 def test(*args) raise SSHKit::Backend::MethodUnavailableError end |
#to_bash ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/capsum/sidekiq.rb', line 72 def to_bash result.map do |args| cmd = [] = args. cmd << "cd #{[:in]} && " if [:in] cmd << args.join(" ") cmd.join end.join("\n") end |
#within(directory, &block) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/capsum/sidekiq.rb', line 65 def within(directory, &block) (@pwd ||= []).push directory.to_s yield ensure @pwd.pop end |