Method: JunglePath::Gen.controllers

Defined in:
lib/jungle_path/gen/controllers.rb

.controllers(app_root_path, tables, output_file = './controllers/generated.rb', controller_name_space = 'Controller', schema_require_relative = '../schemas/schema', template_file = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jungle_path/gen/controllers.rb', line 6

def self.controllers(app_root_path, tables, output_file='./controllers/generated.rb', controller_name_space='Controller', schema_require_relative='../schemas/schema', template_file=nil)
  if template_file
    template_file = ::File.expand_path(template_file, app_root_path)
  else
    template_file = ::File.expand_path('../controller/template.erb', ::File.dirname(__FILE__))
  end

  # template uses name_space and controller_name_space vars:``
  template = ERB.new(File.read(template_file))

  output_file = ::File.expand_path(output_file, app_root_path)
  result = template.result(binding)
  puts result
  File.write(output_file, result)
end