Module: JunglePath::Gen

Defined in:
lib/jungle_path/gen.rb,
lib/jungle_path/gen/api.rb,
lib/jungle_path/gen/controllers.rb,
lib/jungle_path/gen/schema_tree.rb,
lib/jungle_path/gen/schema_tree/node.rb,
lib/jungle_path/gen/schema_tree/filter.rb,
lib/jungle_path/gen/schema_tree/match_tables.rb,
lib/jungle_path/gen/schema_tree/match_columns.rb,
lib/jungle_path/gen/schema_tree/match_table_data.rb

Defined Under Namespace

Modules: SchemaTree

Class Method Summary collapse

Class Method Details

.api(app_root_path, tables, output_file = './api/generated.rb', name_space = 'Server', controller_name_space = 'Controller', class_name = 'API', base_class_name = 'Base', template_file = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jungle_path/gen/api.rb', line 36

def self.api(app_root_path, tables, output_file='./api/generated.rb', name_space='Server', controller_name_space='Controller', class_name='API', base_class_name='Base', template_file=nil)
  if template_file
    template_file = ::File.expand_path(template_file, app_root_path)
  else
    template_file = ::File.expand_path('../api/template.erb', ::File.dirname(__FILE__))
  end

  # template uses name_space,controller_name_space, class_name and base_class_name 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

.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