74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/kashi/dsl/test.rb', line 74
def sc_hash
hash = @sc_test.to_h.keys.each_with_object({}) do |k, h|
next if %w/DownTimes LastTested NextLocation Processing ProcessingOn ProcessingState Sensitive Status Uptime Method ContactGroup ContactID/.include?(k)
h[k.to_s.to_snake.to_sym] = @sc_test.to_h[k]
end
{ uri: :website_url, dnsip: :dns_ip, tags: :test_tags }.each do |k, v|
hash[v] = hash.delete(k)
end
%i/basic_user basic_pass/.each do |k|
hash[k] = ''
end
%i/port use_jar virus/.each do |k|
hash[k] = '' unless hash.key?(k)
end
%i/paused enable_ssl_warning follow_redirect do_not_find/.each do |k|
hash[k] = hash[k] ? 1 : 0
end
hash[:contact_group] = hash.delete(:contact_groups).map { |contact_group| contact_group['Name'] }
hash[:test_tags] = Array(hash[:test_tags])
if hash[:custom_header] == false || hash[:custom_header] == ''
hash[:custom_header] = ''
else
hash[:custom_header] = JSON.parse(hash[:custom_header]).to_json
end
Kashi::Utils.normalize_hash(hash)
end
|