Top Level Namespace
Defined Under Namespace
Modules: AUCoreTestKit, Constants, Helpers, Inferno, SearchTestHelpers, ValidatorHelpers
Instance Method Summary
collapse
Instance Method Details
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/au_core_test_kit/generator/summary_generator.rb', line 69
def (test_file_path_with_id, attribute)
attribute_value = nil
case attribute
when 'resource_type'
attribute_value = find_value_in_file(test_file_path_with_id, 'resource_type').delete(':,').strip
when 'search_param_names'
dirty_value = find_value_in_file(test_file_path_with_id, 'search_param_names')
attribute_value = dirty_value.scan(/\[(.*?)\]/).flatten.first.split(', ') if dirty_value
when 'title', 'short_description'
attribute_value = find_value_in_file(test_file_path_with_id, attribute)
when 'description'
content = File.read(test_file_path_with_id)
matches = content.scan(/%\((.*?)\)/m)
attribute_value = find_value_in_file(test_file_path_with_id, 'description') if matches.empty?
matches.each { |match| attribute_value = match[0].strip }
attribute_value = attribute_value.gsub(
'[AU Core Server CapabilityStatement](http://hl7.org.au/fhir/core/0.3.0-ballot/CapabilityStatement-au-core-server.html',
'[AU Core Server CapabilityStatement](http://hl7.org.au/fhir/core/0.3.0-ballot/CapabilityStatement-au-core-server.html)'
)
else
puts "Unknown attribute: #{attribute}"
end
attribute_value
end
|
#find_value_in_file(file_path, search_str) ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/au_core_test_kit/generator/summary_generator.rb', line 58
def find_value_in_file(file_path, search_str)
value = nil
File.foreach(file_path) do |test_line|
if test_line.include?(search_str)
value = test_line.split(search_str)[1].strip.gsub("'", '')
break
end
end
value
end
|
#generate_summary_md(folder_hashes) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/au_core_test_kit/generator/summary_generator.rb', line 45
def generate_summary_md(folder_hashes)
summary_template = File.read(File.join(__dir__, 'templates', 'summary.md.erb'))
folder_hashes.each do |folder_hash|
folder_name = folder_hash[:folder_name]
folder_path = folder_hash[:folder_path]
test_groups = folder_hash[:test_groups]
summary_content = ERB.new(summary_template).result(binding)
File.open("#{folder_path}/summary.md", 'w') { |summary_file| summary_file.puts summary_content }
end
end
|
#make_search_string(resource_name, search_names) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/au_core_test_kit/generator/summary_generator.rb', line 18
def make_search_string(resource_name, search_names)
search = search_names.map.with_index do |search_name, index|
prefix = index.zero? ? '?' : '&'
"#{prefix}#{search_name}={#{search_name}}"
end
"/#{resource_name}#{search.join('')}"
end
|
#search_string(file_path) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/au_core_test_kit/generator/summary_generator.rb', line 26
def search_string(file_path)
search_names = (file_path, 'search_param_names')
return unless search_names
resource_type = (file_path, 'resource_type')
make_search_string(resource_type, search_names)
end
|
#symbolize_keys(hash) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/au_core_test_kit/generator/summary_generator.rb', line 6
def symbolize_keys(hash)
hash.transform_keys(&:to_sym).transform_values do |value|
if value.is_a?(Hash)
symbolize_keys(value)
elsif value.is_a?(Array)
value.map { |item| item.is_a?(Hash) ? symbolize_keys(item) : item }
else
value
end
end
end
|
#update_test_groups_titles(ig_index, test_groups) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/au_core_test_kit/generator/summary_generator.rb', line 34
def update_test_groups_titles(ig_index, test_groups)
test_groups.each_with_index do |test_group, index|
test_group_index = index + 2
test_group[:title] = "#{ig_index}.#{test_group_index} #{test_group[:title]}"
test_group[:tests].each_with_index do |test, t_index|
test_index = t_index + 1
test[:title] = "#{ig_index}.#{test_group_index}.#{test_index} #{test[:title]}"
end
end
end
|