rails_product 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +619 -0
- data/MIT-LICENSE +21 -0
- data/README +195 -0
- data/Rakefile +413 -0
- data/bin/benchmarker +19 -0
- data/bin/breakpointer +3 -0
- data/bin/breakpointer_for_gem +4 -0
- data/bin/console +23 -0
- data/bin/console_sandbox +0 -0
- data/bin/destroy +7 -0
- data/bin/generate +7 -0
- data/bin/listener +86 -0
- data/bin/process/reaper +123 -0
- data/bin/process/spawner +54 -0
- data/bin/process/spinner +60 -0
- data/bin/profiler +34 -0
- data/bin/rails +17 -0
- data/bin/rails_product +17 -0
- data/bin/runner +28 -0
- data/bin/server +125 -0
- data/bin/tracker +69 -0
- data/bin/update +5 -0
- data/configs/apache/vhost.example.conf +42 -0
- data/configs/apache.conf +40 -0
- data/configs/database.yml +23 -0
- data/configs/empty.log +0 -0
- data/configs/routes.rb +19 -0
- data/dispatches/dispatch.fcgi +24 -0
- data/dispatches/dispatch.rb +10 -0
- data/dispatches/gateway.cgi +97 -0
- data/doc/README_FOR_APP +2 -0
- data/environments/development.rb +14 -0
- data/environments/environment.rb +101 -0
- data/environments/production.rb +8 -0
- data/environments/test.rb +17 -0
- data/fresh_rakefile +223 -0
- data/helpers/application.rb +4 -0
- data/helpers/application_helper.rb +3 -0
- data/helpers/test_helper.rb +26 -0
- data/html/404.html +8 -0
- data/html/500.html +8 -0
- data/html/favicon.ico +0 -0
- data/html/index.html +78 -0
- data/html/javascripts/controls.js +446 -0
- data/html/javascripts/dragdrop.js +537 -0
- data/html/javascripts/effects.js +612 -0
- data/html/javascripts/prototype.js +1038 -0
- data/html/robots.txt +1 -0
- data/lib/binding_of_caller.rb +83 -0
- data/lib/breakpoint.rb +523 -0
- data/lib/breakpoint_client.rb +196 -0
- data/lib/code_statistics.rb +104 -0
- data/lib/console_sandbox.rb +6 -0
- data/lib/dispatcher.rb +59 -0
- data/lib/fcgi_handler.rb +156 -0
- data/lib/productize.rb +116 -0
- data/lib/rails_generator/base.rb +203 -0
- data/lib/rails_generator/commands.rb +409 -0
- data/lib/rails_generator/generators/applications/app/USAGE +16 -0
- data/lib/rails_generator/generators/applications/app/app_generator.rb +126 -0
- data/lib/rails_generator/generators/applications/productized_app/USAGE +16 -0
- data/lib/rails_generator/generators/applications/productized_app/productized_app_generator.rb +133 -0
- data/lib/rails_generator/generators/components/controller/USAGE +30 -0
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +38 -0
- data/lib/rails_generator/generators/components/controller/templates/controller.rb +10 -0
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +18 -0
- data/lib/rails_generator/generators/components/controller/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/controller/templates/view.rhtml +2 -0
- data/lib/rails_generator/generators/components/mailer/USAGE +19 -0
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +32 -0
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +3 -0
- data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +13 -0
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +37 -0
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +3 -0
- data/lib/rails_generator/generators/components/migration/USAGE +14 -0
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +9 -0
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +7 -0
- data/lib/rails_generator/generators/components/model/USAGE +17 -0
- data/lib/rails_generator/generators/components/model/model_generator.rb +18 -0
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +5 -0
- data/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +14 -0
- data/lib/rails_generator/generators/components/scaffold/USAGE +32 -0
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +178 -0
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +54 -0
- data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +3 -0
- data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +1 -0
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +98 -0
- data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +13 -0
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +74 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +9 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +27 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +8 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +8 -0
- data/lib/rails_generator/generators/components/web_service/USAGE +28 -0
- data/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +5 -0
- data/lib/rails_generator/generators/components/web_service/templates/controller.rb +8 -0
- data/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +19 -0
- data/lib/rails_generator/generators/components/web_service/web_service_generator.rb +29 -0
- data/lib/rails_generator/lookup.rb +206 -0
- data/lib/rails_generator/manifest.rb +53 -0
- data/lib/rails_generator/options.rb +134 -0
- data/lib/rails_generator/scripts/destroy.rb +7 -0
- data/lib/rails_generator/scripts/generate.rb +7 -0
- data/lib/rails_generator/scripts/update.rb +12 -0
- data/lib/rails_generator/scripts.rb +83 -0
- data/lib/rails_generator/simple_logger.rb +46 -0
- data/lib/rails_generator/spec.rb +44 -0
- data/lib/rails_generator.rb +43 -0
- data/lib/rubyprof_ext.rb +35 -0
- data/lib/webrick_server.rb +148 -0
- data/sites/fresh_rakefile +176 -0
- metadata +250 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require 'rbconfig'
|
|
2
|
+
|
|
3
|
+
class AppGenerator < Rails::Generator::Base
|
|
4
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
|
5
|
+
Config::CONFIG['ruby_install_name'])
|
|
6
|
+
|
|
7
|
+
default_options :gem => true, :shebang => DEFAULT_SHEBANG
|
|
8
|
+
mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
|
|
9
|
+
|
|
10
|
+
def initialize(runtime_args, runtime_options = {})
|
|
11
|
+
super
|
|
12
|
+
usage if args.empty?
|
|
13
|
+
@destination_root = args.shift
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def manifest
|
|
17
|
+
script_options = { :chmod => 0755, :shebang => options[:shebang] }
|
|
18
|
+
|
|
19
|
+
record do |m|
|
|
20
|
+
# Root directory and all subdirectories.
|
|
21
|
+
m.directory ''
|
|
22
|
+
BASEDIRS.each { |path| m.directory path }
|
|
23
|
+
|
|
24
|
+
# Root
|
|
25
|
+
m.file "fresh_rakefile", "Rakefile"
|
|
26
|
+
m.file "README", "README"
|
|
27
|
+
m.file "CHANGELOG", "CHANGELOG"
|
|
28
|
+
|
|
29
|
+
# Application
|
|
30
|
+
m.template "helpers/application.rb", "app/controllers/application.rb"
|
|
31
|
+
m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
|
|
32
|
+
m.template "helpers/test_helper.rb", "test/test_helper.rb"
|
|
33
|
+
|
|
34
|
+
# database.yml and .htaccess
|
|
35
|
+
m.template "configs/database.yml", "config/database.yml"
|
|
36
|
+
m.template "configs/routes.rb", "config/routes.rb"
|
|
37
|
+
m.template "configs/apache.conf", "public/.htaccess"
|
|
38
|
+
|
|
39
|
+
# Environments
|
|
40
|
+
m.file "environments/environment.rb", "config/environment.rb"
|
|
41
|
+
m.file "environments/production.rb", "config/environments/production.rb"
|
|
42
|
+
m.file "environments/development.rb", "config/environments/development.rb"
|
|
43
|
+
m.file "environments/test.rb", "config/environments/test.rb"
|
|
44
|
+
|
|
45
|
+
# Scripts
|
|
46
|
+
%w(console destroy generate server runner benchmarker profiler process/reaper process/spinner process/spawner ).each do |file|
|
|
47
|
+
m.file "bin/#{file}", "script/#{file}", script_options
|
|
48
|
+
end
|
|
49
|
+
if options[:gem]
|
|
50
|
+
m.file "bin/breakpointer_for_gem", "script/breakpointer", script_options
|
|
51
|
+
else
|
|
52
|
+
m.file "bin/breakpointer", "script/breakpointer", script_options
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Dispatches
|
|
56
|
+
m.file "dispatches/dispatch.rb", "public/dispatch.rb", script_options
|
|
57
|
+
m.file "dispatches/dispatch.rb", "public/dispatch.cgi", script_options
|
|
58
|
+
m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", script_options
|
|
59
|
+
|
|
60
|
+
# HTML files
|
|
61
|
+
%w(404 500 index).each do |file|
|
|
62
|
+
m.template "html/#{file}.html", "public/#{file}.html"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
m.template "html/favicon.ico", "public/favicon.ico"
|
|
66
|
+
m.template "html/robots.txt", "public/robots.txt"
|
|
67
|
+
|
|
68
|
+
# Javascripts
|
|
69
|
+
m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
|
|
70
|
+
m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
|
|
71
|
+
m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
|
|
72
|
+
m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
|
|
73
|
+
|
|
74
|
+
# Docs
|
|
75
|
+
m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
|
|
76
|
+
|
|
77
|
+
# Logs
|
|
78
|
+
%w(server production development test).each { |file|
|
|
79
|
+
m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
protected
|
|
85
|
+
def banner
|
|
86
|
+
"Usage: #{$0} /path/to/your/app [options]"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def add_options!(opt)
|
|
90
|
+
opt.separator ''
|
|
91
|
+
opt.separator 'Options:'
|
|
92
|
+
opt.on("--ruby [#{DEFAULT_SHEBANG}]",
|
|
93
|
+
"Path to the Ruby binary of your choice.") { |options[:shebang]| }
|
|
94
|
+
opt.on("--without-gems",
|
|
95
|
+
"Don't use the Rails gems for your app.",
|
|
96
|
+
"WARNING: see note below.") { |options[:gem]| }
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Installation skeleton. Intermediate directories are automatically
|
|
101
|
+
# created so don't sweat their absence here.
|
|
102
|
+
BASEDIRS = %w(
|
|
103
|
+
app/apis
|
|
104
|
+
app/controllers
|
|
105
|
+
app/helpers
|
|
106
|
+
app/models
|
|
107
|
+
app/views/layouts
|
|
108
|
+
config/environments
|
|
109
|
+
components
|
|
110
|
+
db
|
|
111
|
+
doc
|
|
112
|
+
lib
|
|
113
|
+
log
|
|
114
|
+
public/images
|
|
115
|
+
public/javascripts
|
|
116
|
+
public/stylesheets
|
|
117
|
+
script
|
|
118
|
+
script/process
|
|
119
|
+
test/fixtures
|
|
120
|
+
test/functional
|
|
121
|
+
test/mocks/development
|
|
122
|
+
test/mocks/test
|
|
123
|
+
test/unit
|
|
124
|
+
vendor
|
|
125
|
+
)
|
|
126
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The 'rails_product' command creates a new Productized Rails Application
|
|
3
|
+
with a default directory structure and configuration at the path you
|
|
4
|
+
specify.
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
rails_product ~/Code/Ruby/cart
|
|
8
|
+
|
|
9
|
+
This generates a skeletal Productized Rails installation in
|
|
10
|
+
~/Code/Ruby/cart
|
|
11
|
+
|
|
12
|
+
See the README in the newly created application to get going.
|
|
13
|
+
|
|
14
|
+
On-line Documentation:
|
|
15
|
+
http://inquirylabs.com/productize/ or
|
|
16
|
+
http://wiki.rubyonrails.com/rails/show/HowToProductizeYourApplication
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
require 'rbconfig'
|
|
2
|
+
|
|
3
|
+
class ProductizedAppGenerator < Rails::Generator::Base
|
|
4
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
|
5
|
+
Config::CONFIG['ruby_install_name'])
|
|
6
|
+
|
|
7
|
+
default_options :gem => true, :shebang => DEFAULT_SHEBANG
|
|
8
|
+
mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
|
|
9
|
+
|
|
10
|
+
def initialize(runtime_args, runtime_options = {})
|
|
11
|
+
super
|
|
12
|
+
usage if args.empty?
|
|
13
|
+
@destination_root = args.shift
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def manifest
|
|
17
|
+
script_options = { :chmod => 0755, :shebang => options[:shebang] }
|
|
18
|
+
|
|
19
|
+
record do |m|
|
|
20
|
+
# Root directory and all subdirectories.
|
|
21
|
+
m.directory ''
|
|
22
|
+
BASEDIRS.each { |path| m.directory path }
|
|
23
|
+
|
|
24
|
+
# Root
|
|
25
|
+
m.file "fresh_rakefile", "Rakefile"
|
|
26
|
+
m.file "README", "README"
|
|
27
|
+
m.file "CHANGELOG", "CHANGELOG"
|
|
28
|
+
|
|
29
|
+
# Application
|
|
30
|
+
m.template "helpers/application.rb", "app/controllers/application.rb"
|
|
31
|
+
m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
|
|
32
|
+
m.template "helpers/test_helper.rb", "test/test_helper.rb"
|
|
33
|
+
|
|
34
|
+
# database.yml and .htaccess
|
|
35
|
+
m.file "configs/database.yml", "config/database.yml"
|
|
36
|
+
m.template "configs/routes.rb", "config/routes.rb"
|
|
37
|
+
m.template "configs/apache.conf", "public/.htaccess"
|
|
38
|
+
|
|
39
|
+
# Productized App Files
|
|
40
|
+
m.file "sites/fresh_rakefile", "sites/Rakefile"
|
|
41
|
+
m.file "lib/productize.rb", "lib/productize.rb"
|
|
42
|
+
m.file "configs/apache/vhost.example.conf", "config/apache/vhost.example.conf"
|
|
43
|
+
|
|
44
|
+
# Environments
|
|
45
|
+
m.file "environments/environment.rb", "config/environment.rb"
|
|
46
|
+
m.file "environments/production.rb", "config/environments/production.rb"
|
|
47
|
+
m.file "environments/development.rb", "config/environments/development.rb"
|
|
48
|
+
m.file "environments/test.rb", "config/environments/test.rb"
|
|
49
|
+
|
|
50
|
+
# Scripts (tracker listener)
|
|
51
|
+
%w(console destroy generate server runner benchmarker profiler ).each do |file|
|
|
52
|
+
m.file "bin/#{file}", "script/#{file}", script_options
|
|
53
|
+
end
|
|
54
|
+
if options[:gem]
|
|
55
|
+
m.file "bin/breakpointer_for_gem", "script/breakpointer", script_options
|
|
56
|
+
else
|
|
57
|
+
m.file "bin/breakpointer", "script/breakpointer", script_options
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Dispatches
|
|
61
|
+
m.file "dispatches/dispatch.rb", "public/dispatch.rb", script_options
|
|
62
|
+
m.file "dispatches/dispatch.rb", "public/dispatch.cgi", script_options
|
|
63
|
+
m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", script_options
|
|
64
|
+
# m.file "dispatches/gateway.cgi", "public/gateway.cgi", script_options
|
|
65
|
+
|
|
66
|
+
# HTML files
|
|
67
|
+
%w(404 500 index).each do |file|
|
|
68
|
+
m.template "html/#{file}.html", "public/#{file}.html"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
m.template "html/favicon.ico", "public/favicon.ico"
|
|
72
|
+
m.template "html/robots.txt", "public/robots.txt"
|
|
73
|
+
|
|
74
|
+
# Javascripts
|
|
75
|
+
m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
|
|
76
|
+
m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
|
|
77
|
+
m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
|
|
78
|
+
m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
|
|
79
|
+
|
|
80
|
+
# Docs
|
|
81
|
+
m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
|
|
82
|
+
|
|
83
|
+
# Logs
|
|
84
|
+
%w(server production development test).each { |file|
|
|
85
|
+
m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
|
|
86
|
+
}
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
protected
|
|
91
|
+
def banner
|
|
92
|
+
"Usage: #{$0} /path/to/your/app [options]"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def add_options!(opt)
|
|
96
|
+
opt.separator ''
|
|
97
|
+
opt.separator 'Options:'
|
|
98
|
+
opt.on("--ruby [#{DEFAULT_SHEBANG}]",
|
|
99
|
+
"Path to the Ruby binary of your choice.") { |options[:shebang]| }
|
|
100
|
+
opt.on("--without-gems",
|
|
101
|
+
"Don't use the Rails gems for your app.",
|
|
102
|
+
"WARNING: see note below.") { |options[:gem]| }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Installation skeleton. Intermediate directories are automatically
|
|
107
|
+
# created so don't sweat their absence here.
|
|
108
|
+
BASEDIRS = %w(
|
|
109
|
+
app/apis
|
|
110
|
+
app/controllers
|
|
111
|
+
app/helpers
|
|
112
|
+
app/models
|
|
113
|
+
app/views/layouts
|
|
114
|
+
config/environments
|
|
115
|
+
config/apache
|
|
116
|
+
components
|
|
117
|
+
db
|
|
118
|
+
doc
|
|
119
|
+
lib
|
|
120
|
+
log
|
|
121
|
+
public/images
|
|
122
|
+
public/javascripts
|
|
123
|
+
public/stylesheets
|
|
124
|
+
script
|
|
125
|
+
test/fixtures
|
|
126
|
+
test/functional
|
|
127
|
+
test/mocks/development
|
|
128
|
+
test/mocks/test
|
|
129
|
+
test/unit
|
|
130
|
+
vendor
|
|
131
|
+
sites
|
|
132
|
+
)
|
|
133
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The controller generator creates stubs for a new controller and its views.
|
|
3
|
+
|
|
4
|
+
The generator takes a controller name and a list of views as arguments.
|
|
5
|
+
The controller name may be given in CamelCase or under_score and should
|
|
6
|
+
not be suffixed with 'Controller'. To create a controller within a
|
|
7
|
+
module, specify the controller name as 'module/controller'.
|
|
8
|
+
|
|
9
|
+
The generator creates a controller class in app/controllers with view
|
|
10
|
+
templates in app/views/controller_name, a helper class in app/helpers,
|
|
11
|
+
and a functional test suite in test/functional.
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
./script/generate controller CreditCard open debit credit close
|
|
15
|
+
|
|
16
|
+
Credit card controller with URLs like /credit_card/debit.
|
|
17
|
+
Controller: app/controllers/credit_card_controller.rb
|
|
18
|
+
Views: app/views/credit_card/debit.rhtml [...]
|
|
19
|
+
Helper: app/helpers/credit_card_helper.rb
|
|
20
|
+
Test: test/functional/credit_card_controller_test.rb
|
|
21
|
+
|
|
22
|
+
Modules Example:
|
|
23
|
+
./script/generate controller 'admin/credit_card' suspend late_fee
|
|
24
|
+
|
|
25
|
+
Credit card admin controller with URLs /admin/credit_card/suspend.
|
|
26
|
+
Controller: app/controllers/admin/credit_card_controller.rb
|
|
27
|
+
Views: app/views/admin/credit_card/debit.rhtml [...]
|
|
28
|
+
Helper: app/helpers/admin/credit_card_helper.rb
|
|
29
|
+
Test: test/functional/admin/credit_card_controller_test.rb
|
|
30
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class ControllerGenerator < Rails::Generator::NamedBase
|
|
2
|
+
def manifest
|
|
3
|
+
record do |m|
|
|
4
|
+
# Check for class naming collisions.
|
|
5
|
+
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
|
|
6
|
+
|
|
7
|
+
# Controller, helper, views, and test directories.
|
|
8
|
+
m.directory File.join('app/controllers', class_path)
|
|
9
|
+
m.directory File.join('app/helpers', class_path)
|
|
10
|
+
m.directory File.join('app/views', class_path, file_name)
|
|
11
|
+
m.directory File.join('test/functional', class_path)
|
|
12
|
+
|
|
13
|
+
# Controller class, functional test, and helper class.
|
|
14
|
+
m.template 'controller.rb',
|
|
15
|
+
File.join('app/controllers',
|
|
16
|
+
class_path,
|
|
17
|
+
"#{file_name}_controller.rb")
|
|
18
|
+
|
|
19
|
+
m.template 'functional_test.rb',
|
|
20
|
+
File.join('test/functional',
|
|
21
|
+
class_path,
|
|
22
|
+
"#{file_name}_controller_test.rb")
|
|
23
|
+
|
|
24
|
+
m.template 'helper.rb',
|
|
25
|
+
File.join('app/helpers',
|
|
26
|
+
class_path,
|
|
27
|
+
"#{file_name}_helper.rb")
|
|
28
|
+
|
|
29
|
+
# View template for each action.
|
|
30
|
+
actions.each do |action|
|
|
31
|
+
path = File.join('app/views', class_path, file_name, "#{action}.rhtml")
|
|
32
|
+
m.template 'view.rhtml',
|
|
33
|
+
path,
|
|
34
|
+
:assigns => { :action => action, :path => path }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
|
|
2
|
+
require '<%= file_path %>_controller'
|
|
3
|
+
|
|
4
|
+
# Re-raise errors caught by the controller.
|
|
5
|
+
class <%= class_name %>Controller; def rescue_action(e) raise e end; end
|
|
6
|
+
|
|
7
|
+
class <%= class_name %>ControllerTest < Test::Unit::TestCase
|
|
8
|
+
def setup
|
|
9
|
+
@controller = <%= class_name %>Controller.new
|
|
10
|
+
@request = ActionController::TestRequest.new
|
|
11
|
+
@response = ActionController::TestResponse.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Replace this with your real tests.
|
|
15
|
+
def test_truth
|
|
16
|
+
assert true
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The mailer generator creates stubs for a new mailer and its views.
|
|
3
|
+
|
|
4
|
+
The generator takes a mailer name and a list of views as arguments.
|
|
5
|
+
The mailer name may be given in CamelCase or under_score and should
|
|
6
|
+
not be suffixed with 'Mailer'.
|
|
7
|
+
|
|
8
|
+
The generator creates a mailer class in app/models with view templates
|
|
9
|
+
in app/views/mailer_name, and a test suite with fixtures in test/unit.
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
./script/generate mailer Notifications signup forgot_password invoice
|
|
13
|
+
|
|
14
|
+
This will create a NotificationsMailer:
|
|
15
|
+
Mailer: app/models/notifications.rb
|
|
16
|
+
Views: app/views/notifications/signup.rhtml [...]
|
|
17
|
+
Test: test/unit/credit_card_controller_test.rb
|
|
18
|
+
Fixtures: test/fixtures/notifications/signup [...]
|
|
19
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class MailerGenerator < Rails::Generator::NamedBase
|
|
2
|
+
def manifest
|
|
3
|
+
record do |m|
|
|
4
|
+
# Check for class naming collisions.
|
|
5
|
+
m.class_collisions class_path, class_name, "#{class_name}Test"
|
|
6
|
+
|
|
7
|
+
# Mailer, view, test, and fixture directories.
|
|
8
|
+
m.directory File.join('app/models', class_path)
|
|
9
|
+
m.directory File.join('app/views', class_path, file_name)
|
|
10
|
+
m.directory File.join('test/unit', class_path)
|
|
11
|
+
m.directory File.join('test/fixtures', class_path, file_name)
|
|
12
|
+
|
|
13
|
+
# Mailer class and unit test.
|
|
14
|
+
m.template "mailer.rb", File.join('app/models',
|
|
15
|
+
class_path,
|
|
16
|
+
"#{file_name}.rb")
|
|
17
|
+
m.template "unit_test.rb", File.join('test/unit',
|
|
18
|
+
class_path,
|
|
19
|
+
"#{file_name}_test.rb")
|
|
20
|
+
|
|
21
|
+
# View template and fixture for each action.
|
|
22
|
+
actions.each do |action|
|
|
23
|
+
m.template "view.rhtml",
|
|
24
|
+
File.join('app/views', class_path, file_name, "#{action}.rhtml"),
|
|
25
|
+
:assigns => { :action => action }
|
|
26
|
+
m.template "fixture.rhtml",
|
|
27
|
+
File.join('test/fixtures', class_path, file_name, action),
|
|
28
|
+
:assigns => { :action => action }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class <%= class_name %> < ActionMailer::Base
|
|
2
|
+
<% for action in actions -%>
|
|
3
|
+
|
|
4
|
+
def <%= action %>(sent_at = Time.now)
|
|
5
|
+
@subject = '<%= class_name %>#<%= action %>'
|
|
6
|
+
@body = {}
|
|
7
|
+
@recipients = ''
|
|
8
|
+
@from = ''
|
|
9
|
+
@sent_on = sent_at
|
|
10
|
+
@headers = {}
|
|
11
|
+
end
|
|
12
|
+
<% end -%>
|
|
13
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require '<%= file_name %>'
|
|
3
|
+
|
|
4
|
+
class <%= class_name %>Test < Test::Unit::TestCase
|
|
5
|
+
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
|
|
6
|
+
CHARSET = "utf-8"
|
|
7
|
+
|
|
8
|
+
include ActionMailer::Quoting
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
ActionMailer::Base.delivery_method = :test
|
|
12
|
+
ActionMailer::Base.perform_deliveries = true
|
|
13
|
+
ActionMailer::Base.deliveries = []
|
|
14
|
+
|
|
15
|
+
@expected = TMail::Mail.new
|
|
16
|
+
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
<% for action in actions -%>
|
|
20
|
+
def test_<%= action %>
|
|
21
|
+
@expected.subject = encode '<%= class_name %>#<%= action %>'
|
|
22
|
+
@expected.body = read_fixture('<%= action %>')
|
|
23
|
+
@expected.date = Time.now
|
|
24
|
+
|
|
25
|
+
assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
<% end -%>
|
|
29
|
+
private
|
|
30
|
+
def read_fixture(action)
|
|
31
|
+
IO.readlines("#{FIXTURES_PATH}/<%= file_name %>/#{action}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def encode(subject)
|
|
35
|
+
quoted_printable(subject, CHARSET)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The migration generator creates a stub for a new database migration.
|
|
3
|
+
|
|
4
|
+
The generator takes a migration name as its argument. The migration name may be
|
|
5
|
+
given in CamelCase or under_score.
|
|
6
|
+
|
|
7
|
+
The generator creates a migration class in db/migrate prefixed by its number
|
|
8
|
+
in the queue.
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
./script/generate migration AddSslFlag
|
|
12
|
+
|
|
13
|
+
With 4 existing migrations, this will create an AddSslFlag migration in the
|
|
14
|
+
file db/migrate/5_add_ssl_flag.rb
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
class MigrationGenerator < Rails::Generator::NamedBase
|
|
2
|
+
def manifest
|
|
3
|
+
record do |m|
|
|
4
|
+
m.directory File.join('db/migrate')
|
|
5
|
+
next_migration_number = Dir.glob("db/migrate/[0-9]*.*").size + 1
|
|
6
|
+
m.template 'migration.rb', File.join('db/migrate', "#{next_migration_number}_#{file_name}.rb")
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The model generator creates stubs for a new model.
|
|
3
|
+
|
|
4
|
+
The generator takes a model name as its argument. The model name may be
|
|
5
|
+
given in CamelCase or under_score and should not be suffixed with 'Model'.
|
|
6
|
+
|
|
7
|
+
The generator creates a model class in app/models, a test suite in
|
|
8
|
+
test/unit, and test fixtures in test/fixtures/singular_name.yml.
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
./script/generate model Account
|
|
12
|
+
|
|
13
|
+
This will create an Account model:
|
|
14
|
+
Model: app/models/account.rb
|
|
15
|
+
Test: test/unit/account_test.rb
|
|
16
|
+
Fixtures: test/fixtures/accounts.yml
|
|
17
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class ModelGenerator < Rails::Generator::NamedBase
|
|
2
|
+
def manifest
|
|
3
|
+
record do |m|
|
|
4
|
+
# Check for class naming collisions.
|
|
5
|
+
m.class_collisions class_path, class_name, "#{class_name}Test"
|
|
6
|
+
|
|
7
|
+
# Model, test, and fixture directories.
|
|
8
|
+
m.directory File.join('app/models', class_path)
|
|
9
|
+
m.directory File.join('test/unit', class_path)
|
|
10
|
+
m.directory File.join('test/fixtures', class_path)
|
|
11
|
+
|
|
12
|
+
# Model class, unit test, and fixtures.
|
|
13
|
+
m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
|
14
|
+
m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
|
|
15
|
+
m.template 'fixtures.yml', File.join('test/fixtures', class_path, "#{ActiveRecord::Base.pluralize_table_names ? plural_name : singular_name}.yml")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class <%= class_name %>Test < Test::Unit::TestCase
|
|
4
|
+
fixtures :<%= table_name %>
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@<%= singular_name %> = <%= class_name %>.find(1)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Replace this with your real tests.
|
|
11
|
+
def test_truth
|
|
12
|
+
assert_kind_of <%= class_name %>, @<%= singular_name %>
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The scaffold generator creates a controller to interact with a model.
|
|
3
|
+
If the model does not exist, it creates the model as well. The generated
|
|
4
|
+
code is equivalent to the "scaffold :model" declaration, making it easy
|
|
5
|
+
to migrate when you wish to customize your controller and views.
|
|
6
|
+
|
|
7
|
+
The generator takes a model name, an optional controller name, and a
|
|
8
|
+
list of views as arguments. Scaffolded actions and views are created
|
|
9
|
+
automatically. Any views left over generate empty stubs.
|
|
10
|
+
|
|
11
|
+
The scaffolded actions and views are:
|
|
12
|
+
index, list, show, new, create, edit, update, destroy
|
|
13
|
+
|
|
14
|
+
If a controller name is not given, the plural form of the model name
|
|
15
|
+
will be used. The model and controller names may be given in CamelCase
|
|
16
|
+
or under_score and should not be suffixed with 'Model' or 'Controller'.
|
|
17
|
+
Both model and controller names may be prefixed with a module like a
|
|
18
|
+
file path; see the Modules Example for usage.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
./script/generate scaffold Account Bank debit credit
|
|
22
|
+
|
|
23
|
+
This will generate an Account model and BankController with a full test
|
|
24
|
+
suite and a basic user interface. Now create the accounts table in your
|
|
25
|
+
database and browse to http://localhost/bank/ -- voila, you're on Rails!
|
|
26
|
+
|
|
27
|
+
Modules Example:
|
|
28
|
+
./script/generate scaffold CreditCard 'admin/credit_card' suspend late_fee
|
|
29
|
+
|
|
30
|
+
This will generate a CreditCard model and CreditCardController controller
|
|
31
|
+
in the admin module.
|
|
32
|
+
|