Class: DaVinciPlanNetTestKit::Generator::MustSupportTestGenerator
- Inherits:
-
Object
- Object
- DaVinciPlanNetTestKit::Generator::MustSupportTestGenerator
- Defined in:
- lib/davinci_plan_net_test_kit/generator/must_support_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.
Class Method Summary collapse
Instance Method Summary collapse
- #base_output_file_name ⇒ Object
- #build_must_support_list_string(uscdi_only) ⇒ Object
- #class_name ⇒ Object
- #generate ⇒ Object
-
#initialize(group_metadata, base_output_dir) ⇒ MustSupportTestGenerator
constructor
A new instance of MustSupportTestGenerator.
- #module_name ⇒ Object
- #must_support_list_string ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #read_interaction ⇒ Object
- #resource_collection_string ⇒ Object
- #resource_type ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
- #uscdi_list_string ⇒ Object
Constructor Details
#initialize(group_metadata, base_output_dir) ⇒ MustSupportTestGenerator
Returns a new instance of MustSupportTestGenerator.
17 18 19 20 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 17 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.
15 16 17 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 15 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
15 16 17 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 15 def @group_metadata end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
8 9 10 11 12 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 8 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_name ⇒ Object
30 31 32 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 30 def base_output_file_name "#{class_name.underscore}.rb" end |
#build_must_support_list_string(uscdi_only) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 78 def build_must_support_list_string(uscdi_only) slice_names = .must_supports[:slices] .select { |slice| slice[:uscdi_only].presence == uscdi_only.presence } .map { |slice| slice[:name] } element_names = .must_supports[:elements] .select { |element| element[:uscdi_only].presence == uscdi_only.presence } .map { |element| "#{resource_type}.#{element[:path]}" } extension_names = .must_supports[:extensions] .select { |extension| extension[:uscdi_only].presence == uscdi_only.presence } .map { |extension| extension[:id] } .must_supports[:choices]&.each do |choice| next unless choice[:uscdi_only].presence == uscdi_only.presence && choice.key?(:paths) choice[:paths].each { |path| element_names.delete("#{resource_type}.#{path}") } element_names << choice[:paths].map { |path| "#{resource_type}.#{path}" }.join(' or ') end (slice_names + element_names + extension_names) .uniq .sort .map { |name| "#{' ' * 8}* #{name}" } .join("\n") end |
#class_name ⇒ Object
54 55 56 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 54 def class_name "#{Naming.upper_camel_case_for_profile()}MustSupportTest" end |
#generate ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 105 def generate 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_name ⇒ Object
58 59 60 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 58 def module_name "DaVinciPlanNet#{.reformatted_version.upcase}" end |
#must_support_list_string ⇒ Object
70 71 72 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 70 def must_support_list_string build_must_support_list_string(false) end |
#output ⇒ Object
26 27 28 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 26 def output @output ||= ERB.new(template).result(binding) end |
#output_file_directory ⇒ Object
34 35 36 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 34 def output_file_directory File.join(base_output_dir, profile_identifier) end |
#output_file_name ⇒ Object
38 39 40 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 38 def output_file_name File.join(output_file_directory, base_output_file_name) end |
#profile_identifier ⇒ Object
46 47 48 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 46 def profile_identifier Naming.snake_case_for_profile() end |
#read_interaction ⇒ Object
42 43 44 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 42 def read_interaction self.class.read_interaction() end |
#resource_collection_string ⇒ Object
66 67 68 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 66 def resource_collection_string 'all_scratch_resources' end |
#resource_type ⇒ Object
62 63 64 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 62 def resource_type .resource end |
#template ⇒ Object
22 23 24 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 22 def template @template ||= File.read(File.join(__dir__, 'templates', 'must_support.rb.erb')) end |
#test_id ⇒ Object
50 51 52 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 50 def test_id "davinci_plan_net_#{.reformatted_version}_#{profile_identifier}_must_support_test" end |
#uscdi_list_string ⇒ Object
74 75 76 |
# File 'lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb', line 74 def uscdi_list_string build_must_support_list_string(true) end |