rails 1.2.6 → 2.0.0
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.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +491 -12
- data/MIT-LICENSE +1 -1
- data/README +17 -25
- data/Rakefile +41 -18
- data/bin/about +1 -1
- data/bin/console +1 -1
- data/bin/destroy +1 -1
- data/bin/generate +1 -1
- data/bin/performance/request +3 -0
- data/bin/plugin +1 -1
- data/bin/runner +1 -1
- data/bin/server +1 -1
- data/builtin/rails_info/rails/info.rb +2 -2
- data/configs/apache.conf +1 -1
- data/configs/databases/mysql.yml +9 -3
- data/configs/databases/postgresql.yml +16 -12
- data/configs/initializers/inflections.rb +10 -0
- data/configs/initializers/mime_types.rb +5 -0
- data/configs/routes.rb +23 -11
- data/doc/README_FOR_APP +1 -1
- data/environments/boot.rb +95 -26
- data/environments/development.rb +2 -5
- data/environments/environment.rb +24 -25
- data/environments/test.rb +4 -1
- data/helpers/application.rb +5 -2
- data/helpers/test_helper.rb +10 -0
- data/html/422.html +30 -0
- data/html/500.html +1 -1
- data/html/index.html +2 -2
- data/html/javascripts/controls.js +484 -354
- data/html/javascripts/dragdrop.js +88 -58
- data/html/javascripts/effects.js +396 -364
- data/html/javascripts/prototype.js +2817 -1107
- data/html/robots.txt +5 -1
- data/lib/commands/console.rb +12 -5
- data/lib/commands/performance/request.rb +6 -0
- data/lib/commands/plugin.rb +15 -10
- data/lib/commands/process/spawner.rb +14 -4
- data/lib/commands/servers/base.rb +12 -0
- data/lib/commands/servers/mongrel.rb +5 -1
- data/lib/commands/servers/webrick.rb +14 -7
- data/lib/console_app.rb +5 -2
- data/lib/console_with_helpers.rb +5 -2
- data/lib/dispatcher.rb +3 -151
- data/lib/fcgi_handler.rb +79 -81
- data/lib/initializer.rb +125 -169
- data/lib/rails/plugin.rb +84 -0
- data/lib/rails/plugin/loader.rb +150 -0
- data/lib/rails/plugin/locator.rb +78 -0
- data/lib/rails/version.rb +3 -3
- data/lib/rails_generator/base.rb +11 -9
- data/lib/rails_generator/commands.rb +20 -10
- data/lib/rails_generator/generators/applications/app/USAGE +0 -7
- data/lib/rails_generator/generators/applications/app/app_generator.rb +25 -6
- data/lib/rails_generator/generators/components/controller/USAGE +11 -12
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +2 -2
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +1 -11
- data/lib/rails_generator/generators/components/controller/templates/{view.rhtml → view.html.erb} +0 -0
- data/lib/rails_generator/generators/components/integration_test/USAGE +5 -11
- data/lib/rails_generator/generators/components/mailer/USAGE +8 -10
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +3 -3
- data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +3 -0
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +8 -24
- data/lib/rails_generator/generators/components/mailer/templates/view.erb +3 -0
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -3
- data/lib/rails_generator/generators/components/migration/USAGE +23 -8
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +15 -2
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +6 -2
- data/lib/rails_generator/generators/components/model/USAGE +15 -14
- data/lib/rails_generator/generators/components/model/model_generator.rb +10 -3
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +11 -3
- data/lib/rails_generator/generators/components/model/templates/migration.rb +4 -1
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +1 -3
- data/lib/rails_generator/generators/components/observer/USAGE +5 -7
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -2
- data/lib/rails_generator/generators/components/plugin/USAGE +8 -18
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +1 -0
- data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +20 -0
- data/lib/rails_generator/generators/components/plugin/templates/README +10 -1
- data/lib/rails_generator/generators/components/plugin/templates/USAGE +1 -1
- data/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -1
- data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -1
- data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +1 -1
- data/lib/rails_generator/generators/components/resource/USAGE +23 -0
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +13 -15
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +1 -1
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +2 -14
- data/lib/rails_generator/generators/components/scaffold/USAGE +24 -31
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +45 -146
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +64 -37
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +23 -80
- data/lib/rails_generator/generators/components/scaffold/templates/{layout.rhtml → layout.html.erb} +0 -0
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +1 -1
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_edit.rhtml → scaffold/templates/view_edit.html.erb} +4 -4
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_index.rhtml → scaffold/templates/view_index.html.erb} +4 -4
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_new.rhtml → scaffold/templates/view_new.html.erb} +3 -3
- data/lib/rails_generator/generators/components/{scaffold_resource/templates/view_show.rhtml → scaffold/templates/view_show.html.erb} +1 -1
- data/lib/rails_generator/generators/components/session_migration/USAGE +6 -11
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +3 -3
- data/lib/rails_generator/lookup.rb +45 -10
- data/lib/rails_generator/scripts.rb +6 -3
- data/lib/rails_generator/scripts/destroy.rb +23 -0
- data/lib/rails_generator/secret_key_generator.rb +160 -0
- data/lib/rails_generator/spec.rb +1 -1
- data/lib/source_annotation_extractor.rb +62 -0
- data/lib/tasks/annotations.rake +23 -0
- data/lib/tasks/databases.rake +249 -83
- data/lib/tasks/documentation.rake +11 -13
- data/lib/tasks/framework.rake +1 -1
- data/lib/tasks/rails.rb +1 -1
- data/lib/tasks/testing.rake +5 -7
- data/lib/test_help.rb +4 -3
- data/lib/webrick_server.rb +3 -4
- metadata +31 -49
- data/bin/breakpointer +0 -3
- data/lib/binding_of_caller.rb +0 -85
- data/lib/breakpoint.rb +0 -553
- data/lib/breakpoint_client.rb +0 -196
- data/lib/commands/breakpointer.rb +0 -1
- data/lib/rails_generator/generators/components/resource/templates/USAGE +0 -18
- data/lib/rails_generator/generators/components/resource/templates/fixtures.yml +0 -11
- data/lib/rails_generator/generators/components/resource/templates/migration.rb +0 -13
- data/lib/rails_generator/generators/components/resource/templates/model.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/unit_test.rb +0 -10
- data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +0 -3
- data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +0 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +0 -9
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +0 -27
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +0 -8
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +0 -8
- data/lib/rails_generator/generators/components/scaffold_resource/USAGE +0 -29
- data/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +0 -93
- data/lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb +0 -79
- data/lib/rails_generator/generators/components/scaffold_resource/templates/fixtures.yml +0 -11
- data/lib/rails_generator/generators/components/scaffold_resource/templates/functional_test.rb +0 -57
- data/lib/rails_generator/generators/components/scaffold_resource/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml +0 -17
- data/lib/rails_generator/generators/components/scaffold_resource/templates/migration.rb +0 -13
- data/lib/rails_generator/generators/components/scaffold_resource/templates/model.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold_resource/templates/style.css +0 -74
- data/lib/rails_generator/generators/components/scaffold_resource/templates/unit_test.rb +0 -10
- data/lib/rails_generator/generators/components/web_service/USAGE +0 -28
- data/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +0 -5
- data/lib/rails_generator/generators/components/web_service/templates/controller.rb +0 -8
- data/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +0 -19
- data/lib/rails_generator/generators/components/web_service/web_service_generator.rb +0 -29
- data/lib/tasks/pre_namespace_aliases.rake +0 -53
    
        data/html/robots.txt
    CHANGED
    
    | @@ -1 +1,5 @@ | |
| 1 | 
            -
            # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
         | 
| 1 | 
            +
            # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # To ban all spiders from the entire site uncomment the next two lines:
         | 
| 4 | 
            +
            # User-Agent: *
         | 
| 5 | 
            +
            # Disallow: /
         | 
    
        data/lib/commands/console.rb
    CHANGED
    
    | @@ -10,16 +10,23 @@ OptionParser.new do |opt| | |
| 10 10 | 
             
            end
         | 
| 11 11 |  | 
| 12 12 | 
             
            libs =  " -r irb/completion"
         | 
| 13 | 
            -
            libs <<  | 
| 13 | 
            +
            libs << %( -r "#{RAILS_ROOT}/config/environment")
         | 
| 14 14 | 
             
            libs << " -r console_app"
         | 
| 15 15 | 
             
            libs << " -r console_sandbox" if options[:sandbox]
         | 
| 16 16 | 
             
            libs << " -r console_with_helpers"
         | 
| 17 17 |  | 
| 18 | 
            -
            ENV['RAILS_ENV'] = ARGV.first | 
| 18 | 
            +
            ENV['RAILS_ENV'] = case ARGV.first
         | 
| 19 | 
            +
              when "p": "production"
         | 
| 20 | 
            +
              when "d": "development"
         | 
| 21 | 
            +
              when "t": "test"
         | 
| 22 | 
            +
              else
         | 
| 23 | 
            +
                ARGV.first || ENV['RAILS_ENV'] || 'development'
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
             | 
| 19 26 | 
             
            if options[:sandbox]
         | 
| 20 | 
            -
              puts "Loading #{ENV['RAILS_ENV']} environment in sandbox | 
| 21 | 
            -
              puts "Any modifications you make will be rolled back on exit | 
| 27 | 
            +
              puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails::VERSION::STRING})"
         | 
| 28 | 
            +
              puts "Any modifications you make will be rolled back on exit"
         | 
| 22 29 | 
             
            else
         | 
| 23 | 
            -
              puts "Loading #{ENV['RAILS_ENV']} environment | 
| 30 | 
            +
              puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails::VERSION::STRING})"
         | 
| 24 31 | 
             
            end
         | 
| 25 32 | 
             
            exec "#{options[:irb]} #{libs} --simple-prompt"
         | 
    
        data/lib/commands/plugin.rb
    CHANGED
    
    | @@ -91,7 +91,7 @@ class RailsEnvironment | |
| 91 91 | 
             
                unless plugin.nil?
         | 
| 92 92 | 
             
                  plugin.install
         | 
| 93 93 | 
             
                else
         | 
| 94 | 
            -
                  puts " | 
| 94 | 
            +
                  puts "Plugin not found: #{name_uri_or_plugin}"
         | 
| 95 95 | 
             
                end
         | 
| 96 96 | 
             
              end
         | 
| 97 97 |  | 
| @@ -239,10 +239,10 @@ class Plugin | |
| 239 239 |  | 
| 240 240 | 
             
                def install_using_http(options = {})
         | 
| 241 241 | 
             
                  root = rails_env.root
         | 
| 242 | 
            -
                  mkdir_p "#{root}/vendor/plugins"
         | 
| 243 | 
            -
                  Dir.chdir "#{root}/vendor/plugins" do
         | 
| 242 | 
            +
                  mkdir_p "#{root}/vendor/plugins/#{@name}"
         | 
| 243 | 
            +
                  Dir.chdir "#{root}/vendor/plugins/#{@name}" do
         | 
| 244 244 | 
             
                    puts "fetching from '#{uri}'" if $verbose
         | 
| 245 | 
            -
                    fetcher = RecursiveHTTPFetcher.new(uri)
         | 
| 245 | 
            +
                    fetcher = RecursiveHTTPFetcher.new(uri, -1)
         | 
| 246 246 | 
             
                    fetcher.quiet = true if options[:quiet]
         | 
| 247 247 | 
             
                    fetcher.fetch
         | 
| 248 248 | 
             
                  end
         | 
| @@ -515,7 +515,7 @@ module Commands | |
| 515 515 | 
             
                    o.on(         "--local", 
         | 
| 516 516 | 
             
                                  "List locally installed plugins.") {|@local| @remote = false}
         | 
| 517 517 | 
             
                    o.on(         "--remote",
         | 
| 518 | 
            -
                                  "List remotely  | 
| 518 | 
            +
                                  "List remotely available plugins. This is the default behavior",
         | 
| 519 519 | 
             
                                  "unless --local is provided.") {|@remote|}
         | 
| 520 520 | 
             
                  end
         | 
| 521 521 | 
             
                end
         | 
| @@ -765,8 +765,9 @@ module Commands | |
| 765 765 | 
             
                  args.each do |name|
         | 
| 766 766 | 
             
                    ::Plugin.find(name).install(install_method, @options)
         | 
| 767 767 | 
             
                  end
         | 
| 768 | 
            -
                rescue
         | 
| 768 | 
            +
                rescue StandardError => e
         | 
| 769 769 | 
             
                  puts "Plugin not found: #{args.inspect}"
         | 
| 770 | 
            +
                  puts e.inspect if $verbose
         | 
| 770 771 | 
             
                  exit 1
         | 
| 771 772 | 
             
                end
         | 
| 772 773 | 
             
              end
         | 
| @@ -853,7 +854,8 @@ end | |
| 853 854 |  | 
| 854 855 | 
             
            class RecursiveHTTPFetcher
         | 
| 855 856 | 
             
              attr_accessor :quiet
         | 
| 856 | 
            -
              def initialize(urls_to_fetch, cwd = ".")
         | 
| 857 | 
            +
              def initialize(urls_to_fetch, level = 1, cwd = ".")
         | 
| 858 | 
            +
                @level = level
         | 
| 857 859 | 
             
                @cwd = cwd
         | 
| 858 860 | 
             
                @urls_to_fetch = urls_to_fetch.to_a
         | 
| 859 861 | 
             
                @quiet = false
         | 
| @@ -884,7 +886,8 @@ class RecursiveHTTPFetcher | |
| 884 886 | 
             
                links = []
         | 
| 885 887 | 
             
                contents.scan(/href\s*=\s*\"*[^\">]*/i) do |link|
         | 
| 886 888 | 
             
                  link = link.sub(/href="/i, "")
         | 
| 887 | 
            -
                  next if link =~  | 
| 889 | 
            +
                  next if link =~ /svnindex.xsl$/
         | 
| 890 | 
            +
                  next if link =~ /^(\w*:|)\/\// || link =~ /^\./
         | 
| 888 891 | 
             
                  links << File.join(base_url, link)
         | 
| 889 892 | 
             
                end
         | 
| 890 893 | 
             
                links
         | 
| @@ -906,12 +909,14 @@ class RecursiveHTTPFetcher | |
| 906 909 | 
             
              end
         | 
| 907 910 |  | 
| 908 911 | 
             
              def fetch_dir(url)
         | 
| 909 | 
            -
                 | 
| 912 | 
            +
                @level += 1
         | 
| 913 | 
            +
                push_d(File.basename(url)) if @level > 0
         | 
| 910 914 | 
             
                open(url) do |stream|
         | 
| 911 915 | 
             
                  contents =  stream.read
         | 
| 912 916 | 
             
                  fetch(links(url, contents))
         | 
| 913 917 | 
             
                end
         | 
| 914 | 
            -
                pop_d
         | 
| 918 | 
            +
                pop_d if @level > 0
         | 
| 919 | 
            +
                @level -= 1
         | 
| 915 920 | 
             
              end
         | 
| 916 921 | 
             
            end
         | 
| 917 922 |  | 
| @@ -65,6 +65,14 @@ class MongrelSpawner < Spawner | |
| 65 65 | 
             
                  "-c #{OPTIONS[:rails_root]} " +
         | 
| 66 66 | 
             
                  "-l #{OPTIONS[:rails_root]}/log/mongrel.log"
         | 
| 67 67 |  | 
| 68 | 
            +
                # Add prefix functionality to spawner's call to mongrel_rails
         | 
| 69 | 
            +
                # Digging through monrel's project subversion server, the earliest
         | 
| 70 | 
            +
                # Tag that has prefix implemented in the bin/mongrel_rails file
         | 
| 71 | 
            +
                # is 0.3.15 which also happens to be the earilest tag listed.
         | 
| 72 | 
            +
                # References: http://mongrel.rubyforge.org/svn/tags
         | 
| 73 | 
            +
                if Mongrel::Const::MONGREL_VERSION.to_f >=0.3 && !OPTIONS[:prefix].nil?
         | 
| 74 | 
            +
                  cmd = cmd + " --prefix #{OPTIONS[:prefix]}"
         | 
| 75 | 
            +
                end
         | 
| 68 76 | 
             
                system(cmd)
         | 
| 69 77 | 
             
              end
         | 
| 70 78 |  | 
| @@ -114,14 +122,15 @@ end | |
| 114 122 | 
             
            OPTIONS = {
         | 
| 115 123 | 
             
              :environment => "production",
         | 
| 116 124 | 
             
              :spawner     => '/usr/bin/env spawn-fcgi',
         | 
| 117 | 
            -
              :dispatcher  => File.expand_path( | 
| 118 | 
            -
              :pids        => File.expand_path( | 
| 119 | 
            -
              :rails_root  => File.expand_path( | 
| 125 | 
            +
              :dispatcher  => File.expand_path(RELATIVE_RAILS_ROOT + '/public/dispatch.fcgi'),
         | 
| 126 | 
            +
              :pids        => File.expand_path(RELATIVE_RAILS_ROOT + "/tmp/pids"),
         | 
| 127 | 
            +
              :rails_root  => File.expand_path(RELATIVE_RAILS_ROOT),
         | 
| 120 128 | 
             
              :process     => "dispatch",
         | 
| 121 129 | 
             
              :port        => 8000,
         | 
| 122 130 | 
             
              :address     => '0.0.0.0',
         | 
| 123 131 | 
             
              :instances   => 3,
         | 
| 124 | 
            -
              :repeat      => nil
         | 
| 132 | 
            +
              :repeat      => nil,
         | 
| 133 | 
            +
              :prefix      => nil
         | 
| 125 134 | 
             
            }
         | 
| 126 135 |  | 
| 127 136 | 
             
            ARGV.options do |opts|
         | 
| @@ -182,6 +191,7 @@ ARGV.options do |opts| | |
| 182 191 | 
             
              opts.on("-i", "--instances=number", Integer, "Number of instances (default: #{OPTIONS[:instances]})")            { |v| OPTIONS[:instances] = v }
         | 
| 183 192 | 
             
              opts.on("-r", "--repeat=seconds",   Integer, "Repeat spawn attempts every n seconds (default: off)")             { |v| OPTIONS[:repeat] = v }
         | 
| 184 193 | 
             
              opts.on("-e", "--environment=name", String,  "test|development|production (default: #{OPTIONS[:environment]})")  { |v| OPTIONS[:environment] = v }
         | 
| 194 | 
            +
              opts.on("-P", "--prefix=path",      String,  "URL prefix for Rails app. [Used only with Mongrel > v0.3.15]: (default: #{OPTIONS[:prefix]})")         { |v| OPTIONS[:prefix] = v }
         | 
| 185 195 | 
             
              opts.on("-n", "--process=name",     String,  "default: #{OPTIONS[:process]}")                                    { |v| OPTIONS[:process] = v }
         | 
| 186 196 | 
             
              opts.on("-s", "--spawner=path",     String,  "default: #{OPTIONS[:spawner]}")                                    { |v| OPTIONS[:spawner] = v }
         | 
| 187 197 | 
             
              opts.on("-d", "--dispatcher=path",  String,  "default: #{OPTIONS[:dispatcher]}") { |dispatcher| OPTIONS[:dispatcher] = File.expand_path(dispatcher) }
         | 
| @@ -17,3 +17,15 @@ def tail(log_file) | |
| 17 17 | 
             
              end
         | 
| 18 18 | 
             
              tail_thread
         | 
| 19 19 | 
             
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            def start_debugger
         | 
| 22 | 
            +
              begin
         | 
| 23 | 
            +
                require_library_or_gem 'ruby-debug'
         | 
| 24 | 
            +
                Debugger.start
         | 
| 25 | 
            +
                Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
         | 
| 26 | 
            +
                puts "=> Debugger enabled"
         | 
| 27 | 
            +
              rescue Exception
         | 
| 28 | 
            +
                puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
         | 
| 29 | 
            +
                exit
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -12,13 +12,15 @@ OPTIONS = { | |
| 12 12 | 
             
              :port        => 3000,
         | 
| 13 13 | 
             
              :ip          => "0.0.0.0",
         | 
| 14 14 | 
             
              :environment => (ENV['RAILS_ENV'] || "development").dup,
         | 
| 15 | 
            -
              :detach      => false
         | 
| 15 | 
            +
              :detach      => false,
         | 
| 16 | 
            +
              :debugger    => false
         | 
| 16 17 | 
             
            }
         | 
| 17 18 |  | 
| 18 19 | 
             
            ARGV.clone.options do |opts|
         | 
| 19 20 | 
             
              opts.on("-p", "--port=port", Integer, "Runs Rails on the specified port.", "Default: 3000") { |v| OPTIONS[:port] = v }
         | 
| 20 21 | 
             
              opts.on("-b", "--binding=ip", String, "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| OPTIONS[:ip] = v }
         | 
| 21 22 | 
             
              opts.on("-d", "--daemon", "Make server run as a Daemon.") { OPTIONS[:detach] = true }
         | 
| 23 | 
            +
              opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true }
         | 
| 22 24 | 
             
              opts.on("-e", "--environment=name", String,
         | 
| 23 25 | 
             
                      "Specifies the environment to run this server under (test/development/production).",
         | 
| 24 26 | 
             
                      "Default: development") { |v| OPTIONS[:environment] = v }
         | 
| @@ -46,6 +48,8 @@ else | |
| 46 48 | 
             
              ENV["RAILS_ENV"] = OPTIONS[:environment]
         | 
| 47 49 | 
             
              RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV)
         | 
| 48 50 |  | 
| 51 | 
            +
              start_debugger if OPTIONS[:debugger]
         | 
| 52 | 
            +
             | 
| 49 53 | 
             
              require 'initializer'
         | 
| 50 54 | 
             
              Rails::Initializer.run(:initialize_logger)
         | 
| 51 55 |  | 
| @@ -1,14 +1,17 @@ | |
| 1 1 | 
             
            require 'webrick'
         | 
| 2 2 | 
             
            require 'optparse'
         | 
| 3 | 
            +
            require 'commands/servers/base'
         | 
| 3 4 |  | 
| 4 5 | 
             
            OPTIONS = {
         | 
| 5 | 
            -
              :port | 
| 6 | 
            -
              :ip | 
| 7 | 
            -
              :environment | 
| 8 | 
            -
              :server_root | 
| 9 | 
            -
              :server_type | 
| 10 | 
            -
              :charset | 
| 11 | 
            -
              :mime_types | 
| 6 | 
            +
              :port         => 3000,
         | 
| 7 | 
            +
              :ip           => "0.0.0.0",
         | 
| 8 | 
            +
              :environment  => (ENV['RAILS_ENV'] || "development").dup,
         | 
| 9 | 
            +
              :server_root  => File.expand_path(RAILS_ROOT + "/public/"),
         | 
| 10 | 
            +
              :server_type  => WEBrick::SimpleServer,
         | 
| 11 | 
            +
              :charset      => "UTF-8",
         | 
| 12 | 
            +
              :mime_types   => WEBrick::HTTPUtils::DefaultMimeTypes,
         | 
| 13 | 
            +
              :debugger     => false
         | 
| 14 | 
            +
              
         | 
| 12 15 | 
             
            }
         | 
| 13 16 |  | 
| 14 17 | 
             
            ARGV.options do |opts|
         | 
| @@ -34,6 +37,8 @@ ARGV.options do |opts| | |
| 34 37 | 
             
                      "Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)."
         | 
| 35 38 | 
             
                      ) { OPTIONS[:server_type] = WEBrick::Daemon }
         | 
| 36 39 |  | 
| 40 | 
            +
              opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true }
         | 
| 41 | 
            +
             | 
| 37 42 | 
             
              opts.on("-c", "--charset=charset", String,
         | 
| 38 43 | 
             
                      "Set default charset for output.",
         | 
| 39 44 | 
             
                      "Default: UTF-8") { |v| OPTIONS[:charset] = v }
         | 
| @@ -46,6 +51,8 @@ ARGV.options do |opts| | |
| 46 51 | 
             
              opts.parse!
         | 
| 47 52 | 
             
            end
         | 
| 48 53 |  | 
| 54 | 
            +
            start_debugger if OPTIONS[:debugger]
         | 
| 55 | 
            +
             | 
| 49 56 | 
             
            ENV["RAILS_ENV"] = OPTIONS[:environment]
         | 
| 50 57 | 
             
            RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV)
         | 
| 51 58 |  | 
    
        data/lib/console_app.rb
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            require 'action_controller/integration'
         | 
| 2 2 |  | 
| 3 3 | 
             
            # work around the at_exit hook in test/unit, which kills IRB
         | 
| 4 | 
            -
            Test::Unit.run = true
         | 
| 4 | 
            +
            Test::Unit.run = true if Test::Unit.respond_to?(:run=)
         | 
| 5 5 |  | 
| 6 6 | 
             
            # reference the global "app" instance, created on demand. To recreate the
         | 
| 7 7 | 
             
            # instance, pass a non-false value as the parameter.
         | 
| @@ -23,5 +23,8 @@ end | |
| 23 23 | 
             
            #reloads the environment
         | 
| 24 24 | 
             
            def reload!
         | 
| 25 25 | 
             
              puts "Reloading..."
         | 
| 26 | 
            -
              Dispatcher. | 
| 26 | 
            +
              dispatcher = ActionController::Dispatcher.new($stdout)
         | 
| 27 | 
            +
              dispatcher.cleanup_application(true)
         | 
| 28 | 
            +
              dispatcher.prepare_application(true)
         | 
| 29 | 
            +
              true
         | 
| 27 30 | 
             
            end
         | 
    
        data/lib/console_with_helpers.rb
    CHANGED
    
    | @@ -10,8 +10,10 @@ class Module | |
| 10 10 | 
             
              end
         | 
| 11 11 | 
             
            end
         | 
| 12 12 |  | 
| 13 | 
            -
            def helper
         | 
| 14 | 
            -
              @helper_proxy ||= Object.new 
         | 
| 13 | 
            +
            def helper(*helper_names)
         | 
| 14 | 
            +
              returning @helper_proxy ||= Object.new do |helper|
         | 
| 15 | 
            +
                helper_names.each { |h| helper.extend "#{h}_helper".classify.constantize }
         | 
| 16 | 
            +
              end
         | 
| 15 17 | 
             
            end
         | 
| 16 18 |  | 
| 17 19 | 
             
            require 'application'
         | 
| @@ -21,3 +23,4 @@ class << helper | |
| 21 23 | 
             
            end
         | 
| 22 24 |  | 
| 23 25 | 
             
            @controller = ApplicationController.new
         | 
| 26 | 
            +
            helper :application rescue nil
         | 
    
        data/lib/dispatcher.rb
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            #--
         | 
| 2 | 
            -
            # Copyright (c) 2004- | 
| 2 | 
            +
            # Copyright (c) 2004-2007 David Heinemeier Hansson
         | 
| 3 3 | 
             
            #
         | 
| 4 4 | 
             
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 5 5 | 
             
            # a copy of this software and associated documentation files (the
         | 
| @@ -20,153 +20,5 @@ | |
| 20 20 | 
             
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 21 21 | 
             
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 22 22 | 
             
            #++
         | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 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 | 
            -
              
         | 
| 29 | 
            -
              class << self
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                # Dispatch the given CGI request, using the given session options, and
         | 
| 32 | 
            -
                # emitting the output via the given output.  If you dispatch with your
         | 
| 33 | 
            -
                # own CGI object be sure to handle the exceptions it raises on multipart
         | 
| 34 | 
            -
                # requests (EOFError and ArgumentError).
         | 
| 35 | 
            -
                def dispatch(cgi = nil, session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, output = $stdout)
         | 
| 36 | 
            -
                  controller = nil
         | 
| 37 | 
            -
                  if cgi ||= new_cgi(output)
         | 
| 38 | 
            -
                    request, response = ActionController::CgiRequest.new(cgi, session_options), ActionController::CgiResponse.new(cgi)
         | 
| 39 | 
            -
                    prepare_application
         | 
| 40 | 
            -
                    controller = ActionController::Routing::Routes.recognize(request)
         | 
| 41 | 
            -
                    controller.process(request, response).out(output)
         | 
| 42 | 
            -
                  end
         | 
| 43 | 
            -
                rescue Exception => exception  # errors from CGI dispatch
         | 
| 44 | 
            -
                  failsafe_response(output, '500 Internal Server Error', exception) do
         | 
| 45 | 
            -
                    controller ||= (ApplicationController rescue ActionController::Base)
         | 
| 46 | 
            -
                    controller.process_with_exception(request, response, exception).out(output)
         | 
| 47 | 
            -
                  end
         | 
| 48 | 
            -
                ensure
         | 
| 49 | 
            -
                  # Do not give a failsafe response here.
         | 
| 50 | 
            -
                  reset_after_dispatch
         | 
| 51 | 
            -
                end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                # Reset the application by clearing out loaded controllers, views, actions,
         | 
| 54 | 
            -
                # mailers, and so forth. This allows them to be loaded again without having
         | 
| 55 | 
            -
                # to restart the server (WEBrick, FastCGI, etc.).
         | 
| 56 | 
            -
                def reset_application!
         | 
| 57 | 
            -
                  ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                  Dependencies.clear
         | 
| 60 | 
            -
                  ActiveSupport::Deprecation.silence do # TODO: Remove after 1.2
         | 
| 61 | 
            -
                    Class.remove_class(*Reloadable.reloadable_classes)
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
                    
         | 
| 64 | 
            -
                  ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
         | 
| 65 | 
            -
                end
         | 
| 66 | 
            -
                
         | 
| 67 | 
            -
                # Add a preparation callback. Preparation callbacks are run before every
         | 
| 68 | 
            -
                # request in development mode, and before the first request in production
         | 
| 69 | 
            -
                # mode.
         | 
| 70 | 
            -
                # 
         | 
| 71 | 
            -
                # An optional identifier may be supplied for the callback. If provided,
         | 
| 72 | 
            -
                # to_prepare may be called again with the same identifier to replace the
         | 
| 73 | 
            -
                # existing callback. Passing an identifier is a suggested practice if the
         | 
| 74 | 
            -
                # code adding a preparation block may be reloaded.
         | 
| 75 | 
            -
                def to_prepare(identifier = nil, &block)
         | 
| 76 | 
            -
                  unless identifier.nil?
         | 
| 77 | 
            -
                    callback = preparation_callbacks.detect { |ident, _| ident == identifier }
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                    if callback # Already registered: update the existing callback
         | 
| 80 | 
            -
                      callback[-1] = block
         | 
| 81 | 
            -
                      return
         | 
| 82 | 
            -
                    end
         | 
| 83 | 
            -
                  end
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                  preparation_callbacks << [identifier, block]
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                  return
         | 
| 88 | 
            -
                end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                private
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                  attr_accessor :preparation_callbacks, :preparation_callbacks_run
         | 
| 93 | 
            -
                  alias_method :preparation_callbacks_run?, :preparation_callbacks_run
         | 
| 94 | 
            -
                  
         | 
| 95 | 
            -
                  # CGI.new plus exception handling.  CGI#read_multipart raises EOFError
         | 
| 96 | 
            -
                  # if body.empty? or body.size != Content-Length and raises ArgumentError
         | 
| 97 | 
            -
                  # if Content-Length is non-integer.
         | 
| 98 | 
            -
                  def new_cgi(output)
         | 
| 99 | 
            -
                    failsafe_response(output, '400 Bad Request') { CGI.new }
         | 
| 100 | 
            -
                  end
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                  def prepare_application
         | 
| 103 | 
            -
                    if Dependencies.load?
         | 
| 104 | 
            -
                      ActionController::Routing::Routes.reload
         | 
| 105 | 
            -
                      self.preparation_callbacks_run = false
         | 
| 106 | 
            -
                    end
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                    prepare_breakpoint
         | 
| 109 | 
            -
                    require_dependency 'application' unless Object.const_defined?(:ApplicationController)
         | 
| 110 | 
            -
                    ActiveRecord::Base.verify_active_connections! if defined?(ActiveRecord)
         | 
| 111 | 
            -
                    run_preparation_callbacks
         | 
| 112 | 
            -
                  end
         | 
| 113 | 
            -
             | 
| 114 | 
            -
                  def reset_after_dispatch
         | 
| 115 | 
            -
                    reset_application! if Dependencies.load?
         | 
| 116 | 
            -
                    Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
         | 
| 117 | 
            -
                  end
         | 
| 118 | 
            -
             | 
| 119 | 
            -
                  def prepare_breakpoint
         | 
| 120 | 
            -
                    return unless defined?(BREAKPOINT_SERVER_PORT)
         | 
| 121 | 
            -
                    require 'breakpoint'
         | 
| 122 | 
            -
                    Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI))
         | 
| 123 | 
            -
                    true
         | 
| 124 | 
            -
                  rescue
         | 
| 125 | 
            -
                    nil
         | 
| 126 | 
            -
                  end
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                  def run_preparation_callbacks
         | 
| 129 | 
            -
                    return if preparation_callbacks_run?
         | 
| 130 | 
            -
                    preparation_callbacks.each { |_, callback| callback.call }
         | 
| 131 | 
            -
                    self.preparation_callbacks_run = true
         | 
| 132 | 
            -
                  end
         | 
| 133 | 
            -
             | 
| 134 | 
            -
                  # If the block raises, send status code as a last-ditch response.
         | 
| 135 | 
            -
                  def failsafe_response(output, status, exception = nil)
         | 
| 136 | 
            -
                    yield
         | 
| 137 | 
            -
                  rescue Exception  # errors from executed block
         | 
| 138 | 
            -
                    begin
         | 
| 139 | 
            -
                      output.write "Status: #{status}\r\n"
         | 
| 140 | 
            -
                      
         | 
| 141 | 
            -
                      if exception
         | 
| 142 | 
            -
                        message    = exception.to_s + "\r\n" + exception.backtrace.join("\r\n")
         | 
| 143 | 
            -
                        error_path = File.join(RAILS_ROOT, 'public', '500.html')
         | 
| 144 | 
            -
             | 
| 145 | 
            -
                        if defined?(RAILS_DEFAULT_LOGGER) && !RAILS_DEFAULT_LOGGER.nil?
         | 
| 146 | 
            -
                          RAILS_DEFAULT_LOGGER.fatal(message)
         | 
| 147 | 
            -
             | 
| 148 | 
            -
                          output.write "Content-Type: text/html\r\n\r\n"
         | 
| 149 | 
            -
             | 
| 150 | 
            -
                          if File.exists?(error_path)
         | 
| 151 | 
            -
                            output.write(IO.read(error_path))
         | 
| 152 | 
            -
                          else
         | 
| 153 | 
            -
                            output.write("<html><body><h1>Application error (Rails)</h1></body></html>")
         | 
| 154 | 
            -
                          end
         | 
| 155 | 
            -
                        else
         | 
| 156 | 
            -
                          output.write "Content-Type: text/plain\r\n\r\n"
         | 
| 157 | 
            -
                          output.write(message)
         | 
| 158 | 
            -
                        end
         | 
| 159 | 
            -
                      end
         | 
| 160 | 
            -
                    rescue Exception  # Logger or IO errors
         | 
| 161 | 
            -
                    end
         | 
| 162 | 
            -
                  end
         | 
| 163 | 
            -
              end
         | 
| 164 | 
            -
              
         | 
| 165 | 
            -
              self.preparation_callbacks = []
         | 
| 166 | 
            -
              self.preparation_callbacks_run = false
         | 
| 167 | 
            -
              
         | 
| 168 | 
            -
            end
         | 
| 169 | 
            -
             | 
| 170 | 
            -
            Dispatcher.to_prepare :activerecord_instantiate_observers do
         | 
| 171 | 
            -
              ActiveRecord::Base.instantiate_observers
         | 
| 172 | 
            -
            end if defined?(ActiveRecord)
         | 
| 23 | 
            +
            require 'action_controller/dispatcher'
         | 
| 24 | 
            +
            Dispatcher = ActionController::Dispatcher
         |