提交 b058897d 编写于 作者: M Matthew Draper

Ensure we supply Kernel#y for 1.9 too

In 1.9, it doesn't live in its own file, so we'll have to define it
ourselves.

Check RUBY_VERSION, instead of rescuing the require, because we want
this to break if `psych/y` moves in a future Ruby release.
上级 362203e8
......@@ -332,6 +332,25 @@ def helpers_paths #:nodoc:
config.helpers_paths
end
console do
require "pp"
end
console do
unless ::Kernel.private_method_defined?(:y)
if RUBY_VERSION >= '2.0'
require "psych/y"
else
module ::Kernel
def y(*objects)
puts ::Psych.dump_stream(*objects)
end
private :y
end
end
end
end
protected
alias :build_middleware_stack :app
......
......@@ -429,8 +429,6 @@ def initialize
# Load console and invoke the registered hooks.
# Check <tt>Rails::Railtie.console</tt> for more info.
def load_console(app=self)
require "pp"
require "psych/y"
require "rails/console/app"
require "rails/console/helpers"
run_console_blocks(app)
......
......@@ -221,26 +221,28 @@ def railtie_namespace
protected
def run_console_blocks(app) #:nodoc:
self.class.console.each { |block| block.call(app) }
each_registered_block(:console) { |block| block.call(app) }
end
def run_generators_blocks(app) #:nodoc:
self.class.generators.each { |block| block.call(app) }
each_registered_block(:generators) { |block| block.call(app) }
end
def run_runner_blocks(app) #:nodoc:
self.class.runner.each { |block| block.call(app) }
each_registered_block(:runner) { |block| block.call(app) }
end
def run_tasks_blocks(app) #:nodoc:
extend Rake::DSL
self.class.rake_tasks.each { |block| instance_exec(app, &block) }
each_registered_block(:rake_tasks) { |block| instance_exec(app, &block) }
end
# Load also tasks from all superclasses
klass = self.class.superclass
private
while klass.respond_to?(:rake_tasks)
klass.rake_tasks.each { |t| instance_exec(app, &t) }
def each_registered_block(type, &block)
klass = self.class
while klass.respond_to?(type)
klass.public_send(type).each(&block)
klass = klass.superclass
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册