Module: MaintenanceHelpers
- Defined in:
- lib/m1_api/maintenance_helpers.rb
Overview
to do the replace string, should convert this to a class
Class Method Summary collapse
- .filter_by_top_value(calls, key, value) ⇒ Object
- .load_har(path_to_file) ⇒ Object
- .replace_value_with_key(data, matcher, key) ⇒ Object
Class Method Details
.filter_by_top_value(calls, key, value) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/m1_api/maintenance_helpers.rb', line 35 def filter_by_top_value(calls, key, value) if value.is_a? Regexp calls.select { |call| call if call[:request][key].match?(value) } else calls.select { |call| call if call[:request][key].include?(value) } end end |
.load_har(path_to_file) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/m1_api/maintenance_helpers.rb', line 15 def load_har(path_to_file) out = [] JSON.parse(File.read(path_to_file))['log']['entries'].each do |call| out << { start_time: call['startTime'], request: { method: call['request']['method'], url: call['request']['url'], headers: call['request']['headers'], body: call['request']['postData'] }, response: { status: call['response']['status'], content: call['response']['content'] } } end out end |
.replace_value_with_key(data, matcher, key) ⇒ Object
43 44 45 |
# File 'lib/m1_api/maintenance_helpers.rb', line 43 def replace_value_with_key(data, matcher, key) end |