summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/evendoors.rb3
-rw-r--r--lib/evendoors/board.rb2
-rw-r--r--lib/evendoors/door.rb8
-rw-r--r--lib/evendoors/room.rb32
-rw-r--r--lib/evendoors/space.rb26
-rw-r--r--lib/evendoors/spin.rb (renamed from lib/evendoors/twirl.rb)21
-rw-r--r--spec/evendoors_spec.rb202
-rw-r--r--test/test_evendoors.rb28
8 files changed, 152 insertions, 170 deletions
diff --git a/lib/evendoors.rb b/lib/evendoors.rb
index bab656e..0a9a941 100644
--- a/lib/evendoors.rb
+++ b/lib/evendoors.rb
@@ -33,9 +33,8 @@ end
#
require 'evendoors/particle'
require 'evendoors/spot'
-require 'evendoors/twirl'
require 'evendoors/room'
-require 'evendoors/space'
+require 'evendoors/spin'
require 'evendoors/door'
require 'evendoors/board'
require 'evendoors/link'
diff --git a/lib/evendoors/board.rb b/lib/evendoors/board.rb
index 3cc2240..36ca332 100644
--- a/lib/evendoors/board.rb
+++ b/lib/evendoors/board.rb
@@ -23,7 +23,7 @@ module EvenDoors
@saved = p
receive_p p
if not @saved.nil?
- puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug_errors
+ puts "#{path} didn't give that particle back #{p}" if EvenDoors::Spin.debug_errors
puts "\t#{p.data EvenDoors::ERROR_FIELD}" if p.action==EvenDoors::ACT_ERROR
release_p @saved
@saved = nil
diff --git a/lib/evendoors/door.rb b/lib/evendoors/door.rb
index 6118a27..0fe3867 100644
--- a/lib/evendoors/door.rb
+++ b/lib/evendoors/door.rb
@@ -13,14 +13,14 @@ module EvenDoors
end
#
def require_p p_kls
- p = EvenDoors::Twirl.require_p p_kls
+ p = EvenDoors::Spin.require_p p_kls
p.src = self
p
end
#
def release_p p
@saved=nil if @saved==p # particle is released, all is good
- EvenDoors::Twirl.release_p p
+ EvenDoors::Spin.release_p p
end
#
def process_p p
@@ -28,7 +28,7 @@ module EvenDoors
@saved = p
receive_p p
if not @saved.nil?
- puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug_errors
+ puts "#{path} didn't give that particle back #{p}" if EvenDoors::Spin.debug_errors
puts "\t#{p.data EvenDoors::ERROR_FIELD}" if p.action==EvenDoors::ACT_ERROR
release_p @saved
@saved = nil
@@ -37,7 +37,7 @@ module EvenDoors
#
def process_sys_p p
# nothing todo with it now
- EvenDoors::Twirl.release_p p
+ EvenDoors::Spin.release_p p
end
#
def send_p p
diff --git a/lib/evendoors/room.rb b/lib/evendoors/room.rb
index bc9ee63..d06c00f 100644
--- a/lib/evendoors/room.rb
+++ b/lib/evendoors/room.rb
@@ -28,22 +28,22 @@ module EvenDoors
end
#
def start!
- puts " * start #{path}" if EvenDoors::Twirl.debug_routing
+ puts " * start #{path}" if EvenDoors::Spin.debug_routing
@spots.values.each do |spot| spot.start! if spot.respond_to? :start! end
end
#
def stop!
- puts " * stop #{path}" if EvenDoors::Twirl.debug_routing
+ puts " * stop #{path}" if EvenDoors::Spin.debug_routing
@spots.values.each do |spot| spot.stop! if spot.respond_to? :stop! end
end
#
- def space
- return @space if @space
- @space = ( @parent.nil? ? self : @parent.space )
+ def spin
+ return @spin if @spin
+ @spin = ( @parent.nil? ? self : @parent.spin )
end
#
def try_links p
- puts " -> try_links ..." if EvenDoors::Twirl.debug_routing
+ puts " -> try_links ..." if EvenDoors::Spin.debug_routing
links = @links[p.src.name]
return false if links.nil?
pending_link = nil
@@ -54,7 +54,7 @@ module EvenDoors
if apply_link or (p.link_value==link.cond_value)
# link matches !
if pending_link
- p2 = EvenDoors::Twirl.require_p p.class
+ p2 = EvenDoors::Spin.require_p p.class
p2.clone_data p
p2.apply_link! link
send_p p2
@@ -87,10 +87,10 @@ module EvenDoors
end
#
def send_p p
- puts " * send_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug_routing
+ puts " * send_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Spin.debug_routing
if p.src.nil?
# do not route orphan particles !!
- p.error! EvenDoors::ERROR_ROUTE_NS, space
+ p.error! EvenDoors::ERROR_ROUTE_NS, spin
elsif p.next_dst
p.split_dst!
if p.door
@@ -104,31 +104,31 @@ module EvenDoors
else
p.error! EvenDoors::ERROR_ROUTE_NDNL
end
- puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug_routing
- EvenDoors::Twirl.send_p p
+ puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Spin.debug_routing
+ EvenDoors::Spin.send_p p
end
#
def send_sys_p p
- puts " * send_sys_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug_routing
+ puts " * send_sys_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Spin.debug_routing
if p.next_dst
p.split_dst!
if p.door
route_p p
elsif p.action
- p.dst_routed! space
+ p.dst_routed! spin
end
else
p.error! EvenDoors::ERROR_ROUTE_SND
end
- puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug_routing
- EvenDoors::Twirl.send_sys_p p
+ puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Spin.debug_routing
+ EvenDoors::Spin.send_sys_p p
end
#
def process_sys_p p
if p.action==EvenDoors::SYS_ACT_ADD_LINK
add_link EvenDoors::Link.from_particle_data p
end
- EvenDoors::Twirl.release_p p
+ EvenDoors::Spin.release_p p
end
#
end
diff --git a/lib/evendoors/space.rb b/lib/evendoors/space.rb
deleted file mode 100644
index da13065..0000000
--- a/lib/evendoors/space.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#! /usr/bin/env ruby
-# -*- coding: UTF-8 -*-
-
-#
-module EvenDoors
- #
- class Space < Room
- #
- def initialize n, args={}
- super n, nil
- EvenDoors::Twirl.debug_errors = args[:debug_errors] || false
- EvenDoors::Twirl.debug_routing = args[:debug_routing] || false
- end
- #
- def twirl!
- @spots.values.each do |spot| spot.start! end
- EvenDoors::Twirl.run = true
- EvenDoors::Twirl.twirl!
- @spots.values.each do |spot| spot.stop! end
- end
- #
- end
- #
-end
-#
-# EOF
diff --git a/lib/evendoors/twirl.rb b/lib/evendoors/spin.rb
index cb01618..31904e8 100644
--- a/lib/evendoors/twirl.rb
+++ b/lib/evendoors/spin.rb
@@ -4,15 +4,15 @@
#
module EvenDoors
#
- class Twirl
+ class Spin < Room
#
- @debug_routing = false
- @debug_errors = false
@pool = {} # per particle class free list
@sys_fifo = [] # system particles fifo list
@app_fifo = [] # application particles fifo list
#
@run = false
+ @debug_routing = false
+ @debug_errors = false
#
class << self
#
@@ -43,7 +43,7 @@ module EvenDoors
@sys_fifo << p
end
#
- def twirl!
+ def spin!
while @run and (@sys_fifo.length>0 or @app_fifo.length>0)
while @run and @sys_fifo.length>0
p = @sys_fifo.shift
@@ -64,6 +64,19 @@ module EvenDoors
#
end
#
+ def initialize n, args={}
+ super n, nil
+ self.class.debug_errors = args[:debug_errors] || false
+ self.class.debug_routing = args[:debug_routing] || false
+ end
+ #
+ def spin!
+ @spots.values.each do |spot| spot.start! end
+ self.class.run = true
+ self.class.spin!
+ @spots.values.each do |spot| spot.stop! end
+ end
+ #
end
#
end
diff --git a/spec/evendoors_spec.rb b/spec/evendoors_spec.rb
index 349497d..502abf7 100644
--- a/spec/evendoors_spec.rb
+++ b/spec/evendoors_spec.rb
@@ -48,60 +48,6 @@ describe EvenDoors do
expect{ EvenDoors }.not_to raise_error(NameError)
end
#
- describe EvenDoors::Twirl do
- #
- class MyP < EvenDoors::Particle; end
- #
- it "should correctly manage Particles pool" do
- p0 = EvenDoors::Twirl.require_p EvenDoors::Particle
- p1 = EvenDoors::Twirl.require_p EvenDoors::Particle
- (p0===p1).should be_false
- EvenDoors::Twirl.release_p p0
- p2 = EvenDoors::Twirl.require_p EvenDoors::Particle
- (p0===p2).should be_true
- end
- #
- it "should correctly manage different Particles classes" do
- p0 = EvenDoors::Twirl.require_p EvenDoors::Particle
- p1 = EvenDoors::Twirl.require_p EvenDoors::Particle
- (p0===p1).should be_false
- EvenDoors::Twirl.release_p p0
- p2 = EvenDoors::Twirl.require_p MyP
- p3 = EvenDoors::Twirl.require_p MyP
- (p2===p3).should be_false
- EvenDoors::Twirl.release_p p2
- p4 = EvenDoors::Twirl.require_p MyP
- (p2===p4).should be_true
- end
- #
- it "should correctly release merged data" do
- p0 = EvenDoors::Twirl.require_p EvenDoors::Particle
- p1 = EvenDoors::Twirl.require_p EvenDoors::Particle
- (p0===p1).should be_false
- p0.merge! p1
- EvenDoors::Twirl.release_p p0
- p2 = EvenDoors::Twirl.require_p EvenDoors::Particle
- (p2===p0).should be_true
- p3 = EvenDoors::Twirl.require_p EvenDoors::Particle
- (p3===p1).should be_true
- end
- #
- it "send_p send_sys_p twirl!" do
- f = Fake.new
- p0 = EvenDoors::Twirl.require_p EvenDoors::Particle
- p0.dst_routed! f
- p1 = EvenDoors::Twirl.require_p EvenDoors::Particle
- p1.dst_routed! f
- EvenDoors::Twirl.send_p p0
- EvenDoors::Twirl.send_sys_p p1
- EvenDoors::Twirl.run = true
- EvenDoors::Twirl.twirl!
- f.p.should be p0
- f.sp.should be p1
- end
- #
- end
- #
describe EvenDoors::Particle do
#
it "payload manipulation" do
@@ -286,7 +232,7 @@ describe EvenDoors do
describe EvenDoors::Link do
#
it "from particle data" do
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.set_data EvenDoors::LNK_SRC, 'input1'
p.set_data EvenDoors::LNK_DSTS, 'concat1?follow,output1'
p.set_data EvenDoors::LNK_FIELDS, 'f0,f2'
@@ -317,22 +263,72 @@ describe EvenDoors do
#
end
#
- describe EvenDoors::Space do
+ describe EvenDoors::Spin do
+ #
+ class MyP < EvenDoors::Particle; end
+ #
+ it "should correctly manage Particles pool" do
+ p0 = EvenDoors::Spin.require_p EvenDoors::Particle
+ p1 = EvenDoors::Spin.require_p EvenDoors::Particle
+ (p0===p1).should be_false
+ EvenDoors::Spin.release_p p0
+ p2 = EvenDoors::Spin.require_p EvenDoors::Particle
+ (p0===p2).should be_true
+ end
+ #
+ it "should correctly manage different Particles classes" do
+ p0 = EvenDoors::Spin.require_p EvenDoors::Particle
+ p1 = EvenDoors::Spin.require_p EvenDoors::Particle
+ (p0===p1).should be_false
+ EvenDoors::Spin.release_p p0
+ p2 = EvenDoors::Spin.require_p MyP
+ p3 = EvenDoors::Spin.require_p MyP
+ (p2===p3).should be_false
+ EvenDoors::Spin.release_p p2
+ p4 = EvenDoors::Spin.require_p MyP
+ (p2===p4).should be_true
+ end
+ #
+ it "should correctly release merged data" do
+ p0 = EvenDoors::Spin.require_p EvenDoors::Particle
+ p1 = EvenDoors::Spin.require_p EvenDoors::Particle
+ (p0===p1).should be_false
+ p0.merge! p1
+ EvenDoors::Spin.release_p p0
+ p2 = EvenDoors::Spin.require_p EvenDoors::Particle
+ (p2===p0).should be_true
+ p3 = EvenDoors::Spin.require_p EvenDoors::Particle
+ (p3===p1).should be_true
+ end
+ #
+ it "send_p send_sys_p spin!" do
+ f = Fake.new
+ p0 = EvenDoors::Spin.require_p EvenDoors::Particle
+ p0.dst_routed! f
+ p1 = EvenDoors::Spin.require_p EvenDoors::Particle
+ p1.dst_routed! f
+ EvenDoors::Spin.send_p p0
+ EvenDoors::Spin.send_sys_p p1
+ EvenDoors::Spin.run = true
+ EvenDoors::Spin.spin!
+ f.p.should be p0
+ f.sp.should be p1
+ end
#
it "does really little for now" do
- EvenDoors::Twirl.debug_routing.should be false
- space = EvenDoors::Space.new 'dom0', :debug_routing=>true
- EvenDoors::Twirl.debug_routing.should be true
- space.twirl!
- EvenDoors::Twirl.debug_routing = false
- EvenDoors::Twirl.debug_routing.should be false
+ EvenDoors::Spin.debug_routing.should be false
+ spin = EvenDoors::Spin.new 'dom0', :debug_routing=>true
+ EvenDoors::Spin.debug_routing.should be true
+ spin.spin!
+ EvenDoors::Spin.debug_routing = false
+ EvenDoors::Spin.debug_routing.should be false
#
- EvenDoors::Twirl.debug_errors.should be false
- space = EvenDoors::Space.new 'dom0', :debug_errors=>true
- EvenDoors::Twirl.debug_errors.should be true
- space.twirl!
- EvenDoors::Twirl.debug_errors = false
- EvenDoors::Twirl.debug_errors.should be false
+ EvenDoors::Spin.debug_errors.should be false
+ spin = EvenDoors::Spin.new 'dom0', :debug_errors=>true
+ EvenDoors::Spin.debug_errors.should be true
+ spin.spin!
+ EvenDoors::Spin.debug_errors = false
+ EvenDoors::Spin.debug_errors.should be false
end
#
end
@@ -369,7 +365,7 @@ describe EvenDoors do
end
f = Fake.new
d0 = Door0.new 'door0', f
- p0 = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p0 = EvenDoors::Spin.require_p EvenDoors::Particle
#
p0.set_dst! 'SEND'
p0.split_dst!
@@ -384,17 +380,17 @@ describe EvenDoors do
p0.set_dst! 'RELEASE'
p0.split_dst!
d0.process_p p0
- p1 = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p1 = EvenDoors::Spin.require_p EvenDoors::Particle
p1.should be p0
#
p0.set_dst! 'LOST'
p0.split_dst!
d0.process_p p0
- p1 = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p1 = EvenDoors::Spin.require_p EvenDoors::Particle
p1.should be p0
#
d0.process_sys_p p0
- p1 = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p1 = EvenDoors::Spin.require_p EvenDoors::Particle
p1.should be p0
end
#
@@ -492,32 +488,32 @@ describe EvenDoors do
d0.stop.should be_true
end
#
- it "parent and space should be ok" do
- s = EvenDoors::Space.new 'space'
+ it "parent and spin should be ok" do
+ s = EvenDoors::Spin.new 'dom0'
r0 = EvenDoors::Room.new 'r0', s
r1 = EvenDoors::Room.new 'r0', r0
r2 = EvenDoors::Room.new 'r0', r1
r2.parent.should be r1
r1.parent.should be r0
r0.parent.should be s
- r0.space.should be s
- r1.space.should be s
- r2.space.should be s
+ r0.spin.should be s
+ r1.spin.should be s
+ r2.spin.should be s
end
#
it "route error: no source" do
room = EvenDoors::Room.new 'room', nil
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.set_dst! 'get', 'room/door'
room.send_p p
p.action.should eql EvenDoors::ACT_ERROR
p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_NS
- p.dst.should be room.space
+ p.dst.should be room.spin
end
#
it "route error: no destination no links" do
room = EvenDoors::Room.new 'room', nil
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = Fake.new
room.send_p p
p.action.should eql EvenDoors::ACT_ERROR
@@ -528,7 +524,7 @@ describe EvenDoors do
it "route error: top room, wrong room" do
room0 = EvenDoors::Room.new 'room0', nil
room1 = EvenDoors::Room.new 'room1', room0
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = Fake.new
p.set_dst! 'get', 'noroom/door'
room1.send_p p
@@ -539,7 +535,7 @@ describe EvenDoors do
#
it "route error: right room, wrong door" do
room = EvenDoors::Room.new 'room', nil
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = Fake.new
p.set_dst! 'get', 'room/nodoor'
room.send_p p
@@ -551,7 +547,7 @@ describe EvenDoors do
it "route error: right room, wrong door (bubble up)" do
room0 = EvenDoors::Room.new 'room0', nil
room1 = EvenDoors::Room.new 'room1', room0
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = Fake.new
p.set_dst! 'get', 'room0/nodoor'
room1.send_p p
@@ -563,7 +559,7 @@ describe EvenDoors do
it "routing success (direct)" do
room0 = EvenDoors::Room.new 'room0', nil
door0 = EvenDoors::Door.new 'door0', room0
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = Fake.new
p.set_dst! 'get', 'door0'
room0.send_p p
@@ -575,7 +571,7 @@ describe EvenDoors do
room0 = EvenDoors::Room.new 'room0', nil
room1 = EvenDoors::Room.new 'room1', room0
door0 = EvenDoors::Door.new 'door0', room0
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = Fake.new
p.set_dst! 'get', 'room0/door0'
room1.send_p p
@@ -589,7 +585,7 @@ describe EvenDoors do
room2 = EvenDoors::Room.new 'room2', room0
room3 = EvenDoors::Room.new 'room3', room2
door0 = EvenDoors::Door.new 'door01', room1
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = Fake.new
p.set_dst! 'get', 'room0/room1/door01'
room3.send_p p
@@ -601,7 +597,7 @@ describe EvenDoors do
it "routing success: no door name -> src" do
room0 = EvenDoors::Room.new 'room0', nil
door0 = EvenDoors::Door.new 'door0', room0
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.src = door0
p.set_dst! 'get'
room0.send_p p
@@ -614,7 +610,7 @@ describe EvenDoors do
door0 = EvenDoors::Door.new 'door0', room0
door1 = EvenDoors::Door.new 'door1', room0
room0.add_link EvenDoors::Link.new('door0', 'door1')
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
door0.send_p p
p.action.should be_nil
p.dst.should be door1
@@ -625,7 +621,7 @@ describe EvenDoors do
door0 = EvenDoors::Door.new 'door0', room0
door1 = EvenDoors::Door.new 'door1', room0
room0.add_link EvenDoors::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1')
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p['f0']='v0'
p['f1']='v1'
door0.send_p p
@@ -647,13 +643,13 @@ describe EvenDoors do
door1 = Out.new 'door1', room0
room0.add_link EvenDoors::Link.new('door0', 'door1')
room0.add_link EvenDoors::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1')
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
- EvenDoors::Twirl.clear!
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
+ EvenDoors::Spin.clear!
p['f0']='v0'
p['f1']='v1'
door0.send_p p
- EvenDoors::Twirl.run = true
- EvenDoors::Twirl.twirl!
+ EvenDoors::Spin.run = true
+ EvenDoors::Spin.spin!
door1.ps.length.should eql 2
p0 = door1.ps[0]
p0.action.should be_nil
@@ -668,7 +664,7 @@ describe EvenDoors do
#
it "system route error: system no destination" do
room0 = EvenDoors::Room.new 'room0', nil
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
room0.send_sys_p p
p.action.should eql EvenDoors::ACT_ERROR
p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_SND
@@ -676,17 +672,17 @@ describe EvenDoors do
#
it "system routing success: action only" do
room0 = EvenDoors::Room.new 'room0', nil
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.set_dst! EvenDoors::SYS_ACT_ADD_LINK
room0.send_sys_p p
p.action.should eql EvenDoors::SYS_ACT_ADD_LINK
- p.dst.should be room0.space
+ p.dst.should be room0.spin
end
#
it "system routing success" do
room0 = EvenDoors::Room.new 'room0', nil
door0 = EvenDoors::Door.new 'door0', room0
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p.set_dst! EvenDoors::SYS_ACT_ADD_LINK, 'room0/door0'
room0.send_sys_p p
p.action.should eql EvenDoors::SYS_ACT_ADD_LINK
@@ -694,12 +690,12 @@ describe EvenDoors do
end
#
it "SYS_ACT_ADD_LINK should work" do
- EvenDoors::Twirl.clear!
- space = EvenDoors::Space.new 'space' # needed to be able to route to door
- room0 = EvenDoors::Room.new 'room0', space
+ EvenDoors::Spin.clear!
+ spin = EvenDoors::Spin.new 'dom0' # needed to be able to route to door
+ room0 = EvenDoors::Room.new 'room0', spin
door0 = EvenDoors::Door.new 'door0', room0
door1 = EvenDoors::Door.new 'door1', room0
- p0 = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p0 = EvenDoors::Spin.require_p EvenDoors::Particle
p0.set_data EvenDoors::LNK_SRC, 'door0'
p0.set_data EvenDoors::LNK_DSTS, 'door1'
p0.set_data EvenDoors::LNK_FIELDS, 'fields'
@@ -707,8 +703,8 @@ describe EvenDoors do
p0.set_data EvenDoors::LNK_CONDV, 'v0v1'
p0.set_dst! EvenDoors::SYS_ACT_ADD_LINK, room0.path
room0.send_sys_p p0
- space.twirl!
- p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ spin.spin!
+ p = EvenDoors::Spin.require_p EvenDoors::Particle
p['f0']='v0'
p['f1']='v1'
door0.send_p p
diff --git a/test/test_evendoors.rb b/test/test_evendoors.rb
index 2e8a732..60cd49d 100644
--- a/test/test_evendoors.rb
+++ b/test/test_evendoors.rb
@@ -7,7 +7,7 @@ require 'evendoors'
class InputDoor < EvenDoors::Door
#
def start!
- puts " * start #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing
+ puts " * start #{self.class.name} #{@path}" if EvenDoors::Spin.debug_routing
@lines = [ "#{name} says : hello", "world ( from #{path} )" ]
p = require_p EvenDoors::Particle
p.set_dst! EvenDoors::ACT_GET, path
@@ -15,11 +15,11 @@ class InputDoor < EvenDoors::Door
end
#
# def stop!
- # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing
+ # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Spin.debug_routing
# end
#
def receive_p p
- puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Twirl.debug_routing
+ puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Spin.debug_routing
if p.action==EvenDoors::ACT_GET
p.reset!
p.set_data 'line', @lines.shift
@@ -43,7 +43,7 @@ end
class ConcatBoard < EvenDoors::Board
#
def receive_p p
- puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Twirl.debug_routing
+ puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Spin.debug_routing
if p.action==EvenDoors::ACT_ERROR
#
else
@@ -63,28 +63,28 @@ end
class OutputDoor < EvenDoors::Door
#
# def start!
- # puts " * start #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing
+ # puts " * start #{self.class.name} #{@path}" if EvenDoors::Spin.debug_routing
# end
#
# def stop!
- # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing
+ # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Spin.debug_routing
# end
#
def receive_p p
- if EvenDoors::Twirl.debug_routing
+ if EvenDoors::Spin.debug_routing
puts " * #{self.class.name} receive_p : #{@path} : DATA #{p.get_data('line')}"
else
puts p.get_data 'line'
end
- # we do nothing EvenDoors::Twirl.process will detect it and release it
+ # we do nothing EvenDoors::Spin.process will detect it and release it
end
#
end
#
-space = EvenDoors::Space.new 'space', :debug_routing=>false, :debug_errors=>true
+spin = EvenDoors::Spin.new 'dom0', :debug_routing=>false, :debug_errors=>true
#
-room0 = EvenDoors::Room.new 'room0', space
-room1 = space.add_spot EvenDoors::Room.new 'room1'
+room0 = EvenDoors::Room.new 'room0', spin
+room1 = spin.add_spot EvenDoors::Room.new 'room1'
#
input0 = room0.add_spot InputDoor.new 'input0'
output0 = room0.add_spot OutputDoor.new 'output0'
@@ -97,16 +97,16 @@ room1.add_spot ConcatBoard.new 'concat1'
#
room0.add_link EvenDoors::Link.new('input0', 'output0', nil, nil, nil)
#
-p0 = EvenDoors::Twirl.require_p EvenDoors::Particle
+p0 = EvenDoors::Spin.require_p EvenDoors::Particle
p0.set_data EvenDoors::LNK_SRC, 'input1'
p0.set_data EvenDoors::LNK_DSTS, 'concat1?follow,output1'
p0.set_data EvenDoors::LNK_FIELDS, 'f0,f2'
p0.set_data EvenDoors::LNK_CONDF, 'f0,f1,f2'
p0.set_data EvenDoors::LNK_CONDV, 'v0v1v2'
p0.set_dst! EvenDoors::SYS_ACT_ADD_LINK, room1.path
-room1.send_sys_p p0 # send_sys_p -> room0 -> space -> room1 -> input1
+room1.send_sys_p p0 # send_sys_p -> room0 -> spin -> room1 -> input1
#
-space.twirl!
+spin.spin!
#
#
# EOF