From 0f9b16f6df09fd835e55bd72898806b27ec93e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 8 Jan 2013 13:47:54 +0100 Subject: before_all and after_all accept parameter or proc --- Changelog | 5 +++++ lib/zorglub/node.rb | 8 ++++---- spec/spec_helper.rb | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index 66a5f5d..3986afc 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,9 @@ 2013-01-08 Jérémy Zurcher + * release 0.7 + * zorglub.rb swallows version.rb + * before_all and after_all accept parameter or proc + +2013-01-08 Jérémy Zurcher * release 0.6 * add sass engine * use Bundler diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 8fe1e4e..253d747 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -196,8 +196,8 @@ module Zorglub @cli_vals[:before_all].each do |blk| blk.call obj end end # - def before_all &blk - @cli_vals[:before_all]<< blk + def before_all meth=nil, &blk + @cli_vals[:before_all]<< ( meth.nil? ? blk : meth ) @cli_vals[:before_all].uniq! end # @@ -205,8 +205,8 @@ module Zorglub @cli_vals[:after_all].each do |blk| blk.call obj end end # - def after_all &blk - @cli_vals[:after_all]<< blk + def after_all meth=nil, &blk + @cli_vals[:after_all]<< ( meth.nil? ? blk : meth ) @cli_vals[:after_all].uniq! end # diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9369519..262e966 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -103,13 +103,14 @@ class Node3 < Zorglub::Node @after=0 class << self attr_accessor :before, :after + def post obj + @after +=1 + end end before_all do |node| Node3.before +=1 end - after_all do |node| - Node3.after +=1 - end + after_all Node3.method(:post) layout! 'layout-2' engine! 'engine-2' def index -- cgit v1.1-2-g2b99