Class: AppGenerator

Inherits:
Rails::Generator::Base show all
Defined in:
lib/rails_generator/generators/applications/app/app_generator.rb

Constant Summary collapse

DEFAULT_SHEBANG =
File.join(Config::CONFIG['bindir'],
Config::CONFIG['ruby_install_name'])
DATABASES =
%w(mysql oracle postgresql sqlite2 sqlite3 frontbase)

Instance Attribute Summary

Attributes inherited from Rails::Generator::Base

#args, #destination_root, #source_root

Instance Method Summary collapse

Methods inherited from Rails::Generator::Base

#destination_path, #source_path

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ AppGenerator

Returns a new instance of AppGenerator.



12
13
14
15
16
17
18
# File 'lib/rails_generator/generators/applications/app/app_generator.rb', line 12

def initialize(runtime_args, runtime_options = {})
  super
  usage if args.empty?
  usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db]))
  @destination_root = args.shift
  @app_name = File.basename(File.expand_path(@destination_root))
end

Instance Method Details

#manifestObject



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/rails_generator/generators/applications/app/app_generator.rb', line 20

def manifest
  # Use /usr/bin/env if no special shebang was specified
  script_options     = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
  dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }

  record do |m|
    # Root directory and all subdirectories.
    m.directory ''
    BASEDIRS.each { |path| m.directory path }

    # Root
    m.file "fresh_rakefile", "Rakefile"
    m.file "README",         "README"
    

    # Application
    m.template "helpers/application.rb",        "app/controllers/application.rb", :assigns => { :app_name => @app_name }
    m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
    m.template "helpers/test_helper.rb",        "test/test_helper.rb"
    m.template "helpers/permission_helper.rb",  "app/helpers/permission_helper.rb"
    
    # database.yml and .htaccess
    m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
      :app_name => @app_name,
      :socket   => options[:db] == "mysql" ? mysql_socket_location : nil
    }
    m.template "configs/routes.rb",     "config/routes.rb"
    m.template "configs/apache.conf",   "public/.htaccess"

    # Environments
    m.file "environments/boot.rb",    "config/boot.rb"
    m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }
    m.file "environments/production.rb",  "config/environments/production.rb"
    m.file "environments/development.rb", "config/environments/development.rb"
    m.file "environments/test.rb",        "config/environments/test.rb"

    # Scripts
    %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin ).each do |file|
      m.file "bin/#{file}", "script/#{file}", script_options
    end

    # Dispatches
    m.file "dispatches/dispatch.rb",   "public/dispatch.rb", dispatcher_options
    m.file "dispatches/dispatch.rb",   "public/dispatch.cgi", dispatcher_options
    m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options

    # HTML files
    %w(404 500 index).each do |file|
      m.template "html/#{file}.html", "public/#{file}.html"
    end

    m.template "html/favicon.ico",  "public/favicon.ico"
    m.template "html/robots.txt",   "public/robots.txt"
    m.file "html/images/rails.png", "public/images/rails.png"
    
    #images
    m.file "html/images/delete.png", "public/images/delete.png"
    m.file "html/images/edit.png", "public/images/edit.png"
    m.file "html/images/show.png", "public/images/show.png"
    m.file "html/images/arrow.gif", "public/images/arrow.gif"
    m.file "html/images/minus.gif", "public/images/minus.gif"
    m.file "html/images/plus.gif", "public/images/plus.gif"  
    m.file "html/images/spinner.gif", "public/images/spinner.gif"  
    m.file "html/images/ArrowDn.png", "public/images/ArrowDn.png" 
    m.file "html/images/ArrowUp.png", "public/images/ArrowUp.png" 
    m.file "html/images/authorails_logo.gif", "public/images/authorails_logo.gif"    
    
    # Javascripts
    m.file "html/javascripts/prototype.js",    "public/javascripts/prototype.js"
    m.file "html/javascripts/effects.js",      "public/javascripts/effects.js"
    m.file "html/javascripts/dragdrop.js",     "public/javascripts/dragdrop.js"
    m.file "html/javascripts/controls.js",     "public/javascripts/controls.js"
    m.file "html/javascripts/application.js",  "public/javascripts/application.js"
    m.file "html/javascripts/live_validation.js",  "public/javascripts/live_validation.js"

    # Docs
    m.file "doc/README_FOR_APP", "doc/README_FOR_APP"

    # Logs
    %w(server production development test).each { |file|
      m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
    }
    
    # Controllers
    m.file "controllers/accounts_controller.rb", "app/controllers/accounts_controller.rb"
    m.file "controllers/admin_controller.rb", "app/controllers/admin_controller.rb"
    m.file "controllers/begin_controller.rb", "app/controllers/begin_controller.rb"
    m.file "controllers/login_controller.rb", "app/controllers/login_controller.rb"
    m.file "controllers/permission_controller.rb", "app/controllers/permission_controller.rb"
    m.file "controllers/roles_controller.rb", "app/controllers/roles_controller.rb"
    m.file "controllers/tables_controller.rb", "app/controllers/tables_controller.rb"
  
    #Models
    m.file "models/admin.rb", "app/models/admin.rb"
    m.file "models/attr_operation.rb", "app/models/attr_operation.rb"
    m.file "models/attr_permission.rb", "app/models/attr_permission.rb"
    m.file "models/attr_type.rb", "app/models/attr_type.rb"
    m.file "models/login.rb", "app/models/login.rb"
    m.file "models/relation_permission.rb", "app/models/relation_permission.rb"
    m.file "models/relation.rb", "app/models/relation.rb"
    m.file "models/role.rb", "app/models/role.rb"
    m.file "models/scaffold.rb", "app/models/scaffold.rb"
    m.file "models/tab_operation.rb", "app/models/tab_operation.rb"
    m.file "models/tab_permission.rb", "app/models/tab_permission.rb"
    m.file "models/table.rb", "app/models/table.rb"
    m.file "models/table_field.rb", "app/models/table_field.rb"
    
    
    #Views
    m.file "views/accounts/index.rhtml", "app/views/accounts/index.rhtml"
    m.file "views/accounts/show.rhtml", "app/views/accounts/show.rhtml"
    m.file "views/admin/_form.rhtml", "app/views/admin/_form.rhtml"
    m.file "views/admin/add_user.rhtml", "app/views/admin/add_user.rhtml"
    m.file "views/admin/change_pwd.rhtml", "app/views/admin/change_pwd.rhtml"
    m.file "views/admin/edit_user.rhtml", "app/views/admin/edit_user.rhtml"
    m.file "views/admin/index.rhtml", "app/views/admin/index.rhtml"
    m.file "views/begin/index.rhtml", "app/views/begin/index.rhtml"
    m.file "views/layouts/general.rhtml", "app/views/layouts/general.rhtml"
    m.file "views/layouts/login.rhtml", "app/views/layouts/login.rhtml"
    m.file "views/login/change_pwd.rhtml", "app/views/login/change_pwd.rhtml"
    m.file "views/login/expired_pwd.rhtml", "app/views/login/expired_pwd.rhtml"
    m.file "views/login/index.rhtml", "app/views/login/index.rhtml"
    m.file "views/permission/index.rhtml", "app/views/permission/index.rhtml"
    m.file "views/permission/relations.rhtml", "app/views/permission/relations.rhtml"
    m.file "views/permission/roles.rhtml", "app/views/permission/roles.rhtml"
    m.file "views/permission/tables.rhtml", "app/views/permission/tables.rhtml"
    m.file "views/roles/_form.rhtml", "app/views/roles/_form.rhtml"
    m.file "views/roles/edit.rhtml", "app/views/roles/edit.rhtml"
    m.file "views/roles/list.rhtml", "app/views/roles/list.rhtml"
    m.file "views/roles/new.rhtml", "app/views/roles/new.rhtml"
    m.file "views/roles/show.rhtml", "app/views/roles/show.rhtml"
    m.file "views/shared_views/_advanced_search.rhtml", "app/views/shared_views/_advanced_search.rhtml"
    m.file "views/shared_views/_child_elements.rhtml", "app/views/shared_views/_child_elements.rhtml"
    m.file "views/shared_views/_childs.rhtml", "app/views/shared_views/_childs.rhtml"
    m.file "views/shared_views/_father_elements.rhtml", "app/views/shared_views/_father_elements.rhtml"
    m.file "views/shared_views/_fathers_header.rhtml", "app/views/shared_views/_fathers_header.rhtml"
    m.file "views/shared_views/_fathers.rhtml", "app/views/shared_views/_fathers.rhtml"
    m.file "views/shared_views/_many_to_many_elements.rhtml", "app/views/shared_views/_many_to_many_elements.rhtml"
    m.file "views/shared_views/_many_to_manys.rhtml", "app/views/shared_views/_many_to_manys.rhtml"
    m.file "views/shared_views/_one_to_one_elements.rhtml", "app/views/shared_views/_one_to_one_elements.rhtml"
    m.file "views/shared_views/_one_to_one_father_elements.rhtml", "app/views/shared_views/_one_to_one_father_elements.rhtml"
    m.file "views/shared_views/_one_to_ones_header.rhtml", "app/views/shared_views/_one_to_ones_header.rhtml"
    m.file "views/shared_views/_one_to_ones.rhtml", "app/views/shared_views/_one_to_ones.rhtml"
    m.file "views/shared_views/edit_child.rhtml", "app/views/shared_views/edit_child.rhtml"
    m.file "views/shared_views/edit_many.rhtml", "app/views/shared_views/edit_many.rhtml"
    m.file "views/tables/_cascade.rhtml", "app/views/tables/_cascade.rhtml"
    m.file "views/tables/_field.rhtml", "app/views/tables/_field.rhtml"
    m.file "views/tables/_fk.rhtml", "app/views/tables/_fk.rhtml"
    m.file "views/tables/_form.rhtml", "app/views/tables/_form.rhtml"
    m.file "views/tables/_join_table_name.rhtml", "app/views/tables/_join_table_name.rhtml"
    m.file "views/tables/_relation_types.rhtml", "app/views/tables/_relation_types.rhtml"
    m.file "views/tables/_tables.rhtml", "app/views/tables/_tables.rhtml"
    m.file "views/tables/attributes.rhtml", "app/views/tables/attributes.rhtml"
    m.file "views/tables/edit_field.rhtml", "app/views/tables/edit_field.rhtml"
    m.file "views/tables/edit.rhtml", "app/views/tables/edit.rhtml"
    m.file "views/tables/list.rhtml", "app/views/tables/list.rhtml"
    m.file "views/tables/new_field.rhtml", "app/views/tables/new_field.rhtml"
    m.file "views/tables/new.rhtml", "app/views/tables/new.rhtml"
    m.file "views/tables/relations.rhtml", "app/views/tables/relations.rhtml"
    m.file "views/tables/show.rhtml", "app/views/tables/show.rhtml"
  
    #Migration helper
    m.file "libs/migration_helper.rb", "lib/migration_helper.rb"
    
    #Stylesheet
    m.file "stylesheets/scaffold.css", "public/stylesheets/scaffold.css"
    m.file "stylesheets/print.css", "public/stylesheets/print.css"
    m.file "stylesheets/live_validation.css", "public/stylesheets/live_validation.css"
    
    #Migrations
    m.file "migrations/001_create_logins.rb", "db/migrate/001_create_logins.rb"
    m.file "migrations/002_create_admins.rb", "db/migrate/002_create_admins.rb"
    m.file "migrations/003_create_roles.rb", "db/migrate/003_create_roles.rb"
    m.file "migrations/004_create_tables.rb", "db/migrate/004_create_tables.rb"
    m.file "migrations/005_create_attr_types.rb", "db/migrate/005_create_attr_types.rb"
    m.file "migrations/006_create_table_fields.rb", "db/migrate/006_create_table_fields.rb"
    m.file "migrations/007_create_tab_operations.rb", "db/migrate/007_create_tab_operations.rb"
    m.file "migrations/008_create_attr_operations.rb", "db/migrate/008_create_attr_operations.rb"
    m.file "migrations/009_create_tab_permissions.rb", "db/migrate/009_create_tab_permissions.rb"
    m.file "migrations/010_create_attr_permissions.rb", "db/migrate/010_create_attr_permissions.rb"
    m.file "migrations/011_create_relations.rb", "db/migrate/011_create_relations.rb"
    m.file "migrations/012_create_scaffolds.rb", "db/migrate/012_create_scaffolds.rb"
    m.file "migrations/013_create_relation_permissions.rb", "db/migrate/013_create_relation_permissions.rb"
    
    #Plugin for add a server-side validation
    m.file "plugins/redhillonrails_core/CHANGELOG", "vendor/plugins/redhillonrails_core/CHANGELOG"
    m.file "plugins/redhillonrails_core/init.rb", "vendor/plugins/redhillonrails_core/init.rb"
    m.file "plugins/redhillonrails_core/MIT-LICENSE", "vendor/plugins/redhillonrails_core/MIT-LICENSE"
    m.file "plugins/redhillonrails_core/README", "vendor/plugins/redhillonrails_core/README"
    m.file "plugins/redhillonrails_core/lib/redhillonrails_core.rb", "vendor/plugins/redhillonrails_core/lib/redhillonrails_core.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema_dumper.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema_dumper.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/abstract_adapter.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/abstract_adapter.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/column.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/column.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/foreign_key_definition.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/foreign_key_definition.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/index_definition.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/index_definition.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/mysql_adapter.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/mysql_adapter.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/mysql_column.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/mysql_column.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/postgresql_adapter.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/postgresql_adapter.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/schema_statements.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/schema_statements.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/sqlite3_adapter.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/sqlite3_adapter.rb"
    m.file "plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb", "vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb"
    m.file "plugins/redhillonrails_core/tasks/db/comments.rake", "vendor/plugins/redhillonrails_core/tasks/db/comments.rake"
    m.file "plugins/schema_validations/about.yml", "vendor/plugins/schema_validations/about.yml"
    m.file "plugins/schema_validations/CHANGELOG", "vendor/plugins/schema_validations/CHANGELOG"
    m.file "plugins/schema_validations/init.rb", "vendor/plugins/schema_validations/init.rb"
    m.file "plugins/schema_validations/install.rb", "vendor/plugins/schema_validations/install.rb"
    m.file "plugins/schema_validations/MIT-LICENSE", "vendor/plugins/schema_validations/MIT-LICENSE"
    m.file "plugins/schema_validations/README", "vendor/plugins/schema_validations/README"
    m.file "plugins/schema_validations/lib/schema_validations.rb", "vendor/plugins/schema_validations/lib/schema_validations.rb"
    m.file "plugins/schema_validations/lib/red_hill_consulting/schema_validations/active_record/base.rb", "vendor/plugins/schema_validations/lib/red_hill_consulting/schema_validations/active_record/base.rb"
    
    #Plugin for add a client-side validation
    m.file "plugins/svn/init.rb", "vendor/plugins/svn/init.rb"
    m.file "plugins/svn/install.rb", "vendor/plugins/svn/install.rb"
    m.file "plugins/svn/Rakefile", "vendor/plugins/svn/Rakefile"
    m.file "plugins/svn/README", "vendor/plugins/svn/README"
    m.file "plugins/svn/uninstall.rb", "vendor/plugins/svn/uninstall.rb"
    m.file "plugins/svn/assets/javascripts/live_validation.js", "vendor/plugins/svn/assets/javascripts/live_validation.js"
    m.file "plugins/svn/assets/stylesheets/live_validation.css", "vendor/plugins/svn/assets/stylesheets/live_validation.css"
    m.file "plugins/svn/lib/form_helpers.rb", "vendor/plugins/svn/lib/form_helpers.rb"
    m.file "plugins/svn/lib/live_validations.rb", "vendor/plugins/svn/lib/live_validations.rb"
    m.file "plugins/svn/tasks/live_validation_tasks.rake", "vendor/plugins/svn/tasks/live_validation_tasks.rake"
    m.file "plugins/svn/test/form_helpers_test.rb", "vendor/plugins/svn/test/form_helpers_test.rb"
    m.file "plugins/svn/test/live_validations_test.rb", "vendor/plugins/svn/test/live_validations_test.rb"
    m.file "plugins/svn/test/resource.rb", "vendor/plugins/svn/test/resource.rb"
    
    m.file "AUTHORAILS_README", "AUTHORAILS_README"
    m.readme "AUTHORAILS_README"
  end
end