rails 2.3.18 → 3.2.22.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- metadata +114 -330
- data/CHANGELOG +0 -2193
- data/MIT-LICENSE +0 -20
- data/README +0 -243
- data/Rakefile +0 -365
- data/bin/about +0 -4
- data/bin/console +0 -3
- data/bin/dbconsole +0 -3
- data/bin/destroy +0 -3
- data/bin/generate +0 -3
- data/bin/performance/benchmarker +0 -3
- data/bin/performance/profiler +0 -3
- data/bin/plugin +0 -3
- data/bin/rails +0 -21
- data/bin/runner +0 -3
- data/bin/server +0 -3
- data/builtin/rails_info/rails/info.rb +0 -131
- data/builtin/rails_info/rails/info_controller.rb +0 -9
- data/builtin/rails_info/rails/info_helper.rb +0 -2
- data/builtin/rails_info/rails_info_controller.rb +0 -2
- data/configs/databases/frontbase.yml +0 -28
- data/configs/databases/ibm_db.yml +0 -62
- data/configs/databases/mysql.yml +0 -60
- data/configs/databases/oracle.yml +0 -39
- data/configs/databases/postgresql.yml +0 -51
- data/configs/databases/sqlite2.yml +0 -19
- data/configs/databases/sqlite3.yml +0 -22
- data/configs/empty.log +0 -0
- data/configs/initializers/backtrace_silencers.rb +0 -7
- data/configs/initializers/cookie_verification_secret.rb +0 -7
- data/configs/initializers/inflections.rb +0 -10
- data/configs/initializers/mime_types.rb +0 -5
- data/configs/initializers/new_rails_defaults.rb +0 -21
- data/configs/initializers/session_store.rb +0 -15
- data/configs/locales/en.yml +0 -5
- data/configs/routes.rb +0 -43
- data/configs/seeds.rb +0 -7
- data/dispatches/config.ru +0 -7
- data/dispatches/dispatch.fcgi +0 -24
- data/dispatches/dispatch.rb +0 -10
- data/dispatches/gateway.cgi +0 -97
- data/doc/README_FOR_APP +0 -2
- data/environments/boot.rb +0 -114
- data/environments/development.rb +0 -17
- data/environments/environment.rb +0 -41
- data/environments/production.rb +0 -28
- data/environments/test.rb +0 -28
- data/fresh_rakefile +0 -10
- data/helpers/application_controller.rb +0 -10
- data/helpers/application_helper.rb +0 -3
- data/helpers/performance_test.rb +0 -9
- data/helpers/test_helper.rb +0 -38
- data/html/404.html +0 -30
- data/html/422.html +0 -30
- data/html/500.html +0 -30
- data/html/favicon.ico +0 -0
- data/html/images/rails.png +0 -0
- data/html/index.html +0 -275
- data/html/javascripts/application.js +0 -2
- data/html/javascripts/controls.js +0 -963
- data/html/javascripts/dragdrop.js +0 -973
- data/html/javascripts/effects.js +0 -1128
- data/html/javascripts/prototype.js +0 -4320
- data/html/robots.txt +0 -5
- data/lib/code_statistics.rb +0 -107
- data/lib/commands/about.rb +0 -3
- data/lib/commands/console.rb +0 -45
- data/lib/commands/dbconsole.rb +0 -87
- data/lib/commands/destroy.rb +0 -6
- data/lib/commands/generate.rb +0 -6
- data/lib/commands/ncgi/listener +0 -86
- data/lib/commands/ncgi/tracker +0 -69
- data/lib/commands/performance/benchmarker.rb +0 -24
- data/lib/commands/performance/profiler.rb +0 -50
- data/lib/commands/plugin.rb +0 -968
- data/lib/commands/runner.rb +0 -54
- data/lib/commands/server.rb +0 -114
- data/lib/commands/update.rb +0 -4
- data/lib/commands.rb +0 -17
- data/lib/console_app.rb +0 -30
- data/lib/console_sandbox.rb +0 -6
- data/lib/console_with_helpers.rb +0 -5
- data/lib/dispatcher.rb +0 -24
- data/lib/fcgi_handler.rb +0 -239
- data/lib/initializer.rb +0 -1152
- data/lib/performance_test_help.rb +0 -5
- data/lib/rails/backtrace_cleaner.rb +0 -54
- data/lib/rails/gem_builder.rb +0 -21
- data/lib/rails/gem_dependency.rb +0 -317
- data/lib/rails/plugin/loader.rb +0 -198
- data/lib/rails/plugin/locator.rb +0 -100
- data/lib/rails/plugin.rb +0 -179
- data/lib/rails/rack/debugger.rb +0 -23
- data/lib/rails/rack/log_tailer.rb +0 -35
- data/lib/rails/rack/metal.rb +0 -51
- data/lib/rails/rack/static.rb +0 -46
- data/lib/rails/rack.rb +0 -8
- data/lib/rails/vendor_gem_source_index.rb +0 -140
- data/lib/rails/version.rb +0 -9
- data/lib/rails_generator/base.rb +0 -266
- data/lib/rails_generator/commands.rb +0 -621
- data/lib/rails_generator/generated_attribute.rb +0 -47
- data/lib/rails_generator/generators/applications/app/USAGE +0 -9
- data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -266
- data/lib/rails_generator/generators/applications/app/scm/git.rb +0 -18
- data/lib/rails_generator/generators/applications/app/scm/scm.rb +0 -8
- data/lib/rails_generator/generators/applications/app/scm/svn.rb +0 -7
- data/lib/rails_generator/generators/applications/app/template_runner.rb +0 -401
- data/lib/rails_generator/generators/components/controller/USAGE +0 -30
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -43
- data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -7
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/controller/templates/view.html.erb +0 -2
- data/lib/rails_generator/generators/components/helper/USAGE +0 -24
- data/lib/rails_generator/generators/components/helper/helper_generator.rb +0 -25
- data/lib/rails_generator/generators/components/helper/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/integration_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +0 -10
- data/lib/rails_generator/generators/components/mailer/USAGE +0 -16
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -30
- data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
- data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -15
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -20
- data/lib/rails_generator/generators/components/mailer/templates/view.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
- data/lib/rails_generator/generators/components/metal/USAGE +0 -8
- data/lib/rails_generator/generators/components/metal/metal_generator.rb +0 -8
- data/lib/rails_generator/generators/components/metal/templates/metal.rb +0 -12
- data/lib/rails_generator/generators/components/migration/USAGE +0 -29
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -20
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -11
- data/lib/rails_generator/generators/components/model/USAGE +0 -27
- data/lib/rails_generator/generators/components/model/model_generator.rb +0 -52
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -23
- data/lib/rails_generator/generators/components/model/templates/migration.rb +0 -16
- data/lib/rails_generator/generators/components/model/templates/model.rb +0 -5
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/observer/USAGE +0 -13
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +0 -16
- data/lib/rails_generator/generators/components/observer/templates/observer.rb +0 -2
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/performance_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +0 -9
- data/lib/rails_generator/generators/components/plugin/USAGE +0 -25
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -39
- data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +0 -20
- data/lib/rails_generator/generators/components/plugin/templates/README +0 -13
- data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -23
- data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/install.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
- data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +0 -4
- data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/USAGE +0 -23
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +0 -76
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/scaffold/USAGE +0 -29
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -103
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -83
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -45
- data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -54
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +0 -18
- data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +0 -24
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +0 -10
- data/lib/rails_generator/generators/components/session_migration/USAGE +0 -10
- data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -18
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -16
- data/lib/rails_generator/lookup.rb +0 -249
- data/lib/rails_generator/manifest.rb +0 -53
- data/lib/rails_generator/options.rb +0 -150
- data/lib/rails_generator/scripts/destroy.rb +0 -29
- data/lib/rails_generator/scripts/generate.rb +0 -7
- data/lib/rails_generator/scripts/update.rb +0 -12
- data/lib/rails_generator/scripts.rb +0 -89
- data/lib/rails_generator/secret_key_generator.rb +0 -24
- data/lib/rails_generator/simple_logger.rb +0 -46
- data/lib/rails_generator/spec.rb +0 -44
- data/lib/rails_generator.rb +0 -46
- data/lib/railties_path.rb +0 -1
- data/lib/ruby_version_check.rb +0 -17
- data/lib/rubyprof_ext.rb +0 -35
- data/lib/source_annotation_extractor.rb +0 -102
- data/lib/tasks/annotations.rake +0 -20
- data/lib/tasks/databases.rake +0 -436
- data/lib/tasks/documentation.rake +0 -93
- data/lib/tasks/framework.rake +0 -146
- data/lib/tasks/gems.rake +0 -78
- data/lib/tasks/log.rake +0 -9
- data/lib/tasks/middleware.rake +0 -7
- data/lib/tasks/misc.rake +0 -63
- data/lib/tasks/rails.rb +0 -14
- data/lib/tasks/routes.rake +0 -18
- data/lib/tasks/statistics.rake +0 -17
- data/lib/tasks/testing.rake +0 -139
- data/lib/tasks/tmp.rake +0 -37
- data/lib/test_help.rb +0 -38
- data/lib/webrick_server.rb +0 -156
- data/railties.gemspec +0 -22
@@ -1,266 +0,0 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require File.dirname(__FILE__) + '/template_runner'
|
3
|
-
require 'digest/md5'
|
4
|
-
require 'active_support/secure_random'
|
5
|
-
|
6
|
-
class AppGenerator < Rails::Generator::Base
|
7
|
-
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
8
|
-
|
9
|
-
DATABASES = %w( mysql oracle postgresql sqlite2 sqlite3 frontbase ibm_db )
|
10
|
-
DEFAULT_DATABASE = 'sqlite3'
|
11
|
-
|
12
|
-
mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
|
13
|
-
default_options :db => (ENV["RAILS_DEFAULT_DATABASE"] || DEFAULT_DATABASE),
|
14
|
-
:shebang => DEFAULT_SHEBANG, :with_dispatchers => false, :freeze => false
|
15
|
-
|
16
|
-
|
17
|
-
def initialize(runtime_args, runtime_options = {})
|
18
|
-
super
|
19
|
-
|
20
|
-
usage if args.empty?
|
21
|
-
usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db]))
|
22
|
-
|
23
|
-
@destination_root = args.shift
|
24
|
-
@app_name = File.basename(File.expand_path(@destination_root))
|
25
|
-
end
|
26
|
-
|
27
|
-
def manifest
|
28
|
-
record do |m|
|
29
|
-
create_directories(m)
|
30
|
-
create_root_files(m)
|
31
|
-
create_app_files(m)
|
32
|
-
create_config_files(m)
|
33
|
-
create_script_files(m)
|
34
|
-
create_test_files(m)
|
35
|
-
create_public_files(m)
|
36
|
-
create_documentation_file(m)
|
37
|
-
create_log_files(m)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def after_generate
|
42
|
-
if options[:template]
|
43
|
-
Rails::TemplateRunner.new(options[:template], @destination_root)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
protected
|
48
|
-
def banner
|
49
|
-
"Usage: #{$0} /path/to/your/app [options]"
|
50
|
-
end
|
51
|
-
|
52
|
-
def add_options!(opt)
|
53
|
-
opt.separator ''
|
54
|
-
opt.separator 'Options:'
|
55
|
-
opt.on("-r", "--ruby=path", String,
|
56
|
-
"Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
|
57
|
-
"Default: #{DEFAULT_SHEBANG}") { |v| options[:shebang] = v }
|
58
|
-
|
59
|
-
opt.on("-d", "--database=name", String,
|
60
|
-
"Preconfigure for selected database (options: #{DATABASES.join('/')}).",
|
61
|
-
"Default: #{DEFAULT_DATABASE}") { |v| options[:db] = v }
|
62
|
-
|
63
|
-
opt.on("-D", "--with-dispatchers",
|
64
|
-
"Add CGI/FastCGI/mod_ruby dispatches code to generated application skeleton",
|
65
|
-
"Default: false") { |v| options[:with_dispatchers] = v }
|
66
|
-
|
67
|
-
opt.on("-f", "--freeze",
|
68
|
-
"Freeze Rails in vendor/rails from the gems generating the skeleton",
|
69
|
-
"Default: false") { |v| options[:freeze] = v }
|
70
|
-
|
71
|
-
opt.on("-m", "--template=path", String,
|
72
|
-
"Use an application template that lives at path (can be a filesystem path or URL).",
|
73
|
-
"Default: (none)") { |v| options[:template] = v }
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
private
|
79
|
-
def create_directories(m)
|
80
|
-
m.directory ''
|
81
|
-
|
82
|
-
# Intermediate directories are automatically created so don't sweat their absence here.
|
83
|
-
%w(
|
84
|
-
app/controllers
|
85
|
-
app/helpers
|
86
|
-
app/models
|
87
|
-
app/views/layouts
|
88
|
-
config/environments
|
89
|
-
config/initializers
|
90
|
-
config/locales
|
91
|
-
db
|
92
|
-
doc
|
93
|
-
lib
|
94
|
-
lib/tasks
|
95
|
-
log
|
96
|
-
public/images
|
97
|
-
public/javascripts
|
98
|
-
public/stylesheets
|
99
|
-
script/performance
|
100
|
-
test/fixtures
|
101
|
-
test/functional
|
102
|
-
test/integration
|
103
|
-
test/performance
|
104
|
-
test/unit
|
105
|
-
vendor
|
106
|
-
vendor/plugins
|
107
|
-
tmp/sessions
|
108
|
-
tmp/sockets
|
109
|
-
tmp/cache
|
110
|
-
tmp/pids
|
111
|
-
).each { |path| m.directory(path) }
|
112
|
-
end
|
113
|
-
|
114
|
-
def create_root_files(m)
|
115
|
-
m.file "fresh_rakefile", "Rakefile"
|
116
|
-
m.file "README", "README"
|
117
|
-
end
|
118
|
-
|
119
|
-
def create_app_files(m)
|
120
|
-
m.file "helpers/application_controller.rb", "app/controllers/application_controller.rb"
|
121
|
-
m.file "helpers/application_helper.rb", "app/helpers/application_helper.rb"
|
122
|
-
end
|
123
|
-
|
124
|
-
def create_config_files(m)
|
125
|
-
create_database_configuration_file(m)
|
126
|
-
create_routes_file(m)
|
127
|
-
create_locale_file(m)
|
128
|
-
create_seeds_file(m)
|
129
|
-
create_initializer_files(m)
|
130
|
-
create_environment_files(m)
|
131
|
-
end
|
132
|
-
|
133
|
-
def create_documentation_file(m)
|
134
|
-
m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
|
135
|
-
end
|
136
|
-
|
137
|
-
def create_log_files(m)
|
138
|
-
%w( server production development test ).each do |file|
|
139
|
-
m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def create_public_files(m)
|
144
|
-
create_dispatch_files(m)
|
145
|
-
create_error_files(m)
|
146
|
-
create_welcome_file(m)
|
147
|
-
create_browser_convention_files(m)
|
148
|
-
create_rails_image(m)
|
149
|
-
create_javascript_files(m)
|
150
|
-
end
|
151
|
-
|
152
|
-
def create_script_files(m)
|
153
|
-
%w(
|
154
|
-
about console dbconsole destroy generate runner server plugin
|
155
|
-
performance/benchmarker performance/profiler
|
156
|
-
).each do |file|
|
157
|
-
m.file "bin/#{file}", "script/#{file}", {
|
158
|
-
:chmod => 0755,
|
159
|
-
:shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
|
160
|
-
}
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def create_test_files(m)
|
165
|
-
m.file "helpers/test_helper.rb", "test/test_helper.rb"
|
166
|
-
m.file "helpers/performance_test.rb", "test/performance/browsing_test.rb"
|
167
|
-
end
|
168
|
-
|
169
|
-
|
170
|
-
def create_database_configuration_file(m)
|
171
|
-
m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
|
172
|
-
:app_name => @app_name,
|
173
|
-
:socket => options[:db] == "mysql" ? mysql_socket_location : nil }
|
174
|
-
end
|
175
|
-
|
176
|
-
def create_routes_file(m)
|
177
|
-
m.file "configs/routes.rb", "config/routes.rb"
|
178
|
-
end
|
179
|
-
|
180
|
-
def create_seeds_file(m)
|
181
|
-
m.file "configs/seeds.rb", "db/seeds.rb"
|
182
|
-
end
|
183
|
-
|
184
|
-
def create_initializer_files(m)
|
185
|
-
%w(
|
186
|
-
backtrace_silencers
|
187
|
-
inflections
|
188
|
-
mime_types
|
189
|
-
new_rails_defaults
|
190
|
-
).each do |initializer|
|
191
|
-
m.file "configs/initializers/#{initializer}.rb", "config/initializers/#{initializer}.rb"
|
192
|
-
end
|
193
|
-
|
194
|
-
m.template "configs/initializers/session_store.rb", "config/initializers/session_store.rb",
|
195
|
-
:assigns => { :app_name => @app_name, :app_secret => ActiveSupport::SecureRandom.hex(64) }
|
196
|
-
|
197
|
-
m.template "configs/initializers/cookie_verification_secret.rb", "config/initializers/cookie_verification_secret.rb",
|
198
|
-
:assigns => { :app_secret => ActiveSupport::SecureRandom.hex(64) }
|
199
|
-
end
|
200
|
-
|
201
|
-
def create_locale_file(m)
|
202
|
-
m.file "configs/locales/en.yml", "config/locales/en.yml"
|
203
|
-
end
|
204
|
-
|
205
|
-
def create_environment_files(m)
|
206
|
-
m.template "environments/environment.rb", "config/environment.rb",
|
207
|
-
:assigns => { :freeze => options[:freeze] }
|
208
|
-
|
209
|
-
m.file "environments/boot.rb", "config/boot.rb"
|
210
|
-
m.file "environments/production.rb", "config/environments/production.rb"
|
211
|
-
m.file "environments/development.rb", "config/environments/development.rb"
|
212
|
-
m.file "environments/test.rb", "config/environments/test.rb"
|
213
|
-
end
|
214
|
-
|
215
|
-
|
216
|
-
def create_dispatch_files(m)
|
217
|
-
if options[:with_dispatchers]
|
218
|
-
dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
|
219
|
-
|
220
|
-
m.file "dispatches/config.ru", "config.ru"
|
221
|
-
m.file "dispatches/dispatch.rb", "public/dispatch.rb", dispatcher_options
|
222
|
-
m.file "dispatches/dispatch.rb", "public/dispatch.cgi", dispatcher_options
|
223
|
-
m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def create_error_files(m)
|
228
|
-
%w( 404 422 500 ).each do |file|
|
229
|
-
m.file "html/#{file}.html", "public/#{file}.html"
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
def create_welcome_file(m)
|
234
|
-
m.file 'html/index.html', 'public/index.html'
|
235
|
-
end
|
236
|
-
|
237
|
-
def create_browser_convention_files(m)
|
238
|
-
m.file "html/favicon.ico", "public/favicon.ico"
|
239
|
-
m.file "html/robots.txt", "public/robots.txt"
|
240
|
-
end
|
241
|
-
|
242
|
-
def create_rails_image(m)
|
243
|
-
m.file "html/images/rails.png", "public/images/rails.png"
|
244
|
-
end
|
245
|
-
|
246
|
-
def create_javascript_files(m)
|
247
|
-
%w( prototype effects dragdrop controls application ).each do |javascript|
|
248
|
-
m.file "html/javascripts/#{javascript}.js", "public/javascripts/#{javascript}.js"
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
|
253
|
-
def mysql_socket_location
|
254
|
-
[
|
255
|
-
"/tmp/mysql.sock", # default
|
256
|
-
"/var/run/mysqld/mysqld.sock", # debian/gentoo
|
257
|
-
"/var/tmp/mysql.sock", # freebsd
|
258
|
-
"/var/lib/mysql/mysql.sock", # fedora
|
259
|
-
"/opt/local/lib/mysql/mysql.sock", # fedora
|
260
|
-
"/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
|
261
|
-
"/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
|
262
|
-
"/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
|
263
|
-
"/opt/lampp/var/mysql/mysql.sock" # xampp for linux
|
264
|
-
].find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
|
265
|
-
end
|
266
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
STDOUT.sync = true
|
2
|
-
|
3
|
-
module Rails
|
4
|
-
class Git < Scm
|
5
|
-
def self.clone(repos, branch=nil)
|
6
|
-
system "git clone #{repos}"
|
7
|
-
|
8
|
-
if branch
|
9
|
-
system "cd #{repos.split('/').last}/"
|
10
|
-
system "git checkout #{branch}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.run(command)
|
15
|
-
system "git #{command}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,401 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/scm/scm'
|
2
|
-
require File.dirname(__FILE__) + '/scm/git'
|
3
|
-
require File.dirname(__FILE__) + '/scm/svn'
|
4
|
-
|
5
|
-
require 'open-uri'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
module Rails
|
9
|
-
class TemplateRunner
|
10
|
-
attr_reader :root
|
11
|
-
attr_writer :logger
|
12
|
-
|
13
|
-
def initialize(template, root = '') # :nodoc:
|
14
|
-
@root = File.expand_path(File.directory?(root) ? root : File.join(Dir.pwd, root))
|
15
|
-
|
16
|
-
log 'applying', "template: #{template}"
|
17
|
-
|
18
|
-
load_template(template)
|
19
|
-
|
20
|
-
log 'applied', "#{template}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def load_template(template)
|
24
|
-
begin
|
25
|
-
code = open(template).read
|
26
|
-
in_root { self.instance_eval(code) }
|
27
|
-
rescue LoadError, Errno::ENOENT => e
|
28
|
-
raise "The template [#{template}] could not be loaded. Error: #{e}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Create a new file in the Rails project folder. Specify the
|
33
|
-
# relative path from RAILS_ROOT. Data is the return value of a block
|
34
|
-
# or a data string.
|
35
|
-
#
|
36
|
-
# ==== Examples
|
37
|
-
#
|
38
|
-
# file("lib/fun_party.rb") do
|
39
|
-
# hostname = ask("What is the virtual hostname I should use?")
|
40
|
-
# "vhost.name = #{hostname}"
|
41
|
-
# end
|
42
|
-
#
|
43
|
-
# file("config/apach.conf", "your apache config")
|
44
|
-
#
|
45
|
-
def file(filename, data = nil, log_action = true, &block)
|
46
|
-
log 'file', filename if log_action
|
47
|
-
dir, file = [File.dirname(filename), File.basename(filename)]
|
48
|
-
|
49
|
-
inside(dir) do
|
50
|
-
File.open(file, "w") do |f|
|
51
|
-
if block_given?
|
52
|
-
f.write(block.call)
|
53
|
-
else
|
54
|
-
f.write(data)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Install a plugin. You must provide either a Subversion url or Git url.
|
61
|
-
# For a Git-hosted plugin, you can specify if it should be added as a submodule instead of cloned.
|
62
|
-
#
|
63
|
-
# ==== Examples
|
64
|
-
#
|
65
|
-
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
|
66
|
-
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true
|
67
|
-
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
|
68
|
-
#
|
69
|
-
def plugin(name, options)
|
70
|
-
log 'plugin', name
|
71
|
-
|
72
|
-
if options[:git] && options[:submodule]
|
73
|
-
in_root do
|
74
|
-
Git.run("submodule add #{options[:git]} vendor/plugins/#{name}")
|
75
|
-
end
|
76
|
-
elsif options[:git] || options[:svn]
|
77
|
-
in_root do
|
78
|
-
run_ruby_script("script/plugin install #{options[:svn] || options[:git]}", false)
|
79
|
-
end
|
80
|
-
else
|
81
|
-
log "! no git or svn provided for #{name}. skipping..."
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Adds an entry into config/environment.rb for the supplied gem :
|
86
|
-
def gem(name, options = {})
|
87
|
-
log 'gem', name
|
88
|
-
env = options.delete(:env)
|
89
|
-
|
90
|
-
gems_code = "config.gem '#{name}'"
|
91
|
-
|
92
|
-
if options.any?
|
93
|
-
opts = options.inject([]) {|result, h| result << [":#{h[0]} => #{h[1].inspect.gsub('"',"'")}"] }.sort.join(", ")
|
94
|
-
gems_code << ", #{opts}"
|
95
|
-
end
|
96
|
-
|
97
|
-
environment gems_code, :env => env
|
98
|
-
end
|
99
|
-
|
100
|
-
# Adds a line inside the Initializer block for config/environment.rb. Used by #gem
|
101
|
-
# If options :env is specified, the line is appended to the corresponding
|
102
|
-
# file in config/environments/#{env}.rb
|
103
|
-
def environment(data = nil, options = {}, &block)
|
104
|
-
sentinel = 'Rails::Initializer.run do |config|'
|
105
|
-
|
106
|
-
data = block.call if !data && block_given?
|
107
|
-
|
108
|
-
in_root do
|
109
|
-
if options[:env].nil?
|
110
|
-
gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
111
|
-
"#{match}\n " << data
|
112
|
-
end
|
113
|
-
else
|
114
|
-
Array.wrap(options[:env]).each do|env|
|
115
|
-
append_file "config/environments/#{env}.rb", "\n#{data}"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Run a command in git.
|
122
|
-
#
|
123
|
-
# ==== Examples
|
124
|
-
#
|
125
|
-
# git :init
|
126
|
-
# git :add => "this.file that.rb"
|
127
|
-
# git :add => "onefile.rb", :rm => "badfile.cxx"
|
128
|
-
#
|
129
|
-
def git(command = {})
|
130
|
-
in_root do
|
131
|
-
if command.is_a?(Symbol)
|
132
|
-
log 'running', "git #{command}"
|
133
|
-
Git.run(command.to_s)
|
134
|
-
else
|
135
|
-
command.each do |command, options|
|
136
|
-
log 'running', "git #{command} #{options}"
|
137
|
-
Git.run("#{command} #{options}")
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
# Create a new file in the vendor/ directory. Code can be specified
|
144
|
-
# in a block or a data string can be given.
|
145
|
-
#
|
146
|
-
# ==== Examples
|
147
|
-
#
|
148
|
-
# vendor("sekrit.rb") do
|
149
|
-
# sekrit_salt = "#{Time.now}--#{3.years.ago}--#{rand}--"
|
150
|
-
# "salt = '#{sekrit_salt}'"
|
151
|
-
# end
|
152
|
-
#
|
153
|
-
# vendor("foreign.rb", "# Foreign code is fun")
|
154
|
-
#
|
155
|
-
def vendor(filename, data = nil, &block)
|
156
|
-
log 'vendoring', filename
|
157
|
-
file("vendor/#{filename}", data, false, &block)
|
158
|
-
end
|
159
|
-
|
160
|
-
# Create a new file in the lib/ directory. Code can be specified
|
161
|
-
# in a block or a data string can be given.
|
162
|
-
#
|
163
|
-
# ==== Examples
|
164
|
-
#
|
165
|
-
# lib("crypto.rb") do
|
166
|
-
# "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'"
|
167
|
-
# end
|
168
|
-
#
|
169
|
-
# lib("foreign.rb", "# Foreign code is fun")
|
170
|
-
#
|
171
|
-
def lib(filename, data = nil, &block)
|
172
|
-
log 'lib', filename
|
173
|
-
file("lib/#{filename}", data, false, &block)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Create a new Rakefile with the provided code (either in a block or a string).
|
177
|
-
#
|
178
|
-
# ==== Examples
|
179
|
-
#
|
180
|
-
# rakefile("bootstrap.rake") do
|
181
|
-
# project = ask("What is the UNIX name of your project?")
|
182
|
-
#
|
183
|
-
# <<-TASK
|
184
|
-
# namespace :#{project} do
|
185
|
-
# task :bootstrap do
|
186
|
-
# puts "i like boots!"
|
187
|
-
# end
|
188
|
-
# end
|
189
|
-
# TASK
|
190
|
-
# end
|
191
|
-
#
|
192
|
-
# rakefile("seed.rake", "puts 'im plantin ur seedz'")
|
193
|
-
#
|
194
|
-
def rakefile(filename, data = nil, &block)
|
195
|
-
log 'rakefile', filename
|
196
|
-
file("lib/tasks/#{filename}", data, false, &block)
|
197
|
-
end
|
198
|
-
|
199
|
-
# Create a new initializer with the provided code (either in a block or a string).
|
200
|
-
#
|
201
|
-
# ==== Examples
|
202
|
-
#
|
203
|
-
# initializer("globals.rb") do
|
204
|
-
# data = ""
|
205
|
-
#
|
206
|
-
# ['MY_WORK', 'ADMINS', 'BEST_COMPANY_EVAR'].each do
|
207
|
-
# data << "#{const} = :entp"
|
208
|
-
# end
|
209
|
-
#
|
210
|
-
# data
|
211
|
-
# end
|
212
|
-
#
|
213
|
-
# initializer("api.rb", "API_KEY = '123456'")
|
214
|
-
#
|
215
|
-
def initializer(filename, data = nil, &block)
|
216
|
-
log 'initializer', filename
|
217
|
-
file("config/initializers/#{filename}", data, false, &block)
|
218
|
-
end
|
219
|
-
|
220
|
-
# Generate something using a generator from Rails or a plugin.
|
221
|
-
# The second parameter is the argument string that is passed to
|
222
|
-
# the generator or an Array that is joined.
|
223
|
-
#
|
224
|
-
# ==== Example
|
225
|
-
#
|
226
|
-
# generate(:authenticated, "user session")
|
227
|
-
#
|
228
|
-
def generate(what, *args)
|
229
|
-
log 'generating', what
|
230
|
-
argument = args.map(&:to_s).flatten.join(" ")
|
231
|
-
|
232
|
-
in_root { run_ruby_script("script/generate #{what} #{argument}", false) }
|
233
|
-
end
|
234
|
-
|
235
|
-
# Executes a command
|
236
|
-
#
|
237
|
-
# ==== Example
|
238
|
-
#
|
239
|
-
# inside('vendor') do
|
240
|
-
# run('ln -s ~/edge rails')
|
241
|
-
# end
|
242
|
-
#
|
243
|
-
def run(command, log_action = true)
|
244
|
-
log 'executing', "#{command} from #{Dir.pwd}" if log_action
|
245
|
-
`#{command}`
|
246
|
-
end
|
247
|
-
|
248
|
-
# Executes a ruby script (taking into account WIN32 platform quirks)
|
249
|
-
def run_ruby_script(command, log_action = true)
|
250
|
-
ruby_command = RUBY_PLATFORM=~ /win32/ ? 'ruby ' : ''
|
251
|
-
run("#{ruby_command}#{command}", log_action)
|
252
|
-
end
|
253
|
-
|
254
|
-
# Runs the supplied rake task
|
255
|
-
#
|
256
|
-
# ==== Example
|
257
|
-
#
|
258
|
-
# rake("db:migrate")
|
259
|
-
# rake("db:migrate", :env => "production")
|
260
|
-
# rake("gems:install", :sudo => true)
|
261
|
-
#
|
262
|
-
def rake(command, options = {})
|
263
|
-
log 'rake', command
|
264
|
-
env = options[:env] || 'development'
|
265
|
-
sudo = options[:sudo] ? 'sudo ' : ''
|
266
|
-
in_root { run("#{sudo}rake #{command} RAILS_ENV=#{env}", false) }
|
267
|
-
end
|
268
|
-
|
269
|
-
# Just run the capify command in root
|
270
|
-
#
|
271
|
-
# ==== Example
|
272
|
-
#
|
273
|
-
# capify!
|
274
|
-
#
|
275
|
-
def capify!
|
276
|
-
log 'capifying'
|
277
|
-
in_root { run('capify .', false) }
|
278
|
-
end
|
279
|
-
|
280
|
-
# Add Rails to /vendor/rails
|
281
|
-
#
|
282
|
-
# ==== Example
|
283
|
-
#
|
284
|
-
# freeze!
|
285
|
-
#
|
286
|
-
def freeze!(args = {})
|
287
|
-
log 'vendor', 'rails edge'
|
288
|
-
in_root { run('rake rails:freeze:edge', false) }
|
289
|
-
end
|
290
|
-
|
291
|
-
# Make an entry in Rails routing file conifg/routes.rb
|
292
|
-
#
|
293
|
-
# === Example
|
294
|
-
#
|
295
|
-
# route "map.root :controller => :welcome"
|
296
|
-
#
|
297
|
-
def route(routing_code)
|
298
|
-
log 'route', routing_code
|
299
|
-
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
300
|
-
|
301
|
-
in_root do
|
302
|
-
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
303
|
-
"#{match}\n #{routing_code}\n"
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
protected
|
309
|
-
|
310
|
-
# Get a user's input
|
311
|
-
#
|
312
|
-
# ==== Example
|
313
|
-
#
|
314
|
-
# answer = ask("Should I freeze the latest Rails?")
|
315
|
-
# freeze! if ask("Should I freeze the latest Rails?") == "yes"
|
316
|
-
#
|
317
|
-
def ask(string)
|
318
|
-
log '', string
|
319
|
-
STDIN.gets.strip
|
320
|
-
end
|
321
|
-
|
322
|
-
# Do something in the root of the Rails application or
|
323
|
-
# a provided subfolder; the full path is yielded to the block you provide.
|
324
|
-
# The path is set back to the previous path when the method exits.
|
325
|
-
def inside(dir = '', &block)
|
326
|
-
folder = File.join(root, dir)
|
327
|
-
FileUtils.mkdir_p(folder) unless File.exist?(folder)
|
328
|
-
FileUtils.cd(folder) { block.arity == 1 ? yield(folder) : yield }
|
329
|
-
end
|
330
|
-
|
331
|
-
def in_root
|
332
|
-
FileUtils.cd(root) { yield }
|
333
|
-
end
|
334
|
-
|
335
|
-
# Helper to test if the user says yes(y)?
|
336
|
-
#
|
337
|
-
# ==== Example
|
338
|
-
#
|
339
|
-
# freeze! if yes?("Should I freeze the latest Rails?")
|
340
|
-
#
|
341
|
-
def yes?(question)
|
342
|
-
answer = ask(question).downcase
|
343
|
-
answer == "y" || answer == "yes"
|
344
|
-
end
|
345
|
-
|
346
|
-
# Helper to test if the user does NOT say yes(y)?
|
347
|
-
#
|
348
|
-
# ==== Example
|
349
|
-
#
|
350
|
-
# capify! if no?("Will you be using vlad to deploy your application?")
|
351
|
-
#
|
352
|
-
def no?(question)
|
353
|
-
!yes?(question)
|
354
|
-
end
|
355
|
-
|
356
|
-
# Run a regular expression replacement on a file
|
357
|
-
#
|
358
|
-
# ==== Example
|
359
|
-
#
|
360
|
-
# gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
|
361
|
-
#
|
362
|
-
def gsub_file(relative_destination, regexp, *args, &block)
|
363
|
-
path = destination_path(relative_destination)
|
364
|
-
content = File.read(path).gsub(regexp, *args, &block)
|
365
|
-
File.open(path, 'wb') { |file| file.write(content) }
|
366
|
-
end
|
367
|
-
|
368
|
-
# Append text to a file
|
369
|
-
#
|
370
|
-
# ==== Example
|
371
|
-
#
|
372
|
-
# append_file 'config/environments/test.rb', 'config.gem "rspec"'
|
373
|
-
#
|
374
|
-
def append_file(relative_destination, data)
|
375
|
-
path = destination_path(relative_destination)
|
376
|
-
File.open(path, 'ab') { |file| file.write(data) }
|
377
|
-
end
|
378
|
-
|
379
|
-
def destination_path(relative_destination)
|
380
|
-
File.join(root, relative_destination)
|
381
|
-
end
|
382
|
-
|
383
|
-
def log(action, message = '')
|
384
|
-
logger.log(action, message)
|
385
|
-
end
|
386
|
-
|
387
|
-
def logger
|
388
|
-
@logger ||= Rails::Generator::Base.logger
|
389
|
-
end
|
390
|
-
|
391
|
-
def logger
|
392
|
-
@logger ||= if defined?(Rails::Generator::Base)
|
393
|
-
Rails::Generator::Base.logger
|
394
|
-
else
|
395
|
-
require 'rails_generator/simple_logger'
|
396
|
-
Rails::Generator::SimpleLogger.new(STDOUT)
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
end
|
401
|
-
end
|