rails 0.8.5 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +2 -2
  3. data/README.md +102 -0
  4. metadata +227 -127
  5. data/CHANGELOG +0 -187
  6. data/README +0 -121
  7. data/Rakefile +0 -271
  8. data/bin/rails +0 -28
  9. data/configs/apache.conf +0 -44
  10. data/configs/database.yml +0 -13
  11. data/dispatches/dispatch.fcgi +0 -7
  12. data/dispatches/dispatch.rb +0 -10
  13. data/dispatches/dispatch.servlet +0 -45
  14. data/doc/README_FOR_APP +0 -2
  15. data/doc/apache_protection +0 -3
  16. data/doc/index.html +0 -94
  17. data/environments/production.rb +0 -6
  18. data/environments/shared.rb +0 -27
  19. data/environments/shared_for_gem.rb +0 -17
  20. data/environments/test.rb +0 -6
  21. data/fresh_rakefile +0 -101
  22. data/gem_snapshot +0 -14
  23. data/generators/new_controller.rb +0 -43
  24. data/generators/new_crud.rb +0 -34
  25. data/generators/new_mailer.rb +0 -43
  26. data/generators/new_model.rb +0 -31
  27. data/generators/templates/controller.erb +0 -24
  28. data/generators/templates/controller_test.erb +0 -17
  29. data/generators/templates/controller_view.rhtml +0 -10
  30. data/generators/templates/helper.erb +0 -2
  31. data/generators/templates/mailer.erb +0 -15
  32. data/generators/templates/mailer_action.rhtml +0 -3
  33. data/generators/templates/mailer_fixture.rhtml +0 -4
  34. data/generators/templates/mailer_test.erb +0 -37
  35. data/generators/templates/model.erb +0 -4
  36. data/generators/templates/model_test.erb +0 -11
  37. data/helpers/abstract_application.rb +0 -7
  38. data/helpers/application_helper.rb +0 -3
  39. data/helpers/test_helper.rb +0 -15
  40. data/html/404.html +0 -6
  41. data/html/500.html +0 -6
  42. data/html/index.html +0 -1
  43. data/lib/code_statistics.rb +0 -71
  44. data/lib/dispatcher.rb +0 -46
  45. data/lib/generator.rb +0 -112
  46. data/lib/webrick_server.rb +0 -158
@@ -1,27 +0,0 @@
1
- ADDITIONAL_LOAD_PATHS = [
2
- "app/models",
3
- "app/controllers",
4
- "app/helpers",
5
- "config",
6
- "lib",
7
- "vendor",
8
- "vendor/railties",
9
- "vendor/railties/lib",
10
- "vendor/activerecord/lib",
11
- "vendor/actionpack/lib",
12
- "vendor/actionmailer/lib"
13
- ]
14
-
15
- ADDITIONAL_LOAD_PATHS.each { |dir| $:.unshift "#{File.dirname(__FILE__)}/../../#{dir}" }
16
-
17
- require 'active_record'
18
- require 'action_controller'
19
- require 'action_mailer'
20
-
21
- require 'yaml'
22
-
23
- ActionController::Base.template_root = ActionMailer::Base.template_root = File.dirname(__FILE__) + '/../../app/views/'
24
-
25
- def database_configurations
26
- YAML::load(File.open(File.dirname(__FILE__) + "/../../config/database.yml"))
27
- end
@@ -1,17 +0,0 @@
1
- ADDITIONAL_LOAD_PATHS = [ "app/models", "app/controllers", "app/helpers", "config", "lib", "vendor" ]
2
- ADDITIONAL_LOAD_PATHS.each { |dir| $:.unshift "#{File.dirname(__FILE__)}/../../#{dir}" }
3
-
4
- require 'rubygems'
5
-
6
- require_gem 'activerecord'
7
- require_gem 'actionpack'
8
- require_gem 'actionmailer'
9
- require_gem 'rails'
10
-
11
- require 'yaml'
12
-
13
- ActionController::Base.template_root = ActionMailer::Base.template_root = File.dirname(__FILE__) + '/../../app/views/'
14
-
15
- def database_configurations
16
- YAML::load(File.open(File.dirname(__FILE__) + "/../../config/database.yml"))
17
- end
data/environments/test.rb DELETED
@@ -1,6 +0,0 @@
1
- require File.dirname(__FILE__) + "/shared"
2
-
3
- ActiveRecord::Base.logger = ActionController::Base.logger = ActionMailer::Base.logger =
4
- Logger.new(File.dirname(__FILE__) + "/../../log/test.log")
5
-
6
- ActiveRecord::Base.establish_connection(database_configurations["test"])
data/fresh_rakefile DELETED
@@ -1,101 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- $VERBOSE = nil
6
-
7
- require File.dirname(__FILE__) + '/config/environments/production'
8
- require 'code_statistics'
9
-
10
- desc "Run all the tests on a fresh test database"
11
- task :default => [ :clone_production_structure_to_test, :test_units, :test_functional ]
12
-
13
- desc "Generate API documentatio, show coding stats"
14
- task :doc => [ :appdoc, :stats ]
15
-
16
-
17
- desc "Run the unit tests in test/unit"
18
- Rake::TestTask.new("test_units") { |t|
19
- t.libs << "test"
20
- t.pattern = 'test/unit/*_test.rb'
21
- t.verbose = true
22
- }
23
-
24
- desc "Run the functional tests in test/functional"
25
- Rake::TestTask.new("test_functional") { |t|
26
- t.libs << "test"
27
- t.pattern = 'test/functional/*_test.rb'
28
- t.verbose = true
29
- }
30
-
31
- desc "Generate documentation for the application"
32
- Rake::RDocTask.new("appdoc") { |rdoc|
33
- rdoc.rdoc_dir = 'doc/app'
34
- rdoc.title = "Rails Application Documentation"
35
- rdoc.options << '--line-numbers --inline-source'
36
- rdoc.rdoc_files.include('doc/README_FOR_APP')
37
- rdoc.rdoc_files.include('app/**/*.rb')
38
- }
39
-
40
- desc "Generate documentation for the Rails framework"
41
- Rake::RDocTask.new("apidoc") { |rdoc|
42
- rdoc.rdoc_dir = 'doc/api'
43
- rdoc.title = "Rails Framework Documentation"
44
- rdoc.options << '--line-numbers --inline-source'
45
- rdoc.rdoc_files.include('README')
46
- rdoc.rdoc_files.include('vendor/railties/CHANGELOG')
47
- rdoc.rdoc_files.include('vendor/railties/MIT-LICENSE')
48
- rdoc.rdoc_files.include('vendor/activerecord/README')
49
- rdoc.rdoc_files.include('vendor/activerecord/CHANGELOG')
50
- rdoc.rdoc_files.include('vendor/activerecord/lib/active_record/**/*.rb')
51
- rdoc.rdoc_files.exclude('vendor/activerecord/lib/active_record/vendor/*')
52
- rdoc.rdoc_files.include('vendor/actionpack/README')
53
- rdoc.rdoc_files.include('vendor/actionpack/CHANGELOG')
54
- rdoc.rdoc_files.include('vendor/actionpack/lib/action_controller/**/*.rb')
55
- rdoc.rdoc_files.include('vendor/actionpack/lib/action_view/**/*.rb')
56
- }
57
-
58
- desc "Report code statistics (KLOCs, etc) from the application"
59
- task :stats do
60
- CodeStatistics.new(
61
- ["Controllers", "app/controllers"],
62
- ["Helpers", "app/helpers"],
63
- ["Models", "app/models"],
64
- ["Units", "test/unit"],
65
- ["Functionals", "test/functional"]
66
- ).to_s
67
- end
68
-
69
- desc "Recreate the test databases from the production structure"
70
- task :clone_production_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
71
- if database_configurations["test"]["adapter"] == "mysql"
72
- ActiveRecord::Base.establish_connection(database_configurations["test"])
73
- ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
74
- IO.readlines("db/production_structure.sql").join.split("\n\n").each do |table|
75
- ActiveRecord::Base.connection.execute(table)
76
- end
77
- elsif database_configurations["test"]["adapter"] == "postgresql"
78
- `psql -U #{database_configurations["test"]["username"]} -f db/production_structure.sql #{database_configurations["test"]["database"]}`
79
- end
80
- end
81
-
82
- desc "Dump the database structure to a SQL file"
83
- task :db_structure_dump do
84
- if database_configurations["test"]["adapter"] == "mysql"
85
- ActiveRecord::Base.establish_connection(database_configurations["production"])
86
- File.open("db/production_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
87
- elsif database_configurations["test"]["adapter"] == "postgresql"
88
- `pg_dump -U #{database_configurations["test"]["username"]} -s -f db/production_structure.sql #{database_configurations["production"]["database"]}`
89
- end
90
- end
91
-
92
- desc "Drop the test database and bring it back again"
93
- task :purge_test_database do
94
- if database_configurations["test"]["adapter"] == "mysql"
95
- ActiveRecord::Base.establish_connection(database_configurations["production"])
96
- ActiveRecord::Base.connection.recreate_database(database_configurations["test"]["database"])
97
- elsif database_configurations["test"]["adapter"] == "postgresql"
98
- `dropdb -U #{database_configurations["test"]["username"]} #{database_configurations["test"]["database"]}`
99
- `createdb -U #{database_configurations["test"]["username"]} #{database_configurations["test"]["database"]}`
100
- end
101
- end
data/gem_snapshot DELETED
@@ -1,14 +0,0 @@
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,43 +0,0 @@
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::Controller.new(rails_root, name, actions).generate
10
- else
11
- puts <<-END_HELP
12
-
13
- NAME
14
- new_controller - create controller and view stub files
15
-
16
- SYNOPSIS
17
- new_controller ControllerName action [action ...]
18
-
19
- DESCRIPTION
20
- The new_controller generator takes the name of the new controller as the
21
- first argument and a variable number of view names as subsequent arguments.
22
- The controller name should be supplied without a "Controller" suffix. The
23
- generator will add that itself.
24
-
25
- From the passed arguments, new_controller generates a controller file in
26
- app/controllers with a render action for each of the view names passed.
27
- It then creates a controller test suite in test/functional with one failing
28
- test case. Finally, it creates an HTML stub for each of the view names in
29
- app/views under a directory with the same name as the controller.
30
-
31
- EXAMPLE
32
- new_controller Blog list display new edit
33
-
34
- This will generate a BlogController class in
35
- app/controllers/blog_controller.rb, a BlogHelper class in
36
- app/helpers/blog_helper.rb and a BlogControllerTest in
37
- test/functional/blog_controller_test.rb. It will also create list.rhtml,
38
- display.rhtml, new.rhtml, and edit.rhtml in app/views/blog.
39
-
40
- The BlogController class will have the following methods: list, display, new, edit.
41
- Each will default to render the associated template file.
42
- END_HELP
43
- end
@@ -1,34 +0,0 @@
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,43 +0,0 @@
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::Mailer.new(rails_root, name, actions).generate
10
- else
11
- puts <<-END_HELP
12
-
13
- NAME
14
- new_mailer - create mailer and view stub files
15
-
16
- SYNOPSIS
17
- new_mailer MailerName action [action ...]
18
-
19
- DESCRIPTION
20
- The new_mailer generator takes the name of the new mailer class as the
21
- first argument and a variable number of mail action names as subsequent
22
- arguments.
23
-
24
- From the passed arguments, new_mailer generates a class file in
25
- app/models with a mail action for each of the mail action names passed.
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
-
31
- EXAMPLE
32
- new_mailer Notifications signup forgot_password invoice
33
-
34
- This will generate a Notifications class in
35
- app/models/notifications.rb, a NotificationsTest in
36
- test/unit/notifications_test.rb, and signup, forgot_password, and invoice
37
- in test/fixture/notification. It will also create signup.rhtml,
38
- forgot_password.rhtml, and invoice.rhtml in app/views/notifications.
39
-
40
- The Notifications class will have the following methods: signup,
41
- forgot_password, and invoice.
42
- END_HELP
43
- end
@@ -1,31 +0,0 @@
1
- #!/usr/local/bin/ruby
2
- require File.dirname(__FILE__) + '/../config/environments/production'
3
- require 'generator'
4
-
5
- if ARGV.size == 1
6
- rails_root = File.dirname(__FILE__) + '/..'
7
- name = ARGV.shift
8
- Generator::Model.new(rails_root, name).generate
9
- else
10
- puts <<-HELP
11
-
12
- NAME
13
- new_model - create model stub files
14
-
15
- SYNOPSIS
16
- new_model ModelName
17
-
18
- DESCRIPTION
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
-
23
- EXAMPLE
24
- new_model 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.
29
-
30
- HELP
31
- end
@@ -1,24 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,10 +0,0 @@
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>
@@ -1,2 +0,0 @@
1
- module <%= class_name %>Helper
2
- end
@@ -1,15 +0,0 @@
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
@@ -1,3 +0,0 @@
1
- <%= class_name %>#<%= action %>
2
-
3
- Find me in app/views/<%= file_name %>/<%= action %>.rhtml
@@ -1,4 +0,0 @@
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 %>.
@@ -1,37 +0,0 @@
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
@@ -1,4 +0,0 @@
1
- require 'active_record'
2
-
3
- class <%= class_name %> < ActiveRecord::Base
4
- end
@@ -1,11 +0,0 @@
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,7 +0,0 @@
1
- require 'action_controller'
2
-
3
- # The filters added to this controller will be run for all controllers in the application.
4
- # Likewise will all the methods added be available for all controllers.
5
- class AbstractApplicationController < ActionController::Base
6
- helper :application
7
- end
@@ -1,3 +0,0 @@
1
- # The methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
3
- end
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + "/../config/environments/test"
2
-
3
- require 'test/unit'
4
- require 'active_record/fixtures'
5
- require 'action_controller/test_process'
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
-
11
- def create_fixtures(*table_names)
12
- Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)
13
- end
14
-
15
- Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
data/html/404.html DELETED
@@ -1,6 +0,0 @@
1
- <html>
2
- <body>
3
- <h1>File not found</h1>
4
- <p>Change this error message for pages not found in public/404.html</p>
5
- </body>
6
- </html>
data/html/500.html DELETED
@@ -1,6 +0,0 @@
1
- <html>
2
- <body>
3
- <h1>Application error (Apache)</h1>
4
- <p>Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html</p>
5
- </body>
6
- </html>
data/html/index.html DELETED
@@ -1 +0,0 @@
1
- <html><head><META HTTP-EQUIV="Refresh" CONTENT="0;URL=_doc/index.html"></head></html>
@@ -1,71 +0,0 @@
1
- class CodeStatistics
2
- def initialize(*pairs)
3
- @pairs = pairs
4
- @statistics = calculate_statistics
5
- @total = calculate_total if pairs.length > 1
6
- end
7
-
8
- def to_s
9
- print_header
10
- @statistics.each{ |k, v| print_line(k, v) }
11
- print_splitter
12
-
13
- if @total
14
- print_line("Total", @total)
15
- print_splitter
16
- end
17
- end
18
-
19
- private
20
- def calculate_statistics
21
- @pairs.inject({}) { |stats, pair| stats[pair.first] = calculate_directory_statistics(pair.last); stats }
22
- end
23
-
24
- def calculate_directory_statistics(directory, pattern = /.*rb/)
25
- stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
26
-
27
- Dir.foreach(directory) do |file_name|
28
- next unless file_name =~ pattern
29
-
30
- f = File.open(directory + "/" + file_name)
31
-
32
- while line = f.gets
33
- stats["lines"] += 1
34
- stats["classes"] += 1 if line =~ /class [A-Z]/
35
- stats["methods"] += 1 if line =~ /def [a-z]/
36
- stats["codelines"] += 1 unless line =~ /^\s*$/ || line =~ /^\s*#/
37
- end
38
- end
39
-
40
- stats
41
- end
42
-
43
- def calculate_total
44
- total = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
45
- @statistics.each_value { |pair| pair.each { |k, v| total[k] += v } }
46
- total
47
- end
48
-
49
- def print_header
50
- print_splitter
51
- puts "| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |"
52
- print_splitter
53
- end
54
-
55
- def print_splitter
56
- puts "+----------------------+-------+-------+---------+---------+-----+-------+"
57
- end
58
-
59
- def print_line(name, statistics)
60
- m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0
61
- loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0
62
-
63
- puts "| #{name.ljust(20)} " +
64
- "| #{statistics["lines"].to_s.rjust(5)} " +
65
- "| #{statistics["codelines"].to_s.rjust(5)} " +
66
- "| #{statistics["classes"].to_s.rjust(7)} " +
67
- "| #{statistics["methods"].to_s.rjust(7)} " +
68
- "| #{m_over_c.to_s.rjust(3)} " +
69
- "| #{loc_over_m.to_s.rjust(5)} |"
70
- end
71
- end
data/lib/dispatcher.rb DELETED
@@ -1,46 +0,0 @@
1
- #--
2
- # Copyright (c) 2004 David Heinemeier Hansson
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- class Dispatcher
25
- DEFAULT_SESSION_OPTIONS = { "database_manager" => CGI::Session::PStore, "prefix" => "ruby_sess.", "session_path" => "/" }
26
-
27
- def self.dispatch(cgi = CGI.new, session_options = DEFAULT_SESSION_OPTIONS, error_page = nil)
28
- begin
29
- request = ActionController::CgiRequest.new(cgi, session_options)
30
- response = ActionController::CgiResponse.new(cgi)
31
-
32
- controller_name = request.parameters["controller"].gsub(/[^_a-zA-Z0-9]/, "").untaint
33
-
34
- require "#{Inflector.underscore(controller_name)}_controller"
35
- Object.const_get("#{Inflector.camelize(controller_name)}Controller").process(request, response).out
36
- rescue Exception => e
37
- begin
38
- ActionController::Base.logger.info "\n\nException throw during dispatch: #{e.message}\n#{e.backtrace.join("\n")}"
39
- rescue Exception
40
- # Couldn't log error
41
- end
42
-
43
- if error_page then cgi.out{ IO.readlines(error_page) } else raise e end
44
- end
45
- end
46
- end