Class: AUCoreTestKit::Generator::GroupGenerator
- Inherits:
-
Object
- Object
- AUCoreTestKit::Generator::GroupGenerator
- Defined in:
- lib/au_core_test_kit/generator/group_generator.rb
Instance Attribute Summary collapse
-
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
-
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
Class Method Summary collapse
Instance Method Summary collapse
- #add_special_tests ⇒ Object
- #base_metadata_file_name ⇒ Object
- #base_output_file_name ⇒ Object
- #class_name ⇒ Object
- #description ⇒ Object
- #generate ⇒ Object
- #group_id ⇒ Object
-
#initialize(group_metadata, base_output_dir) ⇒ GroupGenerator
constructor
A new instance of GroupGenerator.
- #metadata_file_name ⇒ Object
- #module_name ⇒ Object
- #optional? ⇒ Boolean
- #output ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #profile_name ⇒ Object
- #profile_url ⇒ Object
- #required_searches ⇒ Object
- #resource_type ⇒ Object
- #search_param_name_string ⇒ Object
- #search_validation_resource_type ⇒ Object
- #short_description ⇒ Object
- #template ⇒ Object
- #test_file_list ⇒ Object
- #test_id_list ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(group_metadata, base_output_dir) ⇒ GroupGenerator
21 22 23 24 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 21 def initialize(, base_output_dir) self. = self.base_output_dir = base_output_dir end |
Instance Attribute Details
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
19 20 21 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 19 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
19 20 21 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 19 def @group_metadata end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 11 def generate(, base_output_dir) .ordered_groups .compact .reject { |group| SpecialCases.exclude_group? group } .each { |group| new(group, base_output_dir).generate } end |
Instance Method Details
#add_special_tests ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 102 def add_special_tests return if .reformatted_version == 'v311' case .resource when 'DocumentReference' .add_test( id: 'au_core_v400_document_reference_custodian_test', file_name: '../../custom_groups/v4.0.0/document_reference_custodian_test.rb' ) end end |
#base_metadata_file_name ⇒ Object
38 39 40 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 38 def 'metadata.yml' end |
#base_output_file_name ⇒ Object
34 35 36 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 34 def base_output_file_name "#{class_name.underscore}.rb" end |
#class_name ⇒ Object
42 43 44 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 42 def class_name "#{Naming.upper_camel_case_for_profile()}Group" end |
#description ⇒ Object
137 138 139 140 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 137 def description Helpers.get_group_description_text(title, resource_type, profile_name, .version, profile_url, required_searches, search_param_name_string, search_validation_resource_type, resource_type) end |
#generate ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 94 def generate add_special_tests File.open(output_file_name, 'w') { |f| f.write(output) } .id = group_id .file_name = base_output_file_name File.open(, 'w') { |f| f.write(YAML.dump(.to_hash)) } end |
#group_id ⇒ Object
70 71 72 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 70 def group_id "au_core_#{.reformatted_version}_#{profile_identifier}" end |
#metadata_file_name ⇒ Object
62 63 64 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 62 def File.join(base_output_dir, profile_identifier, ) end |
#module_name ⇒ Object
46 47 48 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 46 def module_name "AUCore#{.reformatted_version.upcase}" end |
#optional? ⇒ Boolean
90 91 92 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 90 def optional? resource_type == 'QuestionnaireResponse' end |
#output ⇒ Object
30 31 32 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 30 def output @output ||= ERB.new(template).result(binding) end |
#output_file_name ⇒ Object
58 59 60 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 58 def output_file_name File.join(base_output_dir, base_output_file_name) end |
#profile_identifier ⇒ Object
66 67 68 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 66 def profile_identifier Naming.snake_case_for_profile() end |
#profile_name ⇒ Object
82 83 84 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 82 def profile_name .profile_name end |
#profile_url ⇒ Object
86 87 88 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 86 def profile_url .profile_url end |
#required_searches ⇒ Object
126 127 128 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 126 def required_searches .searches.select { |search| search[:expectation] == 'SHALL' } end |
#resource_type ⇒ Object
74 75 76 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 74 def resource_type .resource end |
#search_param_name_string ⇒ Object
130 131 132 133 134 135 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 130 def search_param_name_string required_searches .map { |search| search[:names].join(' + ') } .map { |names| "* #{names}" } .join("\n") end |
#search_validation_resource_type ⇒ Object
78 79 80 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 78 def search_validation_resource_type "#{resource_type} resources" end |
#short_description ⇒ Object
54 55 56 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 54 def short_description .short_description end |
#template ⇒ Object
26 27 28 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 26 def template @template ||= File.read(File.join(__dir__, 'templates', 'group.rb.erb')) end |
#test_file_list ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 118 def test_file_list @test_file_list ||= .tests.map do |test| name_without_suffix = test[:file_name].delete_suffix('.rb') name_without_suffix.start_with?('..') ? name_without_suffix : "#{profile_identifier}/#{name_without_suffix}" end end |
#test_id_list ⇒ Object
114 115 116 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 114 def test_id_list @test_id_list ||= .tests.map { |test| test[:id] } end |
#title ⇒ Object
50 51 52 |
# File 'lib/au_core_test_kit/generator/group_generator.rb', line 50 def title .title end |