Class: Wiretap::TestServer
- Inherits:
-
Object
- Object
- Wiretap::TestServer
- Defined in:
- ext/testserver/testserver.rb
Constant Summary collapse
- @@node_types =
[ "node", "host", "volume", "project", "library", "reel", "clip", "clip_hires", "clip_lowres", "clip_slate", "clip_audio", "clip_audiostream", "user", "setup", "user_preference" ]
Class Method Summary collapse
Instance Method Summary collapse
-
#clip?(node_id) ⇒ Boolean
predicate function, whether node is clip node.
-
#create_clip_node(node_id, display_name, type, format) ⇒ Object
create node, being child of node_id with name display_name of kind type returning id of new node.
-
#create_node(node_id, display_name, type) ⇒ Object
create node, being child of node_id with name display_name of kind type returning id of new node.
-
#destroy_node(node_id) ⇒ Object
destroy node by it’s ID.
-
#get_children(parent_node_id) ⇒ Object
get_children returns list of pairs of name: [ [id, display_name], [id, display_name], …].
-
#get_display_name(node_id) ⇒ Object
get display name of node by it’s physical ID.
-
#get_frame_paths(node_id) ⇒ Object
Loads some mysterious frame paths.
-
#get_node_type(node_id) ⇒ Object
returns numeric type of requested node.
-
#get_node_type_str(node_id) ⇒ Object
returns symbolic (string) type of requested node.
-
#get_root_node ⇒ Object
root node ID is usually “/”.
-
#init(*args) ⇒ Object
initialize with array of argument.
- #path(node_id) ⇒ Object
- #root ⇒ Object
-
#str_to_node_type(str) ⇒ Object
convert string type to node type.
- #to_internal_id(node_id) ⇒ Object
-
#uninitialize ⇒ Object
shutdown server.
Class Method Details
.translate_type_from_string(type) ⇒ Object
139 140 141 |
# File 'ext/testserver/testserver.rb', line 139 def self.translate_type_from_string(type) @@node_types.index(type) || (puts "Fuck: #{type}"; 0) end |
Instance Method Details
#clip?(node_id) ⇒ Boolean
predicate function, whether node is clip node
81 82 83 84 |
# File 'ext/testserver/testserver.rb', line 81 def clip?(node_id) puts "Is clip: #{node_id}" ["clip", "clip_audio", "clip_audiostream"].include? get_node_type(node_id) end |
#create_clip_node(node_id, display_name, type, format) ⇒ Object
create node, being child of node_id with name display_name of kind type returning id of new node
50 51 52 53 |
# File 'ext/testserver/testserver.rb', line 50 def create_clip_node(node_id, display_name, type, format) puts "Creating clip node: #{node_id}:#{display_name}:#{type}:#{format}" "" end |
#create_node(node_id, display_name, type) ⇒ Object
create node, being child of node_id with name display_name of kind type returning id of new node
43 44 45 46 |
# File 'ext/testserver/testserver.rb', line 43 def create_node(node_id, display_name, type) puts "Create node: #{node_id}:#{display_name}:#{type}" "" end |
#destroy_node(node_id) ⇒ Object
destroy node by it’s ID
56 57 58 |
# File 'ext/testserver/testserver.rb', line 56 def destroy_node(node_id) puts "Destroying #{node_id}" end |
#get_children(parent_node_id) ⇒ Object
get_children returns list of pairs of name: [ [id, display_name], [id, display_name], …]
61 62 63 64 65 |
# File 'ext/testserver/testserver.rb', line 61 def get_children(parent_node_id) parent_node_id = to_internal_id(parent_node_id) puts "Get children of: #{parent_node_id}" Node.find(parent_node_id).children.map {|child| ["/"+child.name, child.name]} end |
#get_display_name(node_id) ⇒ Object
get display name of node by it’s physical ID
93 94 95 96 97 |
# File 'ext/testserver/testserver.rb', line 93 def get_display_name(node_id) node_id = to_internal_id(node_id) puts "Get display name: #{node_id}" Node.find(node_id).name end |
#get_frame_paths(node_id) ⇒ Object
Loads some mysterious frame paths
100 101 102 103 |
# File 'ext/testserver/testserver.rb', line 100 def get_frame_paths(node_id) puts "Get frame paths: #{node_id}" [] end |
#get_node_type(node_id) ⇒ Object
returns numeric type of requested node
68 69 70 71 |
# File 'ext/testserver/testserver.rb', line 68 def get_node_type(node_id) puts "Get node type: #{node_id}" self.class.translate_type_from_string(get_node_type_str(node_id)) end |
#get_node_type_str(node_id) ⇒ Object
returns symbolic (string) type of requested node
74 75 76 77 78 |
# File 'ext/testserver/testserver.rb', line 74 def get_node_type_str(node_id) node_id = to_internal_id(node_id) puts "Get node type str: #{node_id}" Node.find(node_id).kind end |
#get_root_node ⇒ Object
root node ID is usually “/”
36 37 38 39 |
# File 'ext/testserver/testserver.rb', line 36 def get_root_node puts "Requested root node" "/" end |
#init(*args) ⇒ Object
initialize with array of argument.
26 27 28 |
# File 'ext/testserver/testserver.rb', line 26 def init(*args) puts "Initing with #{args.inspect}" end |
#path(node_id) ⇒ Object
110 111 112 |
# File 'ext/testserver/testserver.rb', line 110 def path(node_id) root + "/" + node_id end |
#root ⇒ Object
106 107 108 |
# File 'ext/testserver/testserver.rb', line 106 def root File.dirname(__FILE__) + "/../../test/wiretap_root/192.168.171.17" end |
#str_to_node_type(str) ⇒ Object
convert string type to node type
87 88 89 90 |
# File 'ext/testserver/testserver.rb', line 87 def str_to_node_type(str) puts "String to node type: #{str}" self.class.translate_type_from_string str end |
#to_internal_id(node_id) ⇒ Object
114 115 116 117 118 119 120 |
# File 'ext/testserver/testserver.rb', line 114 def to_internal_id(node_id) case node_id when "/" return 1 end Node.find(:first, :conditions => ["name = ?", node_id]).id rescue node_id end |
#uninitialize ⇒ Object
shutdown server
31 32 33 |
# File 'ext/testserver/testserver.rb', line 31 def uninitialize puts "Unitializing" end |