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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



37
38
39
# File 'lib/inprovise/cmd_channel.rb', line 37

def node
  @node
end

Class Method Details

.default_implementationObject



14
15
16
# File 'lib/inprovise/cmd_channel.rb', line 14

def default_implementation
  @default ||= 'ssh'
end

.default_implementation=(impl) ⇒ Object



18
19
20
# File 'lib/inprovise/cmd_channel.rb', line 18

def default_implementation=(impl)
  @default = impl
end

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



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

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



10
11
12
# File 'lib/inprovise/cmd_channel.rb', line 10

def implementations
  @implementations ||= {}
end

.open(node, impl) ⇒ Object



31
32
33
# File 'lib/inprovise/cmd_channel.rb', line 31

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

Instance Method Details

#closeObject

session management



45
46
47
# File 'lib/inprovise/cmd_channel.rb', line 45

def close
  # noop
end

#download(from, to) ⇒ Object

Raises:

  • (RuntimeError)


61
62
63
# File 'lib/inprovise/cmd_channel.rb', line 61

def download(from, to)
  raise RuntimeError, 'UNIMPLEMENTED'
end

#initialize(node) ⇒ Object



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

def initialize(node)
  @node = node
end

#run(command, forcelog = false) ⇒ Object

command execution (MANDATORY)

Raises:

  • (RuntimeError)


51
52
53
# File 'lib/inprovise/cmd_channel.rb', line 51

def run(command, forcelog=false)
  raise RuntimeError, 'UNIMPLEMENTED'
end

#upload(from, to) ⇒ Object

MANDATORY file management routines

Raises:

  • (RuntimeError)


57
58
59
# File 'lib/inprovise/cmd_channel.rb', line 57

def upload(from, to)
  raise RuntimeError, 'UNIMPLEMENTED'
end