Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleanup Rails upgrade

  • Loading branch information...
commit 7d04b937432323adb3077d657eb92cd5431d883d 1 parent 4f66aa1
Alex MacCaw authored

Showing 69 changed files with 0 additions and 29,535 deletions. Show diff stats Hide diff stats

  1. 14  vendor/rails/actionmailer/lib/action_mailer/vendor.rb
  2. 69  vendor/rails/actionpack/lib/action_controller/assertions.rb
  3. 18  vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb
  4. 53  vendor/rails/actionpack/lib/action_controller/cgi_ext/session.rb
  5. 169  vendor/rails/actionpack/lib/action_controller/components.rb
  6. 303  vendor/rails/actionpack/lib/action_controller/rack_process.rb
  7. 169  vendor/rails/actionpack/lib/action_controller/request_profiler.rb
  8. 340  vendor/rails/actionpack/lib/action_controller/session/active_record_store.rb
  9. 32  vendor/rails/actionpack/lib/action_controller/session/drb_server.rb
  10. 35  vendor/rails/actionpack/lib/action_controller/session/drb_store.rb
  11. 263  vendor/rails/actionpack/test/controller/cgi_test.rb
  12. 156  vendor/rails/actionpack/test/controller/components_test.rb
  13. 54  vendor/rails/actionpack/test/controller/http_authentication_test.rb
  14. 43  vendor/rails/actionpack/test/controller/integration_upload_test.rb
  15. 89  vendor/rails/actionpack/test/controller/session_fixation_test.rb
  16. 178  vendor/rails/actionpack/test/controller/session_management_test.rb
  17. 6  vendor/rails/activesupport/lib/active_support/testing/core_ext/test.rb
  18. 72  vendor/rails/activesupport/lib/active_support/testing/core_ext/test/unit/assertions.rb
  19. 194  vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb
  20. 216  vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
  21. 53  vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb
  22. 849  vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb
  23. 1,021  vendor/rails/activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb
  24. 3  vendor/rails/railties/bin/performance/request
  25. 3  vendor/rails/railties/bin/process/inspector
  26. 3  vendor/rails/railties/bin/process/reaper
  27. 3  vendor/rails/railties/bin/process/spawner
  28. 17  vendor/rails/railties/config.ru
  29. 40  vendor/rails/railties/configs/apache.conf
  30. 54  vendor/rails/railties/configs/lighttpd.conf
  31. 1,185  vendor/rails/railties/doc/guides/html/2_2_release_notes.html
  32. 1,270  vendor/rails/railties/doc/guides/html/actioncontroller_basics.html
  33. 749  vendor/rails/railties/doc/guides/html/activerecord_validations_callbacks.html
  34. 2,585  vendor/rails/railties/doc/guides/html/association_basics.html
  35. 240  vendor/rails/railties/doc/guides/html/authors.html
  36. 1,018  vendor/rails/railties/doc/guides/html/benchmarking_and_profiling.html
  37. 583  vendor/rails/railties/doc/guides/html/caching_with_rails.html
  38. 434  vendor/rails/railties/doc/guides/html/command_line.html
  39. 438  vendor/rails/railties/doc/guides/html/configuring.html
  40. 1,594  vendor/rails/railties/doc/guides/html/creating_plugins.html
  41. 1,175  vendor/rails/railties/doc/guides/html/debugging_rails_applications.html
  42. 1,090  vendor/rails/railties/doc/guides/html/finders.html
  43. 638  vendor/rails/railties/doc/guides/html/form_helpers.html
  44. 2,066  vendor/rails/railties/doc/guides/html/getting_started_with_rails.html
  45. 349  vendor/rails/railties/doc/guides/html/index.html
  46. 1,406  vendor/rails/railties/doc/guides/html/layouts_and_rendering.html
  47. 921  vendor/rails/railties/doc/guides/html/migrations.html
  48. 2,213  vendor/rails/railties/doc/guides/html/routing_outside_in.html
  49. 1,346  vendor/rails/railties/doc/guides/html/security.html
  50. 1,859  vendor/rails/railties/doc/guides/html/testing_rails_applications.html
  51. 435  vendor/rails/railties/doc/guides/source/2_2_release_notes.txt
  52. 5  vendor/rails/railties/doc/guides/source/actioncontroller_basics/changelog.txt
  53. 34  vendor/rails/railties/doc/guides/source/actioncontroller_basics/cookies.txt
  54. 32  vendor/rails/railties/doc/guides/source/actioncontroller_basics/csrf.txt
  55. 119  vendor/rails/railties/doc/guides/source/actioncontroller_basics/filters.txt
  56. 24  vendor/rails/railties/doc/guides/source/actioncontroller_basics/http_auth.txt
  57. 40  vendor/rails/railties/doc/guides/source/actioncontroller_basics/index.txt
  58. 9  vendor/rails/railties/doc/guides/source/actioncontroller_basics/introduction.txt
  59. 39  vendor/rails/railties/doc/guides/source/actioncontroller_basics/methods.txt
  60. 14  vendor/rails/railties/doc/guides/source/actioncontroller_basics/parameter_filtering.txt
  61. 93  vendor/rails/railties/doc/guides/source/actioncontroller_basics/params.txt
  62. 43  vendor/rails/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt
  63. 67  vendor/rails/railties/doc/guides/source/actioncontroller_basics/rescue.txt
  64. 187  vendor/rails/railties/doc/guides/source/actioncontroller_basics/session.txt
  65. 91  vendor/rails/railties/doc/guides/source/actioncontroller_basics/streaming.txt
  66. 40  vendor/rails/railties/doc/guides/source/actioncontroller_basics/verification.txt
  67. 181  vendor/rails/railties/doc/guides/source/active_record_basics.txt
  68. 404  vendor/rails/railties/doc/guides/source/activerecord_validations_callbacks.txt
14  vendor/rails/actionmailer/lib/action_mailer/vendor.rb
... ...
@@ -1,14 +0,0 @@
1  
-# Prefer gems to the bundled libs.
2  
-require 'rubygems'
3  
-
4  
-begin
5  
-  gem 'tmail', '~> 1.2.3'
6  
-rescue Gem::LoadError
7  
-  $:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.2.3"
8  
-end
9  
-
10  
-begin
11  
-  gem 'text-format', '>= 0.6.3'
12  
-rescue Gem::LoadError
13  
-  $:.unshift "#{File.dirname(__FILE__)}/vendor/text-format-0.6.3"
14  
-end
69  vendor/rails/actionpack/lib/action_controller/assertions.rb
... ...
@@ -1,69 +0,0 @@
1  
-require 'test/unit/assertions'
2  
-
3  
-module ActionController #:nodoc:
4  
-  # In addition to these specific assertions, you also have easy access to various collections that the regular test/unit assertions
5  
-  # can be used against. These collections are:
6  
-  #
7  
-  # * assigns: Instance variables assigned in the action that are available for the view.
8  
-  # * session: Objects being saved in the session.
9  
-  # * flash: The flash objects currently in the session.
10  
-  # * cookies: Cookies being sent to the user on this request.
11  
-  #
12  
-  # These collections can be used just like any other hash:
13  
-  #
14  
-  #   assert_not_nil assigns(:person) # makes sure that a @person instance variable was set
15  
-  #   assert_equal "Dave", cookies[:name] # makes sure that a cookie called :name was set as "Dave"
16  
-  #   assert flash.empty? # makes sure that there's nothing in the flash
17  
-  #
18  
-  # For historic reasons, the assigns hash uses string-based keys. So assigns[:person] won't work, but assigns["person"] will. To
19  
-  # appease our yearning for symbols, though, an alternative accessor has been devised using a method call instead of index referencing.
20  
-  # So assigns(:person) will work just like assigns["person"], but again, assigns[:person] will not work.
21  
-  #
22  
-  # On top of the collections, you have the complete url that a given action redirected to available in redirect_to_url.
23  
-  #
24  
-  # For redirects within the same controller, you can even call follow_redirect and the redirect will be followed, triggering another
25  
-  # action call which can then be asserted against.
26  
-  #
27  
-  # == Manipulating the request collections
28  
-  #
29  
-  # The collections described above link to the response, so you can test if what the actions were expected to do happened. But
30  
-  # sometimes you also want to manipulate these collections in the incoming request. This is really only relevant for sessions
31  
-  # and cookies, though. For sessions, you just do:
32  
-  #
33  
-  #   @request.session[:key] = "value"
34  
-  #
35  
-  # For cookies, you need to manually create the cookie, like this:
36  
-  #
37  
-  #   @request.cookies["key"] = CGI::Cookie.new("key", "value")
38  
-  #
39  
-  # == Testing named routes
40  
-  #
41  
-  # If you're using named routes, they can be easily tested using the original named routes' methods straight in the test case.
42  
-  # Example:
43  
-  #
44  
-  #  assert_redirected_to page_url(:title => 'foo')
45  
-  module Assertions
46  
-    def self.included(klass)
47  
-      %w(response selector tag dom routing model).each do |kind|
48  
-        require "action_controller/assertions/#{kind}_assertions"
49  
-        klass.module_eval { include const_get("#{kind.camelize}Assertions") }
50  
-      end
51  
-    end
52  
-
53  
-    def clean_backtrace(&block)
54  
-      yield
55  
-    rescue Test::Unit::AssertionFailedError => error
56  
-      framework_path = Regexp.new(File.expand_path("#{File.dirname(__FILE__)}/assertions"))
57  
-      error.backtrace.reject! { |line| File.expand_path(line) =~ framework_path }
58  
-      raise
59  
-    end
60  
-  end
61  
-end
62  
-
63  
-module Test #:nodoc:
64  
-  module Unit #:nodoc:
65  
-    class TestCase #:nodoc:
66  
-      include ActionController::Assertions
67  
-    end
68  
-  end
69  
-end
18  vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb
... ...
@@ -1,18 +0,0 @@
1  
-module ActionController #:nodoc:
2  
-  module Caching
3  
-    module SqlCache
4  
-      def self.included(base) #:nodoc:
5  
-        if defined?(ActiveRecord) && ActiveRecord::Base.respond_to?(:cache)
6  
-          base.alias_method_chain :perform_action, :caching
7  
-        end
8  
-      end
9  
-
10  
-      protected
11  
-        def perform_action_with_caching
12  
-          ActiveRecord::Base.cache do
13  
-            perform_action_without_caching
14  
-          end
15  
-        end
16  
-    end
17  
-  end
18  
-end
53  vendor/rails/actionpack/lib/action_controller/cgi_ext/session.rb
... ...
@@ -1,53 +0,0 @@
1  
-require 'digest/md5'
2  
-require 'cgi/session'
3  
-require 'cgi/session/pstore'
4  
-
5  
-class CGI #:nodoc:
6  
-  # * Expose the CGI instance to session stores.
7  
-  # * Don't require 'digest/md5' whenever a new session id is generated.
8  
-  class Session #:nodoc:
9  
-    def self.generate_unique_id(constant = nil)
10  
-      ActiveSupport::SecureRandom.hex(16)
11  
-    end
12  
-
13  
-    # Make the CGI instance available to session stores.
14  
-    attr_reader :cgi
15  
-    attr_reader :dbman
16  
-    alias_method :initialize_without_cgi_reader, :initialize
17  
-    def initialize(cgi, options = {})
18  
-      @cgi = cgi
19  
-      initialize_without_cgi_reader(cgi, options)
20  
-    end
21  
-
22  
-    private
23  
-      # Create a new session id.
24  
-      def create_new_id
25  
-        @new_session = true
26  
-        self.class.generate_unique_id
27  
-      end
28  
-
29  
-    # * Don't require 'digest/md5' whenever a new session is started.
30  
-    class PStore #:nodoc:
31  
-      def initialize(session, option={})
32  
-        dir = option['tmpdir'] || Dir::tmpdir
33  
-        prefix = option['prefix'] || ''
34  
-        id = session.session_id
35  
-        md5 = Digest::MD5.hexdigest(id)[0,16]
36  
-        path = dir+"/"+prefix+md5
37  
-        path.untaint
38  
-        if File::exist?(path)
39  
-          @hash = nil
40  
-        else
41  
-          unless session.new_session
42  
-            raise CGI::Session::NoSession, "uninitialized session"
43  
-          end
44  
-          @hash = {}
45  
-        end
46  
-        @p = ::PStore.new(path)
47  
-        @p.transaction do |p|
48  
-          File.chmod(0600, p.path)
49  
-        end
50  
-      end
51  
-    end
52  
-  end
53  
-end
169  vendor/rails/actionpack/lib/action_controller/components.rb
... ...
@@ -1,169 +0,0 @@
1  
-module ActionController #:nodoc:
2  
-  # Components allow you to call other actions for their rendered response while executing another action. You can either delegate
3  
-  # the entire response rendering or you can mix a partial response in with your other content.
4  
-  #
5  
-  #   class WeblogController < ActionController::Base
6  
-  #     # Performs a method and then lets hello_world output its render
7  
-  #     def delegate_action
8  
-  #       do_other_stuff_before_hello_world
9  
-  #       render_component :controller => "greeter",  :action => "hello_world", :params => { :person => "david" }
10  
-  #     end
11  
-  #   end
12  
-  #
13  
-  #   class GreeterController < ActionController::Base
14  
-  #     def hello_world
15  
-  #       render :text => "#{params[:person]} says, Hello World!"
16  
-  #     end
17  
-  #   end
18  
-  #
19  
-  # The same can be done in a view to do a partial rendering:
20  
-  #
21  
-  #   Let's see a greeting:
22  
-  #   <%= render_component :controller => "greeter", :action => "hello_world" %>
23  
-  #
24  
-  # It is also possible to specify the controller as a class constant, bypassing the inflector
25  
-  # code to compute the controller class at runtime:
26  
-  #
27  
-  # <%= render_component :controller => GreeterController, :action => "hello_world" %>
28  
-  #
29  
-  # == When to use components
30  
-  #
31  
-  # Components should be used with care. They're significantly slower than simply splitting reusable parts into partials and
32  
-  # conceptually more complicated. Don't use components as a way of separating concerns inside a single application. Instead,
33  
-  # reserve components to those rare cases where you truly have reusable view and controller elements that can be employed
34  
-  # across many applications at once.
35  
-  #
36  
-  # So to repeat: Components are a special-purpose approach that can often be replaced with better use of partials and filters.
37  
-  module Components
38  
-    def self.included(base) #:nodoc:
39  
-      base.class_eval do
40  
-        include InstanceMethods
41  
-        include ActiveSupport::Deprecation
42  
-        extend ClassMethods
43  
-        helper HelperMethods
44  
-
45  
-        # If this controller was instantiated to process a component request,
46  
-        # +parent_controller+ points to the instantiator of this controller.
47  
-        attr_accessor :parent_controller
48  
-
49  
-        alias_method_chain :process_cleanup, :components
50  
-        alias_method_chain :set_session_options, :components
51  
-        alias_method_chain :flash, :components
52  
-
53  
-        alias_method :component_request?, :parent_controller
54  
-      end
55  
-    end
56  
-
57  
-    module ClassMethods
58  
-      # Track parent controller to identify component requests
59  
-      def process_with_components(request, response, parent_controller = nil) #:nodoc:
60  
-        controller = new
61  
-        controller.parent_controller = parent_controller
62  
-        controller.process(request, response)
63  
-      end
64  
-    end
65  
-
66  
-    module HelperMethods
67  
-      def render_component(options)
68  
-        @controller.__send__(:render_component_as_string, options)
69  
-      end
70  
-    end
71  
-
72  
-    module InstanceMethods
73  
-      # Extracts the action_name from the request parameters and performs that action.
74  
-      def process_with_components(request, response, method = :perform_action, *arguments) #:nodoc:
75  
-        flash.discard if component_request?
76  
-        process_without_components(request, response, method, *arguments)
77  
-      end
78  
-
79  
-      protected
80  
-        # Renders the component specified as the response for the current method
81  
-        def render_component(options) #:doc:
82  
-          component_logging(options) do
83  
-            render_for_text(component_response(options, true).body, response.headers["Status"])
84  
-          end
85  
-        end
86  
-        deprecate :render_component => "Please install render_component plugin from http://github.com/rails/render_component/tree/master"
87  
-
88  
-        # Returns the component response as a string
89  
-        def render_component_as_string(options) #:doc:
90  
-          component_logging(options) do
91  
-            response = component_response(options, false)
92  
-
93  
-            if redirected = response.redirected_to
94  
-              render_component_as_string(redirected)
95  
-            else
96  
-              response.body
97  
-            end
98  
-          end
99  
-        end
100  
-        deprecate :render_component_as_string => "Please install render_component plugin from http://github.com/rails/render_component/tree/master"
101  
-
102  
-        def flash_with_components(refresh = false) #:nodoc:
103  
-          if !defined?(@_flash) || refresh
104  
-            @_flash =
105  
-              if defined?(@parent_controller)
106  
-                @parent_controller.flash
107  
-              else
108  
-                flash_without_components
109  
-              end
110  
-          end
111  
-          @_flash
112  
-        end
113  
-
114  
-      private
115  
-        def component_response(options, reuse_response)
116  
-          klass    = component_class(options)
117  
-          request  = request_for_component(klass.controller_name, options)
118  
-          new_response = reuse_response ? response : response.dup
119  
-
120  
-          klass.process_with_components(request, new_response, self)
121  
-        end
122  
-
123  
-        # determine the controller class for the component request
124  
-        def component_class(options)
125  
-          if controller = options[:controller]
126  
-            controller.is_a?(Class) ? controller : "#{controller.camelize}Controller".constantize
127  
-          else
128  
-            self.class
129  
-          end
130  
-        end
131  
-
132  
-        # Create a new request object based on the current request.
133  
-        # The new request inherits the session from the current request,
134  
-        # bypassing any session options set for the component controller's class
135  
-        def request_for_component(controller_name, options)
136  
-          new_request         = request.dup
137  
-          new_request.session = request.session
138  
-
139  
-          new_request.instance_variable_set(
140  
-            :@parameters,
141  
-            (options[:params] || {}).with_indifferent_access.update(
142  
-              "controller" => controller_name, "action" => options[:action], "id" => options[:id]
143  
-            )
144  
-          )
145  
-
146  
-          new_request
147  
-        end
148  
-
149  
-        def component_logging(options)
150  
-          if logger
151  
-            logger.info "Start rendering component (#{options.inspect}): "
152  
-            result = yield
153  
-            logger.info "\n\nEnd of component rendering"
154  
-            result
155  
-          else
156  
-            yield
157  
-          end
158  
-        end
159  
-
160  
-        def set_session_options_with_components(request)
161  
-          set_session_options_without_components(request) unless component_request?
162  
-        end
163  
-
164  
-        def process_cleanup_with_components
165  
-          process_cleanup_without_components unless component_request?
166  
-        end
167  
-    end
168  
-  end
169  
-end
303  vendor/rails/actionpack/lib/action_controller/rack_process.rb
... ...
@@ -1,303 +0,0 @@
1  
-require 'action_controller/cgi_ext'
2  
-require 'action_controller/session/cookie_store'
3  
-
4  
-module ActionController #:nodoc:
5  
-  class RackRequest < AbstractRequest #:nodoc:
6  
-    attr_accessor :session_options
7  
-    attr_reader :cgi
8  
-
9  
-    class SessionFixationAttempt < StandardError #:nodoc:
10  
-    end
11  
-
12  
-    DEFAULT_SESSION_OPTIONS = {
13  
-      :database_manager => CGI::Session::CookieStore, # store data in cookie
14  
-      :prefix           => "ruby_sess.",    # prefix session file names
15  
-      :session_path     => "/",             # available to all paths in app
16  
-      :session_key      => "_session_id",
17  
-      :cookie_only      => true,
18  
-      :session_http_only=> true
19  
-    }
20  
-
21  
-    def initialize(env, session_options = DEFAULT_SESSION_OPTIONS)
22  
-      @session_options = session_options
23  
-      @env = env
24  
-      @cgi = CGIWrapper.new(self)
25  
-      super()
26  
-    end
27  
-
28  
-    %w[ AUTH_TYPE GATEWAY_INTERFACE PATH_INFO
29  
-        PATH_TRANSLATED REMOTE_HOST
30  
-        REMOTE_IDENT REMOTE_USER SCRIPT_NAME
31  
-        SERVER_NAME SERVER_PROTOCOL
32  
-
33  
-        HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
34  
-        HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
35  
-        HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ].each do |env|
36  
-      define_method(env.sub(/^HTTP_/n, '').downcase) do
37  
-        @env[env]
38  
-      end
39  
-    end
40  
-
41  
-    def query_string
42  
-      qs = super
43  
-      if !qs.blank?
44  
-        qs
45  
-      else
46  
-        @env['QUERY_STRING']
47  
-      end
48  
-    end
49  
-
50  
-    def body_stream #:nodoc:
51  
-      @env['rack.input']
52  
-    end
53  
-
54  
-    def key?(key)
55  
-      @env.key?(key)
56  
-    end
57  
-
58  
-    def cookies
59  
-      return {} unless @env["HTTP_COOKIE"]
60  
-
61  
-      unless @env["rack.request.cookie_string"] == @env["HTTP_COOKIE"]
62  
-        @env["rack.request.cookie_string"] = @env["HTTP_COOKIE"]
63  
-        @env["rack.request.cookie_hash"] = CGI::Cookie::parse(@env["rack.request.cookie_string"])
64  
-      end
65  
-
66  
-      @env["rack.request.cookie_hash"]
67  
-    end
68  
-
69  
-    def server_port
70  
-      @env['SERVER_PORT'].to_i
71  
-    end
72  
-
73  
-    def server_software
74  
-      @env['SERVER_SOFTWARE'].split("/").first
75  
-    end
76  
-
77  
-    def session
78  
-      unless defined?(@session)
79  
-        if @session_options == false
80  
-          @session = Hash.new
81  
-        else
82  
-          stale_session_check! do
83  
-            if cookie_only? && query_parameters[session_options_with_string_keys['session_key']]
84  
-              raise SessionFixationAttempt
85  
-            end
86  
-            case value = session_options_with_string_keys['new_session']
87  
-              when true
88  
-                @session = new_session
89  
-              when false
90  
-                begin
91  
-                  @session = CGI::Session.new(@cgi, session_options_with_string_keys)
92  
-                # CGI::Session raises ArgumentError if 'new_session' == false
93  
-                # and no session cookie or query param is present.
94  
-                rescue ArgumentError
95  
-                  @session = Hash.new
96  
-                end
97  
-              when nil
98  
-                @session = CGI::Session.new(@cgi, session_options_with_string_keys)
99  
-              else
100  
-                raise ArgumentError, "Invalid new_session option: #{value}"
101  
-            end
102  
-            @session['__valid_session']
103  
-          end
104  
-        end
105  
-      end
106  
-      @session
107  
-    end
108  
-
109  
-    def reset_session
110  
-      @session.delete if defined?(@session) && @session.is_a?(CGI::Session)
111  
-      @session = new_session
112  
-    end
113  
-
114  
-    private
115  
-      # Delete an old session if it exists then create a new one.
116  
-      def new_session
117  
-        if @session_options == false
118  
-          Hash.new
119  
-        else
120  
-          CGI::Session.new(@cgi, session_options_with_string_keys.merge("new_session" => false)).delete rescue nil
121  
-          CGI::Session.new(@cgi, session_options_with_string_keys.merge("new_session" => true))
122  
-        end
123  
-      end
124  
-
125  
-      def cookie_only?
126  
-        session_options_with_string_keys['cookie_only']
127  
-      end
128  
-
129  
-      def stale_session_check!
130  
-        yield
131  
-      rescue ArgumentError => argument_error
132  
-        if argument_error.message =~ %r{undefined class/module ([\w:]*\w)}
133  
-          begin
134  
-            # Note that the regexp does not allow $1 to end with a ':'
135  
-            $1.constantize
136  
-          rescue LoadError, NameError => const_error
137  
-            raise ActionController::SessionRestoreError, <<-end_msg
138  
-Session contains objects whose class definition isn\'t available.
139  
-Remember to require the classes for all objects kept in the session.
140  
-(Original exception: #{const_error.message} [#{const_error.class}])
141  
-end_msg
142  
-          end
143  
-
144  
-          retry
145  
-        else
146  
-          raise
147  
-        end
148  
-      end
149  
-
150  
-      def session_options_with_string_keys
151  
-        @session_options_with_string_keys ||= DEFAULT_SESSION_OPTIONS.merge(@session_options).stringify_keys
152  
-      end
153  
-  end
154  
-
155  
-  class RackResponse < AbstractResponse #:nodoc:
156  
-    def initialize(request)
157  
-      @cgi = request.cgi
158  
-      @writer = lambda { |x| @body << x }
159  
-      @block = nil
160  
-      super()
161  
-    end
162  
-
163  
-    # Retrieve status from instance variable if has already been delete
164  
-    def status
165  
-      @status || super
166  
-    end
167  
-
168  
-    def out(output = $stdout, &block)
169  
-      # Nasty hack because CGI sessions are closed after the normal
170  
-      # prepare! statement
171  
-      set_cookies!
172  
-
173  
-      @block = block
174  
-      @status = headers.delete("Status")
175  
-      if [204, 304].include?(status.to_i)
176  
-        headers.delete("Content-Type")
177  
-        [status, headers.to_hash, []]
178  
-      else
179  
-        [status, headers.to_hash, self]
180  
-      end
181  
-    end
182  
-    alias to_a out
183  
-
184  
-    def each(&callback)
185  
-      if @body.respond_to?(:call)
186  
-        @writer = lambda { |x| callback.call(x) }
187  
-        @body.call(self, self)
188  
-      elsif @body.is_a?(String)
189  
-        @body.each_line(&callback)
190  
-      else
191  
-        @body.each(&callback)
192  
-      end
193  
-
194  
-      @writer = callback
195  
-      @block.call(self) if @block
196  
-    end
197  
-
198  
-    def write(str)
199  
-      @writer.call str.to_s
200  
-      str
201  
-    end
202  
-
203  
-    def close
204  
-      @body.close if @body.respond_to?(:close)
205  
-    end
206  
-
207  
-    def empty?
208  
-      @block == nil && @body.empty?
209  
-    end
210  
-
211  
-    def prepare!
212  
-      super
213  
-
214  
-      convert_language!
215  
-      convert_expires!
216  
-      set_status!
217  
-      # set_cookies!
218  
-    end
219  
-
220  
-    private
221  
-      def convert_language!
222  
-        headers["Content-Language"] = headers.delete("language") if headers["language"]
223  
-      end
224  
-
225  
-      def convert_expires!
226  
-        headers["Expires"] = headers.delete("") if headers["expires"]
227  
-      end
228  
-
229  
-      def convert_content_type!
230  
-        super
231  
-        headers['Content-Type'] = headers.delete('type') || "text/html"
232  
-        headers['Content-Type'] += "; charset=" + headers.delete('charset') if headers['charset']
233  
-      end
234  
-
235  
-      def set_content_length!
236  
-        super
237  
-        headers["Content-Length"] = headers["Content-Length"].to_s if headers["Content-Length"]
238  
-      end
239  
-
240  
-      def set_status!
241  
-        self.status ||= "200 OK"
242  
-      end
243  
-
244  
-      def set_cookies!
245  
-        # Convert 'cookie' header to 'Set-Cookie' headers.
246  
-        # Because Set-Cookie header can appear more the once in the response body,
247  
-        # we store it in a line break separated string that will be translated to
248  
-        # multiple Set-Cookie header by the handler.
249  
-        if cookie = headers.delete('cookie')
250  
-          cookies = []
251  
-
252  
-          case cookie
253  
-            when Array then cookie.each { |c| cookies << c.to_s }
254  
-            when Hash  then cookie.each { |_, c| cookies << c.to_s }
255  
-            else            cookies << cookie.to_s
256  
-          end
257  
-
258  
-          @cgi.output_cookies.each { |c| cookies << c.to_s } if @cgi.output_cookies
259  
-
260  
-          headers['Set-Cookie'] = [headers['Set-Cookie'], cookies].flatten.compact
261  
-        end
262  
-      end
263  
-  end
264  
-
265  
-  class CGIWrapper < ::CGI
266  
-    attr_reader :output_cookies
267  
-
268  
-    def initialize(request, *args)
269  
-      @request  = request
270  
-      @args     = *args
271  
-      @input    = request.body
272  
-
273  
-      super *args
274  
-    end
275  
-
276  
-    def params
277  
-      @params ||= @request.params
278  
-    end
279  
-
280  
-    def cookies
281  
-      @request.cookies
282  
-    end
283  
-
284  
-    def query_string
285  
-      @request.query_string
286  
-    end
287  
-
288  
-    # Used to wrap the normal args variable used inside CGI.
289  
-    def args
290  
-      @args
291  
-    end
292  
-
293  
-    # Used to wrap the normal env_table variable used inside CGI.
294  
-    def env_table
295  
-      @request.env
296  
-    end
297  
-
298  
-    # Used to wrap the normal stdinput variable used inside CGI.
299  
-    def stdinput
300  
-      @input
301  
-    end
302  
-  end
303  
-end
169  vendor/rails/actionpack/lib/action_controller/request_profiler.rb
... ...
@@ -1,169 +0,0 @@
1  
-require 'optparse'
2  
-require 'action_controller/integration'
3  
-
4  
-module ActionController
5  
-  class RequestProfiler
6  
-    # Wrap up the integration session runner.
7  
-    class Sandbox
8  
-      include Integration::Runner
9  
-
10  
-      def self.benchmark(n, script)
11  
-        new(script).benchmark(n)
12  
-      end
13  
-
14  
-      def initialize(script_path)
15  
-        @quiet = false
16  
-        define_run_method(script_path)
17  
-        reset!
18  
-      end
19  
-
20  
-      def benchmark(n, profiling = false)
21  
-        @quiet = true
22  
-        print '  '
23  
-
24  
-        result = Benchmark.realtime do
25  
-          n.times do |i|
26  
-            run(profiling)
27  
-            print_progress(i)
28  
-          end
29  
-        end
30  
-
31  
-        puts
32  
-        result
33  
-      ensure
34  
-        @quiet = false
35  
-      end
36  
-
37  
-      def say(message)
38  
-        puts "  #{message}" unless @quiet
39  
-      end
40  
-
41  
-      private
42  
-        def define_run_method(script_path)
43  
-          script = File.read(script_path)
44  
-
45  
-          source = <<-end_source
46  
-            def run(profiling = false)
47  
-              if profiling
48  
-                RubyProf.resume do
49  
-                  #{script}
50  
-                end
51  
-              else
52  
-                #{script}
53  
-              end
54  
-
55  
-              old_request_count = request_count
56  
-              reset!
57  
-              self.request_count = old_request_count
58  
-            end
59  
-          end_source
60  
-
61  
-          instance_eval source, script_path, 1
62  
-        end
63  
-
64  
-        def print_progress(i)
65  
-          print "\n  " if i % 60 == 0
66  
-          print ' ' if i % 10 == 0
67  
-          print '.'
68  
-          $stdout.flush
69  
-        end
70  
-    end
71  
-
72  
-
73  
-    attr_reader :options
74  
-
75  
-    def initialize(options = {})
76  
-      @options = default_options.merge(options)
77  
-    end
78  
-
79  
-
80  
-    def self.run(args = nil, options = {})
81  
-      profiler = new(options)
82  
-      profiler.parse_options(args) if args
83  
-      profiler.run
84  
-    end
85  
-
86  
-    def run
87  
-      sandbox = Sandbox.new(options[:script])
88  
-
89  
-      puts 'Warming up once'
90  
-
91  
-      elapsed = warmup(sandbox)
92  
-      puts '%.2f sec, %d requests, %d req/sec' % [elapsed, sandbox.request_count, sandbox.request_count / elapsed]
93  
-      puts "\n#{options[:benchmark] ? 'Benchmarking' : 'Profiling'} #{options[:n]}x"
94  
-
95  
-      options[:benchmark] ? benchmark(sandbox) : profile(sandbox)
96  
-    end
97  
-
98  
-    def profile(sandbox)
99  
-      load_ruby_prof
100  
-
101  
-      benchmark(sandbox, true)
102  
-      results = RubyProf.stop
103  
-
104  
-      show_profile_results results
105  
-      results
106  
-    end
107  
-
108  
-    def benchmark(sandbox, profiling = false)
109  
-      sandbox.request_count = 0
110  
-      elapsed = sandbox.benchmark(options[:n], profiling).to_f
111  
-      count = sandbox.request_count.to_i
112  
-      puts '%.2f sec, %d requests, %d req/sec' % [elapsed, count, count / elapsed]
113  
-    end
114  
-
115  
-    def warmup(sandbox)
116  
-      Benchmark.realtime { sandbox.run(false) }
117  
-    end
118  
-
119  
-    def default_options
120  
-      { :n => 100, :open => 'open %s &' }
121  
-    end
122  
-
123  
-    # Parse command-line options
124  
-    def parse_options(args)
125  
-      OptionParser.new do |opt|
126  
-        opt.banner = "USAGE: #{$0} [options] [session script path]"
127  
-
128  
-        opt.on('-n', '--times [100]', 'How many requests to process. Defaults to 100.') { |v| options[:n] = v.to_i if v }
129  
-        opt.on('-b', '--benchmark', 'Benchmark instead of profiling') { |v| options[:benchmark] = v }
130  
-        opt.on('-m', '--measure [mode]', 'Which ruby-prof measure mode to use: process_time, wall_time, cpu_time, allocations, or memory. Defaults to process_time.') { |v| options[:measure] = v }
131  
-        opt.on('--open [CMD]', 'Command to open profile results. Defaults to "open %s &"') { |v| options[:open] = v }
132  
-        opt.on('-h', '--help', 'Show this help') { puts opt; exit }
133  
-
134  
-        opt.parse args
135  
-
136  
-        if args.empty?
137  
-          puts opt
138  
-          exit
139  
-        end
140  
-        options[:script] = args.pop
141  
-      end
142  
-    end
143  
-
144  
-    protected
145  
-      def load_ruby_prof
146  
-        begin
147  
-          gem 'ruby-prof', '>= 0.6.1'
148  
-          require 'ruby-prof'
149  
-          if mode = options[:measure]
150  
-            RubyProf.measure_mode = RubyProf.const_get(mode.upcase)
151  
-          end
152  
-        rescue LoadError
153  
-          abort '`gem install ruby-prof` to use the profiler'
154  
-        end
155  
-      end
156  
-
157  
-      def show_profile_results(results)
158  
-        File.open "#{RAILS_ROOT}/tmp/profile-graph.html", 'w' do |file|
159  
-          RubyProf::GraphHtmlPrinter.new(results).print(file)
160  
-          `#{options[:open] % file.path}` if options[:open]
161  
-        end
162  
-
163  
-        File.open "#{RAILS_ROOT}/tmp/profile-flat.txt", 'w' do |file|
164  
-          RubyProf::FlatPrinter.new(results).print(file)
165  
-          `#{options[:open] % file.path}` if options[:open]
166  
-        end
167  
-      end
168  
-  end
169  
-end
340  vendor/rails/actionpack/lib/action_controller/session/active_record_store.rb
... ...
@@ -1,340 +0,0 @@
1  
-require 'cgi'
2  
-require 'cgi/session'
3  
-require 'digest/md5'
4  
-
5  
-class CGI
6  
-  class Session
7  
-    attr_reader :data
8  
-
9  
-    # Return this session's underlying Session instance. Useful for the DB-backed session stores.
10  
-    def model
11  
-      @dbman.model if @dbman
12  
-    end
13  
-
14  
-
15  
-    # A session store backed by an Active Record class.  A default class is
16  
-    # provided, but any object duck-typing to an Active Record Session class
17  
-    # with text +session_id+ and +data+ attributes is sufficient.
18  
-    #
19  
-    # The default assumes a +sessions+ tables with columns:
20  
-    #   +id+ (numeric primary key),
21  
-    #   +session_id+ (text, or longtext if your session data exceeds 65K), and
22  
-    #   +data+ (text or longtext; careful if your session data exceeds 65KB).
23  
-    # The +session_id+ column should always be indexed for speedy lookups.
24  
-    # Session data is marshaled to the +data+ column in Base64 format.
25  
-    # If the data you write is larger than the column's size limit,
26  
-    # ActionController::SessionOverflowError will be raised.
27  
-    #
28  
-    # You may configure the table name, primary key, and data column.
29  
-    # For example, at the end of <tt>config/environment.rb</tt>:
30  
-    #   CGI::Session::ActiveRecordStore::Session.table_name = 'legacy_session_table'
31  
-    #   CGI::Session::ActiveRecordStore::Session.primary_key = 'session_id'
32  
-    #   CGI::Session::ActiveRecordStore::Session.data_column_name = 'legacy_session_data'
33  
-    # Note that setting the primary key to the +session_id+ frees you from
34  
-    # having a separate +id+ column if you don't want it.  However, you must
35  
-    # set <tt>session.model.id = session.session_id</tt> by hand!  A before filter
36  
-    # on ApplicationController is a good place.
37  
-    #
38  
-    # Since the default class is a simple Active Record, you get timestamps
39  
-    # for free if you add +created_at+ and +updated_at+ datetime columns to
40  
-    # the +sessions+ table, making periodic session expiration a snap.
41  
-    #
42  
-    # You may provide your own session class implementation, whether a
43  
-    # feature-packed Active Record or a bare-metal high-performance SQL
44  
-    # store, by setting
45  
-    #   CGI::Session::ActiveRecordStore.session_class = MySessionClass
46  
-    # You must implement these methods:
47  
-    #   self.find_by_session_id(session_id)
48  
-    #   initialize(hash_of_session_id_and_data)
49  
-    #   attr_reader :session_id
50  
-    #   attr_accessor :data
51  
-    #   save
52  
-    #   destroy
53  
-    #
54  
-    # The example SqlBypass class is a generic SQL session store.  You may
55  
-    # use it as a basis for high-performance database-specific stores.
56  
-    class ActiveRecordStore
57  
-      # The default Active Record class.
58  
-      class Session < ActiveRecord::Base
59  
-        # Customizable data column name.  Defaults to 'data'.
60  
-        cattr_accessor :data_column_name
61  
-        self.data_column_name = 'data'
62  
-
63  
-        before_save :marshal_data!
64  
-        before_save :raise_on_session_data_overflow!
65  
-
66  
-        class << self
67  
-          # Don't try to reload ARStore::Session in dev mode.
68  
-          def reloadable? #:nodoc:
69  
-            false
70  
-          end
71  
-
72  
-          def data_column_size_limit
73  
-            @data_column_size_limit ||= columns_hash[@@data_column_name].limit
74  
-          end
75  
-
76  
-          # Hook to set up sessid compatibility.
77  
-          def find_by_session_id(session_id)
78  
-            setup_sessid_compatibility!
79  
-            find_by_session_id(session_id)
80  
-          end
81  
-
82  
-          def marshal(data)   ActiveSupport::Base64.encode64(Marshal.dump(data)) if data end
83  
-          def unmarshal(data) Marshal.load(ActiveSupport::Base64.decode64(data)) if data end
84  
-
85  
-          def create_table!
86  
-            connection.execute <<-end_sql
87  
-              CREATE TABLE #{table_name} (
88  
-                id INTEGER PRIMARY KEY,
89  
-                #{connection.quote_column_name('session_id')} TEXT UNIQUE,
90  
-                #{connection.quote_column_name(@@data_column_name)} TEXT(255)
91  
-              )
92  
-            end_sql
93  
-          end
94  
-
95  
-          def drop_table!
96  
-            connection.execute "DROP TABLE #{table_name}"
97  
-          end
98  
-
99  
-          private
100  
-            # Compatibility with tables using sessid instead of session_id.
101  
-            def setup_sessid_compatibility!
102  
-              # Reset column info since it may be stale.
103  
-              reset_column_information
104  
-              if columns_hash['sessid']
105  
-                def self.find_by_session_id(*args)
106  
-                  find_by_sessid(*args)
107  
-                end
108  
-
109  
-                define_method(:session_id)  { sessid }
110  
-                define_method(:session_id=) { |session_id| self.sessid = session_id }
111  
-              else
112  
-                def self.find_by_session_id(session_id)
113  
-                  find :first, :conditions => ["session_id #{attribute_condition(session_id)}", session_id]
114  
-                end
115  
-              end
116  
-            end
117  
-        end
118  
-
119  
-        # Lazy-unmarshal session state.
120  
-        def data
121  
-          @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) || {}
122  
-        end
123  
-
124  
-        attr_writer :data
125  
-
126  
-        # Has the session been loaded yet?
127  
-        def loaded?
128  
-          !! @data
129  
-        end
130  
-
131  
-        private
132  
-
133  
-          def marshal_data!
134  
-            return false if !loaded?
135  
-            write_attribute(@@data_column_name, self.class.marshal(self.data))
136  
-          end
137  
-
138  
-          # Ensures that the data about to be stored in the database is not
139  
-          # larger than the data storage column. Raises
140  
-          # ActionController::SessionOverflowError.
141  
-          def raise_on_session_data_overflow!
142  
-            return false if !loaded?
143  
-            limit = self.class.data_column_size_limit
144  
-            if loaded? and limit and read_attribute(@@data_column_name).size > limit
145  
-              raise ActionController::SessionOverflowError
146  
-            end
147  
-          end
148  
-      end
149  
-
150  
-      # A barebones session store which duck-types with the default session
151  
-      # store but bypasses Active Record and issues SQL directly.  This is
152  
-      # an example session model class meant as a basis for your own classes.
153  
-      #
154  
-      # The database connection, table name, and session id and data columns
155  
-      # are configurable class attributes.  Marshaling and unmarshaling
156  
-      # are implemented as class methods that you may override.  By default,
157  
-      # marshaling data is
158  
-      #
159  
-      #   ActiveSupport::Base64.encode64(Marshal.dump(data))
160  
-      #
161  
-      # and unmarshaling data is
162  
-      #
163  
-      #   Marshal.load(ActiveSupport::Base64.decode64(data))
164  
-      #
165  
-      # This marshaling behavior is intended to store the widest range of
166  
-      # binary session data in a +text+ column.  For higher performance,
167  
-      # store in a +blob+ column instead and forgo the Base64 encoding.
168  
-      class SqlBypass
169  
-        # Use the ActiveRecord::Base.connection by default.
170  
-        cattr_accessor :connection
171  
-
172  
-        # The table name defaults to 'sessions'.
173  
-        cattr_accessor :table_name
174  
-        @@table_name = 'sessions'
175  
-
176  
-        # The session id field defaults to 'session_id'.
177  
-        cattr_accessor :session_id_column
178  
-        @@session_id_column = 'session_id'
179  
-
180  
-        # The data field defaults to 'data'.
181  
-        cattr_accessor :data_column
182  
-        @@data_column = 'data'
183  
-
184  
-        class << self
185  
-
186  
-          def connection
187  
-            @@connection ||= ActiveRecord::Base.connection
188  
-          end
189  
-
190  
-          # Look up a session by id and unmarshal its data if found.
191  
-          def find_by_session_id(session_id)
192  
-            if record = @@connection.select_one("SELECT * FROM #{@@table_name} WHERE #{@@session_id_column}=#{@@connection.quote(session_id)}")
193  
-              new(:session_id => session_id, :marshaled_data => record['data'])
194  
-            end
195  
-          end
196  
-
197  
-          def marshal(data)   ActiveSupport::Base64.encode64(Marshal.dump(data)) if data end
198  
-          def unmarshal(data) Marshal.load(ActiveSupport::Base64.decode64(data)) if data end
199  
-
200  
-          def create_table!
201