Class: IpaTestKit::Generator::ResourceListGenerator
- Inherits:
-
Object
- Object
- IpaTestKit::Generator::ResourceListGenerator
- Defined in:
- lib/ipa_test_kit/generator/resource_list_generator.rb
Class Method Summary collapse
- .base_output_file_name ⇒ Object
- .generate(ig_metadata, base_output_dir) ⇒ Object
- .module_name ⇒ Object
- .output ⇒ Object
- .read_interaction(group_metadata) ⇒ Object
- .resource_list ⇒ Object
- .resource_list_string ⇒ Object
- .template ⇒ Object
Class Method Details
.base_output_file_name ⇒ Object
36 37 38 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 36 def base_output_file_name "resource_list.rb" end |
.generate(ig_metadata, base_output_dir) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 5 def generate(, base_output_dir) @ig_metadata = FileUtils.mkdir_p(base_output_dir) File.open(File.join(base_output_dir, base_output_file_name), 'w') { |f| f.write(output) } end |
.module_name ⇒ Object
20 21 22 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 20 def module_name "Ipa#{@ig_metadata.reformatted_version.upcase}" end |
.output ⇒ Object
32 33 34 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 32 def output ERB.new(template).result(binding) end |
.read_interaction(group_metadata) ⇒ Object
24 25 26 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 24 def read_interaction() .interactions.find { |interaction| interaction[:code] == 'read' } end |
.resource_list ⇒ Object
12 13 14 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 12 def resource_list @ig_metadata.groups.map(&:resource).uniq end |
.resource_list_string ⇒ Object
16 17 18 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 16 def resource_list_string resource_list.map { |resource| " '#{resource}'" }.join(",\n") end |
.template ⇒ Object
28 29 30 |
# File 'lib/ipa_test_kit/generator/resource_list_generator.rb', line 28 def template @template ||= File.read(File.join(__dir__, 'templates', 'resource_list.rb.erb')) end |