Class: TestCentricity::DataSource
- Defined in:
- lib/testcentricity_web/data_objects/data_objects_helper.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
- #read_json_node_data(file_name, node_name) ⇒ Object
- #read_yaml_node_data(file_name, node_name) ⇒ Object
- #write_json_node_data(file_name, node_name, node_data) ⇒ Object
- #write_yaml_node_data(file_name, node_name, node_data) ⇒ Object
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
86 87 88 |
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 86 def file_path @file_path end |
#node ⇒ Object
Returns the value of attribute node.
87 88 89 |
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 87 def node @node end |
Instance Method Details
#read_json_node_data(file_name, node_name) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 102 def read_json_node_data(file_name, node_name) @file_path = "#{PRIMARY_DATA_PATH}#{file_name}" @node = node_name raw_data = File.read(@file_path) data = JSON.parse(raw_data) data[node_name] end |
#read_yaml_node_data(file_name, node_name) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 89 def read_yaml_node_data(file_name, node_name) @file_path = "#{PRIMARY_DATA_PATH}#{file_name}" @node = node_name data = YAML.load_file(@file_path) data[node_name] end |
#write_json_node_data(file_name, node_name, node_data) ⇒ Object
110 111 112 113 114 |
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 110 def write_json_node_data(file_name, node_name, node_data) data = read_json_node_data(file_name, node_name) data[node_name] = node_data File.write(@file_path, data.to_json) end |
#write_yaml_node_data(file_name, node_name, node_data) ⇒ Object
96 97 98 99 100 |
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 96 def write_yaml_node_data(file_name, node_name, node_data) data = read_yaml_node_data(file_name, node_name) data[node_name] = node_data File.write(@file_path, data.to_yaml) end |