From a0115f27c17317cb9d2a2e4012cdbbb88b987063 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Wed, 13 Aug 2014 15:12:09 +0300 Subject: fix pre/post blocks --- lib/oxidized/model/model.rb | 8 ++++---- lib/oxidized/model/outputs.rb | 4 ++++ lib/oxidized/string.rb | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb index 7258912..d3f54b9 100644 --- a/lib/oxidized/model/model.rb +++ b/lib/oxidized/model/model.rb @@ -127,16 +127,16 @@ module Oxidized def get outputs = Outputs.new procs = self.class.procs - procs[:pre].each do |pre_proc| - outputs << instance_eval(&pre_proc) - end self.class.cmds[:cmd].each do |command, block| out = cmd command, &block return false unless out outputs << out end + procs[:pre].each do |pre_proc| + outputs.unshift Oxidized::String.new(instance_eval(&pre_proc)) + end procs[:post].each do |post_proc| - outputs << instance_eval(&post_proc) + outputs << Oxidized::String.new(instance_eval(&post_proc)) end outputs end diff --git a/lib/oxidized/model/outputs.rb b/lib/oxidized/model/outputs.rb index 10015f8..a668e9d 100644 --- a/lib/oxidized/model/outputs.rb +++ b/lib/oxidized/model/outputs.rb @@ -14,6 +14,10 @@ module Oxidized @outputs << output end + def unshift output + @outputs.unshift output + end + def all @outputs end diff --git a/lib/oxidized/string.rb b/lib/oxidized/string.rb index d95bcae..4bdfbf2 100644 --- a/lib/oxidized/string.rb +++ b/lib/oxidized/string.rb @@ -19,5 +19,14 @@ module Oxidized @name = @cmd.strip.gsub(/\s+/, '_') if @name == nil end + def initialize str='' + super + if str.class == Oxidized::String + @cmd = str.cmd + @name = str.name + @type = str.type + end + end + end end -- cgit v1.2.1