6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/generators/rails_pdf/rails_pdf_generator.rb', line 6
def create_helper_file
report = args[0]
if report.nil?
puts "Please specify report starter template which you want to generate or \"new\" to create blank template."
puts "Available types: #{TYPES.join(', ')}"
puts "rails g rails_pdf <type> <name of report>"
puts "sample: rails g rails_pdf #{TYPES[0]} report"
exit
end
if !TYPES.include?(file_name)
puts "Template not found. You can use any of: #{TYPES.join(', ')} "
puts "sample: rails g rails_pdf #{TYPES[0]} report"
return
end
directory "#{file_name}", "app/pdf/#{report}"
case file_name
when 'basic_invoice', 'simple_invoice'
gsub_file "app/pdf/#{report}/invoice.pug.erb", '<%= report %>', report
when 'chart1'
gsub_file "app/pdf/#{report}/chart.pug.erb", '<%= report %>', report
when 'products'
gsub_file "app/pdf/#{report}/index.pug.erb", '<%= report %>', report
end
directory "mixins", "app/pdf/mixins"
directory "shared", "app/pdf/shared"
directory "layouts", "app/pdf/layouts"
end
|