Module: Inprovise::CmdChannel

Defined in:
lib/inprovise/cmd_channel.rb

Overview

Command channel for Inprovise

Author

Martin Corino

License

Distributes under the same license as Ruby

Defined Under Namespace

Classes: Exception

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



39
40
41
# File 'lib/inprovise/cmd_channel.rb', line 39

def node
  @node
end

Class Method Details

.default_implementationObject



16
17
18
# File 'lib/inprovise/cmd_channel.rb', line 16

def default_implementation
  @default ||= 'ssh'
end

.default_implementation=(impl) ⇒ Object



20
21
22
# File 'lib/inprovise/cmd_channel.rb', line 20

def default_implementation=(impl)
  @default = impl
end

.define(impl, base = ::Object, &definition) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/inprovise/cmd_channel.rb', line 24

def define(impl, base=::Object, &definition)
  implklass = Class.new(base) do
    include Inprovise::CmdChannel
  end
  implklass.class_eval(&definition)
  implementations[impl.to_s] = implklass
  implklass
end

.implementationsObject



12
13
14
# File 'lib/inprovise/cmd_channel.rb', line 12

def implementations
  @implementations ||= {}
end

.open(node, impl) ⇒ Object



33
34
35
# File 'lib/inprovise/cmd_channel.rb', line 33

def open(node, impl)
  implementations[impl || default_implementation].new(node)
end

Instance Method Details

#closeObject

session management



47
48
49
# File 'lib/inprovise/cmd_channel.rb', line 47

def close
  # noop
end

#download(_from, _to) ⇒ Object

Raises:

  • (RuntimeError)


63
64
65
# File 'lib/inprovise/cmd_channel.rb', line 63

def download(_from, _to)
  raise RuntimeError, 'UNIMPLEMENTED'
end

#initialize(node) ⇒ Object



41
42
43
# File 'lib/inprovise/cmd_channel.rb', line 41

def initialize(node)
  @node = node
end

#run(_command, _forcelog = false) ⇒ Object

command execution (MANDATORY)

Raises:

  • (RuntimeError)


53
54
55
# File 'lib/inprovise/cmd_channel.rb', line 53

def run(_command, _forcelog=false)
  raise RuntimeError, 'UNIMPLEMENTED'
end

#upload(_from, _to) ⇒ Object

MANDATORY file management routines

Raises:

  • (RuntimeError)


59
60
61
# File 'lib/inprovise/cmd_channel.rb', line 59

def upload(_from, _to)
  raise RuntimeError, 'UNIMPLEMENTED'
end