Class: USCoreTestKit::Generator::PractitionerAddressTestGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/us_core_test_kit/generator/practitioner_address_test_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_metadata, base_output_dir) ⇒ PractitionerAddressTestGenerator

Returns a new instance of PractitionerAddressTestGenerator.



14
15
16
17
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 14

def initialize(, base_output_dir)
  self. = 
  self.base_output_dir = base_output_dir
end

Instance Attribute Details

#base_output_dirObject

Returns the value of attribute base_output_dir.



12
13
14
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 12

def base_output_dir
  @base_output_dir
end

#group_metadataObject

Returns the value of attribute group_metadata.



12
13
14
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 12

def 
  @group_metadata
end

Class Method Details

.generate(ig_metadata, base_output_dir) ⇒ Object



5
6
7
8
9
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 5

def generate(, base_output_dir)
  .groups
    .reject { |group| SpecialCases.exclude_group? group }
    .each { |group| new(group, base_output_dir).generate }
end

Instance Method Details

#base_output_file_nameObject



27
28
29
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 27

def base_output_file_name
  "#{class_name.underscore}.rb"
end

#class_nameObject



47
48
49
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 47

def class_name
  "PractitionerAddressTest"
end

#generateObject



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 55

def generate
  return unless .resource == 'Practitioner' && .version[1].to_i > 5

  FileUtils.mkdir_p(output_file_directory)
  File.open(output_file_name, 'w') { |f| f.write(output) }

  .add_test(
    id: test_id,
    file_name: base_output_file_name
  )
end

#module_nameObject



51
52
53
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 51

def module_name
  "USCore#{.reformatted_version.upcase}"
end

#outputObject



23
24
25
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 23

def output
  @output ||= ERB.new(template).result(binding)
end

#output_file_directoryObject



31
32
33
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 31

def output_file_directory
  File.join(base_output_dir, profile_identifier)
end

#output_file_nameObject



35
36
37
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 35

def output_file_name
  File.join(output_file_directory, base_output_file_name)
end

#profile_identifierObject



39
40
41
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 39

def profile_identifier
  Naming.snake_case_for_profile()
end

#templateObject



19
20
21
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 19

def template
  @template ||= File.read(File.join(__dir__, 'templates', 'practitioner_address_test.rb.erb'))
end

#test_idObject



43
44
45
# File 'lib/us_core_test_kit/generator/practitioner_address_test_generator.rb', line 43

def test_id
  "us_core_#{.reformatted_version}_practitioner_address_test"
end