babascript 0.2.5 → 0.2.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.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/lib/babascript/baba.rb +10 -7
- data/lib/babascript/version.rb +1 -1
- data/samples/sample_distribute.rb +34 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8273f8ae9cc284e08bbd9150f757d26ed6384619
|
4
|
+
data.tar.gz: ac3b267018cf20434db213f0dbcd02a6f8e3e4ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6145693ba511ba2f1f8f6d92ff1c78b8a51c242a982fccf1c03e0d038e95644eb79a4fd71cdac00bad2b5bb9b49d761e6d7a419ca7e64a0f2137f14e3f13cfbc
|
7
|
+
data.tar.gz: 7de8891b5566e5809a8276d726f7a675d61fbcd38c74b0ea082c8022c3fbaecdcaff0a1bdeb7aecc0231c5e5c84854471525c78de7e8ac89bba013f0f6069ce1
|
data/History.txt
CHANGED
data/lib/babascript/baba.rb
CHANGED
@@ -30,17 +30,20 @@ module BabaScript
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.method_missing(name, *args)
|
34
|
-
self.exec name, *args
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.exec(name, *args)
|
33
|
+
def self.method_missing(name, *args, &block)
|
38
34
|
cid = __create_callback_id
|
39
35
|
tuple = [:babascript, :eval, name, args, {:callback => cid}]
|
40
36
|
ts = linda.tuplespace[BabaScript.LINDA_SPACE]
|
41
37
|
ts.write tuple
|
42
|
-
|
43
|
-
|
38
|
+
if block_given?
|
39
|
+
ts.take [:babascript, :return, cid] do |result|
|
40
|
+
next if result.size < 4
|
41
|
+
block.call result[3]
|
42
|
+
end
|
43
|
+
else
|
44
|
+
result = ts.take [:babascript, :return, cid]
|
45
|
+
return result[3]
|
46
|
+
end
|
44
47
|
end
|
45
48
|
|
46
49
|
private
|
data/lib/babascript/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
$:.unshift File.expand_path "../lib", File.dirname(__FILE__)
|
3
|
+
require 'babascript'
|
4
|
+
|
5
|
+
EM::run do
|
6
|
+
BabaScript.baba do
|
7
|
+
count = 0
|
8
|
+
|
9
|
+
電気を消してください do |result|
|
10
|
+
puts result
|
11
|
+
count += 1
|
12
|
+
end
|
13
|
+
|
14
|
+
冷房を切ってください do |result|
|
15
|
+
puts result
|
16
|
+
count += 1
|
17
|
+
end
|
18
|
+
|
19
|
+
机の上を片付けてください do |result|
|
20
|
+
puts result
|
21
|
+
count += 1
|
22
|
+
end
|
23
|
+
|
24
|
+
EM::add_periodic_timer 1 do
|
25
|
+
if count < 3
|
26
|
+
puts "waiting 3 tasks (#{count} finished)"
|
27
|
+
else
|
28
|
+
EM::stop
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
puts "finish"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: babascript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: em-rocketio-linda-client
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- samples/sample.bb
|
124
124
|
- samples/sample.rb
|
125
125
|
- samples/sample_arduino.rb
|
126
|
+
- samples/sample_distribute.rb
|
126
127
|
- test/test_babascript.rb
|
127
128
|
- test/test_helper.rb
|
128
129
|
homepage: https://github.com/masuilab/babascript
|