Class: Jdt::ComponentGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/jdt/generator/component_generator.rb

Instance Attribute Summary

Attributes inherited from Generator

#author, #creation_date, #description, #location, #name

Instance Method Summary collapse

Instance Method Details

#generate(name) ⇒ Object



5
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/jdt/generator/component_generator.rb', line 5

def generate(name)
  super

  view_name = "#{name}"

  empty_directory("#{folder}")
  template('templates/component/manifest.xml.erb', "#{folder}/manifest.xml")
  template('templates/component/script.php.erb', "#{folder}/script.php")

  # site
  site_dir = "#{folder}/site"
  empty_directory("#{site_dir}")
  template('templates/component/site/com_name.php.erb', "#{site_dir}/#{prefixed_name}.php")
  template('templates/component/site/controller.php.erb', "#{site_dir}/controller.php")

  #site view
  empty_directory("#{site_dir}/views/")
  empty_directory("#{site_dir}/views/#{view_name}")
  template('templates/component/site/views/view_name/view.html.erb', "#{site_dir}/views/#{view_name}/view.html.php")
  empty_directory("#{site_dir}/views/#{view_name}/tmpl")
  template('templates/component/site/views/view_name/tmpl/default.php.erb', "#{site_dir}/views/#{view_name}/tmpl/default.php")
  template('templates/component/site/views/view_name/tmpl/default.xml.erb', "#{site_dir}/views/#{view_name}/tmpl/default.xml")

  #site models
  empty_directory("#{site_dir}/models/")
  template('templates/component/site/models/com_model_name.erb', "#{site_dir}/models/com_#{name}.php")

  #site controllers
  empty_directory("#{site_dir}/controllers/")

  #site language
  empty_directory("#{site_dir}/language/")
  empty_directory("#{site_dir}/language/en-GB/")
  empty_directory("#{site_dir}/language/de-DE/")

  # admin
  admin_dir = "#{folder}/admin"
  empty_directory("#{admin_dir}")
  template('templates/component/admin/access.xml.erb', "#{admin_dir}/access.xml")
  template('templates/component/admin/config.xml.erb', "#{admin_dir}/config.xml")
  template('templates/component/admin/com_name.php.erb', "#{admin_dir}/com_#{name}.php")
  template('templates/component/admin/controller.php.erb', "#{admin_dir}/controller.php")

  #admin views
  empty_directory("#{admin_dir}/views/")
  empty_directory("#{admin_dir}/views/#{view_name}")
  template('templates/component/admin/views/view_name/view.html.erb', "#{admin_dir}/views/#{view_name}/view.html.php")
  empty_directory("#{admin_dir}/views/#{view_name}/tmpl")
  template('templates/component/admin/views/view_name/tmpl/default.php.erb', "#{admin_dir}/views/#{view_name}/tmpl/default.php")

  #admin models
  empty_directory("#{admin_dir}/models/")
  empty_directory("#{admin_dir}/models/forms/")
  empty_directory("#{admin_dir}/models/rules/")
  empty_directory("#{admin_dir}/models/fields/")

  #admin controllers
  empty_directory("#{admin_dir}/controllers/")

  #admin helpers
  empty_directory("#{admin_dir}/helpers/")

  #admin tables
  empty_directory("#{admin_dir}/tables/")

  #admin language
  empty_directory("#{admin_dir}/language/")
  empty_directory("#{admin_dir}/language/en-GB/")
  empty_directory("#{admin_dir}/language/de-DE/")

  #admin sql
  empty_directory("#{admin_dir}/sql/")
  empty_directory("#{admin_dir}/sql/updates/")

end