Class: DaVinciPASTestKit::Generator::ResourceListGenerator
- Inherits:
-
Object
- Object
- DaVinciPASTestKit::Generator::ResourceListGenerator
- Defined in:
- lib/davinci_pas_test_kit/generator/resource_list_generator.rb
Class Method Summary collapse
- .base_output_file_name ⇒ Object
- .generate(ig_metadata, base_output_dir) ⇒ Object
- .inquiry_operation(group_metadata) ⇒ Object
- .module_name ⇒ Object
- .output ⇒ Object
- .read_interaction(group_metadata) ⇒ Object
- .resource_list ⇒ Object
- .resource_list_string ⇒ Object
- .resource_supported_profiles ⇒ Object
- .submit_operation(group_metadata) ⇒ Object
- .template ⇒ Object
Class Method Details
.base_output_file_name ⇒ Object
53 54 55 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 53 def base_output_file_name 'resource_list.rb' end |
.generate(ig_metadata, base_output_dir) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 5 def generate(, base_output_dir) @ig_metadata = FileUtils.mkdir_p(base_output_dir) File.write(File.join(base_output_dir, base_output_file_name), output) end |
.inquiry_operation(group_metadata) ⇒ Object
41 42 43 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 41 def inquiry_operation() .operations.find { |operation| operation[:code] == '$inquire' } || {} end |
.module_name ⇒ Object
29 30 31 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 29 def module_name "PAS#{@ig_metadata.reformatted_version.upcase}" end |
.output ⇒ Object
49 50 51 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 49 def output ERB.new(template).result(binding) end |
.read_interaction(group_metadata) ⇒ Object
33 34 35 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 33 def read_interaction() .interactions.find { |interaction| interaction[:code] == 'read' } || {} end |
.resource_list ⇒ Object
12 13 14 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 12 def resource_list @ig_metadata.groups.map(&:title).uniq end |
.resource_list_string ⇒ Object
25 26 27 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 25 def resource_list_string resource_list.map { |resource| " '#{resource}'" }.join(",\n") end |
.resource_supported_profiles ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 16 def resource_supported_profiles dict = {} @ig_metadata.groups.each do |group| dict[group.resource] ||= [] dict[group.resource] << group.profile_url end dict end |
.submit_operation(group_metadata) ⇒ Object
37 38 39 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 37 def submit_operation() .operations.find { |operation| operation[:code] == '$submit' } || {} end |
.template ⇒ Object
45 46 47 |
# File 'lib/davinci_pas_test_kit/generator/resource_list_generator.rb', line 45 def template @template ||= File.read(File.join(__dir__, 'templates', 'resource_list.rb.erb')) end |