Class: TestCentricity::DataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/testcentricity_web/data_objects/data_objects_helper.rb

Overview

:nocov:

Direct Known Subclasses

ExcelDataSource

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



90
91
92
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 90

def file_path
  @file_path
end

#nodeObject

Returns the value of attribute node.



91
92
93
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 91

def node
  @node
end

Instance Method Details

#read_json_node_data(file_name, node_name) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 106

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



93
94
95
96
97
98
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 93

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



114
115
116
117
118
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 114

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



100
101
102
103
104
# File 'lib/testcentricity_web/data_objects/data_objects_helper.rb', line 100

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