rails 1.0.0 → 7.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.

Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +103 -0
  3. metadata +228 -294
  4. data/CHANGELOG +0 -865
  5. data/MIT-LICENSE +0 -20
  6. data/README +0 -153
  7. data/Rakefile +0 -422
  8. data/bin/about +0 -3
  9. data/bin/breakpointer +0 -3
  10. data/bin/console +0 -3
  11. data/bin/destroy +0 -3
  12. data/bin/generate +0 -3
  13. data/bin/performance/benchmarker +0 -3
  14. data/bin/performance/profiler +0 -3
  15. data/bin/plugin +0 -3
  16. data/bin/process/reaper +0 -3
  17. data/bin/process/spawner +0 -3
  18. data/bin/process/spinner +0 -3
  19. data/bin/rails +0 -21
  20. data/bin/runner +0 -3
  21. data/bin/server +0 -3
  22. data/builtin/controllers/rails_info_controller.rb +0 -11
  23. data/configs/apache.conf +0 -40
  24. data/configs/database.yml +0 -85
  25. data/configs/empty.log +0 -0
  26. data/configs/lighttpd.conf +0 -40
  27. data/configs/routes.rb +0 -19
  28. data/dispatches/dispatch.fcgi +0 -24
  29. data/dispatches/dispatch.rb +0 -10
  30. data/dispatches/gateway.cgi +0 -97
  31. data/doc/README_FOR_APP +0 -2
  32. data/environments/boot.rb +0 -19
  33. data/environments/development.rb +0 -19
  34. data/environments/environment.rb +0 -53
  35. data/environments/production.rb +0 -19
  36. data/environments/test.rb +0 -19
  37. data/fresh_rakefile +0 -10
  38. data/helpers/application.rb +0 -4
  39. data/helpers/application_helper.rb +0 -3
  40. data/helpers/test_helper.rb +0 -28
  41. data/html/404.html +0 -8
  42. data/html/500.html +0 -8
  43. data/html/favicon.ico +0 -0
  44. data/html/images/rails.png +0 -0
  45. data/html/index.html +0 -277
  46. data/html/javascripts/controls.js +0 -750
  47. data/html/javascripts/dragdrop.js +0 -584
  48. data/html/javascripts/effects.js +0 -854
  49. data/html/javascripts/prototype.js +0 -1785
  50. data/html/robots.txt +0 -1
  51. data/lib/binding_of_caller.rb +0 -85
  52. data/lib/breakpoint.rb +0 -523
  53. data/lib/breakpoint_client.rb +0 -196
  54. data/lib/code_statistics.rb +0 -107
  55. data/lib/commands/about.rb +0 -2
  56. data/lib/commands/breakpointer.rb +0 -1
  57. data/lib/commands/console.rb +0 -23
  58. data/lib/commands/destroy.rb +0 -6
  59. data/lib/commands/generate.rb +0 -6
  60. data/lib/commands/ncgi/listener +0 -86
  61. data/lib/commands/ncgi/tracker +0 -69
  62. data/lib/commands/performance/benchmarker.rb +0 -24
  63. data/lib/commands/performance/profiler.rb +0 -34
  64. data/lib/commands/plugin.rb +0 -823
  65. data/lib/commands/process/reaper.rb +0 -130
  66. data/lib/commands/process/spawner.rb +0 -52
  67. data/lib/commands/process/spinner.rb +0 -57
  68. data/lib/commands/runner.rb +0 -27
  69. data/lib/commands/server.rb +0 -28
  70. data/lib/commands/servers/lighttpd.rb +0 -60
  71. data/lib/commands/servers/webrick.rb +0 -59
  72. data/lib/commands/update.rb +0 -4
  73. data/lib/commands.rb +0 -17
  74. data/lib/console_sandbox.rb +0 -6
  75. data/lib/dispatcher.rb +0 -99
  76. data/lib/fcgi_handler.rb +0 -189
  77. data/lib/initializer.rb +0 -553
  78. data/lib/rails_generator/base.rb +0 -203
  79. data/lib/rails_generator/commands.rb +0 -509
  80. data/lib/rails_generator/generators/applications/app/USAGE +0 -16
  81. data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -140
  82. data/lib/rails_generator/generators/components/controller/USAGE +0 -30
  83. data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -38
  84. data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -10
  85. data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -18
  86. data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
  87. data/lib/rails_generator/generators/components/controller/templates/view.rhtml +0 -2
  88. data/lib/rails_generator/generators/components/mailer/USAGE +0 -18
  89. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -32
  90. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -3
  91. data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -13
  92. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -37
  93. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -3
  94. data/lib/rails_generator/generators/components/migration/USAGE +0 -14
  95. data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -7
  96. data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -7
  97. data/lib/rails_generator/generators/components/model/USAGE +0 -17
  98. data/lib/rails_generator/generators/components/model/model_generator.rb +0 -18
  99. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -5
  100. data/lib/rails_generator/generators/components/model/templates/model.rb +0 -2
  101. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -10
  102. data/lib/rails_generator/generators/components/plugin/USAGE +0 -33
  103. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -33
  104. data/lib/rails_generator/generators/components/plugin/templates/README +0 -4
  105. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -22
  106. data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
  107. data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
  108. data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
  109. data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
  110. data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
  111. data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
  112. data/lib/rails_generator/generators/components/scaffold/USAGE +0 -32
  113. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -184
  114. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -54
  115. data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +0 -3
  116. data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +0 -1
  117. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -98
  118. data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
  119. data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +0 -13
  120. data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -74
  121. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +0 -9
  122. data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +0 -27
  123. data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +0 -8
  124. data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +0 -8
  125. data/lib/rails_generator/generators/components/session_migration/USAGE +0 -15
  126. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -12
  127. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -15
  128. data/lib/rails_generator/generators/components/web_service/USAGE +0 -28
  129. data/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +0 -5
  130. data/lib/rails_generator/generators/components/web_service/templates/controller.rb +0 -8
  131. data/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +0 -19
  132. data/lib/rails_generator/generators/components/web_service/web_service_generator.rb +0 -29
  133. data/lib/rails_generator/lookup.rb +0 -210
  134. data/lib/rails_generator/manifest.rb +0 -53
  135. data/lib/rails_generator/options.rb +0 -140
  136. data/lib/rails_generator/scripts/destroy.rb +0 -7
  137. data/lib/rails_generator/scripts/generate.rb +0 -7
  138. data/lib/rails_generator/scripts/update.rb +0 -12
  139. data/lib/rails_generator/scripts.rb +0 -83
  140. data/lib/rails_generator/simple_logger.rb +0 -46
  141. data/lib/rails_generator/spec.rb +0 -44
  142. data/lib/rails_generator.rb +0 -43
  143. data/lib/rails_info.rb +0 -104
  144. data/lib/rails_version.rb +0 -9
  145. data/lib/railties_path.rb +0 -1
  146. data/lib/rubyprof_ext.rb +0 -35
  147. data/lib/tasks/databases.rake +0 -158
  148. data/lib/tasks/documentation.rake +0 -76
  149. data/lib/tasks/framework.rake +0 -71
  150. data/lib/tasks/javascripts.rake +0 -6
  151. data/lib/tasks/misc.rake +0 -19
  152. data/lib/tasks/rails.rb +0 -8
  153. data/lib/tasks/statistics.rake +0 -16
  154. data/lib/tasks/testing.rake +0 -50
  155. data/lib/test_help.rb +0 -17
  156. data/lib/webrick_server.rb +0 -170
@@ -1,130 +0,0 @@
1
- require 'optparse'
2
- require 'net/http'
3
- require 'uri'
4
-
5
- if RUBY_PLATFORM =~ /mswin32/ then abort("Reaper is only for Unix") end
6
-
7
- # Instances of this class represent a single running process. Processes may
8
- # be queried by "keyword" to find those that meet a specific set of criteria.
9
- class ProgramProcess
10
- class << self
11
-
12
- # Searches for all processes matching the given keywords, and then invokes
13
- # a specific action on each of them. This is useful for (e.g.) reloading a
14
- # set of processes:
15
- #
16
- # ProgramProcess.process_keywords(:reload, "basecamp")
17
- def process_keywords(action, *keywords)
18
- processes = keywords.collect { |keyword| find_by_keyword(keyword) }.flatten
19
-
20
- if processes.empty?
21
- puts "Couldn't find any process matching: #{keywords.join(" or ")}"
22
- else
23
- processes.each do |process|
24
- puts "#{action.capitalize}ing #{process}"
25
- process.send(action)
26
- end
27
- end
28
- end
29
-
30
- # Searches for all processes matching the given keyword:
31
- #
32
- # ProgramProcess.find_by_keyword("basecamp")
33
- def find_by_keyword(keyword)
34
- process_lines_with_keyword(keyword).split("\n").collect { |line|
35
- next if line =~ /inq|ps axww|grep|spawn-fcgi|spawner|reaper/
36
- pid, *command = line.split
37
- new(pid, command.join(" "))
38
- }.compact
39
- end
40
-
41
- private
42
- def process_lines_with_keyword(keyword)
43
- `ps axww -o 'pid command' | grep #{keyword}`
44
- end
45
- end
46
-
47
- # Create a new ProgramProcess instance that represents the process with the
48
- # given pid, running the given command.
49
- def initialize(pid, command)
50
- @pid, @command = pid, command
51
- end
52
-
53
- # Forces the (rails) application to reload by sending a +HUP+ signal to the
54
- # process.
55
- def reload
56
- `kill -s HUP #{@pid}`
57
- end
58
-
59
- # Forces the (rails) application to gracefully terminate by sending a
60
- # +TERM+ signal to the process.
61
- def graceful
62
- `kill -s TERM #{@pid}`
63
- end
64
-
65
- # Forces the (rails) application to terminate immediately by sending a -9
66
- # signal to the process.
67
- def kill
68
- `kill -9 #{@pid}`
69
- end
70
-
71
- # Send a +USR1+ signal to the process.
72
- def usr1
73
- `kill -s USR1 #{@pid}`
74
- end
75
-
76
- # Force the (rails) application to restart by sending a +USR2+ signal to the
77
- # process.
78
- def restart
79
- `kill -s USR2 #{@pid}`
80
- end
81
-
82
- def to_s #:nodoc:
83
- "[#{@pid}] #{@command}"
84
- end
85
- end
86
-
87
- OPTIONS = {
88
- :action => "restart",
89
- :dispatcher => File.expand_path(RAILS_ROOT + '/public/dispatch.fcgi')
90
- }
91
-
92
- ARGV.options do |opts|
93
- opts.banner = "Usage: reaper [options]"
94
-
95
- opts.separator ""
96
-
97
- opts.on <<-EOF
98
- Description:
99
- The reaper is used to restart, reload, gracefully exit, and forcefully exit FCGI processes
100
- running a Rails Dispatcher. This is commonly done when a new version of the application
101
- is available, so the existing processes can be updated to use the latest code.
102
-
103
- The reaper actions are:
104
-
105
- * restart : Restarts the application by reloading both application and framework code
106
- * reload : Only reloads the application, but not the framework (like the development environment)
107
- * graceful: Marks all of the processes for exit after the next request
108
- * kill : Forcefully exists all processes regardless of whether they're currently serving a request
109
-
110
- Restart is the most common and default action.
111
-
112
- Examples:
113
- reaper # restarts the default dispatcher
114
- reaper -a reload
115
- reaper -a exit -d /my/special/dispatcher.fcgi
116
- EOF
117
-
118
- opts.on(" Options:")
119
-
120
- opts.on("-a", "--action=name", "reload|graceful|kill (default: #{OPTIONS[:action]})", String) { |OPTIONS[:action]| }
121
- opts.on("-d", "--dispatcher=path", "default: #{OPTIONS[:dispatcher]}", String) { |OPTIONS[:dispatcher]| }
122
-
123
- opts.separator ""
124
-
125
- opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
126
-
127
- opts.parse!
128
- end
129
-
130
- ProgramProcess.process_keywords(OPTIONS[:action], OPTIONS[:dispatcher])
@@ -1,52 +0,0 @@
1
- require 'optparse'
2
-
3
- def spawn(port)
4
- print "Starting FCGI on port: #{port}\n "
5
- system("#{OPTIONS[:spawner]} -f #{OPTIONS[:dispatcher]} -p #{port}")
6
- end
7
-
8
- OPTIONS = {
9
- :environment => "production",
10
- :spawner => '/usr/bin/env spawn-fcgi',
11
- :dispatcher => File.expand_path(RAILS_ROOT + '/public/dispatch.fcgi'),
12
- :port => 8000,
13
- :instances => 3
14
- }
15
-
16
- ARGV.options do |opts|
17
- opts.banner = "Usage: spawner [options]"
18
-
19
- opts.separator ""
20
-
21
- opts.on <<-EOF
22
- Description:
23
- The spawner is a wrapper for spawn-fcgi that makes it easier to start multiple FCGI
24
- processes running the Rails dispatcher. The spawn-fcgi command is included with the lighttpd
25
- web server, but can be used with both Apache and lighttpd (and any other web server supporting
26
- externally managed FCGI processes).
27
-
28
- You decide a starting port (default is 8000) and the number of FCGI process instances you'd
29
- like to run. So if you pick 9100 and 3 instances, you'll start processes on 9100, 9101, and 9102.
30
-
31
- Examples:
32
- spawner # starts instances on 8000, 8001, and 8002
33
- spawner -p 9100 -i 10 # starts 10 instances counting from 9100 to 9109
34
- EOF
35
-
36
- opts.on(" Options:")
37
-
38
- opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]| }
39
- opts.on("-i", "--instances=number", Integer, "Number of instances (default: #{OPTIONS[:instances]})") { |OPTIONS[:instances]| }
40
- opts.on("-e", "--environment=name", String, "test|development|production (default: #{OPTIONS[:environment]})") { |OPTIONS[:environment]| }
41
- opts.on("-s", "--spawner=path", String, "default: #{OPTIONS[:spawner]}") { |OPTIONS[:spawner]| }
42
- opts.on("-d", "--dispatcher=path", String, "default: #{OPTIONS[:dispatcher]}") { |dispatcher| OPTIONS[:dispatcher] = File.expand_path(dispatcher) }
43
-
44
- opts.separator ""
45
-
46
- opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
47
-
48
- opts.parse!
49
- end
50
-
51
- ENV["RAILS_ENV"] = OPTIONS[:environment]
52
- OPTIONS[:instances].times { |i| spawn(OPTIONS[:port] + i) }
@@ -1,57 +0,0 @@
1
- require 'optparse'
2
-
3
- def daemonize #:nodoc:
4
- exit if fork # Parent exits, child continues.
5
- Process.setsid # Become session leader.
6
- exit if fork # Zap session leader. See [1].
7
- Dir.chdir "/" # Release old working directory.
8
- File.umask 0000 # Ensure sensible umask. Adjust as needed.
9
- STDIN.reopen "/dev/null" # Free file descriptors and
10
- STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
11
- STDERR.reopen STDOUT # STDOUT/ERR should better go to a logfile.
12
- end
13
-
14
- OPTIONS = {
15
- :interval => 5.0,
16
- :command => File.expand_path(RAILS_ROOT + '/script/process/spawner'),
17
- :daemon => false
18
- }
19
-
20
- ARGV.options do |opts|
21
- opts.banner = "Usage: spinner [options]"
22
-
23
- opts.separator ""
24
-
25
- opts.on <<-EOF
26
- Description:
27
- The spinner is a protection loop for the spawner, which will attempt to restart any FCGI processes
28
- that might have been exited or outright crashed. It's a brute-force attempt that'll just try
29
- to run the spawner every X number of seconds, so it does pose a light load on the server.
30
-
31
- Examples:
32
- spinner # attempts to run the spawner with default settings every second with output on the terminal
33
- spinner -i 3 -d # only run the spawner every 3 seconds and detach from the terminal to become a daemon
34
- spinner -c '/path/to/app/script/process/spawner -p 9000 -i 10' -d # using custom spawner
35
- EOF
36
-
37
- opts.on(" Options:")
38
-
39
- opts.on("-c", "--command=path", String) { |OPTIONS[:command]| }
40
- opts.on("-i", "--interval=seconds", Float) { |OPTIONS[:interval]| }
41
- opts.on("-d", "--daemon") { |OPTIONS[:daemon]| }
42
-
43
- opts.separator ""
44
-
45
- opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
46
-
47
- opts.parse!
48
- end
49
-
50
- daemonize if OPTIONS[:daemon]
51
-
52
- trap(OPTIONS[:daemon] ? "TERM" : "INT") { exit }
53
-
54
- loop do
55
- system(OPTIONS[:command])
56
- sleep(OPTIONS[:interval])
57
- end
@@ -1,27 +0,0 @@
1
- require 'optparse'
2
-
3
- options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
4
-
5
- ARGV.options do |opts|
6
- script_name = File.basename($0)
7
- opts.banner = "Usage: runner 'puts Person.find(1).name' [options]"
8
-
9
- opts.separator ""
10
-
11
- opts.on("-e", "--environment=name", String,
12
- "Specifies the environment for the runner to operate under (test/development/production).",
13
- "Default: development") { |options[:environment]| }
14
-
15
- opts.separator ""
16
-
17
- opts.on("-h", "--help",
18
- "Show this help message.") { puts opts; exit }
19
-
20
- opts.parse!
21
- end
22
-
23
- ENV["RAILS_ENV"] = options[:environment]
24
- RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
25
-
26
- require RAILS_ROOT + '/config/environment'
27
- eval(ARGV.first)
@@ -1,28 +0,0 @@
1
- require 'active_support'
2
-
3
- begin
4
- require_library_or_gem 'fcgi'
5
- rescue Exception
6
- # FCGI not available
7
- end
8
-
9
- server = case ARGV.first
10
- when "lighttpd"
11
- ARGV.shift
12
- when "webrick"
13
- ARGV.shift
14
- else
15
- if RUBY_PLATFORM !~ /mswin/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI)
16
- "lighttpd"
17
- else
18
- "webrick"
19
- end
20
- end
21
-
22
- if server == "webrick"
23
- puts "=> Booting WEBrick..."
24
- else
25
- puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
26
- end
27
-
28
- require "commands/servers/#{server}"
@@ -1,60 +0,0 @@
1
- unless RUBY_PLATFORM !~ /mswin/ && !silence_stderr { `lighttpd -version` }.blank?
2
- puts "PROBLEM: Lighttpd is not available on your system (or not in your path)"
3
- exit 1
4
- end
5
-
6
- unless defined?(FCGI)
7
- puts "PROBLEM: Lighttpd requires that the FCGI Ruby bindings are installed on the system"
8
- exit 1
9
- end
10
-
11
- require 'initializer'
12
- configuration = Rails::Initializer.run(:initialize_logger).configuration
13
-
14
- config_file = "#{RAILS_ROOT}/config/lighttpd.conf"
15
-
16
- unless File.exist?(config_file)
17
- require 'fileutils'
18
- source = File.expand_path(File.join(File.dirname(__FILE__),
19
- "..", "..", "..", "configs", "lighttpd.conf"))
20
- puts "=> #{config_file} not found, copying from #{source}"
21
- FileUtils.cp source, config_file
22
- end
23
-
24
- config = IO.read(config_file)
25
- default_port, default_ip = 3000, '0.0.0.0'
26
- port = config.scan(/^\s*server.port\s*=\s*(\d+)/).first rescue default_port
27
- ip = config.scan(/^\s*server.bind\s*=\s*"([^"]+)"/).first rescue default_ip
28
- puts "=> Rails application started on http://#{ip || default_ip}:#{port || default_port}"
29
-
30
- tail_thread = nil
31
-
32
- if ARGV.first == "-d"
33
- puts "=> Configure in config/lighttpd.conf"
34
- detach = true
35
- else
36
- puts "=> Call with -d to detach (requires absolute paths in config/lighttpd.conf)"
37
- puts "=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)"
38
- detach = false
39
-
40
- cursor = File.size(configuration.log_path)
41
- last_checked = Time.now
42
- tail_thread = Thread.new do
43
- File.open(configuration.log_path, 'r') do |f|
44
- loop do
45
- f.seek cursor
46
- if f.mtime > last_checked
47
- last_checked = f.mtime
48
- contents = f.read
49
- cursor += contents.length
50
- print contents
51
- end
52
- sleep 1
53
- end
54
- end
55
- end
56
- end
57
-
58
- trap(:INT) { exit }
59
- `lighttpd #{!detach ? "-D " : ""}-f #{config_file}`
60
- tail_thread.kill if tail_thread
@@ -1,59 +0,0 @@
1
- require 'webrick'
2
- require 'optparse'
3
-
4
- OPTIONS = {
5
- :port => 3000,
6
- :ip => "0.0.0.0",
7
- :environment => (ENV['RAILS_ENV'] || "development").dup,
8
- :server_root => File.expand_path(RAILS_ROOT + "/public/"),
9
- :server_type => WEBrick::SimpleServer,
10
- :charset => "UTF-8",
11
- :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes
12
- }
13
-
14
- ARGV.options do |opts|
15
- script_name = File.basename($0)
16
- opts.banner = "Usage: ruby #{script_name} [options]"
17
-
18
- opts.separator ""
19
-
20
- opts.on("-p", "--port=port", Integer,
21
- "Runs Rails on the specified port.",
22
- "Default: 3000") { |OPTIONS[:port]| }
23
- opts.on("-b", "--binding=ip", String,
24
- "Binds Rails to the specified ip.",
25
- "Default: 0.0.0.0") { |OPTIONS[:ip]| }
26
- opts.on("-e", "--environment=name", String,
27
- "Specifies the environment to run this server under (test/development/production).",
28
- "Default: development") { |OPTIONS[:environment]| }
29
- opts.on("-m", "--mime-types=filename", String,
30
- "Specifies an Apache style mime.types configuration file to be used for mime types",
31
- "Default: none") { |mime_types_file| OPTIONS[:mime_types] = WEBrick::HTTPUtils::load_mime_types(mime_types_file) }
32
-
33
- opts.on("-d", "--daemon",
34
- "Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)."
35
- ) { OPTIONS[:server_type] = WEBrick::Daemon }
36
-
37
- opts.on("-c", "--charset=charset", String,
38
- "Set default charset for output.",
39
- "Default: UTF-8") { |OPTIONS[:charset]| }
40
-
41
- opts.separator ""
42
-
43
- opts.on("-h", "--help",
44
- "Show this help message.") { puts opts; exit }
45
-
46
- opts.parse!
47
- end
48
-
49
- ENV["RAILS_ENV"] = OPTIONS[:environment]
50
- RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV)
51
-
52
- require RAILS_ROOT + "/config/environment"
53
- require 'webrick_server'
54
-
55
- OPTIONS['working_directory'] = File.expand_path(RAILS_ROOT)
56
-
57
- puts "=> Rails application started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
58
- puts "=> Ctrl-C to shutdown server; call with --help for options" if OPTIONS[:server_type] == WEBrick::SimpleServer
59
- DispatchServlet.dispatch(OPTIONS)
@@ -1,4 +0,0 @@
1
- require "#{RAILS_ROOT}/config/environment"
2
- require 'rails_generator'
3
- require 'rails_generator/scripts/update'
4
- Rails::Generator::Scripts::Update.new.run(ARGV)
data/lib/commands.rb DELETED
@@ -1,17 +0,0 @@
1
- commands = Dir["#{File.dirname(__FILE__)}/commands/*.rb"].collect { |file_path| File.basename(file_path).split(".").first }
2
-
3
- if commands.include?(ARGV.first)
4
- require "#{File.dirname(__FILE__)}/commands/#{ARGV.shift}"
5
- else
6
- puts <<-USAGE
7
- The 'run' provides a unified access point for all the default Rails' commands.
8
-
9
- Usage: ./script/run <command> [OPTIONS]
10
-
11
- Examples:
12
- ./script/run generate controller Admin
13
- ./script/run process reaper
14
-
15
- USAGE
16
- puts "Choose: #{commands.join(", ")}"
17
- end
@@ -1,6 +0,0 @@
1
- ActiveRecord::Base.lock_mutex
2
- ActiveRecord::Base.connection.begin_db_transaction
3
- at_exit do
4
- ActiveRecord::Base.connection.rollback_db_transaction
5
- ActiveRecord::Base.unlock_mutex
6
- end
data/lib/dispatcher.rb DELETED
@@ -1,99 +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
- # This class provides an interface for dispatching a CGI (or CGI-like) request
25
- # to the appropriate controller and action. It also takes care of resetting
26
- # the environment (when Dependencies.load? is true) after each request.
27
- class Dispatcher
28
- class << self
29
-
30
- # Dispatch the given CGI request, using the given session options, and
31
- # emitting the output via the given output. If you dispatch with your
32
- # own CGI object be sure to handle the exceptions it raises on multipart
33
- # requests (EOFError and ArgumentError).
34
- def dispatch(cgi = nil, session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, output = $stdout)
35
- if cgi ||= new_cgi(output)
36
- request, response = ActionController::CgiRequest.new(cgi, session_options), ActionController::CgiResponse.new(cgi)
37
- prepare_application
38
- ActionController::Routing::Routes.recognize!(request).process(request, response).out(output)
39
- end
40
- rescue Object => exception
41
- failsafe_response(output, '500 Internal Server Error') do
42
- ActionController::Base.process_with_exception(request, response, exception).out(output)
43
- end
44
- ensure
45
- # Do not give a failsafe response here.
46
- reset_after_dispatch
47
- end
48
-
49
- # Reset the application by clearing out loaded controllers, views, actions,
50
- # mailers, and so forth. This allows them to be loaded again without having
51
- # to restart the server (WEBrick, FastCGI, etc.).
52
- def reset_application!
53
- Controllers.clear!
54
- Dependencies.clear
55
- ActiveRecord::Base.reset_subclasses
56
- Dependencies.remove_subclasses_for(ActiveRecord::Base, ActiveRecord::Observer, ActionController::Base)
57
- Dependencies.remove_subclasses_for(ActionMailer::Base) if defined?(ActionMailer::Base)
58
- end
59
-
60
- private
61
- # CGI.new plus exception handling. CGI#read_multipart raises EOFError
62
- # if body.empty? or body.size != Content-Length and raises ArgumentError
63
- # if Content-Length is non-integer.
64
- def new_cgi(output)
65
- failsafe_response(output, '400 Bad Request') { CGI.new }
66
- end
67
-
68
- def prepare_application
69
- ActionController::Routing::Routes.reload if Dependencies.load?
70
- prepare_breakpoint
71
- Controllers.const_load!(:ApplicationController, "application") unless Controllers.const_defined?(:ApplicationController)
72
- end
73
-
74
- def reset_after_dispatch
75
- reset_application! if Dependencies.load?
76
- ActiveRecord::Base.clear_connection_cache!
77
- Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
78
- end
79
-
80
- def prepare_breakpoint
81
- return unless defined?(BREAKPOINT_SERVER_PORT)
82
- require 'breakpoint'
83
- Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI))
84
- true
85
- rescue
86
- nil
87
- end
88
-
89
- # If the block raises, send status code as a last-ditch response.
90
- def failsafe_response(output, status)
91
- yield
92
- rescue Object
93
- begin
94
- output.write "Status: #{status}\r\n"
95
- rescue Object
96
- end
97
- end
98
- end
99
- end