farcall 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/farcall.gemspec +2 -2
- data/lib/farcall.rb +1 -3
- data/lib/farcall/em_farcall.rb +5 -4
- data/lib/farcall/endpoint.rb +4 -5
- data/lib/farcall/smart_hash.rb +11 -0
- data/lib/farcall/version.rb +1 -1
- data/spec/websock_spec.rb +4 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ef4214b7086263085157f0c0933815afcfafac6e2c1edb3f3a75ef83c6a371d4
|
4
|
+
data.tar.gz: bc5dc845c3f8f418b219c99ec437c12676008192bf18d2a6c2a411ae6e9946be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c29cd434eb643778ec39f9f14c47a26cd9c1011acc1f69c2b0a386b8f038ba9d0f739c8712f1030e252dd69428ce77d3cf0e96395645d18d32eee72bf76b2b8
|
7
|
+
data.tar.gz: 574e9bd05e4269a4f60bce45abcc8269c2de04ae9886348a71c4040a5ffad539c1dd0baca5983211b1df9e16b9ff5415e35dc932ea33686684d0eb6e16175d5e
|
data/farcall.gemspec
CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.add_dependency 'hashie'
|
26
|
-
spec.add_development_dependency 'bundler', '
|
27
|
-
spec.add_development_dependency 'rake', '
|
26
|
+
spec.add_development_dependency 'bundler', '>= 1.7'
|
27
|
+
spec.add_development_dependency 'rake', '>= 10.0'
|
28
28
|
spec.add_development_dependency 'rspec'
|
29
29
|
spec.add_development_dependency 'em-websocket'
|
30
30
|
spec.add_development_dependency 'websocket-client-simple'
|
data/lib/farcall.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
1
|
require 'farcall/version'
|
2
|
+
require 'farcall/smart_hash'
|
3
3
|
require 'farcall/transport'
|
4
4
|
require 'farcall/json_transport'
|
5
5
|
require 'farcall/endpoint'
|
@@ -15,8 +15,6 @@ rescue LoadError
|
|
15
15
|
$!.to_s =~ /em-websocket/ or raise
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
18
|
module Farcall
|
21
19
|
# Your code goes here...
|
22
20
|
end
|
data/lib/farcall/em_farcall.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require 'hashie'
|
2
1
|
require 'eventmachine'
|
3
2
|
require_relative './promise'
|
4
3
|
|
4
|
+
include Farcall
|
5
|
+
|
5
6
|
# As the eventmachine callback paradigm is completely different from the threaded paradigm
|
6
7
|
# of the Farcall, that runs pretty well under JRuby and in multithreaded MRI, we provide
|
7
8
|
# compatible but different implementations: {EmFarcall::Endpoint}, {EmFarcall::Interface}
|
@@ -14,7 +15,7 @@ require_relative './promise'
|
|
14
15
|
# require 'eventmachine'
|
15
16
|
# require 'farcall'
|
16
17
|
module EmFarcall
|
17
|
-
|
18
|
+
|
18
19
|
# Endpoint that run in the reactor thread of the EM. Eventmachine should run by the time of
|
19
20
|
# creation of the endpoint. All the methods can be called from any thread, not only
|
20
21
|
# EM's reactor thread.
|
@@ -195,7 +196,7 @@ module EmFarcall
|
|
195
196
|
# :nodoc: important that this method is called from reactor thread only
|
196
197
|
def process_input data
|
197
198
|
# To be free from :keys and 'keys'
|
198
|
-
data =
|
199
|
+
data = SmartHash.new(data) unless data.is_a?(SmartHash)
|
199
200
|
if data.serial != @in_serial
|
200
201
|
error "framing error (wrong serial:)"
|
201
202
|
else
|
@@ -206,7 +207,7 @@ module EmFarcall
|
|
206
207
|
ref = data.ref
|
207
208
|
if ref
|
208
209
|
if (block = @callbacks.delete(ref)) != nil
|
209
|
-
block.call(
|
210
|
+
block.call(SmartHash.new(result: data.result, error: data.error))
|
210
211
|
end
|
211
212
|
else
|
212
213
|
error "framing error: no ref in block #{data.inspect}"
|
data/lib/farcall/endpoint.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'hashie'
|
2
1
|
require_relative 'promise'
|
3
2
|
|
4
3
|
module Farcall
|
@@ -7,7 +6,7 @@ module Farcall
|
|
7
6
|
# it. You can use it direcly or with Farcall::RemoteInterface and Farcall::LocalProvider helper
|
8
7
|
# classes.
|
9
8
|
#
|
10
|
-
# Note that the returned data is converted to
|
9
|
+
# Note that the returned data is converted to SmartHash primarily for the sake of :key vs.
|
11
10
|
# 'key' ambigity that otherwise might appear depending on the transport encoding protocol. Anyway
|
12
11
|
# it is better than ruby hash ;)
|
13
12
|
#
|
@@ -84,7 +83,7 @@ module Farcall
|
|
84
83
|
# Optionally the block could be provided
|
85
84
|
# that takes |error, result| parameters. Error must be nil or
|
86
85
|
#
|
87
|
-
#
|
86
|
+
# SmartHash.new({'class' =>, 'text' => text [, data: {some_data}] })
|
88
87
|
#
|
89
88
|
# if error is presented, the result is always the nil.
|
90
89
|
#
|
@@ -118,7 +117,7 @@ module Farcall
|
|
118
117
|
# Farcall::RemoteInterface rather than this low-level method.
|
119
118
|
#
|
120
119
|
# @param [String] name of the remote command
|
121
|
-
# @return [Object] any data that remote party retruns. If it is a hash, it is a
|
120
|
+
# @return [Object] any data that remote party retruns. If it is a hash, it is a SmartHash
|
122
121
|
# instance.
|
123
122
|
# @raise [Farcall::RemoteError]
|
124
123
|
#
|
@@ -197,7 +196,7 @@ module Farcall
|
|
197
196
|
|
198
197
|
def _received(data)
|
199
198
|
# p [:r, data]
|
200
|
-
data =
|
199
|
+
data = SmartHash.new data
|
201
200
|
|
202
201
|
cmd, serial, args, kwargs, ref, result, error =
|
203
202
|
%w{cmd serial args kwargs ref result error}.map { |k| data[k] || data[k.to_sym] }
|
data/lib/farcall/version.rb
CHANGED
data/spec/websock_spec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'eventmachine'
|
3
3
|
|
4
|
+
include Farcall
|
5
|
+
|
4
6
|
def standard_check_wsclient(cnt1, r1, r2, r3)
|
5
|
-
r1 =
|
6
|
-
r2 =
|
7
|
+
r1 = SmartHash.new(r1)
|
8
|
+
r2 = SmartHash.new(r2)
|
7
9
|
|
8
10
|
r1.kwargs.hello.should == 'world'
|
9
11
|
r1.superpong.should == [1, 2, 3]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: farcall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergeych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -28,28 +28,28 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.7'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/farcall/json_transport.rb
|
136
136
|
- lib/farcall/monitor_lock.rb
|
137
137
|
- lib/farcall/promise.rb
|
138
|
+
- lib/farcall/smart_hash.rb
|
138
139
|
- lib/farcall/transport.rb
|
139
140
|
- lib/farcall/version.rb
|
140
141
|
- lib/farcall/wsclient_transport.rb
|
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
163
|
version: '0'
|
163
164
|
requirements: []
|
164
165
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.7.3
|
166
167
|
signing_key:
|
167
168
|
specification_version: 4
|
168
169
|
summary: Simple, elegant and cross-platofrm RPC protocol
|