rails 1.1.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +267 -2
- data/MIT-LICENSE +1 -1
- data/README +62 -63
- data/Rakefile +26 -15
- data/bin/process/inspector +3 -0
- data/configs/databases/frontbase.yml +28 -0
- data/configs/databases/mysql.yml +3 -2
- data/configs/databases/oracle.yml +10 -1
- data/configs/databases/sqlite3.yml +3 -0
- data/configs/lighttpd.conf +1 -0
- data/configs/routes.rb +1 -0
- data/environments/boot.rb +4 -3
- data/environments/environment.rb +9 -2
- data/environments/production.rb +1 -1
- data/helpers/application.rb +5 -2
- data/html/404.html +27 -5
- data/html/500.html +27 -5
- data/html/javascripts/controls.js +41 -23
- data/html/javascripts/dragdrop.js +105 -76
- data/html/javascripts/effects.js +293 -163
- data/html/javascripts/prototype.js +897 -389
- data/lib/breakpoint.rb +31 -1
- data/lib/breakpoint_client.rb +5 -5
- data/lib/code_statistics.rb +1 -1
- data/lib/commands/performance/profiler.rb +25 -9
- data/lib/commands/plugin.rb +69 -23
- data/lib/commands/process/inspector.rb +68 -0
- data/lib/commands/process/reaper.rb +88 -69
- data/lib/commands/process/spawner.rb +148 -33
- data/lib/commands/runner.rb +27 -6
- data/lib/commands/server.rb +18 -9
- data/lib/commands/servers/base.rb +19 -0
- data/lib/commands/servers/lighttpd.rb +20 -18
- data/lib/commands/servers/mongrel.rb +65 -0
- data/lib/console_sandbox.rb +2 -2
- data/lib/dispatcher.rb +67 -11
- data/lib/fcgi_handler.rb +52 -34
- data/lib/initializer.rb +190 -111
- data/lib/rails/version.rb +2 -2
- data/lib/rails_generator/base.rb +82 -24
- data/lib/rails_generator/commands.rb +87 -25
- data/lib/rails_generator/generated_attribute.rb +42 -0
- data/lib/rails_generator/generators/applications/app/app_generator.rb +13 -10
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +1 -2
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +10 -8
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +1 -1
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +4 -4
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +1 -1
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +1 -1
- data/lib/rails_generator/generators/components/model/USAGE +19 -12
- data/lib/rails_generator/generators/components/model/model_generator.rb +4 -0
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +8 -2
- data/lib/rails_generator/generators/components/model/templates/migration.rb +3 -1
- data/lib/rails_generator/generators/components/observer/USAGE +15 -0
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
- data/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +10 -0
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +4 -0
- data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +76 -0
- data/lib/rails_generator/generators/components/resource/templates/USAGE +18 -0
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/fixtures.yml +11 -0
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +20 -0
- data/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/migration.rb +13 -0
- data/lib/rails_generator/generators/components/resource/templates/model.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/unit_test.rb +10 -0
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +10 -1
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +11 -7
- data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +5 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +2 -2
- data/lib/rails_generator/generators/components/scaffold_resource/USAGE +29 -0
- data/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +92 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb +79 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/fixtures.yml +11 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/functional_test.rb +57 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml +17 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/migration.rb +13 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/model.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/style.css +74 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/unit_test.rb +10 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml +19 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_index.rhtml +24 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml +18 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_show.rhtml +10 -0
- data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +7 -1
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +5 -4
- data/lib/rails_generator/lookup.rb +1 -2
- data/lib/rails_generator/options.rb +6 -3
- data/lib/tasks/databases.rake +46 -20
- data/lib/tasks/documentation.rake +1 -0
- data/lib/tasks/framework.rake +1 -3
- data/lib/tasks/pre_namespace_aliases.rake +34 -27
- data/lib/tasks/rails.rb +2 -2
- data/lib/tasks/statistics.rake +6 -5
- data/lib/tasks/testing.rake +28 -13
- data/lib/tasks/tmp.rake +8 -1
- data/lib/test_help.rb +3 -2
- data/lib/webrick_server.rb +6 -8
- metadata +50 -9
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>Editing <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%%= error_messages_for :<%= singular_name %> %>
|
4
|
+
|
5
|
+
<%% form_for(:<%= singular_name %>, :url => <%= singular_name %>_path(@<%= singular_name %>), :html => { :method => :put }) do |f| %>
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<p>
|
8
|
+
<b><%= attribute.column.human_name %></b><br />
|
9
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<% end -%>
|
13
|
+
<p>
|
14
|
+
<%%= submit_tag "Update" %>
|
15
|
+
</p>
|
16
|
+
<%% end %>
|
17
|
+
|
18
|
+
<%%= link_to 'Show', <%= singular_name %>_path(@<%= singular_name %>) %> |
|
19
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>Listing <%= plural_name %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
<th><%= attribute.column.human_name %></th>
|
7
|
+
<% end -%>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
|
+
<tr>
|
12
|
+
<% for attribute in attributes -%>
|
13
|
+
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
|
+
<% end -%>
|
15
|
+
<td><%%= link_to 'Show', <%= singular_name %>_path(<%= singular_name %>) %></td>
|
16
|
+
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
17
|
+
<td><%%= link_to 'Destroy', <%= singular_name %>_path(<%= singular_name %>), :confirm => 'Are you sure?', :method => :delete %></td>
|
18
|
+
</tr>
|
19
|
+
<%% end %>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<br />
|
23
|
+
|
24
|
+
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h1>New <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%%= error_messages_for :<%= singular_name %> %>
|
4
|
+
|
5
|
+
<%% form_for(:<%= singular_name %>, :url => <%= plural_name %>_path) do |f| %>
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<p>
|
8
|
+
<b><%= attribute.column.human_name %></b><br />
|
9
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<% end -%>
|
13
|
+
<p>
|
14
|
+
<%%= submit_tag "Create" %>
|
15
|
+
</p>
|
16
|
+
<%% end %>
|
17
|
+
|
18
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% for attribute in attributes -%>
|
2
|
+
<p>
|
3
|
+
<b><%= attribute.column.human_name %>:</b>
|
4
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
10
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb
CHANGED
@@ -6,7 +6,13 @@ class SessionMigrationGenerator < Rails::Generator::NamedBase
|
|
6
6
|
|
7
7
|
def manifest
|
8
8
|
record do |m|
|
9
|
-
m.migration_template 'migration.rb', 'db/migrate'
|
9
|
+
m.migration_template 'migration.rb', 'db/migrate',
|
10
|
+
:assigns => { :session_table_name => default_session_table_name }
|
10
11
|
end
|
11
12
|
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
def default_session_table_name
|
16
|
+
ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session'
|
17
|
+
end
|
12
18
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
class <%= class_name %> < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
create_table
|
3
|
+
create_table :<%= session_table_name %> do |t|
|
4
4
|
t.column :session_id, :string
|
5
5
|
t.column :data, :text
|
6
6
|
t.column :updated_at, :datetime
|
7
7
|
end
|
8
|
-
|
9
|
-
add_index
|
8
|
+
|
9
|
+
add_index :<%= session_table_name %>, :session_id
|
10
|
+
add_index :<%= session_table_name %>, :updated_at
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.down
|
13
|
-
drop_table
|
14
|
+
drop_table :<%= session_table_name %>
|
14
15
|
end
|
15
16
|
end
|
@@ -48,8 +48,7 @@ module Rails
|
|
48
48
|
# the generator and how to create it. A source is anything that
|
49
49
|
# yields generators from #each. PathSource and GemSource are provided.
|
50
50
|
module Lookup
|
51
|
-
def self.
|
52
|
-
super
|
51
|
+
def self.included(base)
|
53
52
|
base.extend(ClassMethods)
|
54
53
|
base.use_component_sources!
|
55
54
|
end
|
@@ -3,8 +3,7 @@ require 'optparse'
|
|
3
3
|
module Rails
|
4
4
|
module Generator
|
5
5
|
module Options
|
6
|
-
def self.
|
7
|
-
super
|
6
|
+
def self.included(base)
|
8
7
|
base.extend(ClassMethods)
|
9
8
|
class << base
|
10
9
|
if respond_to?(:inherited)
|
@@ -118,6 +117,11 @@ module Rails
|
|
118
117
|
|
119
118
|
# Adds general options like -h and --quiet. Usually don't override.
|
120
119
|
def add_general_options!(opt)
|
120
|
+
opt.separator ''
|
121
|
+
opt.separator 'Rails Info:'
|
122
|
+
opt.on('-v', '--version', 'Show the Rails version number and quit.')
|
123
|
+
opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }
|
124
|
+
|
121
125
|
opt.separator ''
|
122
126
|
opt.separator 'General Options:'
|
123
127
|
|
@@ -126,7 +130,6 @@ module Rails
|
|
126
130
|
opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
|
127
131
|
opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
|
128
132
|
opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
|
129
|
-
opt.on('-h', '--help', 'Show this help message.') { |v| options[:help] = v }
|
130
133
|
opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
|
131
134
|
options[:svn] = `svn status`.inject({}) do |opt, e|
|
132
135
|
opt[e.chomp[7..-1]] = true
|
data/lib/tasks/databases.rake
CHANGED
@@ -5,16 +5,16 @@ namespace :db do
|
|
5
5
|
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
namespace :fixtures do
|
9
|
+
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
10
|
+
task :load => :environment do
|
11
|
+
require 'active_record/fixtures'
|
12
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
13
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
14
|
+
Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
18
|
|
19
19
|
namespace :schema do
|
20
20
|
desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
|
@@ -36,8 +36,8 @@ namespace :db do
|
|
36
36
|
desc "Dump the database structure to a SQL file"
|
37
37
|
task :dump => :environment do
|
38
38
|
abcs = ActiveRecord::Base.configurations
|
39
|
-
case abcs[RAILS_ENV]["adapter"]
|
40
|
-
when "mysql", "oci"
|
39
|
+
case abcs[RAILS_ENV]["adapter"]
|
40
|
+
when "mysql", "oci", "oracle"
|
41
41
|
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
|
42
42
|
File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
43
43
|
when "postgresql"
|
@@ -54,7 +54,11 @@ namespace :db do
|
|
54
54
|
when "sqlserver"
|
55
55
|
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
|
56
56
|
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
|
57
|
-
|
57
|
+
when "firebird"
|
58
|
+
set_firebird_env(abcs[RAILS_ENV])
|
59
|
+
db_string = firebird_db_string(abcs[RAILS_ENV])
|
60
|
+
sh "isql -a #{db_string} > db/#{RAILS_ENV}_structure.sql"
|
61
|
+
else
|
58
62
|
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
|
59
63
|
end
|
60
64
|
|
@@ -66,13 +70,13 @@ namespace :db do
|
|
66
70
|
|
67
71
|
namespace :test do
|
68
72
|
desc "Recreate the test database from the current environment's database schema"
|
69
|
-
task :clone =>
|
73
|
+
task :clone => %w(db:schema:dump db:test:purge) do
|
70
74
|
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
|
71
75
|
ActiveRecord::Schema.verbose = false
|
72
76
|
Rake::Task["db:schema:load"].invoke
|
73
77
|
end
|
74
78
|
|
75
|
-
|
79
|
+
|
76
80
|
desc "Recreate the test databases from the development structure"
|
77
81
|
task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
|
78
82
|
abcs = ActiveRecord::Base.configurations
|
@@ -93,12 +97,16 @@ namespace :db do
|
|
93
97
|
`#{abcs["test"]["adapter"]} #{dbfile} < db/#{RAILS_ENV}_structure.sql`
|
94
98
|
when "sqlserver"
|
95
99
|
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
96
|
-
when "oci"
|
100
|
+
when "oci", "oracle"
|
97
101
|
ActiveRecord::Base.establish_connection(:test)
|
98
102
|
IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
|
99
103
|
ActiveRecord::Base.connection.execute(ddl)
|
100
104
|
end
|
101
|
-
|
105
|
+
when "firebird"
|
106
|
+
set_firebird_env(abcs["test"])
|
107
|
+
db_string = firebird_db_string(abcs["test"])
|
108
|
+
sh "isql -i db/#{RAILS_ENV}_structure.sql #{db_string}"
|
109
|
+
else
|
102
110
|
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
|
103
111
|
end
|
104
112
|
end
|
@@ -115,6 +123,8 @@ namespace :db do
|
|
115
123
|
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
116
124
|
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
|
117
125
|
enc_option = "-E #{abcs["test"]["encoding"]}" if abcs["test"]["encoding"]
|
126
|
+
|
127
|
+
ActiveRecord::Base.clear_active_connections!
|
118
128
|
`dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
119
129
|
`createdb #{enc_option} -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
120
130
|
when "sqlite","sqlite3"
|
@@ -124,11 +134,14 @@ namespace :db do
|
|
124
134
|
dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
|
125
135
|
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
|
126
136
|
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
127
|
-
when "oci"
|
137
|
+
when "oci", "oracle"
|
128
138
|
ActiveRecord::Base.establish_connection(:test)
|
129
139
|
ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
|
130
140
|
ActiveRecord::Base.connection.execute(ddl)
|
131
141
|
end
|
142
|
+
when "firebird"
|
143
|
+
ActiveRecord::Base.establish_connection(:test)
|
144
|
+
ActiveRecord::Base.connection.recreate_database!
|
132
145
|
else
|
133
146
|
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
|
134
147
|
end
|
@@ -136,7 +149,9 @@ namespace :db do
|
|
136
149
|
|
137
150
|
desc 'Prepare the test database and load the schema'
|
138
151
|
task :prepare => :environment do
|
139
|
-
|
152
|
+
if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
|
153
|
+
Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
|
154
|
+
end
|
140
155
|
end
|
141
156
|
end
|
142
157
|
|
@@ -151,7 +166,9 @@ namespace :db do
|
|
151
166
|
|
152
167
|
desc "Clear the sessions table"
|
153
168
|
task :clear => :environment do
|
154
|
-
|
169
|
+
session_table = 'session'
|
170
|
+
session_table = Inflector.pluralize(session_table) if ActiveRecord::Base.pluralize_table_names
|
171
|
+
ActiveRecord::Base.connection.execute "DELETE FROM #{session_table}"
|
155
172
|
end
|
156
173
|
end
|
157
174
|
end
|
@@ -159,3 +176,12 @@ end
|
|
159
176
|
def session_table_name
|
160
177
|
ActiveRecord::Base.pluralize_table_names ? :sessions : :session
|
161
178
|
end
|
179
|
+
|
180
|
+
def set_firebird_env(config)
|
181
|
+
ENV["ISC_USER"] = config["username"].to_s if config["username"]
|
182
|
+
ENV["ISC_PASSWORD"] = config["password"].to_s if config["password"]
|
183
|
+
end
|
184
|
+
|
185
|
+
def firebird_db_string(config)
|
186
|
+
FireRuby::Database.db_string_for(config.symbolize_keys)
|
187
|
+
end
|
@@ -6,6 +6,7 @@ namespace :doc do
|
|
6
6
|
rdoc.options << '--line-numbers' << '--inline-source'
|
7
7
|
rdoc.rdoc_files.include('doc/README_FOR_APP')
|
8
8
|
rdoc.rdoc_files.include('app/**/*.rb')
|
9
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
9
10
|
}
|
10
11
|
|
11
12
|
desc "Generate documentation for the Rails framework"
|
data/lib/tasks/framework.rake
CHANGED
@@ -103,11 +103,9 @@ namespace :rails do
|
|
103
103
|
FileUtils.cp(scripts, project_dir)
|
104
104
|
end
|
105
105
|
|
106
|
-
desc "Update boot
|
106
|
+
desc "Update config/boot.rb from your current rails install"
|
107
107
|
task :configs do
|
108
108
|
require 'railties_path'
|
109
|
-
project_dir = RAILS_ROOT + '/public/javascripts/'
|
110
|
-
scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js']
|
111
109
|
FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')
|
112
110
|
end
|
113
111
|
end
|
@@ -1,46 +1,53 @@
|
|
1
|
+
def deprecated_task(name, new_name)
|
2
|
+
task name=>new_name do
|
3
|
+
$stderr.puts "The rake task #{name} has been deprecated, please use the replacement version #{new_name}"
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
|
1
8
|
# clear
|
2
|
-
|
9
|
+
deprecated_task :clear_logs, "log:clear"
|
3
10
|
|
4
11
|
# test
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
12
|
+
deprecated_task :recent, "test:recent"
|
13
|
+
deprecated_task :test_units, "test:units"
|
14
|
+
deprecated_task :test_functional, "test:functionals"
|
15
|
+
deprecated_task :test_plugins, "test:plugins"
|
9
16
|
|
10
17
|
|
11
18
|
# doc
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
deprecated_task :appdoc, "doc:app"
|
20
|
+
deprecated_task :apidoc, "doc:rails"
|
21
|
+
deprecated_task :plugindoc, "doc:plugins"
|
22
|
+
deprecated_task :clobber_plugindoc, "doc:clobber_plugins"
|
16
23
|
|
17
24
|
FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }.each do |plugin|
|
18
|
-
|
25
|
+
deprecated_task :"#{plugin}_plugindoc", "doc:plugins:#{plugin}"
|
19
26
|
end
|
20
27
|
|
21
28
|
|
22
29
|
# rails
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
deprecated_task :freeze_gems, "rails:freeze:gems"
|
31
|
+
deprecated_task :freeze_edge, "rails:freeze:edge"
|
32
|
+
deprecated_task :unfreeze_rails, "rails:unfreeze"
|
33
|
+
deprecated_task :add_new_scripts, "rails:update:scripts"
|
34
|
+
deprecated_task :update_javascripts, "rails:update:javascripts"
|
28
35
|
|
29
36
|
|
30
37
|
# db
|
31
|
-
|
32
|
-
|
38
|
+
deprecated_task :migrate, "db:migrate"
|
39
|
+
deprecated_task :load_fixtures, "db:fixtures:load"
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
deprecated_task :db_schema_dump, "db:schema:dump"
|
42
|
+
deprecated_task :db_schema_import, "db:schema:load"
|
36
43
|
|
37
|
-
|
44
|
+
deprecated_task :db_structure_dump, "db:structure:dump"
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
deprecated_task :purge_test_database, "db:test:purge"
|
47
|
+
deprecated_task :clone_schema_to_test, "db:test:clone"
|
48
|
+
deprecated_task :clone_structure_to_test, "db:test:clone_structure"
|
49
|
+
deprecated_task :prepare_test_database, "db:test:prepare"
|
43
50
|
|
44
|
-
|
45
|
-
|
46
|
-
|
51
|
+
deprecated_task :create_sessions_table, "db:sessions:create"
|
52
|
+
deprecated_task :drop_sessions_table, "db:sessions:drop"
|
53
|
+
deprecated_task :purge_sessions_table, "db:sessions:recreate"
|
data/lib/tasks/rails.rb
CHANGED
@@ -4,5 +4,5 @@ $VERBOSE = nil
|
|
4
4
|
Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
|
5
5
|
|
6
6
|
# Load any custom rakefile extensions
|
7
|
-
Dir["
|
8
|
-
Dir["
|
7
|
+
Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
|
8
|
+
Dir["#{RAILS_ROOT}/vendor/plugins/**/tasks/**/*.rake"].sort.each { |ext| load ext }
|
data/lib/tasks/statistics.rake
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
STATS_DIRECTORIES = [
|
2
|
+
%w(Controllers app/controllers),
|
2
3
|
%w(Helpers app/helpers),
|
3
|
-
%w(
|
4
|
+
%w(Models app/models),
|
5
|
+
%w(Libraries lib/),
|
4
6
|
%w(APIs app/apis),
|
5
7
|
%w(Components components),
|
8
|
+
%w(Integration\ tests test/integration),
|
6
9
|
%w(Functional\ tests test/functional),
|
7
|
-
%w(
|
8
|
-
|
9
|
-
%w(Libraries lib/),
|
10
|
-
%w(Integration\ tests test/integration)
|
10
|
+
%w(Unit\ tests test/unit)
|
11
|
+
|
11
12
|
].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
12
13
|
|
13
14
|
desc "Report code statistics (KLOCs, etc) from the application"
|
data/lib/tasks/testing.rake
CHANGED
@@ -4,10 +4,25 @@ TEST_CHANGES_SINCE = Time.now - 600
|
|
4
4
|
def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
|
5
5
|
FileList[source_pattern].map do |path|
|
6
6
|
if File.mtime(path) > touched_since
|
7
|
-
|
8
|
-
|
7
|
+
tests = []
|
8
|
+
source_dir = File.dirname(path).split("/")
|
9
|
+
source_file = File.basename(path, '.rb')
|
10
|
+
|
11
|
+
# Support subdirs in app/models and app/controllers
|
12
|
+
modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
|
13
|
+
|
14
|
+
# For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb
|
15
|
+
test = "#{modified_test_path}/#{source_file}_test.rb"
|
16
|
+
tests.push test if File.exists?(test)
|
17
|
+
|
18
|
+
# For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
|
19
|
+
test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
|
20
|
+
FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exists?(test)
|
21
|
+
|
22
|
+
return tests
|
23
|
+
|
9
24
|
end
|
10
|
-
end.compact
|
25
|
+
end.flatten.compact
|
11
26
|
end
|
12
27
|
|
13
28
|
|
@@ -36,25 +51,24 @@ task :test do
|
|
36
51
|
end
|
37
52
|
|
38
53
|
namespace :test do
|
39
|
-
desc 'Test recent changes'
|
40
54
|
Rake::TestTask.new(:recent => "db:test:prepare") do |t|
|
41
55
|
since = TEST_CHANGES_SINCE
|
42
56
|
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
|
43
|
-
recent_tests('app/models
|
44
|
-
recent_tests('app/controllers
|
57
|
+
recent_tests('app/models/**/*.rb', 'test/unit', since) +
|
58
|
+
recent_tests('app/controllers/**/*.rb', 'test/functional', since)
|
45
59
|
|
46
60
|
t.libs << 'test'
|
47
61
|
t.verbose = true
|
48
62
|
t.test_files = touched.uniq
|
49
63
|
end
|
64
|
+
Rake::Task['test:recent'].comment = "Test recent changes"
|
50
65
|
|
51
|
-
desc 'Test changes since last checkin (only Subversion)'
|
52
66
|
Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t|
|
53
67
|
def t.file_list
|
54
68
|
changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
|
55
69
|
|
56
|
-
models = changed_since_checkin.select { |path| path =~ /app
|
57
|
-
controllers = changed_since_checkin.select { |path| path =~ /app
|
70
|
+
models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb/ }
|
71
|
+
controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb/ }
|
58
72
|
|
59
73
|
unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
|
60
74
|
functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
|
@@ -65,29 +79,29 @@ namespace :test do
|
|
65
79
|
t.libs << 'test'
|
66
80
|
t.verbose = true
|
67
81
|
end
|
82
|
+
Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion)"
|
68
83
|
|
69
|
-
desc "Run the unit tests in test/unit"
|
70
84
|
Rake::TestTask.new(:units => "db:test:prepare") do |t|
|
71
85
|
t.libs << "test"
|
72
86
|
t.pattern = 'test/unit/**/*_test.rb'
|
73
87
|
t.verbose = true
|
74
88
|
end
|
89
|
+
Rake::Task['test:units'].comment = "Run the unit tests in test/unit"
|
75
90
|
|
76
|
-
desc "Run the functional tests in test/functional"
|
77
91
|
Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
|
78
92
|
t.libs << "test"
|
79
93
|
t.pattern = 'test/functional/**/*_test.rb'
|
80
94
|
t.verbose = true
|
81
95
|
end
|
96
|
+
Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional"
|
82
97
|
|
83
|
-
desc "Run the integration tests in test/integration"
|
84
98
|
Rake::TestTask.new(:integration => "db:test:prepare") do |t|
|
85
99
|
t.libs << "test"
|
86
100
|
t.pattern = 'test/integration/**/*_test.rb'
|
87
101
|
t.verbose = true
|
88
102
|
end
|
103
|
+
Rake::Task['test:integration'].comment = "Run the integration tests in test/integration"
|
89
104
|
|
90
|
-
desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
|
91
105
|
Rake::TestTask.new(:plugins => :environment) do |t|
|
92
106
|
t.libs << "test"
|
93
107
|
|
@@ -99,4 +113,5 @@ namespace :test do
|
|
99
113
|
|
100
114
|
t.verbose = true
|
101
115
|
end
|
116
|
+
Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
|
102
117
|
end
|