rails 0.8.0 → 0.8.5

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 CHANGED
@@ -1,3 +1,31 @@
1
+ *0.8.5* (9)
2
+
3
+ * Made dev-util available to all tests, so you can insert breakpoints in any test case to get an IRB prompt at that point [bitsweat]:
4
+
5
+ def test_complex_stuff
6
+ @david.projects << @new_project
7
+ breakpoint "Let's have a closer look at @david"
8
+ end
9
+
10
+ You need to install dev-utils yourself for this to work ("gem install dev-util").
11
+
12
+ * Added shared generator behavior so future upgrades should be possible without manually copying over files [bitsweat]
13
+
14
+ * Added the new helper style to both controller and helper templates [bitsweat]
15
+
16
+ * Added new_crud generator for creating a model and controller at the same time with explicit scaffolding [bitsweat]
17
+
18
+ * Added configuration of Test::Unit::TestCase.fixture_path to test_helper to concide with the new AR fixtures style
19
+
20
+ * Fixed that new_model was generating singular table/fixture names
21
+
22
+ * Upgraded to Action Mailer 0.4.0
23
+
24
+ * Upgraded to Action Pack 0.9.5
25
+
26
+ * Upgraded to Active Record 1.1.0
27
+
28
+
1
29
  *0.8.0 (15)*
2
30
 
3
31
  * Removed custom_table_name option for new_model now that the Inflector is as powerful as it is
data/README CHANGED
@@ -82,7 +82,7 @@ app
82
82
 
83
83
  app/controllers
84
84
  Holds controllers that should be named like weblog_controller.rb for
85
- automated URL mapping. All controllers should descent from
85
+ automated URL mapping. All controllers should descend from
86
86
  ActionController::Base.
87
87
 
88
88
  app/models
@@ -118,4 +118,4 @@ test
118
118
  Unit and functional tests along with fixtures.
119
119
 
120
120
  vendor
121
- External libraries that the application depend on. This directory is in the load path.
121
+ External libraries that the application depend on. This directory is in the load path.
data/Rakefile CHANGED
@@ -2,11 +2,15 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rake/gempackagetask'
5
+ require 'rake/contrib/rubyforgepublisher'
5
6
 
6
7
  require 'date'
7
8
 
8
- PKG_NAME = "rails"
9
- PKG_VERSION = "0.8.0"
9
+
10
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11
+ PKG_NAME = 'rails'
12
+ PKG_VERSION = '0.8.5' + PKG_BUILD
13
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
10
14
  PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
11
15
 
12
16
  desc "Default Task"
@@ -163,9 +167,11 @@ task :copy_generators do
163
167
  File.cp "generators/new_controller.rb", "#{PKG_DESTINATION}/script/new_controller"
164
168
  File.cp "generators/new_model.rb", "#{PKG_DESTINATION}/script/new_model"
165
169
  File.cp "generators/new_mailer.rb", "#{PKG_DESTINATION}/script/new_mailer"
170
+ File.cp "generators/new_crud.rb", "#{PKG_DESTINATION}/script/new_crud"
166
171
  chmod 0755, "#{PKG_DESTINATION}/script/new_controller"
167
172
  chmod 0755, "#{PKG_DESTINATION}/script/new_model"
168
173
  chmod 0755, "#{PKG_DESTINATION}/script/new_mailer"
174
+ chmod 0755, "#{PKG_DESTINATION}/script/new_crud"
169
175
  end
170
176
 
171
177
  task :copy_rootfiles do
@@ -237,10 +243,10 @@ spec = Gem::Specification.new do |s|
237
243
  on top of either MySQL, PostgreSQL, or SQLite with eRuby-based templates.
238
244
  EOF
239
245
 
240
- s.add_dependency('rake', '>= 0.4.4')
241
- s.add_dependency('activerecord', '>= 1.0.0')
242
- s.add_dependency('actionpack', '>= 0.9.0')
243
- s.add_dependency('actionmailer', '>= 0.3.0')
246
+ s.add_dependency('rake', '>= 0.4.11')
247
+ s.add_dependency('activerecord', '>= 1.1.0')
248
+ s.add_dependency('actionpack', '>= 0.9.5')
249
+ s.add_dependency('actionmailer', '>= 0.4.0')
244
250
 
245
251
  s.files = PKG_FILES.to_a
246
252
  s.require_path = 'lib'
@@ -256,4 +262,10 @@ spec = Gem::Specification.new do |s|
256
262
  end
257
263
 
258
264
  Rake::GemPackageTask.new(spec) do |pkg|
265
+ end
266
+
267
+ # Publish beta gem
268
+ desc "Publish the API documentation"
269
+ task :pgem => [:gem] do
270
+ Rake::SshFilePublisher.new("davidhh@one.textdrive.com", "domains/rubyonrails.org/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
259
271
  end
@@ -30,10 +30,10 @@
30
30
  <h1>Congratulations, you're on Rails!</h1>
31
31
 
32
32
  <p>
33
- <i>You've succesfully configured your wb-server to point at this Rails application.</i>
33
+ <i>You've succesfully configured your web server to point at this Rails application.</i>
34
34
  </p>
35
35
 
36
- <p>Before you move on, verify that the following conditions have been meet:</p>
36
+ <p>Before you move on, verify that the following conditions have been met:</p>
37
37
 
38
38
  <ol>
39
39
  <li>The log directory and the empty log files must be writable to the web server (<code>chmod -R 777 log</code>).
@@ -60,7 +60,7 @@
60
60
  <small>Help: Run with no arguments for documentation</small>
61
61
  <li>Create a new model using the <code>script/new_model</code> generator <br/>
62
62
  <small>Help: Run with no arguments for documentation</small>
63
- <li>See all the tests run and by running <code>rake</code>.
63
+ <li>See all the tests run and fail by running <code>rake</code>.
64
64
  <li>Develop your Rails application!
65
65
  <li>Setup FastCGI or mod_ruby to get production-level performance
66
66
  </ol>
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+ WORK=$1-snapshot
3
+ cd /tmp
4
+ if [ -d $WORK ]; then
5
+ cd $WORK
6
+ cvs update
7
+ else
8
+ cvs -d:pserver:anonymous@rubyforge.org:/var/cvs/$1 login
9
+ cvs -d:pserver:anonymous@rubyforge.org:/var/cvs/$1 checkout -d $WORK $1
10
+ cd $WORK
11
+ fi
12
+ rm -rf pkg
13
+ EDGE_RAILS=`date -u "+%Y%m%d"` rake gem
14
+ cp pkg/$1*gem /tmp
@@ -1,87 +1,12 @@
1
1
  #!/usr/local/bin/ruby
2
-
3
2
  require File.dirname(__FILE__) + '/../config/environments/production'
3
+ require 'generator'
4
4
 
5
- def create_controller_class(controller_class_name, controller_file_name, show_actions)
6
- File.open("app/controllers/" + controller_file_name + "_controller.rb", "w", 0777) do |controller_file|
7
- controller_file.write <<EOF
8
- require 'abstract_application'
9
- require '#{controller_file_name}_helper'
10
-
11
- class #{controller_class_name}Controller < AbstractApplicationController
12
- include #{controller_class_name}Helper
13
-
14
- #{show_actions.collect { |action| " def #{action}\n end" }.join "\n\n" }
15
- end
16
- EOF
17
- end
18
- end
19
-
20
- def create_helper_class(controller_class_name, controller_file_name)
21
- File.open("app/helpers/" + controller_file_name + "_helper.rb", "w", 0777) do |helper_file|
22
- helper_file.write <<EOF
23
- module #{controller_class_name}Helper
24
- def self.append_features(controller) #:nodoc:
25
- controller.ancestors.include?(ActionController::Base) ? controller.add_template_helper(self) : super
26
- end
27
- end
28
- EOF
29
- end
30
- end
31
-
32
- def create_templates(controller_class_name, controller_file_name, show_actions)
33
- Dir.mkdir("app/views/#{controller_file_name}") rescue nil
34
- show_actions.each { |action| File.open("app/views/#{controller_file_name}/#{action}.rhtml", "w", 0777) do |template_file|
35
- template_file.write <<EOF
36
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
37
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
38
- <head>
39
- <title>#{controller_class_name}##{action}</title>
40
- </head>
41
- <body>
42
- <h1>#{controller_class_name}##{action}</h1>
43
- <p>Find me in app/views/#{controller_file_name}/#{action}.rhtml</p>
44
- </body>
45
- </html>
46
- EOF
47
- end }
48
- end
49
-
50
- def create_test_class(controller_class_name, controller_file_name)
51
- File.open("test/functional/" + controller_file_name + "_controller_test.rb", "w", 0777) do |test_file|
52
- test_file.write <<EOF
53
- require File.dirname(__FILE__) + '/../test_helper'
54
- require '#{controller_file_name}_controller'
55
-
56
- # Raise errors beyond the default web-based presentation
57
- class #{controller_class_name}Controller; def rescue_action(e) raise e end; end
58
-
59
- class #{controller_class_name}ControllerTest < Test::Unit::TestCase
60
- def setup
61
- @controller = #{controller_class_name}Controller.new
62
- @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
63
- end
64
-
65
- def test_truth
66
- assert true, "Test implementation missing"
67
- end
68
- end
69
- EOF
70
- end
71
- end
72
-
73
-
74
- if !ARGV.empty?
75
- controller_name = ARGV[0]
76
- show_actions = ARGV[1..-1]
77
-
78
- controller_class_name = Inflector.camelize(controller_name)
79
- controller_file_name = Inflector.underscore(controller_name)
80
-
81
- create_controller_class(controller_class_name, controller_file_name, show_actions)
82
- create_helper_class(controller_class_name, controller_file_name)
83
- create_templates(controller_class_name, controller_file_name, show_actions)
84
- create_test_class(controller_class_name, controller_file_name)
5
+ unless ARGV.empty?
6
+ rails_root = File.dirname(__FILE__) + '/..'
7
+ name = ARGV.shift
8
+ actions = ARGV
9
+ Generator::Controller.new(rails_root, name, actions).generate
85
10
  else
86
11
  puts <<-END_HELP
87
12
 
@@ -89,7 +14,7 @@ NAME
89
14
  new_controller - create controller and view stub files
90
15
 
91
16
  SYNOPSIS
92
- new_controller [controller_name] [view_name ...]
17
+ new_controller ControllerName action [action ...]
93
18
 
94
19
  DESCRIPTION
95
20
  The new_controller generator takes the name of the new controller as the
@@ -115,4 +40,4 @@ EXAMPLE
115
40
  The BlogController class will have the following methods: list, display, new, edit.
116
41
  Each will default to render the associated template file.
117
42
  END_HELP
118
- end
43
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.dirname(__FILE__) + '/../config/environments/production'
3
+ require 'generator'
4
+
5
+ unless ARGV.empty?
6
+ rails_root = File.dirname(__FILE__) + '/..'
7
+ name = ARGV.shift
8
+ actions = ARGV
9
+ Generator::Model.new(rails_root, name).generate
10
+ Generator::Controller.new(rails_root, name, actions, :scaffold => true).generate
11
+ else
12
+ puts <<-END_HELP
13
+
14
+ NAME
15
+ new_crud - create a model and a controller scaffold
16
+
17
+ SYNOPSIS
18
+ new_crud ModelName [action ...]
19
+
20
+ DESCRIPTION
21
+ The new_crud generator takes the name of the new model as the
22
+ first argument and an optional list of controller actions as the
23
+ subsequent arguments. All actions may be omitted since the controller
24
+ will have scaffolding automatically set up for this model.
25
+
26
+ EXAMPLE
27
+ new_crud Account
28
+
29
+ This will generate an Account model and controller with scaffolding.
30
+ Now create the accounts table in your database and browse to
31
+ http://localhost/account/ -- voila, you're on Rails!
32
+
33
+ END_HELP
34
+ end
@@ -1,90 +1,12 @@
1
1
  #!/usr/local/bin/ruby
2
-
3
2
  require File.dirname(__FILE__) + '/../config/environments/production'
3
+ require 'generator'
4
4
 
5
- def create_mailer_class(class_name, file_name, mail_actions)
6
- File.open("app/models/" + file_name + ".rb", "w", 0777) do |mailer_file|
7
- mailer_file.write <<EOF
8
- class #{class_name} < ActionMailer::Base
9
- #{mail_actions.collect { |action|
10
- " def #{action}(sent_on = Time.now)\n" +
11
- " @recipients = ''\n" +
12
- " @from = ''\n" +
13
- " @subject = ''\n" +
14
- " @body = { }\n" +
15
- " @sent_on = sent_on\n" +
16
- " end"
17
- }.join "\n\n" }
18
- end
19
- EOF
20
- end
21
- end
22
-
23
- def create_templates(class_name, file_name, mail_actions)
24
- Dir.mkdir("app/views/#{file_name}") rescue nil
25
- mail_actions.each { |action| File.open("app/views/#{file_name}/#{action}.rhtml", "w", 0777) do |template_file|
26
- template_file.write <<EOF
27
- #{class_name}##{action}
28
- EOF
29
- end }
30
- end
31
-
32
- def create_fixtures(class_name, file_name, mail_actions)
33
- Dir.mkdir("test/fixtures/" + file_name) rescue nil
34
- mail_actions.each { |action| File.open("test/fixtures/#{file_name}/#{action}", "w", 0777) do |template_file|
35
- template_file.write <<EOF
36
- #{class_name}##{action}
37
- EOF
38
- end }
39
- end
40
-
41
-
42
- def create_test_class(class_name, file_name, mail_actions)
43
- File.open("test/unit/" + file_name + "_test.rb", "w", 0777) do |test_file|
44
- test_file.write <<EOF
45
- require File.dirname(__FILE__) + '/../test_helper'
46
- require '#{file_name}'
47
-
48
- class #{class_name}Test < Test::Unit::TestCase
49
- def setup
50
- @expected = TMail::Mail.new
51
- end
52
-
53
- #{mail_actions.collect { |action|
54
- " def test_#{action}\n" +
55
- " @expected.to = ''\n" +
56
- " @expected.from = ''\n" +
57
- " @expected.subject = ''\n" +
58
- " @expected.body = read_notification_fixture \"#{action}\"\n" +
59
- " @expected.date = Time.now\n" +
60
- " \n" +
61
- " actual = #{class_name}.create_#{action}(@expected.date)\n" +
62
- " \n" +
63
- " assert_equal @expected.encoded, actual.encoded\n" +
64
- " end"
65
- }.join "\n\n" }
66
-
67
- private
68
- def read_notification_fixture(name)
69
- IO.readlines(File.dirname(__FILE__) + "/../fixtures/#{file_name}/\#{name}").join
70
- end
71
- end
72
- EOF
73
- end
74
- end
75
-
76
-
77
- if !ARGV.empty?
78
- mailer_name = ARGV[0]
79
- mail_actions = ARGV[1..-1]
80
-
81
- class_name = Inflector.camelize(mailer_name)
82
- file_name = Inflector.underscore(mailer_name)
83
-
84
- create_mailer_class(class_name, file_name, mail_actions)
85
- create_templates(class_name, file_name, mail_actions)
86
- create_fixtures(class_name, file_name, mail_actions)
87
- create_test_class(class_name, file_name, mail_actions)
5
+ unless ARGV.empty?
6
+ rails_root = File.dirname(__FILE__) + '/..'
7
+ name = ARGV.shift
8
+ actions = ARGV
9
+ Generator::Mailer.new(rails_root, name, actions).generate
88
10
  else
89
11
  puts <<-END_HELP
90
12
 
@@ -92,28 +14,30 @@ NAME
92
14
  new_mailer - create mailer and view stub files
93
15
 
94
16
  SYNOPSIS
95
- new_mailer [mailer_name] [mail_actions ...]
17
+ new_mailer MailerName action [action ...]
96
18
 
97
19
  DESCRIPTION
98
20
  The new_mailer generator takes the name of the new mailer class as the
99
- first argument and a variable number of mail action names as subsequent arguments.
100
-
21
+ first argument and a variable number of mail action names as subsequent
22
+ arguments.
23
+
101
24
  From the passed arguments, new_mailer generates a class file in
102
25
  app/models with a mail action for each of the mail action names passed.
103
- It then creates a mail test suite in test/unit with one stub test case and one
104
- stub fixture per mail action. Finally, it creates a template stub for each of the
105
- mail action names in app/views under a directory with the same name as the class.
106
-
26
+ It then creates a mail test suite in test/unit with one stub test case
27
+ and one stub fixture per mail action. Finally, it creates a template stub
28
+ for each of the mail action names in app/views under a directory with the
29
+ same name as the class.
30
+
107
31
  EXAMPLE
108
32
  new_mailer Notifications signup forgot_password invoice
109
-
33
+
110
34
  This will generate a Notifications class in
111
35
  app/models/notifications.rb, a NotificationsTest in
112
36
  test/unit/notifications_test.rb, and signup, forgot_password, and invoice
113
37
  in test/fixture/notification. It will also create signup.rhtml,
114
38
  forgot_password.rhtml, and invoice.rhtml in app/views/notifications.
115
39
 
116
- The Notifications class will have the following methods: signup, forgot_password,
117
- and invoice.
40
+ The Notifications class will have the following methods: signup,
41
+ forgot_password, and invoice.
118
42
  END_HELP
119
- end
43
+ end
@@ -1,50 +1,11 @@
1
1
  #!/usr/local/bin/ruby
2
-
3
2
  require File.dirname(__FILE__) + '/../config/environments/production'
3
+ require 'generator'
4
4
 
5
- def create_model_class(model_name, file_name)
6
- File.open("app/models/" + file_name + ".rb", "w", 0777) do |model_file|
7
- model_file.write <<EOF
8
- require 'active_record'
9
-
10
- class #{model_name} < ActiveRecord::Base
11
- end
12
- EOF
13
- end
14
- end
15
-
16
- def create_test_class(model_name, file_name, table_name)
17
- File.open("test/unit/" + file_name + "_test.rb", "w", 0777) do |test_file|
18
- test_file.write <<EOF
19
- require File.dirname(__FILE__) + '/../test_helper'
20
- require '#{file_name}'
21
-
22
- class #{model_name}Test < Test::Unit::TestCase
23
- def setup
24
- @#{table_name} = create_fixtures "#{table_name}"
25
- end
26
-
27
- def test_something
28
- assert true, "Test implementation missing"
29
- end
30
- end
31
- EOF
32
- end
33
- end
34
-
35
- def create_fixtures_directory(table_name)
36
- Dir.mkdir("test/fixtures/" + table_name) rescue puts "Fixtures directory already exists"
37
- end
38
-
39
-
40
- if !ARGV.empty?
41
- model_name = ARGV.shift
42
- file_name = Inflector.underscore(model_name)
43
- table_name = ARGV.shift || file_name
44
-
45
- create_model_class(model_name, file_name)
46
- create_test_class(model_name, file_name, table_name)
47
- create_fixtures_directory(table_name)
5
+ if ARGV.size == 1
6
+ rails_root = File.dirname(__FILE__) + '/..'
7
+ name = ARGV.shift
8
+ Generator::Model.new(rails_root, name).generate
48
9
  else
49
10
  puts <<-HELP
50
11
 
@@ -52,19 +13,19 @@ NAME
52
13
  new_model - create model stub files
53
14
 
54
15
  SYNOPSIS
55
- new_model [model_name]
16
+ new_model ModelName
56
17
 
57
18
  DESCRIPTION
58
- The new_model generator takes the name of the new model and generates a model
59
- file in app/models that decents from ActiveRecord::Base but is otherwise empty.
60
- It then creates a model test suite in test/unit with one failing
61
- test case. Finally, it creates fixture directory in test/fixtures.
62
-
19
+ The new_model generator takes a model name (in CamelCase) and generates
20
+ a new, empty model in app/models, a test suite in test/unit with one
21
+ failing test case, and a fixtures directory in test/fixtures.
22
+
63
23
  EXAMPLE
64
24
  new_model Account
65
-
66
- This will generate a Account class in app/models/account.rb, a AccountTest in
67
- test/unit/account_test.rb, and the directory test/fixtures/account.
25
+
26
+ This will generate an Account class in app/models/account.rb, an
27
+ AccountTest in test/unit/account_test.rb, and the directory
28
+ test/fixtures/account.
68
29
 
69
30
  HELP
70
- end
31
+ end
@@ -0,0 +1,24 @@
1
+ require 'abstract_application'
2
+ <% if options[:scaffold] -%>
3
+ require '<%= file_name %>'
4
+ <% end -%>
5
+
6
+ class <%= class_name %>Controller < AbstractApplicationController
7
+ helper :<%= file_name %>
8
+
9
+ <% if options[:scaffold] -%>
10
+ scaffold :<%= options[:scaffold] %>
11
+
12
+ <%- for action in actions -%>
13
+ #def <%= action %>
14
+ #end
15
+
16
+ <%- end -%>
17
+ <% else -%>
18
+ <%- for action in actions -%>
19
+ def <%= action %>
20
+ end
21
+
22
+ <%- end -%>
23
+ <% end -%>
24
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require '<%= file_name %>_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, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
11
+ end
12
+
13
+ # Replace this with your real tests
14
+ def test_truth
15
+ assert true
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <title><%= class_name %>#<%= action %></title>
5
+ </head>
6
+ <body>
7
+ <h1><%= class_name %>#<%= action %></h1>
8
+ <p>Find me in app/views/<%= file_name %>/<%= action %>.rhtml</p>
9
+ </body>
10
+ </html>
@@ -0,0 +1,2 @@
1
+ module <%= class_name %>Helper
2
+ end
@@ -0,0 +1,15 @@
1
+ require 'action_mailer'
2
+
3
+ class <%= class_name %> < ActionMailer::Base
4
+
5
+ <% for action in actions -%>
6
+ def <%= action %>(sent_on = Time.now)
7
+ @recipients = ''
8
+ @from = ''
9
+ @subject = ''
10
+ @body = {}
11
+ @sent_on = sent_on
12
+ end
13
+
14
+ <% end -%>
15
+ end
@@ -0,0 +1,3 @@
1
+ <%= class_name %>#<%= action %>
2
+
3
+ Find me in app/views/<%= file_name %>/<%= action %>.rhtml
@@ -0,0 +1,4 @@
1
+ <%= class_name %>#<%= action %>
2
+
3
+ Find me in test/fixtures/<%= file_name %>/<%= action %>.
4
+ I'm tested against the view in app/views/<%= file_name %>/<%= action %>.
@@ -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
+
7
+ def setup
8
+ ActionMailer::Base.delivery_method = :test
9
+ ActionMailer::Base.perform_deliveries = true
10
+ ActionMailer::Base.deliveries = []
11
+
12
+ @expected = TMail::Mail.new
13
+ @expected.to = 'test@localhost'
14
+ @expected.from = 'test@localhost'
15
+ @expected.subject = '<%= class_name %> test mail'
16
+ end
17
+
18
+ <% for action in actions -%>
19
+ def test_<%= action %>
20
+ @expected.body = read_fixture('<%= action %>')
21
+ @expected.date = Time.now
22
+
23
+ created = nil
24
+ assert_nothing_raised { created = <%= class_name %>.create_<%= action %>(@expected.date) }
25
+ assert_not_nil created
26
+ assert_equal expected.encoded, created.encoded
27
+
28
+ assert_nothing_raised { <%= class_name %>.deliver_<%= action %>(@expected.date) }
29
+ assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
30
+ end
31
+
32
+ <% end -%>
33
+ private
34
+ def read_fixture(action)
35
+ IO.readlines("#{FIXTURES_PATH}/<%= file_name %>/#{action}")
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ require 'active_record'
2
+
3
+ class <%= class_name %> < ActiveRecord::Base
4
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require '<%= file_name %>'
3
+
4
+ class <%= class_name %>Test < Test::Unit::TestCase
5
+ fixtures :<%= table_name %>
6
+
7
+ # Replace this with your real tests
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -1,8 +1,7 @@
1
1
  require 'action_controller'
2
- require 'application_helper'
3
2
 
4
3
  # The filters added to this controller will be run for all controllers in the application.
5
4
  # Likewise will all the methods added be available for all controllers.
6
5
  class AbstractApplicationController < ActionController::Base
7
- include ApplicationHelper
6
+ helper :application
8
7
  end
@@ -1,6 +1,3 @@
1
1
  # The methods added to this helper will be available to all templates in the application.
2
2
  module ApplicationHelper
3
- def self.append_features(controller) #:nodoc:
4
- controller.ancestors.include?(ActionController::Base) ? controller.add_template_helper(self) : super
5
- end
6
3
  end
@@ -4,6 +4,12 @@ require 'test/unit'
4
4
  require 'active_record/fixtures'
5
5
  require 'action_controller/test_process'
6
6
 
7
+ # Make rubygems available for testing if possible
8
+ begin require('rubygems'); rescue LoadError; end
9
+ begin require('dev-utils/debug'); rescue LoadError; end
10
+
7
11
  def create_fixtures(*table_names)
8
12
  Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)
9
- end
13
+ end
14
+
15
+ Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
@@ -0,0 +1,112 @@
1
+ require 'fileutils'
2
+ require 'active_record/support/inflector'
3
+
4
+ module Generator
5
+ class GeneratorError < StandardError; end
6
+
7
+ class Base
8
+ @@template_root = File.dirname(__FILE__) + '/../generators/templates'
9
+ cattr_accessor :template_root
10
+
11
+ attr_reader :rails_root, :class_name, :file_name, :table_name,
12
+ :actions, :options
13
+
14
+ def initialize(rails_root, object_name, actions = [], options = {})
15
+ @rails_root = rails_root
16
+ @class_name = Inflector.camelize(object_name)
17
+ @file_name = Inflector.underscore(@class_name)
18
+ @table_name = Inflector.pluralize(@file_name)
19
+ @actions = actions
20
+ @options = options
21
+
22
+ # Use local templates if rails_root/generators directory exists.
23
+ local_template_root = File.join(@rails_root, 'generators')
24
+ if File.directory?(local_template_root)
25
+ self.class.template_root = local_template_root
26
+ end
27
+ end
28
+
29
+ protected
30
+
31
+ # Generate a file in a fresh Rails app from an ERB template.
32
+ # Takes a template path relative to +template_root+, a
33
+ # destination path relative to +rails_root+, evaluates the template,
34
+ # and writes the result to the destination.
35
+ def generate_file(template_file_path, rails_file_path, eval_binding = nil)
36
+ # Determine full paths for source and destination files.
37
+ template_path = File.join(template_root, template_file_path)
38
+ rails_path = File.join(rails_root, rails_file_path)
39
+
40
+ # Create destination directories.
41
+ FileUtils.mkdir_p(File.dirname(rails_path))
42
+
43
+ # Render template and write result.
44
+ eval_binding ||= binding
45
+ contents = ERB.new(File.read(template_path), nil, '-').result(eval_binding)
46
+ File.open(rails_path, 'w') { |file| file.write(contents) }
47
+ end
48
+ end
49
+
50
+ # Generate controller, helper, functional test, and views.
51
+ class Controller < Base
52
+ def generate
53
+ options[:scaffold] = file_name if options[:scaffold]
54
+
55
+ # Controller class.
56
+ generate_file "controller.erb", "app/controllers/#{file_name}_controller.rb"
57
+
58
+ # Helper class.
59
+ generate_file "helper.erb", "app/helpers/#{file_name}_helper.rb"
60
+
61
+ # Function test.
62
+ generate_file "controller_test.erb", "test/functional/#{file_name}_controller_test.rb"
63
+
64
+ # View template for each action.
65
+ @actions.each do |action|
66
+ generate_file "controller_view.rhtml",
67
+ "app/views/#{file_name}/#{action}.rhtml",
68
+ binding
69
+ end
70
+ end
71
+ end
72
+
73
+ # Generate model, unit test, and fixtures.
74
+ class Model < Base
75
+ def generate
76
+
77
+ # Model class.
78
+ generate_file "model.erb", "app/models/#{file_name}.rb"
79
+
80
+ # Model unit test.
81
+ generate_file "model_test.erb", "test/unit/#{file_name}_test.rb"
82
+
83
+ # Test fixtures directory.
84
+ FileUtils.mkdir_p("test/fixtures/#{table_name}")
85
+ end
86
+ end
87
+
88
+ # Generate mailer, helper, functional test, and views.
89
+ class Mailer < Base
90
+ def generate
91
+
92
+ # Mailer class.
93
+ generate_file "mailer.erb", "app/models/#{file_name}.rb"
94
+
95
+ # Mailer unit test.
96
+ generate_file "mailer_test.erb", "test/unit/#{file_name}_test.rb"
97
+
98
+ # Test fixtures directory.
99
+ FileUtils.mkdir_p("test/fixtures/#{table_name}")
100
+
101
+ # View template and fixture for each action.
102
+ @actions.each do |action|
103
+ generate_file "mailer_action.rhtml",
104
+ "app/views/#{file_name}/#{action}.rhtml",
105
+ binding
106
+ generate_file "mailer_fixture.rhtml",
107
+ "test/fixtures/#{table_name}/#{action}",
108
+ binding
109
+ end
110
+ end
111
+ end
112
+ end
@@ -110,7 +110,7 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
110
110
  end
111
111
 
112
112
  dispatch_rb_path = File.expand_path(File.join(@server_options[:server_root], "dispatch.rb"))
113
- IO.popen(ruby_interpreter, "r+") do |ruby|
113
+ IO.popen(ruby_interpreter, "rb+") do |ruby|
114
114
  ruby.puts <<-END
115
115
  require 'cgi'
116
116
  require 'stringio'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.1
3
3
  specification_version: 1
4
4
  name: rails
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.8.0
7
- date: 2004-10-25
6
+ version: 0.8.5
7
+ date: 2004-11-18
8
8
  summary: "Web-application framework with template engine, control-flow layer, and ORM."
9
9
  require_paths:
10
10
  - lib
@@ -33,6 +33,7 @@ files:
33
33
  - doc
34
34
  - environments
35
35
  - fresh_rakefile
36
+ - gem_snapshot
36
37
  - generators
37
38
  - helpers
38
39
  - html
@@ -56,8 +57,20 @@ files:
56
57
  - environments/shared_for_gem.rb
57
58
  - environments/test.rb
58
59
  - generators/new_controller.rb
60
+ - generators/new_crud.rb
59
61
  - generators/new_mailer.rb
60
62
  - generators/new_model.rb
63
+ - generators/templates
64
+ - generators/templates/controller.erb
65
+ - generators/templates/controller_test.erb
66
+ - generators/templates/controller_view.rhtml
67
+ - generators/templates/helper.erb
68
+ - generators/templates/mailer.erb
69
+ - generators/templates/mailer_action.rhtml
70
+ - generators/templates/mailer_fixture.rhtml
71
+ - generators/templates/mailer_test.erb
72
+ - generators/templates/model.erb
73
+ - generators/templates/model_test.erb
61
74
  - helpers/abstract_application.rb
62
75
  - helpers/application_helper.rb
63
76
  - helpers/test_helper.rb
@@ -66,6 +79,7 @@ files:
66
79
  - html/index.html
67
80
  - lib/code_statistics.rb
68
81
  - lib/dispatcher.rb
82
+ - lib/generator.rb
69
83
  - lib/webrick_server.rb
70
84
  test_files: []
71
85
  rdoc_options: []
@@ -83,7 +97,7 @@ dependencies:
83
97
  -
84
98
  - ">="
85
99
  - !ruby/object:Gem::Version
86
- version: 0.4.4
100
+ version: 0.4.11
87
101
  version:
88
102
  - !ruby/object:Gem::Dependency
89
103
  name: activerecord
@@ -93,7 +107,7 @@ dependencies:
93
107
  -
94
108
  - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: 1.0.0
110
+ version: 1.1.0
97
111
  version:
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: actionpack
@@ -103,7 +117,7 @@ dependencies:
103
117
  -
104
118
  - ">="
105
119
  - !ruby/object:Gem::Version
106
- version: 0.9.0
120
+ version: 0.9.5
107
121
  version:
108
122
  - !ruby/object:Gem::Dependency
109
123
  name: actionmailer
@@ -113,5 +127,5 @@ dependencies:
113
127
  -
114
128
  - ">="
115
129
  - !ruby/object:Gem::Version
116
- version: 0.3.0
130
+ version: 0.4.0
117
131
  version: