パイプ処理 デバッグコード消し

デバッグ用に出力していた部分を修正。
他に execute に設定ファイルの設定を渡すように修正。

require 'yaml'

module Xry
  class Core
    def initialize(config)
      @config = YAML.load(File.read(config))
    end

    def load_plugin(dir)
      Dir::glob("#{dir}/*rb") {|file|
        File::open(file, "r") {|fd|
          eval(fd.read)
        }
      }
    end

    def execute
      pipelist = []

      @config.each {|m|
        c = nil

        code = %Q{c = #{self.class}::#{m['module']}.new\n}
        eval(code)

        pipelist << {:class => c, :config => m['config']}
      }

      context = {}

      pipelist.each {|p|
        ctx = nil

        code = %Q{ctx = p[:class].execute(p[:config], context)\n}
        eval(code)
      }
    end
  end
end

if $0 == __FILE__

  xry = Xry::Core.new("sample.conf")

  xry.load_plugin("./plugin")

  xry.execute

end