rails 1.2.6 → 2.0.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 +491 -12
- data/MIT-LICENSE +1 -1
- data/README +17 -25
- data/Rakefile +41 -18
- data/bin/about +1 -1
- data/bin/console +1 -1
- data/bin/destroy +1 -1
- data/bin/generate +1 -1
- data/bin/performance/request +3 -0
- data/bin/plugin +1 -1
- data/bin/runner +1 -1
- data/bin/server +1 -1
- data/builtin/rails_info/rails/info.rb +2 -2
- data/configs/apache.conf +1 -1
- data/configs/databases/mysql.yml +9 -3
- data/configs/databases/postgresql.yml +16 -12
- data/configs/initializers/inflections.rb +10 -0
- data/configs/initializers/mime_types.rb +5 -0
- data/configs/routes.rb +23 -11
- data/doc/README_FOR_APP +1 -1
- data/environments/boot.rb +95 -26
- data/environments/development.rb +2 -5
- data/environments/environment.rb +24 -25
- data/environments/test.rb +4 -1
- data/helpers/application.rb +5 -2
- data/helpers/test_helper.rb +10 -0
- data/html/422.html +30 -0
- data/html/500.html +1 -1
- data/html/index.html +2 -2
- data/html/javascripts/controls.js +484 -354
- data/html/javascripts/dragdrop.js +88 -58
- data/html/javascripts/effects.js +396 -364
- data/html/javascripts/prototype.js +2817 -1107
- data/html/robots.txt +5 -1
- data/lib/commands/console.rb +12 -5
- data/lib/commands/performance/request.rb +6 -0
- data/lib/commands/plugin.rb +15 -10
- data/lib/commands/process/spawner.rb +14 -4
- data/lib/commands/servers/base.rb +12 -0
- data/lib/commands/servers/mongrel.rb +5 -1
- data/lib/commands/servers/webrick.rb +14 -7
- data/lib/console_app.rb +5 -2
- data/lib/console_with_helpers.rb +5 -2
- data/lib/dispatcher.rb +3 -151
- data/lib/fcgi_handler.rb +79 -81
- data/lib/initializer.rb +125 -169
- data/lib/rails/plugin.rb +84 -0
- data/lib/rails/plugin/loader.rb +150 -0
- data/lib/rails/plugin/locator.rb +78 -0
- data/lib/rails/version.rb +3 -3
- data/lib/rails_generator/base.rb +11 -9
- data/lib/rails_generator/commands.rb +20 -10
- data/lib/rails_generator/generators/applications/app/USAGE +0 -7
- data/lib/rails_generator/generators/applications/app/app_generator.rb +25 -6
- data/lib/rails_generator/generators/components/controller/USAGE +11 -12
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +2 -2
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +1 -11
- data/lib/rails_generator/generators/components/controller/templates/{view.rhtml → view.html.erb} +0 -0
- data/lib/rails_generator/generators/components/integration_test/USAGE +5 -11
- data/lib/rails_generator/generators/components/mailer/USAGE +8 -10
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +3 -3
- data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +3 -0
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +8 -24
- data/lib/rails_generator/generators/components/mailer/templates/view.erb +3 -0
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -3
- data/lib/rails_generator/generators/components/migration/USAGE +23 -8
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +15 -2
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +6 -2
- data/lib/rails_generator/generators/components/model/USAGE +15 -14
- data/lib/rails_generator/generators/components/model/model_generator.rb +10 -3
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +11 -3
- data/lib/rails_generator/generators/components/model/templates/migration.rb +4 -1
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +1 -3
- data/lib/rails_generator/generators/components/observer/USAGE +5 -7
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -2
- data/lib/rails_generator/generators/components/plugin/USAGE +8 -18
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +1 -0
- data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +20 -0
- data/lib/rails_generator/generators/components/plugin/templates/README +10 -1
- data/lib/rails_generator/generators/components/plugin/templates/USAGE +1 -1
- data/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -1
- data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -1
- data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +1 -1
- data/lib/rails_generator/generators/components/resource/USAGE +23 -0
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +13 -15
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +1 -1
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +2 -14
- data/lib/rails_generator/generators/components/scaffold/USAGE +24 -31
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +45 -146
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +64 -37
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +23 -80
- data/lib/rails_generator/generators/components/scaffold/templates/{layout.rhtml → layout.html.erb} +0 -0
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +1 -1
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_edit.rhtml → scaffold/templates/view_edit.html.erb} +4 -4
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_index.rhtml → scaffold/templates/view_index.html.erb} +4 -4
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_new.rhtml → scaffold/templates/view_new.html.erb} +3 -3
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_show.rhtml → scaffold/templates/view_show.html.erb} +1 -1
- data/lib/rails_generator/generators/components/session_migration/USAGE +6 -11
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +3 -3
- data/lib/rails_generator/lookup.rb +45 -10
- data/lib/rails_generator/scripts.rb +6 -3
- data/lib/rails_generator/scripts/destroy.rb +23 -0
- data/lib/rails_generator/secret_key_generator.rb +160 -0
- data/lib/rails_generator/spec.rb +1 -1
- data/lib/source_annotation_extractor.rb +62 -0
- data/lib/tasks/annotations.rake +23 -0
- data/lib/tasks/databases.rake +249 -83
- data/lib/tasks/documentation.rake +11 -13
- data/lib/tasks/framework.rake +1 -1
- data/lib/tasks/rails.rb +1 -1
- data/lib/tasks/testing.rake +5 -7
- data/lib/test_help.rb +4 -3
- data/lib/webrick_server.rb +3 -4
- metadata +31 -49
- data/bin/breakpointer +0 -3
- data/lib/binding_of_caller.rb +0 -85
- data/lib/breakpoint.rb +0 -553
- data/lib/breakpoint_client.rb +0 -196
- data/lib/commands/breakpointer.rb +0 -1
- data/lib/rails_generator/generators/components/resource/templates/USAGE +0 -18
- data/lib/rails_generator/generators/components/resource/templates/fixtures.yml +0 -11
- data/lib/rails_generator/generators/components/resource/templates/migration.rb +0 -13
- data/lib/rails_generator/generators/components/resource/templates/model.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/unit_test.rb +0 -10
- data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +0 -3
- data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +0 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +0 -9
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +0 -27
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +0 -8
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +0 -8
- data/lib/rails_generator/generators/components/scaffold_resource/USAGE +0 -29
- data/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +0 -93
- data/lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb +0 -79
- data/lib/rails_generator/generators/components/scaffold_resource/templates/fixtures.yml +0 -11
- data/lib/rails_generator/generators/components/scaffold_resource/templates/functional_test.rb +0 -57
- data/lib/rails_generator/generators/components/scaffold_resource/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml +0 -17
- data/lib/rails_generator/generators/components/scaffold_resource/templates/migration.rb +0 -13
- data/lib/rails_generator/generators/components/scaffold_resource/templates/model.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold_resource/templates/style.css +0 -74
- data/lib/rails_generator/generators/components/scaffold_resource/templates/unit_test.rb +0 -10
- data/lib/rails_generator/generators/components/web_service/USAGE +0 -28
- data/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +0 -5
- data/lib/rails_generator/generators/components/web_service/templates/controller.rb +0 -8
- data/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +0 -19
- data/lib/rails_generator/generators/components/web_service/web_service_generator.rb +0 -29
- data/lib/tasks/pre_namespace_aliases.rake +0 -53
@@ -1,58 +1,85 @@
|
|
1
1
|
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
-
|
2
|
+
# GET /<%= table_name %>
|
3
|
+
# GET /<%= table_name %>.xml
|
3
4
|
def index
|
4
|
-
|
5
|
-
render :action => 'list'
|
6
|
-
end
|
7
|
-
<% end -%>
|
5
|
+
@<%= table_name %> = <%= class_name %>.find(:all)
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.xml { render :xml => @<%= table_name %> }
|
10
|
+
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
13
|
+
# GET /<%= table_name %>/1
|
14
|
+
# GET /<%= table_name %>/1.xml
|
15
|
+
def show
|
16
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.xml { render :xml => @<%= file_name %> }
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
# GET /<%= table_name %>/new
|
25
|
+
# GET /<%= table_name %>/new.xml
|
26
|
+
def new
|
27
|
+
@<%= file_name %> = <%= class_name %>.new
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.xml { render :xml => @<%= file_name %> }
|
32
|
+
end
|
28
33
|
end
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
flash[:notice] = '<%= model_name %> was successfully created.'
|
34
|
-
redirect_to :action => 'list<%= suffix %>'
|
35
|
-
else
|
36
|
-
render :action => 'new<%= suffix %>'
|
37
|
-
end
|
35
|
+
# GET /<%= table_name %>/1/edit
|
36
|
+
def edit
|
37
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
# POST /<%= table_name %>
|
41
|
+
# POST /<%= table_name %>.xml
|
42
|
+
def create
|
43
|
+
@<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
if @<%= file_name %>.save
|
47
|
+
flash[:notice] = '<%= class_name %> was successfully created.'
|
48
|
+
format.html { redirect_to(@<%= file_name %>) }
|
49
|
+
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
|
50
|
+
else
|
51
|
+
format.html { render :action => "new" }
|
52
|
+
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
53
|
+
end
|
54
|
+
end
|
42
55
|
end
|
43
56
|
|
57
|
+
# PUT /<%= table_name %>/1
|
58
|
+
# PUT /<%= table_name %>/1.xml
|
44
59
|
def update
|
45
|
-
@<%=
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
61
|
+
|
62
|
+
respond_to do |format|
|
63
|
+
if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
|
64
|
+
flash[:notice] = '<%= class_name %> was successfully updated.'
|
65
|
+
format.html { redirect_to(@<%= file_name %>) }
|
66
|
+
format.xml { head :ok }
|
67
|
+
else
|
68
|
+
format.html { render :action => "edit" }
|
69
|
+
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
70
|
+
end
|
51
71
|
end
|
52
72
|
end
|
53
73
|
|
54
|
-
|
55
|
-
|
56
|
-
|
74
|
+
# DELETE /<%= table_name %>/1
|
75
|
+
# DELETE /<%= table_name %>/1.xml
|
76
|
+
def destroy
|
77
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
78
|
+
@<%= file_name %>.destroy
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
format.html { redirect_to(<%= table_name %>_url) }
|
82
|
+
format.xml { head :ok }
|
83
|
+
end
|
57
84
|
end
|
58
85
|
end
|
@@ -1,102 +1,45 @@
|
|
1
|
-
require File.dirname(__FILE__) + '<%=
|
2
|
-
require '<%= controller_file_path %>_controller'
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
8
|
-
fixtures :<%= table_name %>
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@controller = <%= controller_class_name %>Controller.new
|
12
|
-
@request = ActionController::TestRequest.new
|
13
|
-
@response = ActionController::TestResponse.new
|
14
|
-
|
15
|
-
@first_id = <%= plural_name %>(:first).id
|
16
|
-
end
|
17
|
-
|
18
|
-
<% for action in unscaffolded_actions -%>
|
19
|
-
def test_<%= action %>
|
20
|
-
get :<%= action %>
|
21
|
-
assert_response :success
|
22
|
-
assert_template '<%= action %>'
|
23
|
-
end
|
24
|
-
|
25
|
-
<% end -%>
|
26
|
-
<% unless suffix -%>
|
27
|
-
def test_index
|
3
|
+
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
4
|
+
def test_should_get_index
|
28
5
|
get :index
|
29
6
|
assert_response :success
|
30
|
-
|
7
|
+
assert_not_nil assigns(:<%= table_name %>)
|
31
8
|
end
|
32
9
|
|
33
|
-
|
34
|
-
|
35
|
-
get :list<%= suffix %>
|
36
|
-
|
10
|
+
def test_should_get_new
|
11
|
+
get :new
|
37
12
|
assert_response :success
|
38
|
-
assert_template 'list<%= suffix %>'
|
39
|
-
|
40
|
-
assert_not_nil assigns(:<%= plural_name %>)
|
41
13
|
end
|
42
14
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
assert_template 'show'
|
15
|
+
def test_should_create_<%= file_name %>
|
16
|
+
assert_difference('<%= class_name %>.count') do
|
17
|
+
post :create, :<%= file_name %> => { }
|
18
|
+
end
|
48
19
|
|
49
|
-
|
50
|
-
assert assigns(:<%= singular_name %>).valid?
|
20
|
+
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
51
21
|
end
|
52
22
|
|
53
|
-
def
|
54
|
-
get :
|
55
|
-
|
23
|
+
def test_should_show_<%= file_name %>
|
24
|
+
get :show, :id => 1
|
56
25
|
assert_response :success
|
57
|
-
assert_template 'new<%= suffix %>'
|
58
|
-
|
59
|
-
assert_not_nil assigns(:<%= singular_name %>)
|
60
26
|
end
|
61
27
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
post :create<%= suffix %>, :<%= singular_name %> => {}
|
66
|
-
|
67
|
-
assert_response :redirect
|
68
|
-
assert_redirected_to :action => 'list<%= suffix %>'
|
69
|
-
|
70
|
-
assert_equal num_<%= plural_name %> + 1, <%= model_name %>.count
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_edit<%= suffix %>
|
74
|
-
get :edit<%= suffix %>, :id => @first_id
|
75
|
-
|
28
|
+
def test_should_get_edit
|
29
|
+
get :edit, :id => 1
|
76
30
|
assert_response :success
|
77
|
-
assert_template 'edit<%= suffix %>'
|
78
|
-
|
79
|
-
assert_not_nil assigns(:<%= singular_name %>)
|
80
|
-
assert assigns(:<%= singular_name %>).valid?
|
81
31
|
end
|
82
32
|
|
83
|
-
def
|
84
|
-
|
85
|
-
|
86
|
-
assert_redirected_to :action => 'show<%= suffix %>', :id => @first_id
|
33
|
+
def test_should_update_<%= file_name %>
|
34
|
+
put :update, :id => 1, :<%= file_name %> => { }
|
35
|
+
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
87
36
|
end
|
88
37
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
post :destroy, :id => @first_id
|
95
|
-
assert_response :redirect
|
96
|
-
assert_redirected_to :action => 'list<%= suffix %>'
|
38
|
+
def test_should_destroy_<%= file_name %>
|
39
|
+
assert_difference('<%= class_name %>.count', -1) do
|
40
|
+
delete :destroy, :id => 1
|
41
|
+
end
|
97
42
|
|
98
|
-
|
99
|
-
<%= model_name %>.find(@first_id)
|
100
|
-
}
|
43
|
+
assert_redirected_to <%= table_name %>_path
|
101
44
|
end
|
102
45
|
end
|
data/lib/rails_generator/generators/components/scaffold/templates/{layout.rhtml → layout.html.erb}
RENAMED
File without changes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<%%= error_messages_for :<%= singular_name %> %>
|
4
4
|
|
5
|
-
<%% form_for(
|
5
|
+
<%% form_for(@<%= singular_name %>) do |f| %>
|
6
6
|
<% for attribute in attributes -%>
|
7
7
|
<p>
|
8
8
|
<b><%= attribute.column.human_name %></b><br />
|
@@ -11,9 +11,9 @@
|
|
11
11
|
|
12
12
|
<% end -%>
|
13
13
|
<p>
|
14
|
-
<%%=
|
14
|
+
<%%= f.submit "Update" %>
|
15
15
|
</p>
|
16
16
|
<%% end %>
|
17
17
|
|
18
|
-
<%%= link_to 'Show',
|
19
|
-
<%%= link_to 'Back', <%= plural_name %>_path %>
|
18
|
+
<%%= link_to 'Show', @<%= singular_name %> %> |
|
19
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -6,19 +6,19 @@
|
|
6
6
|
<th><%= attribute.column.human_name %></th>
|
7
7
|
<% end -%>
|
8
8
|
</tr>
|
9
|
-
|
9
|
+
|
10
10
|
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
11
|
<tr>
|
12
12
|
<% for attribute in attributes -%>
|
13
13
|
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
14
|
<% end -%>
|
15
|
-
<td><%%= link_to 'Show', <%= singular_name %>
|
15
|
+
<td><%%= link_to 'Show', <%= singular_name %> %></td>
|
16
16
|
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
17
|
-
<td><%%= link_to 'Destroy', <%= singular_name
|
17
|
+
<td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
18
18
|
</tr>
|
19
19
|
<%% end %>
|
20
20
|
</table>
|
21
21
|
|
22
22
|
<br />
|
23
23
|
|
24
|
-
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
24
|
+
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<%%= error_messages_for :<%= singular_name %> %>
|
4
4
|
|
5
|
-
<%% form_for(
|
5
|
+
<%% form_for(@<%= singular_name %>) do |f| %>
|
6
6
|
<% for attribute in attributes -%>
|
7
7
|
<p>
|
8
8
|
<b><%= attribute.column.human_name %></b><br />
|
@@ -11,8 +11,8 @@
|
|
11
11
|
|
12
12
|
<% end -%>
|
13
13
|
<p>
|
14
|
-
<%%=
|
14
|
+
<%%= f.submit "Create" %>
|
15
15
|
</p>
|
16
16
|
<%% end %>
|
17
17
|
|
18
|
-
<%%= link_to 'Back', <%= plural_name %>_path %>
|
18
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -1,15 +1,10 @@
|
|
1
1
|
Description:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
The generator takes a migration name as its argument. The migration name may be
|
6
|
-
given in CamelCase or under_score.
|
7
|
-
|
8
|
-
The generator creates a migration class in db/migrate prefixed by its number
|
9
|
-
in the queue.
|
2
|
+
Creates a migration to add the sessions table used by the Active Record
|
3
|
+
session store. Pass the migration name, either CamelCased or under_scored,
|
4
|
+
as an argument.
|
10
5
|
|
11
6
|
Example:
|
12
|
-
|
7
|
+
`./script/generate session_migration CreateSessionTable`
|
13
8
|
|
14
|
-
With 4 existing migrations, this
|
15
|
-
|
9
|
+
With 4 existing migrations, this creates the AddSessionTable migration
|
10
|
+
in db/migrate/005_add_session_table.rb
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class <%= class_name %> < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
create_table :<%= session_table_name %> do |t|
|
4
|
-
t.
|
5
|
-
t.
|
6
|
-
t.
|
4
|
+
t.string :session_id, :null => false
|
5
|
+
t.text :data
|
6
|
+
t.timestamps
|
7
7
|
end
|
8
8
|
|
9
9
|
add_index :<%= session_table_name %>, :session_id
|
@@ -46,7 +46,7 @@ module Rails
|
|
46
46
|
#
|
47
47
|
# A spec is not a generator: it's a description of where to find
|
48
48
|
# the generator and how to create it. A source is anything that
|
49
|
-
# yields generators from #each. PathSource and
|
49
|
+
# yields generators from #each. PathSource and GemGeneratorSource are provided.
|
50
50
|
module Lookup
|
51
51
|
def self.included(base)
|
52
52
|
base.extend(ClassMethods)
|
@@ -92,18 +92,26 @@ module Rails
|
|
92
92
|
# 1. Rails application. If RAILS_ROOT is defined we know we're
|
93
93
|
# generating in the context of a Rails application, so search
|
94
94
|
# RAILS_ROOT/generators.
|
95
|
-
# 2.
|
96
|
-
#
|
97
|
-
#
|
95
|
+
# 2. Look in plugins, either for generators/ or rails_generators/
|
96
|
+
# directories within each plugin
|
97
|
+
# 3. User home directory. Search ~/.rails/generators.
|
98
|
+
# 4. RubyGems. Search for gems named *_generator, and look for
|
99
|
+
# generators within any RubyGem's
|
100
|
+
# /rails_generators/<generator_name>_generator.rb file.
|
101
|
+
# 5. Builtins. Model, controller, mailer, scaffold, and so on.
|
98
102
|
def use_component_sources!
|
99
103
|
reset_sources
|
100
104
|
if defined? ::RAILS_ROOT
|
101
105
|
sources << PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators")
|
102
106
|
sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators")
|
103
|
-
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins
|
107
|
+
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/generators")
|
108
|
+
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/rails_generators")
|
104
109
|
end
|
105
110
|
sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators")
|
106
|
-
|
111
|
+
if Object.const_defined?(:Gem)
|
112
|
+
sources << GemGeneratorSource.new
|
113
|
+
sources << GemPathSource.new
|
114
|
+
end
|
107
115
|
sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/components")
|
108
116
|
end
|
109
117
|
|
@@ -185,14 +193,15 @@ module Rails
|
|
185
193
|
end
|
186
194
|
end
|
187
195
|
|
188
|
-
|
189
|
-
# GemSource hits the mines to quarry for generators. The latest versions
|
190
|
-
# of gems named *_generator are selected.
|
191
|
-
class GemSource < Source
|
196
|
+
class AbstractGemSource < Source
|
192
197
|
def initialize
|
193
198
|
super :RubyGems
|
194
199
|
end
|
200
|
+
end
|
195
201
|
|
202
|
+
# GemGeneratorSource hits the mines to quarry for generators. The latest versions
|
203
|
+
# of gems named *_generator are selected.
|
204
|
+
class GemGeneratorSource < AbstractGemSource
|
196
205
|
# Yield latest versions of generator gems.
|
197
206
|
def each
|
198
207
|
Gem::cache.search(/_generator$/).inject({}) { |latest, gem|
|
@@ -205,5 +214,31 @@ module Rails
|
|
205
214
|
end
|
206
215
|
end
|
207
216
|
|
217
|
+
# GemPathSource looks for generators within any RubyGem's /rails_generators/<generator_name>_generator.rb file.
|
218
|
+
class GemPathSource < AbstractGemSource
|
219
|
+
# Yield each generator within rails_generator subdirectories.
|
220
|
+
def each
|
221
|
+
generator_full_paths.each do |generator|
|
222
|
+
yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
private
|
227
|
+
def generator_full_paths
|
228
|
+
@generator_full_paths ||=
|
229
|
+
Gem::cache.inject({}) do |latest, name_gem|
|
230
|
+
name, gem = name_gem
|
231
|
+
hem = latest[gem.name]
|
232
|
+
latest[gem.name] = gem if hem.nil? or gem.version > hem.version
|
233
|
+
latest
|
234
|
+
end.values.inject([]) do |mem, gem|
|
235
|
+
Dir[gem.full_gem_path + '/{rails_,}generators/**/*_generator.rb'].each do |generator|
|
236
|
+
mem << generator
|
237
|
+
end
|
238
|
+
mem
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
208
243
|
end
|
209
244
|
end
|