Class: DaVinciPlanNetTestKit::Generator::ResourceListGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_plan_net_test_kit/generator/resource_list_generator.rb

Class Method Summary collapse

Class Method Details

.base_output_file_nameObject



36
37
38
# File 'lib/davinci_plan_net_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/davinci_plan_net_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_nameObject



20
21
22
# File 'lib/davinci_plan_net_test_kit/generator/resource_list_generator.rb', line 20

def module_name
  "DaVinciPlanNet#{@ig_metadata.reformatted_version.upcase}"
end

.outputObject



32
33
34
# File 'lib/davinci_plan_net_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/davinci_plan_net_test_kit/generator/resource_list_generator.rb', line 24

def read_interaction()
  .interactions.find { |interaction| interaction[:code] == 'read' }
end

.resource_listObject



12
13
14
# File 'lib/davinci_plan_net_test_kit/generator/resource_list_generator.rb', line 12

def resource_list
  @ig_metadata.groups.map(&:resource).uniq
end

.resource_list_stringObject



16
17
18
# File 'lib/davinci_plan_net_test_kit/generator/resource_list_generator.rb', line 16

def resource_list_string
  resource_list.map { |resource| "      '#{resource}'" }.join(",\n")
end

.templateObject



28
29
30
# File 'lib/davinci_plan_net_test_kit/generator/resource_list_generator.rb', line 28

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