edoors-ruby 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/.travis.yml +7 -0
- data/Changelog +23 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +28 -0
- data/LICENSE +661 -0
- data/README.md +18 -0
- data/Rakefile +6 -0
- data/bin/edoors.rb +71 -0
- data/edoors-ruby.gemspec +28 -0
- data/examples/hello_world.json +38 -0
- data/examples/hello_world.rb +76 -0
- data/lib/edoors.rb +51 -0
- data/lib/edoors/board.rb +69 -0
- data/lib/edoors/door.rb +95 -0
- data/lib/edoors/iota.rb +67 -0
- data/lib/edoors/link.rb +70 -0
- data/lib/edoors/particle.rb +235 -0
- data/lib/edoors/room.rb +190 -0
- data/lib/edoors/spin.rb +168 -0
- data/lib/version.rb +28 -0
- data/spec/board_spec.rb +92 -0
- data/spec/door_spec.rb +95 -0
- data/spec/link_spec.rb +38 -0
- data/spec/particle_spec.rb +266 -0
- data/spec/room_spec.rb +315 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/spin_spec.rb +132 -0
- data/spec/spot_spec.rb +26 -0
- data/test/test_iotas.rb +168 -0
- metadata +136 -0
data/spec/spot_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
|
5
|
+
require 'spec_helper'
|
6
|
+
#
|
7
|
+
describe Edoors::Iota do
|
8
|
+
#
|
9
|
+
it "path construction" do
|
10
|
+
class S<Edoors::Iota
|
11
|
+
def add_iota s
|
12
|
+
end
|
13
|
+
end
|
14
|
+
s0 = S.new 'top', nil
|
15
|
+
s1 = S.new 'room0', s0
|
16
|
+
s2 = S.new 'room1', s1
|
17
|
+
s3 = S.new 'door', s2
|
18
|
+
s3.path.should eql 'top/room0/room1/door'
|
19
|
+
lambda { Edoors::Iota.new('do/or0', nil) }.should raise_error(Edoors::Exception)
|
20
|
+
lambda { Edoors::Iota.new('/door0', nil) }.should raise_error(Edoors::Exception)
|
21
|
+
lambda { Edoors::Iota.new('door0/', nil) }.should raise_error(Edoors::Exception)
|
22
|
+
end
|
23
|
+
#
|
24
|
+
end
|
25
|
+
#
|
26
|
+
# EOF
|
data/test/test_iotas.rb
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
|
4
|
+
require 'edoors'
|
5
|
+
|
6
|
+
HBN_PATH='hibernate.json'
|
7
|
+
#
|
8
|
+
class InputDoor < Edoors::Door
|
9
|
+
#
|
10
|
+
@count = 0
|
11
|
+
#
|
12
|
+
class << self
|
13
|
+
attr_accessor :count
|
14
|
+
end
|
15
|
+
#
|
16
|
+
def initialize n, p
|
17
|
+
super n, p
|
18
|
+
@lines = [ "#{name} says : hello", "world ( from #{path} )" ]
|
19
|
+
@idx = 0
|
20
|
+
end
|
21
|
+
#
|
22
|
+
def start!
|
23
|
+
puts " -> start #{self.class.name} (#{@path})"
|
24
|
+
# stimulate myself
|
25
|
+
p = require_p Edoors::Particle
|
26
|
+
# p.add_dst Edoors::ACT_GET, path
|
27
|
+
send_p p, Edoors::ACT_GET
|
28
|
+
end
|
29
|
+
#
|
30
|
+
def stop!
|
31
|
+
puts " >- stop #{self.class.name} (#{@path})"
|
32
|
+
end
|
33
|
+
#
|
34
|
+
def hibernate!
|
35
|
+
puts " !! hibernate #{self.class.name} (#{@path})"
|
36
|
+
# we want to remember where we are in the data flow
|
37
|
+
{'idx'=>@idx}
|
38
|
+
end
|
39
|
+
#
|
40
|
+
def resume! o
|
41
|
+
puts " !! resume #{self.class.name} (#{@path})"
|
42
|
+
# restore idx
|
43
|
+
@idx = o['idx']
|
44
|
+
end
|
45
|
+
#
|
46
|
+
def receive_p p
|
47
|
+
puts " @ #{self.class.name} (#{@path}) receive_p : #{p.action}"
|
48
|
+
if p.action==Edoors::ACT_GET
|
49
|
+
p.reset!
|
50
|
+
p.set_data 'line', @lines[@idx]
|
51
|
+
p.set_data 'f0', 'v0'
|
52
|
+
p.set_data 'f1', 'v1'
|
53
|
+
p.set_data 'f2', 'v2'
|
54
|
+
send_p p # will follow the link
|
55
|
+
@idx+=1
|
56
|
+
if @idx<@lines.length
|
57
|
+
# there is more to read, restimulate myself
|
58
|
+
p = require_p Edoors::Particle
|
59
|
+
p.add_dst Edoors::ACT_GET, name
|
60
|
+
send_p p
|
61
|
+
end
|
62
|
+
else
|
63
|
+
# we can release it or let the Door do it
|
64
|
+
release_p p
|
65
|
+
end
|
66
|
+
# I want to hibernate now!
|
67
|
+
self.class.count+=1
|
68
|
+
if self.class.count==3
|
69
|
+
p = require_p Edoors::Particle
|
70
|
+
p[Edoors::FIELD_HIBERNATE_PATH] = HBN_PATH
|
71
|
+
p.add_dst Edoors::SYS_ACT_HIBERNATE
|
72
|
+
send_sys_p p
|
73
|
+
end
|
74
|
+
end
|
75
|
+
#
|
76
|
+
end
|
77
|
+
#
|
78
|
+
class ConcatBoard < Edoors::Board
|
79
|
+
#
|
80
|
+
def initialize n, p, m=false
|
81
|
+
super n, p
|
82
|
+
@manual = m
|
83
|
+
end
|
84
|
+
#
|
85
|
+
def start!
|
86
|
+
puts " -> start #{self.class.name} (#{@path})"
|
87
|
+
end
|
88
|
+
#
|
89
|
+
def stop!
|
90
|
+
puts " >- stop #{self.class.name} (#{@path})"
|
91
|
+
end
|
92
|
+
#
|
93
|
+
def receive_p p
|
94
|
+
puts " @ #{self.class.name} receive_p : #{p.action}"
|
95
|
+
if p.action==Edoors::ACT_ERROR
|
96
|
+
#
|
97
|
+
else
|
98
|
+
if @manual
|
99
|
+
# cleanup unnecessary p2 Particle
|
100
|
+
p2 = p.merged_shift
|
101
|
+
p.set_data 'line', (p.data('line')+' '+p2.data('line'))
|
102
|
+
release_p p2
|
103
|
+
else
|
104
|
+
# Or let the system do it
|
105
|
+
p.set_data 'line', (p.data('line')+' '+p.merged(0).data('line'))
|
106
|
+
end
|
107
|
+
send_p p
|
108
|
+
end
|
109
|
+
end
|
110
|
+
#
|
111
|
+
end
|
112
|
+
#
|
113
|
+
class OutputDoor < Edoors::Door
|
114
|
+
#
|
115
|
+
def initialize n, p, c=false
|
116
|
+
super n, p
|
117
|
+
@clean = c
|
118
|
+
end
|
119
|
+
#
|
120
|
+
def start!
|
121
|
+
puts " -> start #{self.class.name} (#{@path})"
|
122
|
+
end
|
123
|
+
#
|
124
|
+
def stop!
|
125
|
+
puts " >- stop #{self.class.name} (#{@path})"
|
126
|
+
end
|
127
|
+
#
|
128
|
+
def receive_p p
|
129
|
+
puts " #==> #{self.class.name} (#{@path}) receive_p : #{p.get_data('line')}"
|
130
|
+
if @clean
|
131
|
+
release_p p
|
132
|
+
else
|
133
|
+
# we do nothing Edoors::Door#process_p will detect it and release it
|
134
|
+
end
|
135
|
+
end
|
136
|
+
#
|
137
|
+
end
|
138
|
+
#
|
139
|
+
spin = Edoors::Spin.new 'dom0', :debug_routing=>false, :debug_errors=>true
|
140
|
+
#
|
141
|
+
room0 = Edoors::Room.new 'room0', spin
|
142
|
+
room1 = Edoors::Room.new 'room1', spin
|
143
|
+
#
|
144
|
+
input0 = InputDoor.new 'input0', room0
|
145
|
+
output0 = OutputDoor.new 'output0', room0
|
146
|
+
#
|
147
|
+
input1 = InputDoor.new 'input1', room1
|
148
|
+
output1 = OutputDoor.new 'output1', room1, true
|
149
|
+
concat1 = ConcatBoard.new 'concat1', room1
|
150
|
+
#
|
151
|
+
room0.add_link Edoors::Link.new('input0', 'output0', nil, nil, nil)
|
152
|
+
#
|
153
|
+
p0 = spin.require_p Edoors::Particle
|
154
|
+
p0.set_data Edoors::LNK_SRC, 'input1'
|
155
|
+
p0.set_data Edoors::LNK_DSTS, 'concat1?follow,output1'
|
156
|
+
p0.set_data Edoors::LNK_FIELDS, 'f0,f2'
|
157
|
+
p0.set_data Edoors::LNK_CONDF, 'f0,f1,f2'
|
158
|
+
p0.set_data Edoors::LNK_CONDV, 'v0v1v2'
|
159
|
+
p0.add_dst Edoors::SYS_ACT_ADD_LINK, room1.path
|
160
|
+
room1.send_sys_p p0 # send_sys_p -> room0 -> spin -> room1 -> input1
|
161
|
+
#
|
162
|
+
spin.spin!
|
163
|
+
#
|
164
|
+
dom0 = Edoors::Spin.resume! HBN_PATH
|
165
|
+
dom0.spin!
|
166
|
+
File.unlink HBN_PATH if File.exists? HBN_PATH
|
167
|
+
#
|
168
|
+
# EOF
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: edoors-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jérémy Zurcher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.6'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.6'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: ! "Evenja propose a data centric paradigm. A traditional programm composed
|
63
|
+
of many functions\n is decomposed into small autonomous modifications applied
|
64
|
+
on the data implemented in different instances of Door base class.\n Routing
|
65
|
+
between these doors is handled through links or user application destinations."
|
66
|
+
email:
|
67
|
+
- jeremy@asynk.ch
|
68
|
+
executables:
|
69
|
+
- edoors.rb
|
70
|
+
extensions: []
|
71
|
+
extra_rdoc_files: []
|
72
|
+
files:
|
73
|
+
- .gitignore
|
74
|
+
- .travis.yml
|
75
|
+
- Changelog
|
76
|
+
- Gemfile
|
77
|
+
- Gemfile.lock
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/edoors.rb
|
82
|
+
- edoors-ruby.gemspec
|
83
|
+
- examples/hello_world.json
|
84
|
+
- examples/hello_world.rb
|
85
|
+
- lib/edoors.rb
|
86
|
+
- lib/edoors/board.rb
|
87
|
+
- lib/edoors/door.rb
|
88
|
+
- lib/edoors/iota.rb
|
89
|
+
- lib/edoors/link.rb
|
90
|
+
- lib/edoors/particle.rb
|
91
|
+
- lib/edoors/room.rb
|
92
|
+
- lib/edoors/spin.rb
|
93
|
+
- lib/version.rb
|
94
|
+
- spec/board_spec.rb
|
95
|
+
- spec/door_spec.rb
|
96
|
+
- spec/link_spec.rb
|
97
|
+
- spec/particle_spec.rb
|
98
|
+
- spec/room_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/spin_spec.rb
|
101
|
+
- spec/spot_spec.rb
|
102
|
+
- test/test_iotas.rb
|
103
|
+
homepage: http://github.com/jeremyz/edoors-ruby
|
104
|
+
licenses: []
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.8.23
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: ruby rewrite of C++ application framework evenja (http://www.revena.com/evenja)
|
127
|
+
test_files:
|
128
|
+
- spec/board_spec.rb
|
129
|
+
- spec/door_spec.rb
|
130
|
+
- spec/link_spec.rb
|
131
|
+
- spec/particle_spec.rb
|
132
|
+
- spec/room_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
- spec/spin_spec.rb
|
135
|
+
- spec/spot_spec.rb
|
136
|
+
- test/test_iotas.rb
|