lib/rails_view.rb in rails_view-2.3.0 vs lib/rails_view.rb in rails_view-3.0.0

- old
+ new

@@ -1,73 +1,25 @@ -require 'rails' unless defined?(::Rails) -require 'action_controller' unless defined?(::ActionController) class View - VERSION = '2.3.0' + require_relative '../_lib.rb' - def View.version - View::VERSION + begin + require 'rubygems' + rescue LoadError + nil end - def View.load_shit! - @loaded_shit ||= ( - unless defined?(::Rails) - require 'rails' - end + require 'rails' unless defined?(::Rails) + require 'action_controller' unless defined?(::ActionController) - unless defined?(::ActionController) - require 'action_controller' - end - - unless defined?(::ActionDispatch::TestRequest) - require 'action_dispatch/testing/test_request.rb' - end - - unless defined?(::ActionDispatch::TestResponse) - require 'action_dispatch/testing/test_response.rb' - end - - true - ) + View.dependencies.each do |lib, dependency| + gem(*dependency) if defined?(gem) + require(lib) end - if defined?(::Rails_current) && defined?(::Current) - def View.controller(&block) - controller = ::Current.controller ? ::Current.controller.dup : ::Current.mock_controller - block ? controller.instance_eval(&block) : controller - end - else - def View.controller(&block) - load_shit! - - controller_class = Class.new(::ActionController::Base) do - layout false - helper :all - end - - default_url_options = - begin - require 'rails_default_url_options' - DefaultUrlOptions - rescue LoadError - options[:default_url_options] || {} - end - - store = ActiveSupport::Cache::MemoryStore.new - request = ActionDispatch::TestRequest.new - response = ActionDispatch::TestResponse.new - - controller = controller_class.new() - - controller.perform_caching = false - controller.cache_store = store - controller.request = request - controller.response = response - #controller.send(:initialize_template_class, response) - #controller.send(:assign_shortcuts, request, response) - controller.send(:default_url_options).merge!(default_url_options) - block ? controller.instance_eval(&block) : controller - end + def View.controller(&block) + controller = ::Current.controller ? ::Current.controller.dup : ::Current.mock_controller + block ? controller.instance_eval(&block) : controller end def View.render(*args) options = args.extract_options!.to_options! args.push(options)