Class: Melomel::Cucumber
Class Method Summary collapse
-
.find_by_id!(class_name, id, root = {}, properties = {}) ⇒ Object
Finds a component by id.
-
.find_by_label!(class_name, label, root = {}, properties = {}) ⇒ Object
Finds a component by label.
-
.find_by_text!(class_name, text, root = {}, properties = {}) ⇒ Object
Finds a component by text.
-
.find_by_title!(class_name, title, root = {}, properties = {}) ⇒ Object
Finds a component by title.
-
.find_labeled!(class_name, label, root = {}, properties = {}) ⇒ Object
Finds a component that shares the same parent as a given label.
-
.get_grid_data(grid) ⇒ Object
Retrieves grid data as a 2D array of rows of columns.
-
.run! ⇒ Object
A wrapper for Melomel actions that automatically waits until the Flash virtual machine is not busy before continuing.
-
.set_properties_key(properties, key, name) ⇒ Object
Sets the key in the properties hash.
Class Method Details
.find_by_id!(class_name, id, root = {}, properties = {}) ⇒ Object
Finds a component by id.
class_name - The class or classes to match on. id - The id of the component. root - The root component to search from. Defaults to the stage. properties - Additional properties to search on.
Returns a component matching the id and the additional properties.
25 26 27 28 |
# File 'lib/melomel/cucumber.rb', line 25 def self.find_by_id!(class_name, id, root={}, properties={}) properties['id'] = id Melomel.find!(class_name, root, properties) end |
.find_by_label!(class_name, label, root = {}, properties = {}) ⇒ Object
Finds a component by label. If the first character is a “#” then the component should be found by id. Otherwise it is found by label.
class_name - The class or classes to match on. label - The label of the component. root - The root component to search from. Defaults to the stage. properties - Additional properties to search on.
Returns a component matching the label and the additional properties.
39 40 41 42 |
# File 'lib/melomel/cucumber.rb', line 39 def self.find_by_label!(class_name, label, root={}, properties={}) set_properties_key(properties, 'label', label) Melomel.find!(class_name, root, properties) end |
.find_by_text!(class_name, text, root = {}, properties = {}) ⇒ Object
Finds a component by text. If the first character is a “#” then the component should be found by id. Otherwise it is found by text.
class_name - The class or classes to match on. text - The text property of the component. root - The root component to search from. Defaults to the stage. properties - Additional properties to search on.
Returns a component matching the text and the additional properties.
85 86 87 88 |
# File 'lib/melomel/cucumber.rb', line 85 def self.find_by_text!(class_name, text, root={}, properties={}) set_properties_key(properties, 'text', text) Melomel.find!(class_name, root, properties) end |
.find_by_title!(class_name, title, root = {}, properties = {}) ⇒ Object
Finds a component by title. If the first character is a “#” then the component should be found by id. Otherwise it is found by title.
class_name - The class or classes to match on. title - The title of the component. root - The root component to search from. Defaults to the stage. properties - Additional properties to search on.
Returns a component matching the title and the additional properties.
71 72 73 74 |
# File 'lib/melomel/cucumber.rb', line 71 def self.find_by_title!(class_name, title, root={}, properties={}) set_properties_key(properties, 'title', title) Melomel.find!(class_name, root, properties) end |
.find_labeled!(class_name, label, root = {}, properties = {}) ⇒ Object
Finds a component that shares the same parent as a given label. If the first character is a “#” then the component should be found by id. Otherwise it is found by label.
class_name - The class or classes to match on. label - The label text. root - The root component to search from. Defaults to the stage. properties - Additional properties to search on.
Returns a component labeled by another component.
54 55 56 57 58 59 60 |
# File 'lib/melomel/cucumber.rb', line 54 def self.find_labeled!(class_name, label, root={}, properties={}) if label.index('#') == 0 find_by_id!(class_name, label[1..-1], root, properties) else Melomel.find_labeled!(class_name, label, root, properties) end end |
.get_grid_data(grid) ⇒ Object
Retrieves grid data as a 2D array of rows of columns. The first row contains the grid’s header.
grid - The grid to generate the table from.
Returns a 2D array of rows of columns of data.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/melomel/cucumber.rb', line 112 def self.get_grid_data(grid) # Retrieve as columns of rows data = [] grid.columns.length.times do |i| column_data = [] column = grid.columns[i] labels = Melomel.items_to_labels!(column, grid.dataProvider) # Add column header column_data << column.headerText # Add label data labels.length.times do |j| column_data << labels[j] end # Add column data to data set data << column_data end # Transpose data data = data.transpose() # Trim whitespace from each cell data.each {|row| row.each {|cell| cell.strip! unless cell.nil?}} return data end |
.run! ⇒ Object
A wrapper for Melomel actions that automatically waits until the Flash virtual machine is not busy before continuing.
Returns nothing.
12 13 14 15 |
# File 'lib/melomel/cucumber.rb', line 12 def self.run! Melomel.wait() yield end |
.set_properties_key(properties, key, name) ⇒ Object
Sets the key in the properties hash. If the first character is “#” then the key is “id”. Otherwise it is set to the value of “key”.
properties - The properties hash. key - The name of the key to set. name - The name of the component.
Returns nothing.
98 99 100 101 102 103 104 |
# File 'lib/melomel/cucumber.rb', line 98 def self.set_properties_key(properties, key, name) if name.index('#') == 0 properties['id'] = name[1..-1] else properties[key] = name end end |