babascript 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3aeb3ba4411427fee529dcbb7fbe34688dad3a57
4
- data.tar.gz: 5ece4327e81b3dee667120289c5a7fc06977d143
3
+ metadata.gz: 8273f8ae9cc284e08bbd9150f757d26ed6384619
4
+ data.tar.gz: ac3b267018cf20434db213f0dbcd02a6f8e3e4ce
5
5
  SHA512:
6
- metadata.gz: 9422869567d055c38a22a3c09759bf082ee94c41a99fe57d77791f4edd54cd84c5d08d9e83af6fd2657462711d668a62513e8211e12b21771db7673ab0f3828c
7
- data.tar.gz: 7989e74cba67c6fb8ff5f27c345e085b03cb6ac58eb85a7cb55eb9d2b5910d240fce031c318cfd2899ae6ebd8f0a2c206209c4b1f5104b982b144204d271e6c3
6
+ metadata.gz: 6145693ba511ba2f1f8f6d92ff1c78b8a51c242a982fccf1c03e0d038e95644eb79a4fd71cdac00bad2b5bb9b49d761e6d7a419ca7e64a0f2137f14e3f13cfbc
7
+ data.tar.gz: 7de8891b5566e5809a8276d726f7a675d61fbcd38c74b0ea082c8022c3fbaecdcaff0a1bdeb7aecc0231c5e5c84854471525c78de7e8ac89bba013f0f6069ce1
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.6 2013-08-13
2
+
3
+ * bugfix callback if block given in babascript-code
4
+
1
5
  === 0.2.5 2013-08-08
2
6
 
3
7
  * add test
@@ -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
- result = ts.take [:babascript, :return, cid]
43
- return result[3]
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
@@ -1,3 +1,3 @@
1
1
  module BabaScript
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -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.5
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-07 00:00:00.000000000 Z
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