Sha256: 855f7b8962b54067bedbfa357a5211b06af12ec5f7d01aed2c863f0ca8e12f8f
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'populus/pool' require 'populus/accepter' module Populus # Populus.watch :event, name: "sample" do # When {|data| data.has_key?('Payload') } # Runs do |data| # Populus.logger.info Base64.decode(data['Payload']) # end # end module DSL class DSLContext def initialize(wrap_obj) @wrap_obj = wrap_obj end def When(&do_foobar) @wrap_obj.condition = do_foobar end def Runs(&do_foobar) @wrap_obj.runner = do_foobar end end def watch(type, *arg, &b) accepter = find_accepter(type.to_s).new(metadata: arg.first) DSLContext.new(accepter).instance_eval(&b) Pool.register_object accepter end def find_accepter(type) const = type.gsub(/(^.|_.)/) {|c| c.tr('_', '').upcase } Accepter.const_get(const) end def eval_setting(path) load path rescue => e STDERR.puts "Invalid setting format! #{path}", "error is:", e.class, e.message, e.backtrace exit 1 end end extend DSL end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
populus-0.0.1 | lib/populus/dsl.rb |