Class: Orca::ExecutionContext
- Inherits:
-
Object
- Object
- Orca::ExecutionContext
- Defined in:
- lib/orca/execution_context.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #apply(blk) ⇒ Object
- #binary_exists?(binary) ⇒ Boolean
- #download(from, to) ⇒ Object
-
#initialize(node) ⇒ ExecutionContext
constructor
A new instance of ExecutionContext.
- #local(path) ⇒ Object
- #log(msg) ⇒ Object
- #remote(path) ⇒ Object
- #remove(path) ⇒ Object
- #run(cmd) ⇒ Object
- #setstat(path, opts) ⇒ Object
- #stat(path) ⇒ Object
- #sudo(cmd) ⇒ Object
- #trigger(action_ref, *args) ⇒ Object
- #upload(from, to) ⇒ Object
Constructor Details
#initialize(node) ⇒ ExecutionContext
Returns a new instance of ExecutionContext.
4 5 6 |
# File 'lib/orca/execution_context.rb', line 4 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
2 3 4 |
# File 'lib/orca/execution_context.rb', line 2 def node @node end |
Instance Method Details
#apply(blk) ⇒ Object
8 9 10 |
# File 'lib/orca/execution_context.rb', line 8 def apply(blk) instance_eval(&blk) end |
#binary_exists?(binary) ⇒ Boolean
60 61 62 |
# File 'lib/orca/execution_context.rb', line 60 def binary_exists?(binary) run("which #{binary}") =~ /\/#{binary}/ end |
#download(from, to) ⇒ Object
28 29 30 |
# File 'lib/orca/execution_context.rb', line 28 def download(from, to) @node.download(from, to) end |
#local(path) ⇒ Object
32 33 34 |
# File 'lib/orca/execution_context.rb', line 32 def local(path) Orca::LocalFile.new(path) end |
#log(msg) ⇒ Object
16 17 18 |
# File 'lib/orca/execution_context.rb', line 16 def log(msg) @node.log('log', msg) end |
#remote(path) ⇒ Object
48 49 50 |
# File 'lib/orca/execution_context.rb', line 48 def remote(path) Orca::RemoteFile.new(self, path) end |
#remove(path) ⇒ Object
36 37 38 |
# File 'lib/orca/execution_context.rb', line 36 def remove(path) @node.remove(path) end |
#run(cmd) ⇒ Object
12 13 14 |
# File 'lib/orca/execution_context.rb', line 12 def run(cmd) @node.execute(cmd) end |
#setstat(path, opts) ⇒ Object
44 45 46 |
# File 'lib/orca/execution_context.rb', line 44 def setstat(path, opts) @node.setstat(path, opts) end |
#stat(path) ⇒ Object
40 41 42 |
# File 'lib/orca/execution_context.rb', line 40 def stat(path) @node.stat(path) end |
#sudo(cmd) ⇒ Object
20 21 22 |
# File 'lib/orca/execution_context.rb', line 20 def sudo(cmd) @node.sudo(cmd) end |
#trigger(action_ref, *args) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/orca/execution_context.rb', line 52 def trigger(action_ref, *args) pkg_name, action_name = *action_ref.split(':', 2) pkg = Orca::PackageIndex.default.get(pkg_name) action = pkg.actions[action_name] raise Orca::MissingActionError.new(action_ref) unless action instance_exec(*args, &action) end |
#upload(from, to) ⇒ Object
24 25 26 |
# File 'lib/orca/execution_context.rb', line 24 def upload(from, to) @node.upload(from, to) end |