dnode 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,5 +2,5 @@ require 'rubygems'
2
2
  require 'dnode'
3
3
 
4
4
  DNode.new({}).connect(5050) do |remote|
5
- remote.f(30000) { |x| puts "x=<#{x}>" }
5
+ remote.f(30000, proc { |x| puts "x=<#{x}>" })
6
6
  end
@@ -2,5 +2,5 @@ require 'rubygems'
2
2
  require 'dnode'
3
3
 
4
4
  DNode.new({
5
- :f => proc { |x| yield x + 1337 }
5
+ :f => proc { |x,cb| cb.call(x + 1337) }
6
6
  }).listen(5050)
@@ -29,12 +29,24 @@ class Conn
29
29
 
30
30
  if req['method'].is_a? Integer then
31
31
  id = req['method']
32
- @scrub.callbacks[id].call(*JSObject.create(args))
32
+ cb = @scrub.callbacks[id]
33
+ if cb.arity < 0 then
34
+ cb.call(*JSObject.create(args))
35
+ else
36
+ argv = *JSObject.create(args)
37
+ padding = argv.length.upto(cb.arity - 1).map{ nil }
38
+ argv = argv.concat(padding).take(cb.arity)
39
+ cb.call(*argv)
40
+ end
33
41
  elsif req['method'] == 'methods' then
34
42
  @remote.update(args[0])
35
43
  js = JSObject.create(@remote)
36
44
 
37
- @block.call(*[ js, self ][ 0 .. @block.arity - 1 ])
45
+ if @block.arity === 0 then
46
+ @block.call
47
+ else
48
+ @block.call(*[ js, self ][ 0 .. @block.arity - 1 ])
49
+ end
38
50
  self.emit('remote', js)
39
51
  self.emit('ready')
40
52
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnode
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 1
10
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - James Halliday
@@ -15,10 +14,35 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-11-12 00:00:00 +00:00
17
+ date: 2011-11-06 00:00:00 -07:00
19
18
  default_executable:
20
- dependencies: []
21
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: events
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: eventmachine
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
22
46
  description: "\n With DNode you can tie together servers written in ruby, node.js, and\n perl.\n \n DNode is similar to DRb, but is asynchronous and transforms callbacks\n embedded in deeply nested structures.\n "
23
47
  email: mail@substack.net
24
48
  executables: []
@@ -30,14 +54,14 @@ extra_rdoc_files:
30
54
  files:
31
55
  - LICENSE
32
56
  - lib/dnode.rb
33
- - lib/dnode/conn.rb
34
- - lib/dnode/scrub.rb
35
57
  - lib/dnode/walk.rb
58
+ - lib/dnode/scrub.rb
59
+ - lib/dnode/conn.rb
36
60
  - lib/dnode/jsobject.rb
37
- - examples/simple/client.rb
38
61
  - examples/simple/server.rb
39
- - examples/moo/client.rb
62
+ - examples/simple/client.rb
40
63
  - examples/moo/server.rb
64
+ - examples/moo/client.rb
41
65
  has_rdoc: true
42
66
  homepage: http://github.com/substack/dnode-ruby
43
67
  licenses: []
@@ -52,7 +76,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
76
  requirements:
53
77
  - - ">="
54
78
  - !ruby/object:Gem::Version
55
- hash: 3
56
79
  segments:
57
80
  - 0
58
81
  version: "0"
@@ -61,7 +84,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
84
  requirements:
62
85
  - - ">="
63
86
  - !ruby/object:Gem::Version
64
- hash: 3
65
87
  segments:
66
88
  - 0
67
89
  version: "0"