From e5d95944c4843cedc485c0d08157055f8afe64cf Mon Sep 17 00:00:00 2001 From: Nico Hagenburger Date: Sun, 2 Feb 2014 11:12:57 +0100 Subject: [PATCH] =?UTF-8?q?use=20instance=20hooks=20provided=20by=20hooks?= =?UTF-8?q?=20instead=20of=20changing=20the=20gem=E2=80=99s=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Conflicts: middleman-core/lib/middleman-core/core_extensions/extensions.rb --- middleman-core/lib/middleman-core/application.rb | 7 +++++++ .../lib/middleman-more/core_extensions/compass.rb | 4 ++-- .../lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb | 5 ----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 0ae9a811..bf549708 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -32,6 +32,7 @@ module Middleman # Uses callbacks include Hooks + include Hooks::InstanceHooks # Before request hook define_hook :before @@ -223,6 +224,12 @@ module Middleman end alias :inspect :to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s + # Hooks clones _hooks from the class to the instance. + # https://github.com/apotonick/hooks/blob/master/lib/hooks/instance_hooks.rb#L10 + # Middleman expects the same list of hooks for class and instance hooks: + def _hooks + self.class._hooks + end end end diff --git a/middleman-core/lib/middleman-more/core_extensions/compass.rb b/middleman-core/lib/middleman-more/core_extensions/compass.rb index cdf2c299..2aa46d47 100644 --- a/middleman-core/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-more/core_extensions/compass.rb @@ -49,7 +49,7 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension end # Call hook - app.run_hook :compass_config, ::Compass.configuration + app.run_hook_for :compass_config, app, ::Compass.configuration # Tell Tilt to use it as well (for inline sass blocks) ::Tilt.register 'sass', CompassSassTemplate @@ -73,4 +73,4 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension super.merge(::Compass.configuration.to_sass_engine_options) end end -end \ No newline at end of file +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb index 02ad0964..d7c6d5dd 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb @@ -77,11 +77,6 @@ module Hooks end def define_hook_writer(name) - self.send(:define_method, name.to_sym) do |&block| - if self.class.respond_to?(name) - self.class.send(name.to_sym, &block) - end - end instance_eval *hook_writer_args(name) end