diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-18 11:40:38 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-18 11:40:38 +0200 |
commit | 3e01a17ec9ed22867b409ffedab20e160de90ff7 (patch) | |
tree | d6708850502d3b320c4ea1c8bd2e37bd68a9b9c2 | |
parent | 18164a443ff6a6c4547e54357e48cd473298a806 (diff) | |
download | edoors-ruby-3e01a17ec9ed22867b409ffedab20e160de90ff7.zip edoors-ruby-3e01a17ec9ed22867b409ffedab20e160de90ff7.tar.gz |
social skills failure ;) evendoors-ruby is renamed into iotas
-rw-r--r-- | README.rdoc | 20 | ||||
-rw-r--r-- | Rakefile | 4 | ||||
-rw-r--r-- | lib/iotas.rb (renamed from lib/evendoors.rb) | 24 | ||||
-rw-r--r-- | lib/iotas/board.rb (renamed from lib/evendoors/board.rb) | 18 | ||||
-rw-r--r-- | lib/iotas/door.rb (renamed from lib/evendoors/door.rb) | 14 | ||||
-rw-r--r-- | lib/iotas/link.rb (renamed from lib/evendoors/link.rb) | 18 | ||||
-rw-r--r-- | lib/iotas/particle.rb (renamed from lib/evendoors/particle.rb) | 30 | ||||
-rw-r--r-- | lib/iotas/room.rb (renamed from lib/evendoors/room.rb) | 42 | ||||
-rw-r--r-- | lib/iotas/spin.rb (renamed from lib/evendoors/spin.rb) | 22 | ||||
-rw-r--r-- | lib/iotas/spot.rb (renamed from lib/evendoors/spot.rb) | 18 | ||||
-rw-r--r-- | spec/board_spec.rb | 32 | ||||
-rw-r--r-- | spec/door_spec.rb | 30 | ||||
-rw-r--r-- | spec/link_spec.rb | 22 | ||||
-rw-r--r-- | spec/particle_spec.rb | 76 | ||||
-rw-r--r-- | spec/room_spec.rb | 230 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 | ||||
-rw-r--r-- | spec/spin_spec.rb | 86 | ||||
-rw-r--r-- | spec/spot_spec.rb | 10 | ||||
-rw-r--r-- | test/test_evendoors.rb | 52 |
19 files changed, 371 insertions, 381 deletions
diff --git a/README.rdoc b/README.rdoc index ba5bab3..64c8812 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,26 +1,16 @@ -evendoors +iotas by Jérémy Zurcher http://asynk.ch == DESCRIPTION: -* a ruby port of evenja C++ application framework -* see http://www.revena.com/evenja/telecharger-evenja - -== FEATURES/PROBLEMS: - -* experimental material, we'll see where it leads +* a ruby rewrite of evenja C++ application framework concept +* see http://www.revena.com/evenja == SYNOPSIS: -# hum hum, well ... - -== CREDITS: - -Special thanks to: - -* Fabian Padilla +* experimental material, we'll see where it leads == LICENSE: -See LICENSE file. +AGPL http://www.gnu.org/licenses/agpl-3.0.html @@ -3,10 +3,10 @@ load './tasks/setup.rb' # # Project general information -PROJ.name = 'evendoors-ruby' +PROJ.name = 'iotas' PROJ.authors = 'Jérémy Zurcher' PROJ.email = 'jeremy@asynk.ch' -PROJ.url = 'https://github.com/jeremyz/evendoors-ruby' +PROJ.url = 'https://github.com/jeremyz/iotas' PROJ.version = '0.0.1' PROJ.rubyforge.name = 'FIXME' PROJ.readme_file = 'README.rdoc' diff --git a/lib/evendoors.rb b/lib/iotas.rb index e57cf26..24c021e 100644 --- a/lib/evendoors.rb +++ b/lib/iotas.rb @@ -3,23 +3,23 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. # -module EvenDoors +module Iotas # PATH_SEP = '/'.freeze LINK_SEP = ','.freeze @@ -53,12 +53,12 @@ module EvenDoors end # require 'json' -require 'evendoors/particle' -require 'evendoors/spot' -require 'evendoors/room' -require 'evendoors/spin' -require 'evendoors/door' -require 'evendoors/board' -require 'evendoors/link' +require 'iotas/particle' +require 'iotas/spot' +require 'iotas/room' +require 'iotas/spin' +require 'iotas/door' +require 'iotas/board' +require 'iotas/link' # # EOF diff --git a/lib/evendoors/board.rb b/lib/iotas/board.rb index a81b31a..8c1991f 100644 --- a/lib/evendoors/board.rb +++ b/lib/iotas/board.rb @@ -3,23 +3,23 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. # -module EvenDoors +module Iotas # class Board < Door # @@ -37,10 +37,10 @@ module EvenDoors end # def self.json_create o - raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + raise Iotas::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name board = self.new o['name'], o['parent'] o['postponed'].each do |link_value,particle| - board.process_p EvenDoors::Particle.json_create(particle.merge!('spin'=>board.spin)) + board.process_p Iotas::Particle.json_create(particle.merge!('spin'=>board.spin)) end board.resume! o board @@ -48,11 +48,11 @@ module EvenDoors # def process_p p @viewer.receive_p p if @viewer - if p.action!=EvenDoors::ACT_ERROR + if p.action!=Iotas::ACT_ERROR p2 = @postponed[p.link_value] ||= p return if p2==p @postponed.delete p.link_value - p,p2 = p2,p if p.action==EvenDoors::ACT_FOLLOW + p,p2 = p2,p if p.action==Iotas::ACT_FOLLOW p.merge! p2 end @saved = p diff --git a/lib/evendoors/door.rb b/lib/iotas/door.rb index bcf8534..8474b09 100644 --- a/lib/evendoors/door.rb +++ b/lib/iotas/door.rb @@ -3,23 +3,23 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. # -module EvenDoors +module Iotas # class Door < Spot # @@ -36,7 +36,7 @@ module EvenDoors end # def self.json_create o - raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + raise Iotas::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name door = self.new o['name'], o['parent'] door.resume! o door @@ -55,7 +55,7 @@ module EvenDoors # def garbage puts " ! #{path} didn't give back #{@saved}" if @spin.debug_errors - puts "\t#{@saved.data EvenDoors::FIELD_ERROR_MSG}" if @saved.action==EvenDoors::ACT_ERROR + puts "\t#{@saved.data Iotas::FIELD_ERROR_MSG}" if @saved.action==Iotas::ACT_ERROR release_p @saved @saved = nil end diff --git a/lib/evendoors/link.rb b/lib/iotas/link.rb index 1e11191..b1fd9ba 100644 --- a/lib/evendoors/link.rb +++ b/lib/iotas/link.rb @@ -3,23 +3,23 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. # -module EvenDoors +module Iotas # class Link # @@ -44,14 +44,14 @@ module EvenDoors end # def self.json_create o - raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + raise Iotas::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name self.new o['src'], o['dsts'], o['fields'], o['cond_fields'], o['cond_value'] end # def self.from_particle_data p - EvenDoors::Link.new(p.get_data(EvenDoors::LNK_SRC), p.get_data(EvenDoors::LNK_DSTS), - p.get_data(EvenDoors::LNK_FIELDS), p.get_data(EvenDoors::LNK_CONDF), - p.get_data(EvenDoors::LNK_CONDV)) + Iotas::Link.new(p.get_data(Iotas::LNK_SRC), p.get_data(Iotas::LNK_DSTS), + p.get_data(Iotas::LNK_FIELDS), p.get_data(Iotas::LNK_CONDF), + p.get_data(Iotas::LNK_CONDV)) end # attr_accessor :door diff --git a/lib/evendoors/particle.rb b/lib/iotas/particle.rb index b3bfa82..ffb141b 100644 --- a/lib/evendoors/particle.rb +++ b/lib/iotas/particle.rb @@ -3,24 +3,24 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. require 'time' # -module EvenDoors +module Iotas # class Particle # @@ -71,7 +71,7 @@ module EvenDoors end # def self.json_create o - raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + raise Iotas::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name self.new o end # @@ -98,10 +98,10 @@ module EvenDoors end # def add_dsts dsts - dsts.split(EvenDoors::LINK_SEP).each do |dst| - if dst.empty? or dst[0]==EvenDoors::PATH_SEP or dst[0]==EvenDoors::PATH_SEP or dst=~/\/\?/\ - or dst=~/\/{2,}/ or dst=~/\s+/ or dst==EvenDoors::ACT_SEP - raise EvenDoors::Exception.new "destination #{dst} is not acceptable" + dsts.split(Iotas::LINK_SEP).each do |dst| + if dst.empty? or dst[0]==Iotas::PATH_SEP or dst[0]==Iotas::PATH_SEP or dst=~/\/\?/\ + or dst=~/\/{2,}/ or dst=~/\s+/ or dst==Iotas::ACT_SEP + raise Iotas::Exception.new "destination #{dst} is not acceptable" end @dsts << dst end @@ -110,14 +110,14 @@ module EvenDoors def set_dst! a, d='' @dst = @room = @door = @action = nil clear_dsts! - add_dsts d+EvenDoors::ACT_SEP+a + add_dsts d+Iotas::ACT_SEP+a end # def split_dst! @dst = @room = @door = @action = nil return if (n = next_dst).nil? - p, @action = n.split EvenDoors::ACT_SEP - i = p.rindex EvenDoors::PATH_SEP + p, @action = n.split Iotas::ACT_SEP + i = p.rindex Iotas::PATH_SEP if i.nil? @room = nil @door = p @@ -134,9 +134,9 @@ module EvenDoors end # def error! e, dst=nil - @action = EvenDoors::ACT_ERROR + @action = Iotas::ACT_ERROR @dst = dst||@src - @payload[EvenDoors::FIELD_ERROR_MSG]=e + @payload[Iotas::FIELD_ERROR_MSG]=e end # def apply_link! lnk diff --git a/lib/evendoors/room.rb b/lib/iotas/room.rb index caaf565..569c921 100644 --- a/lib/evendoors/room.rb +++ b/lib/iotas/room.rb @@ -3,23 +3,23 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. # -module EvenDoors +module Iotas # class Room < Spot # @@ -39,29 +39,29 @@ module EvenDoors end # def self.json_create o - raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + raise Iotas::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name room = self.new o['name'], o['parent'] o['spots'].each do |name,spot| eval( spot['kls'] ).json_create(spot.merge!('parent'=>room)) end o['links'].each do |src,links| links.each do |link| - room.add_link EvenDoors::Link.json_create(link) + room.add_link Iotas::Link.json_create(link) end end room end # def add_spot s - raise EvenDoors::Exception.new "Spot #{s.name} already has #{s.parent.name} as parent" if not s.parent.nil? and s.parent!=self - raise EvenDoors::Exception.new "Spot #{s.name} already exists in #{path}" if @spots.has_key? s.name + raise Iotas::Exception.new "Spot #{s.name} already has #{s.parent.name} as parent" if not s.parent.nil? and s.parent!=self + raise Iotas::Exception.new "Spot #{s.name} already exists in #{path}" if @spots.has_key? s.name s.parent = self if s.parent.nil? @spots[s.name]=s end # def add_link l l.door = @spots[l.src] - raise EvenDoors::Exception.new "Link source #{l.src} does not exist in #{path}" if l.door.nil? + raise Iotas::Exception.new "Link source #{l.src} does not exist in #{path}" if l.door.nil? (@links[l.src] ||= [])<< l end # @@ -117,19 +117,19 @@ module EvenDoors if door = @spots[p.door] p.dst_routed! door else - p.error! EvenDoors::ERROR_ROUTE_RRWD + p.error! Iotas::ERROR_ROUTE_RRWD end elsif (p.room=~/^#{path}\/(.*)/)==0 - room, *more = $1.split EvenDoors::PATH_SEP + room, *more = $1.split Iotas::PATH_SEP if child=@spots[room] child.route_p p else - p.error! EvenDoors::ERROR_ROUTE_DDWR + p.error! Iotas::ERROR_ROUTE_DDWR end elsif @parent @parent.route_p p else - p.error! EvenDoors::ERROR_ROUTE_TRWR + p.error! Iotas::ERROR_ROUTE_TRWR end end # @@ -137,7 +137,7 @@ module EvenDoors puts " * send_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if @spin.debug_routing if p.src.nil? # do not route orphan particles !! - p.error! EvenDoors::ERROR_ROUTE_NS, @spin + p.error! Iotas::ERROR_ROUTE_NS, @spin elsif p.next_dst p.split_dst! if p.door @@ -149,9 +149,9 @@ module EvenDoors elsif try_links p return else - p.error! EvenDoors::ERROR_ROUTE_NDNL + p.error! Iotas::ERROR_ROUTE_NDNL end - puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if @spin.debug_routing + puts " -> #{p.dst.path}#{Iotas::ACT_SEP}#{p.action}" if @spin.debug_routing @spin.post_p p end # @@ -165,15 +165,15 @@ module EvenDoors p.dst_routed! @spin end else - p.error! EvenDoors::ERROR_ROUTE_SND + p.error! Iotas::ERROR_ROUTE_SND end - puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if @spin.debug_routing + puts " -> #{p.dst.path}#{Iotas::ACT_SEP}#{p.action}" if @spin.debug_routing @spin.post_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 + if p.action==Iotas::SYS_ACT_ADD_LINK + add_link Iotas::Link.from_particle_data p end @spin.release_p p end diff --git a/lib/evendoors/spin.rb b/lib/iotas/spin.rb index 5361a76..03c0141 100644 --- a/lib/evendoors/spin.rb +++ b/lib/iotas/spin.rb @@ -3,23 +3,23 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. # -module EvenDoors +module Iotas # class Spin < Room # @@ -32,19 +32,19 @@ module EvenDoors # @run = false @hibernation = o['hibernation']||false - @hibernate_path = 'evendoors-hibernate-'+n+'.json' + @hibernate_path = 'iotas-hibernate-'+n+'.json' @debug_errors = o[:debug_errors]||o['debug_errors']||false @debug_routing = o[:debug_routing]||o['debug_routing']||false # if not o.empty? o['spots'].each do |name,spot| - EvenDoors::Room.json_create(spot.merge!('parent'=>self)) + Iotas::Room.json_create(spot.merge!('parent'=>self)) end if o['spots'] o['app_fifo'].each do |particle| - @app_fifo << EvenDoors::Particle.json_create(particle.merge!('spin'=>self)) + @app_fifo << Iotas::Particle.json_create(particle.merge!('spin'=>self)) end if o['app_fifo'] o['sys_fifo'].each do |particle| - @sys_fifo << EvenDoors::Particle.json_create(particle.merge!('spin'=>self)) + @sys_fifo << Iotas::Particle.json_create(particle.merge!('spin'=>self)) end if o['sys_fifo'] end end @@ -66,7 +66,7 @@ module EvenDoors end # def self.json_create o - raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + raise Iotas::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name self.new o['name'], o end # @@ -104,7 +104,7 @@ module EvenDoors end # def process_sys_p p - if p.action==EvenDoors::SYS_ACT_HIBERNATE + if p.action==Iotas::SYS_ACT_HIBERNATE stop! hibernate! p[FIELD_HIBERNATE_PATH] else diff --git a/lib/evendoors/spot.rb b/lib/iotas/spot.rb index cbaba7a..aca0c2b 100644 --- a/lib/evendoors/spot.rb +++ b/lib/iotas/spot.rb @@ -3,23 +3,23 @@ # # Copyright 2012 Jérémy Zurcher <jeremy@asynk.ch> # -# This file is part of evendoors-ruby. +# This file is part of iotas. # -# evendoors-ruby is free software: you can redistribute it and/or modify +# iotas is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# evendoors-ruby is distributed in the hope that it will be useful, +# iotas is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with evendoors-ruby. If not, see <http://www.gnu.org/licenses/>. +# along with iotas. If not, see <http://www.gnu.org/licenses/>. # -module EvenDoors +module Iotas # class Spot # @@ -27,21 +27,21 @@ module EvenDoors @name = n # unique in it's room @parent = p # single direct parent @viewer = nil # particle going through that position will be sent there readonly - @path = ( @parent ? @parent.path+EvenDoors::PATH_SEP : '') + @name + @path = ( @parent ? @parent.path+Iotas::PATH_SEP : '') + @name @spin = ( @parent ? @parent.spin : self ) @parent.add_spot self if @parent - raise EvenDoors::Exception.new "Spot name #{name} is not valid" if @name.include? EvenDoors::PATH_SEP + raise Iotas::Exception.new "Spot name #{name} is not valid" if @name.include? Iotas::PATH_SEP end # attr_reader :name, :path, :spin attr_accessor :viewer, :parent # def start! - # override this to initialize yout object on stystem start + # override this to initialize your object on system start end # def stop! - # override this to initialize yout object on stystem stop + # override this to initialize your object on system stop end # def hibernate! diff --git a/spec/board_spec.rb b/spec/board_spec.rb index 9f76dc7..b533b23 100644 --- a/spec/board_spec.rb +++ b/spec/board_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe EvenDoors::Board do +describe Iotas::Board do # before (:all) do - @spin = EvenDoors::Spin.new 'dom0' + @spin = Iotas::Spin.new 'dom0' end # before(:each) do @@ -15,26 +15,26 @@ describe EvenDoors::Board do end # it "require_p release_p" do - board = EvenDoors::Board.new 'hell', @spin - p0 = board.require_p EvenDoors::Particle + board = Iotas::Board.new 'hell', @spin + p0 = board.require_p Iotas::Particle p0.src.should be board - p1 = board.require_p EvenDoors::Particle + p1 = board.require_p Iotas::Particle p1.src.should be board (p0===p1).should be_false board.release_p p0 - p2 = board.require_p EvenDoors::Particle + p2 = board.require_p Iotas::Particle p2.src.should be board (p0===p2).should be_true end # it "particle wait and merge" do - p0 = EvenDoors::Particle.new + p0 = Iotas::Particle.new p0['k0'] = 'v0' p0['k1'] = 'neither' p0['k2'] = 'v2' p0.set_link_fields 'k0,k2' p0.link_value.should eql 'v0v2' - p1 = EvenDoors::Particle.new + p1 = Iotas::Particle.new p1['k0'] = 'v0' p1['k1'] = 'nore' p1['k2'] = 'v2' @@ -42,12 +42,12 @@ describe EvenDoors::Board do p1.link_value.should eql 'v0v2' P0 = p0 P1 = p1 - class Board0 < EvenDoors::Board + class Board0 < Iotas::Board attr_reader :ok, :follow def receive_p p @ok = false case p.action - when EvenDoors::ACT_FOLLOW + when Iotas::ACT_FOLLOW @follow = true @ok = (p===P0 and p.merged(0)===P1) else @@ -68,9 +68,9 @@ describe EvenDoors::Board do b0.process_p p0 p0.merged(0).should be_nil # need to set it to p0 too, so case in Board0 is ok - p0.set_dst! EvenDoors::ACT_FOLLOW + p0.set_dst! Iotas::ACT_FOLLOW p0.split_dst! - p1.set_dst! EvenDoors::ACT_FOLLOW + p1.set_dst! Iotas::ACT_FOLLOW p1.split_dst! b0.process_p p1 b0.ok.should be_true @@ -78,14 +78,14 @@ describe EvenDoors::Board do end # it "board->json->board" do - board = EvenDoors::Board.new 'hell', @spin - p0 = EvenDoors::Particle.new - p1 = EvenDoors::Particle.new + board = Iotas::Board.new 'hell', @spin + p0 = Iotas::Particle.new + p1 = Iotas::Particle.new p1['v0']=0 p1.set_link_fields 'v0' board.process_p p0 board.process_p p1 - hell = EvenDoors::Board.json_create( JSON.load( JSON.generate(board) ) ) + hell = Iotas::Board.json_create( JSON.load( JSON.generate(board) ) ) board.name.should eql hell.name JSON.generate(board).should eql JSON.generate(hell) end diff --git a/spec/door_spec.rb b/spec/door_spec.rb index 254d59c..3d93518 100644 --- a/spec/door_spec.rb +++ b/spec/door_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe EvenDoors::Door do +describe Iotas::Door do # before (:all) do - @spin = EvenDoors::Spin.new 'dom0' + @spin = Iotas::Spin.new 'dom0' end # before(:each) do @@ -15,29 +15,29 @@ describe EvenDoors::Door do end # it "require_p release_p" do - door = EvenDoors::Door.new 'hell', @spin - p0 = door.require_p EvenDoors::Particle + door = Iotas::Door.new 'hell', @spin + p0 = door.require_p Iotas::Particle p0.src.should be door - p1 = door.require_p EvenDoors::Particle + p1 = door.require_p Iotas::Particle p1.src.should be door (p0===p1).should be_false door.release_p p0 - p2 = door.require_p EvenDoors::Particle + p2 = door.require_p Iotas::Particle p2.src.should be door (p0===p2).should be_true end # it "NoMethodError when receive_p not overridden" do - class Door0 < EvenDoors::Door + class Door0 < Iotas::Door end f = Fake.new 'fake', @spin d0 = Door0.new 'door0', f - p0 = d0.require_p EvenDoors::Particle + p0 = d0.require_p Iotas::Particle lambda { d0.process_p p0 }.should raise_error(NoMethodError) end # it "send_p, send_sys_p, release_p and release of lost particles" do - class Door0 < EvenDoors::Door + class Door0 < Iotas::Door def receive_p p case p.action when 'RELEASE' @@ -53,7 +53,7 @@ describe EvenDoors::Door do end f = Fake.new 'fake', @spin d0 = Door0.new 'door0', f - p0 = d0.require_p EvenDoors::Particle + p0 = d0.require_p Iotas::Particle # p0.set_dst! 'SEND' p0.split_dst! @@ -68,23 +68,23 @@ describe EvenDoors::Door do p0.set_dst! 'RELEASE' p0.split_dst! d0.process_p p0 - p1 = d0.require_p EvenDoors::Particle + p1 = d0.require_p Iotas::Particle p1.should be p0 # p0.set_dst! 'LOST' p0.split_dst! d0.process_p p0 - p1 = d0.require_p EvenDoors::Particle + p1 = d0.require_p Iotas::Particle p1.should be p0 # d0.process_sys_p p0 - p1 = @spin.require_p EvenDoors::Particle + p1 = @spin.require_p Iotas::Particle p1.should be p0 end # it "door->json->door" do - door = EvenDoors::Door.new 'hell', @spin - hell = EvenDoors::Door.json_create( JSON.load( JSON.generate(door) ) ) + door = Iotas::Door.new 'hell', @spin + hell = Iotas::Door.json_create( JSON.load( JSON.generate(door) ) ) door.name.should eql hell.name JSON.generate(door).should eql JSON.generate(hell) end diff --git a/spec/link_spec.rb b/spec/link_spec.rb index abfa162..6120677 100644 --- a/spec/link_spec.rb +++ b/spec/link_spec.rb @@ -4,17 +4,17 @@ require 'spec_helper' # -describe EvenDoors::Link do +describe Iotas::Link do # it "from particle data" do - @spin = EvenDoors::Spin.new 'dom0' - p = @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' - p.set_data EvenDoors::LNK_CONDF, 'f0,f1,f2' - p.set_data EvenDoors::LNK_CONDV, 'v0v1v2' - lnk = EvenDoors::Link.from_particle_data p + @spin = Iotas::Spin.new 'dom0' + p = @spin.require_p Iotas::Particle + p.set_data Iotas::LNK_SRC, 'input1' + p.set_data Iotas::LNK_DSTS, 'concat1?follow,output1' + p.set_data Iotas::LNK_FIELDS, 'f0,f2' + p.set_data Iotas::LNK_CONDF, 'f0,f1,f2' + p.set_data Iotas::LNK_CONDV, 'v0v1v2' + lnk = Iotas::Link.from_particle_data p lnk.src.should eql 'input1' lnk.dsts.should eql 'concat1?follow,output1' lnk.fields.should eql 'f0,f2' @@ -23,8 +23,8 @@ describe EvenDoors::Link do end # it "link->json->link" do - link = EvenDoors::Link.new 'input1', 'concat1?follow,output1', 'f0,f2', 'f0,f1,f2', 'v0v1v2' - lnk = EvenDoors::Link.json_create( JSON.load( JSON.generate(link) ) ) + link = Iotas::Link.new 'input1', 'concat1?follow,output1', 'f0,f2', 'f0,f1,f2', 'v0v1v2' + lnk = Iotas::Link.json_create( JSON.load( JSON.generate(link) ) ) link.src.should eql lnk.src link.dsts.should eql lnk.dsts link.fields.should eql lnk.fields diff --git a/spec/particle_spec.rb b/spec/particle_spec.rb index a3f8127..2a6d073 100644 --- a/spec/particle_spec.rb +++ b/spec/particle_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe EvenDoors::Particle do +describe Iotas::Particle do # it "payload manipulation" do - p = EvenDoors::Particle.new + p = Iotas::Particle.new # p['key']=666 p['key'].should eql 666 @@ -21,10 +21,10 @@ describe EvenDoors::Particle do end # it "payload clone" do - p = EvenDoors::Particle.new + p = Iotas::Particle.new p['k00'] = { 'k0'=>0,'k1'=>1} p['k11'] = [1,2,3] - o = EvenDoors::Particle.new + o = Iotas::Particle.new o.clone_data p p['k00']=nil p['k00'].should be_nil @@ -38,9 +38,9 @@ describe EvenDoors::Particle do end # it "particle merge" do - p = EvenDoors::Particle.new - q = EvenDoors::Particle.new - o = EvenDoors::Particle.new + p = Iotas::Particle.new + q = Iotas::Particle.new + o = Iotas::Particle.new p.merge! q p.merge! o p.merged(0).should be q @@ -60,9 +60,9 @@ describe EvenDoors::Particle do end # it "routing: add_dsts, next_dst and dst_routed!" do - p = EvenDoors::Particle.new - d0 = EvenDoors::Door.new 'door0', nil - d1 = EvenDoors::Door.new 'door1', nil + p = Iotas::Particle.new + d0 = Iotas::Door.new 'door0', nil + d1 = Iotas::Door.new 'door1', nil p.dst.should be_nil p.next_dst.should be_nil p.add_dsts 'some?where,room0/room1/door?action,room/door,door' @@ -79,24 +79,24 @@ describe EvenDoors::Particle do end # it "wrong path should raise exeption" do - p = EvenDoors::Particle.new - lambda { p.set_dst! 'action', '/room' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! 'action', 'room/' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! '', 'room/' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! 'action', 'room//door' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! ' ' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! ' ', '' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! 'f f' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! '', ' d' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! '' }.should raise_error(EvenDoors::Exception) - lambda { p.set_dst! '', '' }.should raise_error(EvenDoors::Exception) + p = Iotas::Particle.new + lambda { p.set_dst! 'action', '/room' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! 'action', 'room/' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! '', 'room/' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! 'action', 'room//door' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! ' ' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! ' ', '' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! 'f f' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! '', ' d' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! '' }.should raise_error(Iotas::Exception) + lambda { p.set_dst! '', '' }.should raise_error(Iotas::Exception) lambda { p.set_dst! nil }.should raise_error(TypeError) lambda { p.set_dst! 'action', nil }.should raise_error(NoMethodError) end # it "routing: set_dst! and split_dst!" do - p = EvenDoors::Particle.new - d0 = EvenDoors::Door.new 'door0', nil + p = Iotas::Particle.new + d0 = Iotas::Door.new 'door0', nil # p.set_dst! 'action', 'room0/room1/door' p.split_dst! @@ -140,19 +140,19 @@ describe EvenDoors::Particle do end # it "routing: error!" do - p = EvenDoors::Particle.new - d = EvenDoors::Door.new 'door', nil + p = Iotas::Particle.new + d = Iotas::Door.new 'door', nil p.src = d p.add_dsts 'door?action,?action' p.next_dst.should eql 'door?action' p.error! 'err_msg' - p[EvenDoors::FIELD_ERROR_MSG].should eql 'err_msg' - p.action.should eq EvenDoors::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql 'err_msg' + p.action.should eq Iotas::ACT_ERROR p.dst.should be d end # it "link fields and link value" do - p = EvenDoors::Particle.new + p = Iotas::Particle.new p['k0'] = 'v0' p['k1'] = 'v1' p['k2'] = 'v2' @@ -165,7 +165,7 @@ describe EvenDoors::Particle do end # it "apply_link!" do - p = EvenDoors::Particle.new + p = Iotas::Particle.new p['k0'] = 'v0' p['k1'] = 'v1' p['k2'] = 'v2' @@ -174,7 +174,7 @@ describe EvenDoors::Particle do p.src.should be_nil p.link_value.should eql 'v0v2' p.next_dst.should eql 'door?action' - lnk = EvenDoors::Link.new('door0', 'door1?get,door2', 'k1', 'f0,f1', 'v0v1') + lnk = Iotas::Link.new('door0', 'door1?get,door2', 'k1', 'f0,f1', 'v0v1') f = Fake.new 'fake', nil lnk.door = f p.apply_link! lnk @@ -184,12 +184,12 @@ describe EvenDoors::Particle do end # it "particle->json->particle" do - s0 = EvenDoors::Spin.new 'top' - s1 = EvenDoors::Room.new 'room0', s0 - s2 = EvenDoors::Room.new 'room1', s1 - s3 = EvenDoors::Door.new 'doora', s2 - s4 = EvenDoors::Door.new 'doorb', s1 - p0 = EvenDoors::Particle.new + s0 = Iotas::Spin.new 'top' + s1 = Iotas::Room.new 'room0', s0 + s2 = Iotas::Room.new 'room1', s1 + s3 = Iotas::Door.new 'doora', s2 + s4 = Iotas::Door.new 'doorb', s1 + p0 = Iotas::Particle.new p0['k0'] = 'v0' p0['k1'] = 'v1' p0['k2'] = 'v2' @@ -197,7 +197,7 @@ describe EvenDoors::Particle do p0.set_link_fields 'k0,k2' p0.add_dsts 'room0/room1/room2/doorX?myaction,door?action,?action' p0.split_dst! - p1 = EvenDoors::Particle.new + p1 = Iotas::Particle.new p1['k3'] = 'v6' p1['k4'] = 'v7' p1['k5'] = 'v8' @@ -208,7 +208,7 @@ describe EvenDoors::Particle do p0.merge! p1 o = JSON.load( JSON.generate(p0) ) o['spin'] = s0 - px = EvenDoors::Particle.json_create( o ) + px = Iotas::Particle.json_create( o ) ((px.ts-p0.ts)<0.5).should be_true px.src.should be s3 px.dst.should be_nil diff --git a/spec/room_spec.rb b/spec/room_spec.rb index c876204..06811a5 100644 --- a/spec/room_spec.rb +++ b/spec/room_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe EvenDoors::Room do +describe Iotas::Room do # before (:all) do - @spin = EvenDoors::Spin.new 'dom0' + @spin = Iotas::Spin.new 'dom0' end # before(:each) do @@ -15,16 +15,16 @@ describe EvenDoors::Room do end # it "add_spot and add_link correctly" do - r0 = EvenDoors::Room.new 'room0', @spin - d0 = EvenDoors::Door.new 'door0', r0 - lambda { EvenDoors::Door.new('door0', r0) }.should raise_error(EvenDoors::Exception) - lambda { r0.add_spot EvenDoors::Door.new('door1', r0) }.should raise_error(EvenDoors::Exception) - r0.add_link EvenDoors::Link.new 'door0', 'somewhere' - lambda { r0.add_link(EvenDoors::Link.new('nowhere', 'somewhere')) }.should raise_error(EvenDoors::Exception) + r0 = Iotas::Room.new 'room0', @spin + d0 = Iotas::Door.new 'door0', r0 + lambda { Iotas::Door.new('door0', r0) }.should raise_error(Iotas::Exception) + lambda { r0.add_spot Iotas::Door.new('door1', r0) }.should raise_error(Iotas::Exception) + r0.add_link Iotas::Link.new 'door0', 'somewhere' + lambda { r0.add_link(Iotas::Link.new('nowhere', 'somewhere')) }.should raise_error(Iotas::Exception) end # it "start! and stop! should work" do - r0 = EvenDoors::Room.new 'room0', @spin + r0 = Iotas::Room.new 'room0', @spin d0 = Fake.new 'fake', r0 d0.start.should be_nil d0.stop.should be_nil @@ -37,11 +37,11 @@ describe EvenDoors::Room do end # it "parent, spin and search_down should be ok" do - r0 = EvenDoors::Room.new 'r0', @spin - r1 = EvenDoors::Room.new 'r1', r0 - r2 = EvenDoors::Room.new 'r2', r1 - r3 = EvenDoors::Room.new 'r3', @spin - r4 = EvenDoors::Room.new 'r4', r3 + r0 = Iotas::Room.new 'r0', @spin + r1 = Iotas::Room.new 'r1', r0 + r2 = Iotas::Room.new 'r2', r1 + r3 = Iotas::Room.new 'r3', @spin + r4 = Iotas::Room.new 'r4', r3 r2.parent.should be r1 r1.parent.should be r0 r0.parent.should be @spin @@ -59,64 +59,64 @@ describe EvenDoors::Room do end # it "route error: no source" do - room = EvenDoors::Room.new 'room', @spin - p = @spin.require_p EvenDoors::Particle + room = Iotas::Room.new 'room', @spin + p = @spin.require_p Iotas::Particle p.set_dst! 'get', 'room/door' room.send_p p - p.action.should eql EvenDoors::ACT_ERROR - p[EvenDoors::FIELD_ERROR_MSG].should eql EvenDoors::ERROR_ROUTE_NS + p.action.should eql Iotas::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_NS p.dst.should be room.spin end # it "route error: no destination no links" do - room = EvenDoors::Room.new 'room', @spin - p = @spin.require_p EvenDoors::Particle + room = Iotas::Room.new 'room', @spin + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin room.send_p p - p.action.should eql EvenDoors::ACT_ERROR - p[EvenDoors::FIELD_ERROR_MSG].should eql EvenDoors::ERROR_ROUTE_NDNL + p.action.should eql Iotas::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_NDNL p.dst.should be p.src end # it "route error: top room, wrong room" do - room0 = EvenDoors::Room.new 'room0', @spin - room1 = EvenDoors::Room.new 'room1', room0 - p = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + room1 = Iotas::Room.new 'room1', room0 + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin p.set_dst! 'get', 'noroom/door' room1.send_p p - p.action.should eql EvenDoors::ACT_ERROR - p[EvenDoors::FIELD_ERROR_MSG].should eql EvenDoors::ERROR_ROUTE_TRWR + p.action.should eql Iotas::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_TRWR p.dst.should be p.src end # it "route error: right room, wrong door" do - room = EvenDoors::Room.new 'room', @spin - p = @spin.require_p EvenDoors::Particle + room = Iotas::Room.new 'room', @spin + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin p.set_dst! 'get', 'dom0/room/nodoor' room.send_p p - p.action.should eql EvenDoors::ACT_ERROR - p[EvenDoors::FIELD_ERROR_MSG].should eql EvenDoors::ERROR_ROUTE_RRWD + p.action.should eql Iotas::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_RRWD p.dst.should be p.src end # it "route error: right room, wrong door (bubble up)" do - room0 = EvenDoors::Room.new 'room0', @spin - room1 = EvenDoors::Room.new 'room1', room0 - p = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + room1 = Iotas::Room.new 'room1', room0 + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin p.set_dst! 'get', 'dom0/room0/nodoor' room1.send_p p - p.action.should eql EvenDoors::ACT_ERROR - p[EvenDoors::FIELD_ERROR_MSG].should eql EvenDoors::ERROR_ROUTE_RRWD + p.action.should eql Iotas::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_RRWD p.dst.should be p.src end # it "routing success (direct)" do - room0 = EvenDoors::Room.new 'room0', @spin - door0 = EvenDoors::Door.new 'door0', room0 - p = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + door0 = Iotas::Door.new 'door0', room0 + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin p.set_dst! 'get', 'door0' room0.send_p p @@ -125,10 +125,10 @@ describe EvenDoors::Room do end # it "routing success (bubble up the direct door)" do - room0 = EvenDoors::Room.new 'room0', @spin - room1 = EvenDoors::Room.new 'room1', room0 - door0 = EvenDoors::Door.new 'door0', room0 - p = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + room1 = Iotas::Room.new 'room1', room0 + door0 = Iotas::Door.new 'door0', room0 + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin p.set_dst! 'get', 'dom0/room0/door0' room1.send_p p @@ -137,13 +137,13 @@ describe EvenDoors::Room do end # it "route success: bubble up x2, drill down x3" do - room00 = EvenDoors::Room.new 'room00', @spin - room01 = EvenDoors::Room.new 'room01', room00 - room02 = EvenDoors::Room.new 'room02', room01 - door000 = EvenDoors::Door.new 'door000', room02 - room10 = EvenDoors::Room.new 'room10', @spin - room11 = EvenDoors::Room.new 'room11', room10 - p = @spin.require_p EvenDoors::Particle + room00 = Iotas::Room.new 'room00', @spin + room01 = Iotas::Room.new 'room01', room00 + room02 = Iotas::Room.new 'room02', room01 + door000 = Iotas::Door.new 'door000', room02 + room10 = Iotas::Room.new 'room10', @spin + room11 = Iotas::Room.new 'room11', room10 + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin p.set_dst! 'get', 'dom0/room00/room01/room02/door000' room11.send_p p @@ -152,25 +152,25 @@ describe EvenDoors::Room do end # it "route error: bubble up x2 drill down x2" do - room00 = EvenDoors::Room.new 'room00', @spin - room01 = EvenDoors::Room.new 'room01', room00 - room02 = EvenDoors::Room.new 'room02', room01 - door000 = EvenDoors::Door.new 'door000', room02 - room10 = EvenDoors::Room.new 'room10', @spin - room11 = EvenDoors::Room.new 'room11', room10 - p = @spin.require_p EvenDoors::Particle + room00 = Iotas::Room.new 'room00', @spin + room01 = Iotas::Room.new 'room01', room00 + room02 = Iotas::Room.new 'room02', room01 + door000 = Iotas::Door.new 'door000', room02 + room10 = Iotas::Room.new 'room10', @spin + room11 = Iotas::Room.new 'room11', room10 + p = @spin.require_p Iotas::Particle p.src = Fake.new 'fake', @spin p.set_dst! 'get', 'dom0/room00/room01/wrong/door000' room11.send_p p - p.action.should eql EvenDoors::ACT_ERROR - p[EvenDoors::FIELD_ERROR_MSG].should eql EvenDoors::ERROR_ROUTE_DDWR + p.action.should eql Iotas::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_DDWR p.dst.should be p.src end # it "routing success: no door name -> src" do - room0 = EvenDoors::Room.new 'room0', @spin - door0 = EvenDoors::Door.new 'door0', room0 - p = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + door0 = Iotas::Door.new 'door0', room0 + p = @spin.require_p Iotas::Particle p.src = door0 p.set_dst! 'get' room0.send_p p @@ -179,22 +179,22 @@ describe EvenDoors::Room do end # it "routing success: unconditional link" do - room0 = EvenDoors::Room.new 'room0', @spin - door0 = EvenDoors::Door.new 'door0', room0 - door1 = EvenDoors::Door.new 'door1', room0 - room0.add_link EvenDoors::Link.new('door0', 'door1') - p = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + door0 = Iotas::Door.new 'door0', room0 + door1 = Iotas::Door.new 'door1', room0 + room0.add_link Iotas::Link.new('door0', 'door1') + p = @spin.require_p Iotas::Particle door0.send_p p p.action.should be_nil p.dst.should be door1 end # it "routing success: conditional link" do - room0 = EvenDoors::Room.new 'room0', @spin - 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 = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + door0 = Iotas::Door.new 'door0', room0 + door1 = Iotas::Door.new 'door1', room0 + room0.add_link Iotas::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1') + p = @spin.require_p Iotas::Particle p['f0']='v0' p['f1']='v1' door0.send_p p @@ -204,9 +204,9 @@ describe EvenDoors::Room do end # it "routing success: more then one matching link" do - room0 = EvenDoors::Room.new 'room0', @spin - door0 = EvenDoors::Door.new 'door0', room0 - class Out < EvenDoors::Door + room0 = Iotas::Room.new 'room0', @spin + door0 = Iotas::Door.new 'door0', room0 + class Out < Iotas::Door attr_reader :ps def receive_p p @ps||=[] @@ -214,9 +214,9 @@ describe EvenDoors::Room do end end 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 = @spin.require_p EvenDoors::Particle + room0.add_link Iotas::Link.new('door0', 'door1') + room0.add_link Iotas::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1') + p = @spin.require_p Iotas::Particle p['f0']='v0' p['f1']='v1' door0.send_p p @@ -234,46 +234,46 @@ describe EvenDoors::Room do end # it "system route error: system no destination" do - room0 = EvenDoors::Room.new 'room0', @spin - p = @spin.require_p EvenDoors::Particle + room0 = Iotas::Room.new 'room0', @spin + p = @spin.require_p Iotas::Particle room0.send_sys_p p - p.action.should eql EvenDoors::ACT_ERROR - p[EvenDoors::FIELD_ERROR_MSG].should eql EvenDoors::ERROR_ROUTE_SND + p.action.should eql Iotas::ACT_ERROR + p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_SND end # it "system routing success: action only" do - room0 = EvenDoors::Room.new 'room0', @spin - p = @spin.require_p EvenDoors::Particle - p.set_dst! EvenDoors::SYS_ACT_ADD_LINK + room0 = Iotas::Room.new 'room0', @spin + p = @spin.require_p Iotas::Particle + p.set_dst! Iotas::SYS_ACT_ADD_LINK room0.send_sys_p p - p.action.should eql EvenDoors::SYS_ACT_ADD_LINK + p.action.should eql Iotas::SYS_ACT_ADD_LINK p.dst.should be room0.spin end # it "system routing success" do - room0 = EvenDoors::Room.new 'room0', @spin - door0 = EvenDoors::Door.new 'door0', room0 - p = @spin.require_p EvenDoors::Particle - p.set_dst! EvenDoors::SYS_ACT_ADD_LINK, 'dom0/room0/door0' + room0 = Iotas::Room.new 'room0', @spin + door0 = Iotas::Door.new 'door0', room0 + p = @spin.require_p Iotas::Particle + p.set_dst! Iotas::SYS_ACT_ADD_LINK, 'dom0/room0/door0' room0.send_sys_p p - p.action.should eql EvenDoors::SYS_ACT_ADD_LINK + p.action.should eql Iotas::SYS_ACT_ADD_LINK p.dst.should be door0 end # it "SYS_ACT_ADD_LINK" do - room0 = EvenDoors::Room.new 'room0', @spin - door0 = EvenDoors::Door.new 'door0', room0 - door1 = EvenDoors::Door.new 'door1', room0 - p0 = @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' - p0.set_data EvenDoors::LNK_CONDF, 'f0,f1' - p0.set_data EvenDoors::LNK_CONDV, 'v0v1' - p0.set_dst! EvenDoors::SYS_ACT_ADD_LINK, room0.path + room0 = Iotas::Room.new 'room0', @spin + door0 = Iotas::Door.new 'door0', room0 + door1 = Iotas::Door.new 'door1', room0 + p0 = @spin.require_p Iotas::Particle + p0.set_data Iotas::LNK_SRC, 'door0' + p0.set_data Iotas::LNK_DSTS, 'door1' + p0.set_data Iotas::LNK_FIELDS, 'fields' + p0.set_data Iotas::LNK_CONDF, 'f0,f1' + p0.set_data Iotas::LNK_CONDV, 'v0v1' + p0.set_dst! Iotas::SYS_ACT_ADD_LINK, room0.path room0.send_sys_p p0 @spin.spin! - p = @spin.require_p EvenDoors::Particle + p = @spin.require_p Iotas::Particle p['f0']='v0' p['f1']='v1' door0.send_p p @@ -283,19 +283,19 @@ describe EvenDoors::Room do end # it "room->json->room" do - r0 = EvenDoors::Room.new 'r0', @spin - r1 = EvenDoors::Room.new 'r1', r0 - r2 = EvenDoors::Room.new 'r2', r1 - r3 = EvenDoors::Room.new 'r3', r1 - r4 = EvenDoors::Room.new 'r4', r3 - d0 = EvenDoors::Door.new 'd0', r1 - d1 = EvenDoors::Door.new 'd1', r1 - d2 = EvenDoors::Door.new 'd2', r2 - r1.add_link EvenDoors::Link.new('d0', 'd1', 'fields', 'f0,f1', 'v0v1') - r1.add_link EvenDoors::Link.new('d0', 'd2') - r1.add_link EvenDoors::Link.new('d1', 'd0') - r2.add_link EvenDoors::Link.new('d2', 'd1', 'fies', 'f5,f1', 'v9v1') - rx = EvenDoors::Room.json_create( JSON.load( JSON.generate(r0) ) ) + r0 = Iotas::Room.new 'r0', @spin + r1 = Iotas::Room.new 'r1', r0 + r2 = Iotas::Room.new 'r2', r1 + r3 = Iotas::Room.new 'r3', r1 + r4 = Iotas::Room.new 'r4', r3 + d0 = Iotas::Door.new 'd0', r1 + d1 = Iotas::Door.new 'd1', r1 + d2 = Iotas::Door.new 'd2', r2 + r1.add_link Iotas::Link.new('d0', 'd1', 'fields', 'f0,f1', 'v0v1') + r1.add_link Iotas::Link.new('d0', 'd2') + r1.add_link Iotas::Link.new('d1', 'd0') + r2.add_link Iotas::Link.new('d2', 'd1', 'fies', 'f5,f1', 'v9v1') + rx = Iotas::Room.json_create( JSON.load( JSON.generate(r0) ) ) JSON.generate(r0).should eql JSON.generate(rx) end# # diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 852e17e..e3e0aa1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,9 +9,9 @@ begin rescue LoadError end # -require 'evendoors' +require 'iotas' # -class Fake < EvenDoors::Spot +class Fake < Iotas::Spot attr_reader :p, :sp, :start, :stop def process_p p @p = p diff --git a/spec/spin_spec.rb b/spec/spin_spec.rb index a58fd5c..aba79a8 100644 --- a/spec/spin_spec.rb +++ b/spec/spin_spec.rb @@ -4,24 +4,24 @@ require 'spec_helper' # -describe EvenDoors::Spin do +describe Iotas::Spin do # - class MyP < EvenDoors::Particle; end + class MyP < Iotas::Particle; end # it "Particles pool" do - spin = EvenDoors::Spin.new 'dom0' - p0 = spin.require_p EvenDoors::Particle - p1 = spin.require_p EvenDoors::Particle + spin = Iotas::Spin.new 'dom0' + p0 = spin.require_p Iotas::Particle + p1 = spin.require_p Iotas::Particle (p0===p1).should be_false spin.release_p p0 - p2 = spin.require_p EvenDoors::Particle + p2 = spin.require_p Iotas::Particle (p0===p2).should be_true end # it "different Particles classes in pool" do - spin = EvenDoors::Spin.new 'dom0' - p0 = spin.require_p EvenDoors::Particle - p1 = spin.require_p EvenDoors::Particle + spin = Iotas::Spin.new 'dom0' + p0 = spin.require_p Iotas::Particle + p1 = spin.require_p Iotas::Particle (p0===p1).should be_false spin.release_p p0 p2 = spin.require_p MyP @@ -33,36 +33,36 @@ describe EvenDoors::Spin do end # it "release of merged particles" do - spin = EvenDoors::Spin.new 'dom0' - p0 = spin.require_p EvenDoors::Particle - p1 = spin.require_p EvenDoors::Particle + spin = Iotas::Spin.new 'dom0' + p0 = spin.require_p Iotas::Particle + p1 = spin.require_p Iotas::Particle (p0===p1).should be_false p0.merge! p1 spin.release_p p0 - p2 = spin.require_p EvenDoors::Particle + p2 = spin.require_p Iotas::Particle (p2===p0).should be_true - p3 = spin.require_p EvenDoors::Particle + p3 = spin.require_p Iotas::Particle (p3===p1).should be_true end # it "clear!" do - spin = EvenDoors::Spin.new 'dom0' - p0 = spin.require_p EvenDoors::Particle - p1 = spin.require_p EvenDoors::Particle + spin = Iotas::Spin.new 'dom0' + p0 = spin.require_p Iotas::Particle + p1 = spin.require_p Iotas::Particle spin.send_p p0 spin.release_p p1 spin.clear! - p2 = spin.require_p EvenDoors::Particle + p2 = spin.require_p Iotas::Particle (p2==p0).should be_false (p2==p1).should be_false end # it "post_p post_sys_p spin!" do - spin = EvenDoors::Spin.new 'dom0' + spin = Iotas::Spin.new 'dom0' f = Fake.new 'fake', spin - p0 = spin.require_p EvenDoors::Particle + p0 = spin.require_p Iotas::Particle p0.dst_routed! f - p1 = spin.require_p EvenDoors::Particle + p1 = spin.require_p Iotas::Particle p1.dst_routed! f spin.post_p p0 spin.post_sys_p p1 @@ -74,52 +74,52 @@ describe EvenDoors::Spin do end # it "process_sys" do - spin = EvenDoors::Spin.new 'dom0' - p0 = spin.require_p EvenDoors::Particle + spin = Iotas::Spin.new 'dom0' + p0 = spin.require_p Iotas::Particle p0.set_dst! 'unknown' spin.send_sys_p p0 spin.spin! - p1 = spin.require_p EvenDoors::Particle + p1 = spin.require_p Iotas::Particle p0.should be p0 end # it "option debug" do - spin = EvenDoors::Spin.new 'dom0' + spin = Iotas::Spin.new 'dom0' spin.debug_routing.should be false spin.debug_errors.should be false - spin = EvenDoors::Spin.new 'dom0', :debug_routing=>true, :debug_errors=>true + spin = Iotas::Spin.new 'dom0', :debug_routing=>true, :debug_errors=>true spin.debug_routing.should be true spin.debug_errors.should be true end # it "spin->json->spin" do - spin = EvenDoors::Spin.new 'dom0', :debug_routing=>true - r0 = EvenDoors::Room.new 'r0', spin - r1 = EvenDoors::Room.new 'r1', r0 - r2 = EvenDoors::Room.new 'r2', r1 - r3 = EvenDoors::Room.new 'r3', r1 - r4 = EvenDoors::Room.new 'r4', r3 - d0 = EvenDoors::Door.new 'd0', r1 - d1 = EvenDoors::Door.new 'd1', r1 - d2 = EvenDoors::Door.new 'd2', r2 - p0 = spin.require_p EvenDoors::Particle - p1 = spin.require_p EvenDoors::Particle - p2 = spin.require_p EvenDoors::Particle + spin = Iotas::Spin.new 'dom0', :debug_routing=>true + r0 = Iotas::Room.new 'r0', spin + r1 = Iotas::Room.new 'r1', r0 + r2 = Iotas::Room.new 'r2', r1 + r3 = Iotas::Room.new 'r3', r1 + r4 = Iotas::Room.new 'r4', r3 + d0 = Iotas::Door.new 'd0', r1 + d1 = Iotas::Door.new 'd1', r1 + d2 = Iotas::Door.new 'd2', r2 + p0 = spin.require_p Iotas::Particle + p1 = spin.require_p Iotas::Particle + p2 = spin.require_p Iotas::Particle spin.post_p p0 spin.post_p p1 spin.post_sys_p p2 json = JSON.generate spin - dom0 = EvenDoors::Spin.json_create( JSON.load( json ) ) + dom0 = Iotas::Spin.json_create( JSON.load( json ) ) json.should eql JSON.generate(dom0) end # it "hibernate! resume!" do - spin = EvenDoors::Spin.new 'dom0' - p0 = spin.require_p EvenDoors::Particle - p0.set_dst! EvenDoors::SYS_ACT_HIBERNATE + spin = Iotas::Spin.new 'dom0' + p0 = spin.require_p Iotas::Particle + p0.set_dst! Iotas::SYS_ACT_HIBERNATE spin.send_sys_p p0 spin.spin! - dom0 = EvenDoors::Spin.resume! spin.hibernate_path + dom0 = Iotas::Spin.resume! spin.hibernate_path dom0.name.should eql spin.name File.unlink dom0.hibernate_path end diff --git a/spec/spot_spec.rb b/spec/spot_spec.rb index 94d415d..eb64f33 100644 --- a/spec/spot_spec.rb +++ b/spec/spot_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe EvenDoors::Spot do +describe Iotas::Spot do # it "path construction" do - class S<EvenDoors::Spot + class S<Iotas::Spot def add_spot s end end @@ -16,9 +16,9 @@ describe EvenDoors::Spot do s2 = S.new 'room1', s1 s3 = S.new 'door', s2 s3.path.should eql 'top/room0/room1/door' - lambda { EvenDoors::Spot.new('do/or0', nil) }.should raise_error(EvenDoors::Exception) - lambda { EvenDoors::Spot.new('/door0', nil) }.should raise_error(EvenDoors::Exception) - lambda { EvenDoors::Spot.new('door0/', nil) }.should raise_error(EvenDoors::Exception) + lambda { Iotas::Spot.new('do/or0', nil) }.should raise_error(Iotas::Exception) + lambda { Iotas::Spot.new('/door0', nil) }.should raise_error(Iotas::Exception) + lambda { Iotas::Spot.new('door0/', nil) }.should raise_error(Iotas::Exception) end # end diff --git a/test/test_evendoors.rb b/test/test_evendoors.rb index 833c085..03a8853 100644 --- a/test/test_evendoors.rb +++ b/test/test_evendoors.rb @@ -1,11 +1,11 @@ #! /usr/bin/env ruby # -*- coding: UTF-8 -*- -require 'evendoors' +require 'iotas' HBN_PATH='hibernate.json' # -class InputDoor < EvenDoors::Door +class InputDoor < Iotas::Door # @count = 0 # @@ -22,8 +22,8 @@ class InputDoor < EvenDoors::Door def start! puts " -> start #{self.class.name} (#{@path})" # stimulate myself - p = require_p EvenDoors::Particle - p.set_dst! EvenDoors::ACT_GET, path + p = require_p Iotas::Particle + p.set_dst! Iotas::ACT_GET, path send_p p end # @@ -45,7 +45,7 @@ class InputDoor < EvenDoors::Door # def receive_p p puts " @ #{self.class.name} (#{@path}) receive_p : #{p.action}" - if p.action==EvenDoors::ACT_GET + if p.action==Iotas::ACT_GET p.reset! p.set_data 'line', @lines[@idx] p.set_data 'f0', 'v0' @@ -55,8 +55,8 @@ class InputDoor < EvenDoors::Door @idx+=1 if @idx<@lines.length # there is more to read, restimulate myself - p = require_p EvenDoors::Particle - p.set_dst! EvenDoors::ACT_GET, name + p = require_p Iotas::Particle + p.set_dst! Iotas::ACT_GET, name send_p p end else @@ -66,16 +66,16 @@ class InputDoor < EvenDoors::Door # I want to hibernate now! self.class.count+=1 if self.class.count==3 - p = require_p EvenDoors::Particle - p[EvenDoors::FIELD_HIBERNATE_PATH] = HBN_PATH - p.set_dst! EvenDoors::SYS_ACT_HIBERNATE + p = require_p Iotas::Particle + p[Iotas::FIELD_HIBERNATE_PATH] = HBN_PATH + p.set_dst! Iotas::SYS_ACT_HIBERNATE send_sys_p p end end # end # -class ConcatBoard < EvenDoors::Board +class ConcatBoard < Iotas::Board # def initialize n, p, m=false super n, p @@ -92,7 +92,7 @@ class ConcatBoard < EvenDoors::Board # def receive_p p puts " @ #{self.class.name} receive_p : #{p.action}" - if p.action==EvenDoors::ACT_ERROR + if p.action==Iotas::ACT_ERROR # else if @manual @@ -110,7 +110,7 @@ class ConcatBoard < EvenDoors::Board # end # -class OutputDoor < EvenDoors::Door +class OutputDoor < Iotas::Door # def initialize n, p, c=false super n, p @@ -130,16 +130,16 @@ class OutputDoor < EvenDoors::Door if @clean release_p p else - # we do nothing EvenDoors::Door#process_p will detect it and release it + # we do nothing Iotas::Door#process_p will detect it and release it end end # end # -spin = EvenDoors::Spin.new 'dom0', :debug_routing=>false, :debug_errors=>true +spin = Iotas::Spin.new 'dom0', :debug_routing=>false, :debug_errors=>true # -room0 = EvenDoors::Room.new 'room0', spin -room1 = EvenDoors::Room.new 'room1', spin +room0 = Iotas::Room.new 'room0', spin +room1 = Iotas::Room.new 'room1', spin # input0 = InputDoor.new 'input0', room0 output0 = OutputDoor.new 'output0', room0 @@ -148,20 +148,20 @@ input1 = InputDoor.new 'input1', room1 output1 = OutputDoor.new 'output1', room1, true concat1 = ConcatBoard.new 'concat1', room1 # -room0.add_link EvenDoors::Link.new('input0', 'output0', nil, nil, nil) +room0.add_link Iotas::Link.new('input0', 'output0', nil, nil, nil) # -p0 = 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 +p0 = spin.require_p Iotas::Particle +p0.set_data Iotas::LNK_SRC, 'input1' +p0.set_data Iotas::LNK_DSTS, 'concat1?follow,output1' +p0.set_data Iotas::LNK_FIELDS, 'f0,f2' +p0.set_data Iotas::LNK_CONDF, 'f0,f1,f2' +p0.set_data Iotas::LNK_CONDV, 'v0v1v2' +p0.set_dst! Iotas::SYS_ACT_ADD_LINK, room1.path room1.send_sys_p p0 # send_sys_p -> room0 -> spin -> room1 -> input1 # spin.spin! # -dom0 = EvenDoors::Spin.resume! HBN_PATH +dom0 = Iotas::Spin.resume! HBN_PATH dom0.spin! File.unlink HBN_PATH if File.exists? HBN_PATH # |