Skip to content
Snippets Groups Projects
Commit a1fe7c47 authored by cleemy desu wayo's avatarcleemy desu wayo
Browse files

odify: add new feature "hooklo" and change event_cond to be optional

parent eebee8e9
No related merge requests found
#!/usr/bin/env ruby
#
# ==========================================================================
# Outvoke -- version 0.0.99.20240817
# Outvoke -- version 0.0.99.20240818
#
# written by cleemy desu wayo / Licensed under CC0 1.0
#
......@@ -23,7 +23,7 @@ class Outvoke
@version = Struct.new(:branch, :body).new(
'0.1',
'0.0.99.20240817'
'0.0.99.20240818'
)
@sources = Hash.new
......@@ -159,7 +159,7 @@ end
module OutvokeDSL
refine Kernel do
def hook(ds_cond, event_cond, &block)
def hook(ds_cond, event_cond = /./, &block)
raise '$outvoke is not an Outvoke object' unless $outvoke.is_a?(Outvoke)
$outvoke.extract_ds(ds_cond).each do |label|
......@@ -176,7 +176,7 @@ module OutvokeDSL
end
# if block is given, execute in another thread (concurrent computing)
def hookcc(ds_cond, event_cond, &block)
def hookcc(ds_cond, event_cond = /./, &block)
if block_given?
hook(ds_cond, event_cond) {|x| Thread.start { yield x } ; nil }
else
......@@ -184,6 +184,14 @@ module OutvokeDSL
end
end
def hooklo(event_cond = /./, &block)
if block_given?
hook("lo", event_cond) {|x| yield x }
else
hook("lo", event_cond)
end
end
def loputs(x)
$outvoke.loputs(x)
end
......
    0% or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment