Class: USCoreTestKit::Generator::GranularScopeReadTestGenerator
- Inherits:
-
Object
- Object
- USCoreTestKit::Generator::GranularScopeReadTestGenerator
- Defined in:
- lib/us_core_test_kit/generator/granular_scope_read_test_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.
-
#group_number ⇒ Object
Returns the value of attribute group_number.
Class Method Summary collapse
Instance Method Summary collapse
- #array_of_strings(array) ⇒ Object
- #base_output_file_name ⇒ Object
- #class_name ⇒ Object
- #description ⇒ Object
- #generate ⇒ Object
-
#initialize(group_metadata, base_output_dir) ⇒ GranularScopeReadTestGenerator
constructor
A new instance of GranularScopeReadTestGenerator.
- #module_name ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #path_for_value(path) ⇒ Object
- #profile_identifier ⇒ Object
- #resource_type ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
Constructor Details
#initialize(group_metadata, base_output_dir) ⇒ GranularScopeReadTestGenerator
Returns a new instance of GranularScopeReadTestGenerator.
28 29 30 31 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 28 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.
26 27 28 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 26 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
26 27 28 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 26 def @group_metadata end |
#group_number ⇒ Object
Returns the value of attribute group_number.
26 27 28 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 26 def group_number @group_number end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 9 def generate(, base_output_dir) return if .ig_version[1].to_i < 6 scopes = SmartScopesConstants::SMART_GRANULAR_SCOPES_GROUP1[.reformatted_version] + (SmartScopesConstants::SMART_GRANULAR_SCOPES_GROUP2[.reformatted_version] || []) SmartScopesConstants::SMART_GRANULAR_SCOPE_RESOURCES.each do |resource_type| group = .groups.find { |group| group.resource == resource_type } next if scopes.none? { |scope| scope.start_with? "patient/#{group.resource}" } new(group, base_output_dir).generate end end |
Instance Method Details
#array_of_strings(array) ⇒ Object
77 78 79 80 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 77 def array_of_strings(array) quoted_strings = array.map { |element| "'#{element}'" } "[#{quoted_strings.join(', ')}]" end |
#base_output_file_name ⇒ Object
41 42 43 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 41 def base_output_file_name "#{class_name.underscore}.rb" end |
#class_name ⇒ Object
61 62 63 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 61 def class_name "#{resource_type}GranularScopeReadTest" end |
#description ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 92 def description <<~DESCRIPTION.gsub(/\n{3,}/, "\n\n") This test attempts #{resource_type} reads and verifies that the results have been filtered based on the granted granular scopes. DESCRIPTION end |
#generate ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 82 def generate FileUtils.mkdir_p(output_file_directory) File.open(output_file_name, 'w') { |f| f.write(output) } .add_granular_scope_test( id: test_id, file_name: base_output_file_name ) end |
#module_name ⇒ Object
65 66 67 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 65 def module_name "USCore#{.reformatted_version.upcase}" end |
#output ⇒ Object
37 38 39 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 37 def output @output ||= ERB.new(template).result(binding) end |
#output_file_directory ⇒ Object
45 46 47 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 45 def output_file_directory File.join(base_output_dir, 'granular_scope_tests', resource_type.underscore) end |
#output_file_name ⇒ Object
49 50 51 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 49 def output_file_name File.join(output_file_directory, base_output_file_name) end |
#path_for_value(path) ⇒ Object
73 74 75 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 73 def path_for_value(path) path == 'class' ? 'local_class' : path end |
#profile_identifier ⇒ Object
53 54 55 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 53 def profile_identifier Naming.snake_case_for_profile() end |
#resource_type ⇒ Object
69 70 71 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 69 def resource_type .resource end |
#template ⇒ Object
33 34 35 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 33 def template @template ||= File.read(File.join(__dir__, 'templates', 'granular_scope_read_test.rb.erb')) end |
#test_id ⇒ Object
57 58 59 |
# File 'lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb', line 57 def test_id "us_core_#{.reformatted_version}_#{resource_type}_granular_scope_read_test" end |