rails_product 0.5
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.
- data/CHANGELOG +619 -0
- data/MIT-LICENSE +21 -0
- data/README +195 -0
- data/Rakefile +413 -0
- data/bin/benchmarker +19 -0
- data/bin/breakpointer +3 -0
- data/bin/breakpointer_for_gem +4 -0
- data/bin/console +23 -0
- data/bin/console_sandbox +0 -0
- data/bin/destroy +7 -0
- data/bin/generate +7 -0
- data/bin/listener +86 -0
- data/bin/process/reaper +123 -0
- data/bin/process/spawner +54 -0
- data/bin/process/spinner +60 -0
- data/bin/profiler +34 -0
- data/bin/rails +17 -0
- data/bin/rails_product +17 -0
- data/bin/runner +28 -0
- data/bin/server +125 -0
- data/bin/tracker +69 -0
- data/bin/update +5 -0
- data/configs/apache/vhost.example.conf +42 -0
- data/configs/apache.conf +40 -0
- data/configs/database.yml +23 -0
- data/configs/empty.log +0 -0
- data/configs/routes.rb +19 -0
- data/dispatches/dispatch.fcgi +24 -0
- data/dispatches/dispatch.rb +10 -0
- data/dispatches/gateway.cgi +97 -0
- data/doc/README_FOR_APP +2 -0
- data/environments/development.rb +14 -0
- data/environments/environment.rb +101 -0
- data/environments/production.rb +8 -0
- data/environments/test.rb +17 -0
- data/fresh_rakefile +223 -0
- data/helpers/application.rb +4 -0
- data/helpers/application_helper.rb +3 -0
- data/helpers/test_helper.rb +26 -0
- data/html/404.html +8 -0
- data/html/500.html +8 -0
- data/html/favicon.ico +0 -0
- data/html/index.html +78 -0
- data/html/javascripts/controls.js +446 -0
- data/html/javascripts/dragdrop.js +537 -0
- data/html/javascripts/effects.js +612 -0
- data/html/javascripts/prototype.js +1038 -0
- data/html/robots.txt +1 -0
- data/lib/binding_of_caller.rb +83 -0
- data/lib/breakpoint.rb +523 -0
- data/lib/breakpoint_client.rb +196 -0
- data/lib/code_statistics.rb +104 -0
- data/lib/console_sandbox.rb +6 -0
- data/lib/dispatcher.rb +59 -0
- data/lib/fcgi_handler.rb +156 -0
- data/lib/productize.rb +116 -0
- data/lib/rails_generator/base.rb +203 -0
- data/lib/rails_generator/commands.rb +409 -0
- data/lib/rails_generator/generators/applications/app/USAGE +16 -0
- data/lib/rails_generator/generators/applications/app/app_generator.rb +126 -0
- data/lib/rails_generator/generators/applications/productized_app/USAGE +16 -0
- data/lib/rails_generator/generators/applications/productized_app/productized_app_generator.rb +133 -0
- data/lib/rails_generator/generators/components/controller/USAGE +30 -0
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +38 -0
- data/lib/rails_generator/generators/components/controller/templates/controller.rb +10 -0
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +18 -0
- data/lib/rails_generator/generators/components/controller/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/controller/templates/view.rhtml +2 -0
- data/lib/rails_generator/generators/components/mailer/USAGE +19 -0
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +32 -0
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +3 -0
- data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +13 -0
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +37 -0
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +3 -0
- data/lib/rails_generator/generators/components/migration/USAGE +14 -0
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +9 -0
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +7 -0
- data/lib/rails_generator/generators/components/model/USAGE +17 -0
- data/lib/rails_generator/generators/components/model/model_generator.rb +18 -0
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +5 -0
- data/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +14 -0
- data/lib/rails_generator/generators/components/scaffold/USAGE +32 -0
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +178 -0
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +54 -0
- data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +3 -0
- data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +1 -0
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +98 -0
- data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +13 -0
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +74 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +9 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +27 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +8 -0
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +8 -0
- data/lib/rails_generator/generators/components/web_service/USAGE +28 -0
- data/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +5 -0
- data/lib/rails_generator/generators/components/web_service/templates/controller.rb +8 -0
- data/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +19 -0
- data/lib/rails_generator/generators/components/web_service/web_service_generator.rb +29 -0
- data/lib/rails_generator/lookup.rb +206 -0
- data/lib/rails_generator/manifest.rb +53 -0
- data/lib/rails_generator/options.rb +134 -0
- data/lib/rails_generator/scripts/destroy.rb +7 -0
- data/lib/rails_generator/scripts/generate.rb +7 -0
- data/lib/rails_generator/scripts/update.rb +12 -0
- data/lib/rails_generator/scripts.rb +83 -0
- data/lib/rails_generator/simple_logger.rb +46 -0
- data/lib/rails_generator/spec.rb +44 -0
- data/lib/rails_generator.rb +43 -0
- data/lib/rubyprof_ext.rb +35 -0
- data/lib/webrick_server.rb +148 -0
- data/sites/fresh_rakefile +176 -0
- metadata +250 -0
data/configs/apache.conf
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# General Apache options
|
|
2
|
+
AddHandler fastcgi-script .fcgi
|
|
3
|
+
AddHandler cgi-script .cgi
|
|
4
|
+
Options +FollowSymLinks +ExecCGI
|
|
5
|
+
|
|
6
|
+
# If you don't want Rails to look in certain directories,
|
|
7
|
+
# use the following rewrite rules so that Apache won't rewrite certain requests
|
|
8
|
+
#
|
|
9
|
+
# Example:
|
|
10
|
+
# RewriteCond %{REQUEST_URI} ^/notrails.*
|
|
11
|
+
# RewriteRule .* - [L]
|
|
12
|
+
|
|
13
|
+
# Redirect all requests not available on the filesystem to Rails
|
|
14
|
+
# By default the cgi dispatcher is used which is very slow
|
|
15
|
+
#
|
|
16
|
+
# For better performance replace the dispatcher with the fastcgi one
|
|
17
|
+
#
|
|
18
|
+
# Example:
|
|
19
|
+
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
|
|
20
|
+
RewriteEngine On
|
|
21
|
+
|
|
22
|
+
# If your Rails application is accessed via an Alias directive,
|
|
23
|
+
# then you MUST also set the RewriteBase in this htaccess file.
|
|
24
|
+
#
|
|
25
|
+
# Example:
|
|
26
|
+
# Alias /myrailsapp /path/to/myrailsapp/public
|
|
27
|
+
# RewriteBase /myrailsapp
|
|
28
|
+
|
|
29
|
+
RewriteRule ^$ index.html [QSA]
|
|
30
|
+
RewriteRule ^([^.]+)$ $1.html [QSA]
|
|
31
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
32
|
+
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
|
|
33
|
+
|
|
34
|
+
# In case Rails experiences terminal errors
|
|
35
|
+
# Instead of displaying this message you can supply a file here which will be rendered instead
|
|
36
|
+
#
|
|
37
|
+
# Example:
|
|
38
|
+
# ErrorDocument 500 /500.html
|
|
39
|
+
|
|
40
|
+
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
development:
|
|
2
|
+
adapter: mysql
|
|
3
|
+
database: <%= SITE %>_dev
|
|
4
|
+
host: localhost
|
|
5
|
+
username: root
|
|
6
|
+
password:
|
|
7
|
+
|
|
8
|
+
# Warning: The database defined as 'test' will be erased and
|
|
9
|
+
# re-generated from your development database when you run 'rake'.
|
|
10
|
+
# Do not set this db to the same as development or production.
|
|
11
|
+
test:
|
|
12
|
+
adapter: mysql
|
|
13
|
+
database: <%= SITE %>_test
|
|
14
|
+
host: localhost
|
|
15
|
+
username: root
|
|
16
|
+
password:
|
|
17
|
+
|
|
18
|
+
production:
|
|
19
|
+
adapter: mysql
|
|
20
|
+
database: <%= SITE %>
|
|
21
|
+
host: localhost
|
|
22
|
+
username: root
|
|
23
|
+
password:
|
data/configs/empty.log
ADDED
|
File without changes
|
data/configs/routes.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
|
2
|
+
# Add your own custom routes here.
|
|
3
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
|
4
|
+
|
|
5
|
+
# Here's a sample route:
|
|
6
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
|
8
|
+
|
|
9
|
+
# You can have the root of your site routed by hooking up ''
|
|
10
|
+
# -- just remember to delete public/index.html.
|
|
11
|
+
# map.connect '', :controller => "welcome"
|
|
12
|
+
|
|
13
|
+
# Allow downloading Web Service WSDL as a file with an extension
|
|
14
|
+
# instead of a file named 'wsdl'
|
|
15
|
+
map.connect ':controller/service.wsdl', :action => 'wsdl'
|
|
16
|
+
|
|
17
|
+
# Install the default route as the lowest priority.
|
|
18
|
+
map.connect ':controller/:action/:id'
|
|
19
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# You may specify the path to the FastCGI crash log (a log of unhandled
|
|
4
|
+
# exceptions which forced the FastCGI instance to exit, great for debugging)
|
|
5
|
+
# and the number of requests to process before running garbage collection.
|
|
6
|
+
#
|
|
7
|
+
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
|
|
8
|
+
# and the GC period is nil (turned off). A reasonable number of requests
|
|
9
|
+
# could range from 10-100 depending on the memory footprint of your app.
|
|
10
|
+
#
|
|
11
|
+
# Example:
|
|
12
|
+
# # Default log path, normal GC behavior.
|
|
13
|
+
# RailsFCGIHandler.process!
|
|
14
|
+
#
|
|
15
|
+
# # Default log path, 50 requests between GC.
|
|
16
|
+
# RailsFCGIHandler.process! nil, 50
|
|
17
|
+
#
|
|
18
|
+
# # Custom log path, normal GC behavior.
|
|
19
|
+
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
|
|
20
|
+
#
|
|
21
|
+
require File.dirname(__FILE__) + "/../config/environment"
|
|
22
|
+
require 'fcgi_handler'
|
|
23
|
+
|
|
24
|
+
RailsFCGIHandler.process!
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
|
|
4
|
+
|
|
5
|
+
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
|
|
6
|
+
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
|
|
7
|
+
require "dispatcher"
|
|
8
|
+
|
|
9
|
+
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
|
10
|
+
Dispatcher.dispatch
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'drb'
|
|
4
|
+
|
|
5
|
+
# This file includes an experimental gateway CGI implementation. It will work
|
|
6
|
+
# only on platforms which support both fork and sockets.
|
|
7
|
+
#
|
|
8
|
+
# To enable it edit public/.htaccess and replace dispatch.cgi with gateway.cgi.
|
|
9
|
+
#
|
|
10
|
+
# Next, create the directory log/drb_gateway and grant the apache user rw access
|
|
11
|
+
# to said directory.
|
|
12
|
+
#
|
|
13
|
+
# On the next request to your server, the gateway tracker should start up, along
|
|
14
|
+
# with a few listener processes. This setup should provide you with much better
|
|
15
|
+
# speeds than dispatch.cgi.
|
|
16
|
+
#
|
|
17
|
+
# Keep in mind that the first request made to the server will be slow, as the
|
|
18
|
+
# tracker and listeners will have to load. Also, the tracker and listeners will
|
|
19
|
+
# shutdown after a period if inactivity. You can set this value below -- the
|
|
20
|
+
# default is 90 seconds.
|
|
21
|
+
|
|
22
|
+
TrackerSocket = File.expand_path(File.join(File.dirname(__FILE__), '../log/drb_gateway/tracker.sock'))
|
|
23
|
+
DieAfter = 90 # Seconds
|
|
24
|
+
Listeners = 3
|
|
25
|
+
|
|
26
|
+
def message(s)
|
|
27
|
+
$stderr.puts "gateway.cgi: #{s}" if ENV && ENV["DEBUG_GATEWAY"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def listener_socket(number)
|
|
31
|
+
File.expand_path(File.join(File.dirname(__FILE__), "../log/drb_gateway/listener_#{number}.sock"))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
unless File.exists? TrackerSocket
|
|
35
|
+
message "Starting tracker and #{Listeners} listeners"
|
|
36
|
+
fork do
|
|
37
|
+
Process.setsid
|
|
38
|
+
STDIN.reopen "/dev/null"
|
|
39
|
+
STDOUT.reopen "/dev/null", "a"
|
|
40
|
+
|
|
41
|
+
root = File.expand_path(File.dirname(__FILE__) + '/..')
|
|
42
|
+
|
|
43
|
+
message "starting tracker"
|
|
44
|
+
fork do
|
|
45
|
+
ARGV.clear
|
|
46
|
+
ARGV << TrackerSocket << Listeners.to_s << DieAfter.to_s
|
|
47
|
+
load File.join(root, 'script', 'tracker')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
message "starting listeners"
|
|
51
|
+
require File.join(root, 'config/environment.rb')
|
|
52
|
+
Listeners.times do |number|
|
|
53
|
+
fork do
|
|
54
|
+
ARGV.clear
|
|
55
|
+
ARGV << listener_socket(number) << DieAfter.to_s
|
|
56
|
+
load File.join(root, 'script', 'listener')
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
message "waiting for tracker and listener to arise..."
|
|
62
|
+
ready = false
|
|
63
|
+
10.times do
|
|
64
|
+
sleep 0.5
|
|
65
|
+
break if (ready = File.exists?(TrackerSocket) && File.exists?(listener_socket(0)))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if ready
|
|
69
|
+
message "tracker and listener are ready"
|
|
70
|
+
else
|
|
71
|
+
message "Waited 5 seconds, listener and tracker not ready... dropping request"
|
|
72
|
+
Kernel.exit 1
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
DRb.start_service
|
|
77
|
+
|
|
78
|
+
message "connecting to tracker"
|
|
79
|
+
tracker = DRbObject.new_with_uri("drbunix:#{TrackerSocket}")
|
|
80
|
+
|
|
81
|
+
input = $stdin.read
|
|
82
|
+
$stdin.close
|
|
83
|
+
|
|
84
|
+
env = ENV.inspect
|
|
85
|
+
|
|
86
|
+
output = nil
|
|
87
|
+
tracker.with_listener do |number|
|
|
88
|
+
message "connecting to listener #{number}"
|
|
89
|
+
socket = listener_socket(number)
|
|
90
|
+
listener = DRbObject.new_with_uri("drbunix:#{socket}")
|
|
91
|
+
output = listener.process(env, input)
|
|
92
|
+
message "listener #{number} has finished, writing output"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
$stdout.write output
|
|
96
|
+
$stdout.flush
|
|
97
|
+
$stdout.close
|
data/doc/README_FOR_APP
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# In the development environment your application's code is reloaded on
|
|
2
|
+
# every request. This slows down response time but is perfect for development
|
|
3
|
+
# since you don't have to restart the webserver when you make code changes.
|
|
4
|
+
|
|
5
|
+
# Log error messages when you accidentally call methods on nil.
|
|
6
|
+
require 'active_support/whiny_nil'
|
|
7
|
+
|
|
8
|
+
# Reload code; show full error reports; disable caching.
|
|
9
|
+
Dependencies.mechanism = :load
|
|
10
|
+
ActionController::Base.consider_all_requests_local = true
|
|
11
|
+
ActionController::Base.perform_caching = false
|
|
12
|
+
|
|
13
|
+
# The breakpoint server port that script/breakpointer connects to.
|
|
14
|
+
BREAKPOINT_SERVER_PORT = 42531
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Load the Rails framework and configure your application.
|
|
2
|
+
# You can include your own configuration at the end of this file.
|
|
3
|
+
#
|
|
4
|
+
# Be sure to restart your webserver when you modify this file.
|
|
5
|
+
|
|
6
|
+
# Uncomment to set UTF-8 as the encoding for strings. The Ruby default
|
|
7
|
+
# is US-ASCII (may differ on different platforms though). This setting is
|
|
8
|
+
# required if you need to return non-ASCII UTF-8 strings from ActionWebService.
|
|
9
|
+
#
|
|
10
|
+
# $KCODE = 'UTF8'
|
|
11
|
+
|
|
12
|
+
# The path to the root directory of your application.
|
|
13
|
+
RAILS_ROOT = File.join(File.dirname(__FILE__), '..')
|
|
14
|
+
|
|
15
|
+
# The environment your application is currently running. Don't set
|
|
16
|
+
# this here; put it in your webserver's configuration as the RAILS_ENV
|
|
17
|
+
# environment variable instead.
|
|
18
|
+
#
|
|
19
|
+
# See config/environments/*.rb for environment-specific configuration.
|
|
20
|
+
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Load the Rails framework. Mock classes for testing come first.
|
|
24
|
+
ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
|
|
25
|
+
|
|
26
|
+
# Then model subdirectories.
|
|
27
|
+
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
|
|
28
|
+
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
|
|
29
|
+
|
|
30
|
+
# Followed by the standard includes.
|
|
31
|
+
ADDITIONAL_LOAD_PATHS.concat %w(
|
|
32
|
+
app
|
|
33
|
+
app/models
|
|
34
|
+
app/controllers
|
|
35
|
+
app/helpers
|
|
36
|
+
app/apis
|
|
37
|
+
components
|
|
38
|
+
config
|
|
39
|
+
lib
|
|
40
|
+
vendor
|
|
41
|
+
vendor/rails/railties
|
|
42
|
+
vendor/rails/railties/lib
|
|
43
|
+
vendor/rails/actionpack/lib
|
|
44
|
+
vendor/rails/activesupport/lib
|
|
45
|
+
vendor/rails/activerecord/lib
|
|
46
|
+
vendor/rails/actionmailer/lib
|
|
47
|
+
vendor/rails/actionwebservice/lib
|
|
48
|
+
).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
|
|
49
|
+
|
|
50
|
+
# Prepend to $LOAD_PATH
|
|
51
|
+
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
|
52
|
+
|
|
53
|
+
# Require Rails libraries.
|
|
54
|
+
require 'rubygems' unless File.directory?("#{RAILS_ROOT}/vendor/rails")
|
|
55
|
+
|
|
56
|
+
require 'active_support'
|
|
57
|
+
require 'active_record'
|
|
58
|
+
require 'action_controller'
|
|
59
|
+
require 'action_mailer'
|
|
60
|
+
require 'action_web_service'
|
|
61
|
+
|
|
62
|
+
# Since this application serves several different sites, load the SITE from the
|
|
63
|
+
# environment. See 'lib/productize.rb' for full documentation on how we make a
|
|
64
|
+
# generic site into a hierarchical structure of specific sites.
|
|
65
|
+
SITE = ENV['SITE'] || ENV['site']
|
|
66
|
+
require 'productize'
|
|
67
|
+
|
|
68
|
+
# Environment-specific configuration.
|
|
69
|
+
require_dependency "environments/#{RAILS_ENV}"
|
|
70
|
+
ActiveRecord::Base.configurations = YAML::load(ERB.new((IO.read("#{RAILS_ROOT}/config/database.yml"))).result)
|
|
71
|
+
ActiveRecord::Base.establish_connection
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Configure defaults if the included environment did not.
|
|
75
|
+
begin
|
|
76
|
+
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
|
|
77
|
+
RAILS_DEFAULT_LOGGER.level = (RAILS_ENV == 'production' ? Logger::INFO : Logger::DEBUG)
|
|
78
|
+
rescue StandardError
|
|
79
|
+
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
|
|
80
|
+
RAILS_DEFAULT_LOGGER.level = Logger::WARN
|
|
81
|
+
RAILS_DEFAULT_LOGGER.warn(
|
|
82
|
+
"Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
|
|
83
|
+
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER }
|
|
88
|
+
[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" }
|
|
89
|
+
|
|
90
|
+
# Set up routes.
|
|
91
|
+
ActionController::Routing::Routes.reload
|
|
92
|
+
|
|
93
|
+
Controllers = Dependencies::LoadingModule.root(
|
|
94
|
+
File.join(RAILS_ROOT, 'app', 'controllers'),
|
|
95
|
+
# Load site-specific controllers if we can't find a generic one first (order matters)
|
|
96
|
+
File.join(SITE_ROOT, 'app', 'controllers'),
|
|
97
|
+
File.join(RAILS_ROOT, 'components')
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Include your app's configuration here:
|
|
101
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# The production environment is meant for finished, "live" apps.
|
|
2
|
+
# Code is not reloaded between requests, full error reports are disabled,
|
|
3
|
+
# and caching is turned on.
|
|
4
|
+
|
|
5
|
+
# Don't reload code; don't show full error reports; enable caching.
|
|
6
|
+
Dependencies.mechanism = :require
|
|
7
|
+
ActionController::Base.consider_all_requests_local = false
|
|
8
|
+
ActionController::Base.perform_caching = true
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# The test environment is used exclusively to run your application's
|
|
2
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
3
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
4
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
5
|
+
|
|
6
|
+
# Log error messages when you accidentally call methods on nil.
|
|
7
|
+
require 'active_support/whiny_nil'
|
|
8
|
+
|
|
9
|
+
# Don't reload code; show full error reports; disable caching.
|
|
10
|
+
Dependencies.mechanism = :require
|
|
11
|
+
ActionController::Base.consider_all_requests_local = true
|
|
12
|
+
ActionController::Base.perform_caching = false
|
|
13
|
+
|
|
14
|
+
# Tell ActionMailer not to deliver emails to the real world.
|
|
15
|
+
# The :test delivery method accumulates sent emails in the
|
|
16
|
+
# ActionMailer::Base.deliveries array.
|
|
17
|
+
ActionMailer::Base.delivery_method = :test
|
data/fresh_rakefile
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
require 'rake/rdoctask'
|
|
4
|
+
|
|
5
|
+
$VERBOSE = nil
|
|
6
|
+
TEST_CHANGES_SINCE = Time.now - 600
|
|
7
|
+
|
|
8
|
+
desc "Run all the tests on a fresh test database"
|
|
9
|
+
task :default => [ :test_units, :test_functional ]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
desc 'Require application environment.'
|
|
13
|
+
task :environment do
|
|
14
|
+
unless defined? RAILS_ROOT
|
|
15
|
+
require File.dirname(__FILE__) + '/config/environment'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "Generate API documentation, show coding stats"
|
|
20
|
+
task :doc => [ :appdoc, :stats ]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Look up tests for recently modified sources.
|
|
24
|
+
def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
|
|
25
|
+
FileList[source_pattern].map do |path|
|
|
26
|
+
if File.mtime(path) > touched_since
|
|
27
|
+
test = "#{test_path}/#{File.basename(path, '.rb')}_test.rb"
|
|
28
|
+
test if File.exists?(test)
|
|
29
|
+
end
|
|
30
|
+
end.compact
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc 'Test recent changes.'
|
|
34
|
+
Rake::TestTask.new(:recent => [ :clone_structure_to_test ]) do |t|
|
|
35
|
+
since = TEST_CHANGES_SINCE
|
|
36
|
+
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
|
|
37
|
+
recent_tests('app/models/*.rb', 'test/unit', since) +
|
|
38
|
+
recent_tests('app/controllers/*.rb', 'test/functional', since)
|
|
39
|
+
|
|
40
|
+
t.libs << 'test'
|
|
41
|
+
t.verbose = true
|
|
42
|
+
t.test_files = touched.uniq
|
|
43
|
+
end
|
|
44
|
+
task :test_recent => [ :clone_structure_to_test ]
|
|
45
|
+
|
|
46
|
+
desc "Run the unit tests in test/unit"
|
|
47
|
+
Rake::TestTask.new("test_units") { |t|
|
|
48
|
+
t.libs << "test"
|
|
49
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
|
50
|
+
t.verbose = true
|
|
51
|
+
}
|
|
52
|
+
task :test_units => [ :clone_structure_to_test ]
|
|
53
|
+
|
|
54
|
+
desc "Run the functional tests in test/functional"
|
|
55
|
+
Rake::TestTask.new("test_functional") { |t|
|
|
56
|
+
t.libs << "test"
|
|
57
|
+
t.pattern = 'test/functional/**/*_test.rb'
|
|
58
|
+
t.verbose = true
|
|
59
|
+
}
|
|
60
|
+
task :test_functional => [ :clone_structure_to_test ]
|
|
61
|
+
|
|
62
|
+
desc "Generate documentation for the application"
|
|
63
|
+
Rake::RDocTask.new("appdoc") { |rdoc|
|
|
64
|
+
rdoc.rdoc_dir = 'doc/app'
|
|
65
|
+
rdoc.title = "Rails Application Documentation"
|
|
66
|
+
rdoc.options << '--line-numbers --inline-source'
|
|
67
|
+
rdoc.rdoc_files.include('doc/README_FOR_APP')
|
|
68
|
+
rdoc.rdoc_files.include('app/**/*.rb')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
desc "Generate documentation for the Rails framework"
|
|
72
|
+
Rake::RDocTask.new("apidoc") { |rdoc|
|
|
73
|
+
rdoc.rdoc_dir = 'doc/api'
|
|
74
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
|
75
|
+
rdoc.title = "Rails Framework Documentation"
|
|
76
|
+
rdoc.options << '--line-numbers --inline-source'
|
|
77
|
+
rdoc.rdoc_files.include('README')
|
|
78
|
+
rdoc.rdoc_files.include('CHANGELOG')
|
|
79
|
+
rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG')
|
|
80
|
+
rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE')
|
|
81
|
+
rdoc.rdoc_files.include('vendor/rails/activerecord/README')
|
|
82
|
+
rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG')
|
|
83
|
+
rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb')
|
|
84
|
+
rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*')
|
|
85
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/README')
|
|
86
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG')
|
|
87
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb')
|
|
88
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb')
|
|
89
|
+
rdoc.rdoc_files.include('vendor/rails/actionmailer/README')
|
|
90
|
+
rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG')
|
|
91
|
+
rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb')
|
|
92
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/README')
|
|
93
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/CHANGELOG')
|
|
94
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service.rb')
|
|
95
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/*.rb')
|
|
96
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/api/*.rb')
|
|
97
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/client/*.rb')
|
|
98
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/container/*.rb')
|
|
99
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/dispatcher/*.rb')
|
|
100
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/protocol/*.rb')
|
|
101
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/support/*.rb')
|
|
102
|
+
rdoc.rdoc_files.include('vendor/rails/activesupport/README')
|
|
103
|
+
rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG')
|
|
104
|
+
rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb')
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
desc "Report code statistics (KLOCs, etc) from the application"
|
|
108
|
+
task :stats => [ :environment ] do
|
|
109
|
+
require 'code_statistics'
|
|
110
|
+
CodeStatistics.new(
|
|
111
|
+
["Helpers", "app/helpers"],
|
|
112
|
+
["Controllers", "app/controllers"],
|
|
113
|
+
["APIs", "app/apis"],
|
|
114
|
+
["Components", "components"],
|
|
115
|
+
["Functionals", "test/functional"],
|
|
116
|
+
["Models", "app/models"],
|
|
117
|
+
["Units", "test/unit"]
|
|
118
|
+
).to_s
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
desc "Recreate the test databases from the development structure"
|
|
122
|
+
task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
|
|
123
|
+
abcs = ActiveRecord::Base.configurations
|
|
124
|
+
case abcs["test"]["adapter"]
|
|
125
|
+
when "mysql"
|
|
126
|
+
ActiveRecord::Base.establish_connection(:test)
|
|
127
|
+
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
|
|
128
|
+
IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
|
|
129
|
+
ActiveRecord::Base.connection.execute(table)
|
|
130
|
+
end
|
|
131
|
+
when "postgresql"
|
|
132
|
+
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
|
|
133
|
+
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
|
134
|
+
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
|
|
135
|
+
`psql -U "#{abcs["test"]["username"]}" -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
|
|
136
|
+
when "sqlite", "sqlite3"
|
|
137
|
+
`#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql`
|
|
138
|
+
when "sqlserver"
|
|
139
|
+
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
|
140
|
+
when "oci",
|
|
141
|
+
ActiveRecord::Base.establish_connection(:test)
|
|
142
|
+
IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
|
|
143
|
+
ActiveRecord::Base.connection.execute(ddl)
|
|
144
|
+
end
|
|
145
|
+
else
|
|
146
|
+
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
desc "Dump the database structure to a SQL file"
|
|
151
|
+
task :db_structure_dump => :environment do
|
|
152
|
+
abcs = ActiveRecord::Base.configurations
|
|
153
|
+
case abcs[RAILS_ENV]["adapter"]
|
|
154
|
+
when "mysql", "oci"
|
|
155
|
+
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
|
|
156
|
+
File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
|
157
|
+
when "postgresql"
|
|
158
|
+
ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
|
|
159
|
+
ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
|
|
160
|
+
ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"]
|
|
161
|
+
`pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}`
|
|
162
|
+
when "sqlite", "sqlite3"
|
|
163
|
+
`#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql`
|
|
164
|
+
when "sqlserver"
|
|
165
|
+
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
|
|
166
|
+
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
|
|
167
|
+
else
|
|
168
|
+
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
desc "Empty the test database"
|
|
173
|
+
task :purge_test_database => :environment do
|
|
174
|
+
abcs = ActiveRecord::Base.configurations
|
|
175
|
+
case abcs["test"]["adapter"]
|
|
176
|
+
when "mysql"
|
|
177
|
+
ActiveRecord::Base.establish_connection(:test)
|
|
178
|
+
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
|
|
179
|
+
when "postgresql"
|
|
180
|
+
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
|
|
181
|
+
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
|
182
|
+
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
|
|
183
|
+
`dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
|
184
|
+
`createdb -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
|
185
|
+
when "sqlite","sqlite3"
|
|
186
|
+
File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"])
|
|
187
|
+
when "sqlserver"
|
|
188
|
+
dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
|
|
189
|
+
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
|
|
190
|
+
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
|
191
|
+
when "oci"
|
|
192
|
+
ActiveRecord::Base.establish_connection(:test)
|
|
193
|
+
ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
|
|
194
|
+
ActiveRecord::Base.connection.execute(ddl)
|
|
195
|
+
end
|
|
196
|
+
else
|
|
197
|
+
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
desc "Clears all *.log files in log/"
|
|
202
|
+
task :clear_logs => :environment do
|
|
203
|
+
FileList["log/*.log"].each do |log_file|
|
|
204
|
+
f = File.open(log_file, "w")
|
|
205
|
+
f.close
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Commented out because it's no use migrating the generic app (it has no database).
|
|
210
|
+
# TODO: Make 'rake migrate' do a migration for each and every site instead.
|
|
211
|
+
#desc "Migrate the database according to the migrate scripts in db/migrate (only supported on PG/MySQL). A specific version can be targetted with VERSION=x"
|
|
212
|
+
#task :migrate => :environment do
|
|
213
|
+
# ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/db/migrate/', ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
|
214
|
+
#end
|
|
215
|
+
|
|
216
|
+
desc "Load fixtures into the current environment's database"
|
|
217
|
+
task :load_fixtures => :environment do
|
|
218
|
+
require 'active_record/fixtures'
|
|
219
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
|
220
|
+
Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.yml')).each do |fixture_file|
|
|
221
|
+
Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
|
|
222
|
+
end
|
|
223
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
|
2
|
+
|
|
3
|
+
# Expand the path to environment so that Ruby does not load it multiple times
|
|
4
|
+
# File.expand_path can be removed if Ruby 1.9 is in use.
|
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
6
|
+
require 'application'
|
|
7
|
+
|
|
8
|
+
require 'test/unit'
|
|
9
|
+
require 'active_record/fixtures'
|
|
10
|
+
require 'action_controller/test_process'
|
|
11
|
+
require 'action_web_service/test_invoke'
|
|
12
|
+
require 'breakpoint'
|
|
13
|
+
|
|
14
|
+
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
|
15
|
+
|
|
16
|
+
class Test::Unit::TestCase
|
|
17
|
+
# Turn these on to use transactional fixtures with table_name(:fixture_name) instantiation of fixtures
|
|
18
|
+
# self.use_transactional_fixtures = true
|
|
19
|
+
# self.use_instantiated_fixtures = false
|
|
20
|
+
|
|
21
|
+
def create_fixtures(*table_names)
|
|
22
|
+
Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Add more helper methods to be used by all tests here...
|
|
26
|
+
end
|
data/html/404.html
ADDED
data/html/500.html
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
|
3
|
+
<html>
|
|
4
|
+
<body>
|
|
5
|
+
<h1>Application error (Apache)</h1>
|
|
6
|
+
<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>
|
|
7
|
+
</body>
|
|
8
|
+
</html>
|
data/html/favicon.ico
ADDED
|
File without changes
|