From 5fbda1780698b2470133672aea247cfd35ba3e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 10 Jun 2012 23:27:09 +0200 Subject: Spin: to_json stores iota and links into inner_room This allows top iotas to be Doors and not only Rooms --- lib/edoors/spin.rb | 16 ++++++++++++---- spec/spin_spec.rb | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/edoors/spin.rb b/lib/edoors/spin.rb index 9894409..9f62b47 100644 --- a/lib/edoors/spin.rb +++ b/lib/edoors/spin.rb @@ -38,9 +38,17 @@ module Edoors @debug_routing = o[:debug_routing]||o['debug_routing']||false # if not o.empty? - o['iotas'].each do |name,iota| - Edoors::Room.json_create(iota.merge!('parent'=>self)) - end if o['iotas'] + room = o['inner_room'] + if room + room['iotas'].each do |name,iota| + eval( iota['kls'] ).json_create(iota.merge!('parent'=>self)) + end + room['links'].each do |src,links| + links.each do |link| + add_link Edoors::Link.json_create(link) + end + end + end o['app_fifo'].each do |particle| @app_fifo << Edoors::Particle.json_create(particle.merge!('spin'=>self)) end if o['app_fifo'] @@ -58,7 +66,7 @@ module Edoors 'timestamp' => Time.now, 'name' => @name, 'hibernation' => @hibernation, - 'iotas' => @iotas, + 'inner_room' => { :iotas=>@iotas, :links=>@links }, 'sys_fifo' => @sys_fifo, 'app_fifo' => @app_fifo, 'debug_errors' => @debug_errors, diff --git a/spec/spin_spec.rb b/spec/spin_spec.rb index 93ddf27..9d73b90 100644 --- a/spec/spin_spec.rb +++ b/spec/spin_spec.rb @@ -117,6 +117,9 @@ describe Edoors::Spin do spin = Edoors::Spin.new 'dom0' p0 = spin.require_p Edoors::Particle p0.add_dst Edoors::SYS_ACT_HIBERNATE + Edoors::Room.new 'input', spin + Edoors::Room.new 'output', spin + spin.add_link Edoors::Link.new('input', 'output', nil, nil, nil) spin.send_sys_p p0 spin.spin! dom0 = Edoors::Spin.resume! spin.hibernate_path -- cgit v1.1-2-g2b99