ruby_fs 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/ruby_fs/stream.rb +19 -10
- data/lib/ruby_fs/version.rb +1 -1
- data/ruby_fs.gemspec +1 -1
- data/spec/ruby_fs/stream_spec.rb +7 -4
- data/spec/support/mock_server.rb +4 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b68c933f40664fb0b884507a542b4d10914e91
|
4
|
+
data.tar.gz: e7e1821584741db70d7040deeadd2017f15bc1f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a1ddf66fe30a97596f9bf9f83fcde3909e69aeb3fb05480e21781eb0207af4c811ef345c8768b7b1d9ff1da8e05a8b88d963f3fea7475d34e8bc559fe729bc8
|
7
|
+
data.tar.gz: 9f138ddc9b654c4e9f7188ace388920413fceefa08461ec959cf76f055b096027139ebdd41677d7b4c3f28895fedd1833207eb655da45309aec20e2a619cb8d1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# develop
|
2
2
|
|
3
|
+
# 1.0.5
|
4
|
+
* Bugfix: Allow sending large app arguments. Application arguments (headers in general) are limited to 2048 bytes. The work-around is to send them in the body of the message with a content-length header.
|
5
|
+
* CS: Avoid Celluloid deprecation warnings
|
6
|
+
|
3
7
|
# 1.0.4
|
4
8
|
* Bugfix: Loosen celluloid dependency
|
5
9
|
|
data/lib/ruby_fs/stream.rb
CHANGED
@@ -17,6 +17,8 @@ module RubyFS
|
|
17
17
|
|
18
18
|
include Celluloid::IO
|
19
19
|
|
20
|
+
finalizer :finalize
|
21
|
+
|
20
22
|
def initialize(host, port, secret, event_callback, events = true)
|
21
23
|
super()
|
22
24
|
@host, @port, @secret, @event_callback, @events = host, port, secret, event_callback, events
|
@@ -60,9 +62,11 @@ module RubyFS
|
|
60
62
|
uuid = SecureRandom.uuid
|
61
63
|
@command_callbacks << (callback || lambda { |reply| signal uuid, reply })
|
62
64
|
string = "#{command}\n"
|
65
|
+
body_value = options.delete :command_body_value
|
63
66
|
options.each_pair do |key, value|
|
64
67
|
string << "#{key.to_s.gsub '_', '-'}: #{value}\n" if value
|
65
68
|
end
|
69
|
+
string << "\n" << body_value << "\n" if body_value
|
66
70
|
string << "\n"
|
67
71
|
send_data string
|
68
72
|
wait uuid unless callback
|
@@ -108,21 +112,19 @@ module RubyFS
|
|
108
112
|
#
|
109
113
|
# @return [RubyFS::Response] response the application's response object
|
110
114
|
def application(call, appname, options = nil)
|
111
|
-
|
115
|
+
opts = {call_command: 'execute', execute_app_name: appname}
|
116
|
+
if options
|
117
|
+
opts[:content_type] = 'text/plain'
|
118
|
+
opts[:content_length] = options.bytesize
|
119
|
+
opts[:command_body_value] = options
|
120
|
+
end
|
121
|
+
sendmsg call, opts
|
112
122
|
end
|
113
123
|
|
114
124
|
#
|
115
125
|
# Shutdown the stream and disconnect from the socket
|
116
126
|
alias :shutdown :terminate
|
117
127
|
|
118
|
-
# @private
|
119
|
-
def finalize
|
120
|
-
logger.debug "Finalizing stream"
|
121
|
-
@socket.close if @socket
|
122
|
-
@state = :stopped
|
123
|
-
fire_event Disconnected.new
|
124
|
-
end
|
125
|
-
|
126
128
|
#
|
127
129
|
# Fire an event to the specified callback
|
128
130
|
#
|
@@ -145,6 +147,13 @@ module RubyFS
|
|
145
147
|
|
146
148
|
private
|
147
149
|
|
150
|
+
def finalize
|
151
|
+
logger.debug "Finalizing stream"
|
152
|
+
@socket.close if @socket
|
153
|
+
@state = :stopped
|
154
|
+
fire_event Disconnected.new
|
155
|
+
end
|
156
|
+
|
148
157
|
def receive_data(data)
|
149
158
|
logger.trace "[RECV] #{data}"
|
150
159
|
@lexer << data
|
@@ -159,7 +168,7 @@ module RubyFS
|
|
159
168
|
@command_callbacks.pop.call CommandReply.new(headers, (content == '' ? nil : content))
|
160
169
|
when 'auth/request'
|
161
170
|
command "auth #{@secret}" do
|
162
|
-
command
|
171
|
+
async.command "event json ALL" if @events
|
163
172
|
end
|
164
173
|
when 'text/disconnect-notice'
|
165
174
|
terminate
|
data/lib/ruby_fs/version.rb
CHANGED
data/ruby_fs.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_runtime_dependency %q<celluloid-io>, ["~> 0.
|
21
|
+
s.add_runtime_dependency %q<celluloid-io>, ["~> 0.13"]
|
22
22
|
s.add_runtime_dependency %q<json>
|
23
23
|
|
24
24
|
s.add_development_dependency %q<bundler>, ["~> 1.0"]
|
data/spec/ruby_fs/stream_spec.rb
CHANGED
@@ -34,7 +34,7 @@ module RubyFS
|
|
34
34
|
mock_target.should_receive(:receive_data).send(*(times ? [:exactly, times] : [:at_least, 1])).with &block
|
35
35
|
s = ServerMock.new '127.0.0.1', server_port, mock_target
|
36
36
|
@stream = Stream.new '127.0.0.1', server_port, secret, lambda { |m| client.message_received m }, events
|
37
|
-
@stream.run
|
37
|
+
@stream.async.run
|
38
38
|
sleep 0.1
|
39
39
|
fake_client.call s if fake_client.respond_to? :call
|
40
40
|
Celluloid::Actor.join s
|
@@ -156,7 +156,7 @@ Reply-Text: +OK accepted
|
|
156
156
|
it "can send commands with options" do
|
157
157
|
expect_connected_event
|
158
158
|
expect_disconnected_event
|
159
|
-
mocked_server(1, lambda { |server| @stream.command
|
159
|
+
mocked_server(1, lambda { |server| @stream.async.command 'foo', :one => 1, :foo_bar => :doo_dah }) do |val, server|
|
160
160
|
val.should == %Q(foo
|
161
161
|
one: 1
|
162
162
|
foo-bar: doo_dah
|
@@ -231,7 +231,7 @@ Reply-Text: +OK accepted
|
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
|
-
it "can execute applications on calls with options and returns the response" do
|
234
|
+
it "can execute applications on calls with options (in the body) and returns the response" do
|
235
235
|
expect_connected_event
|
236
236
|
expect_disconnected_event
|
237
237
|
reply = CommandReply.new(:content_type => 'command/reply', :reply_text => '+OK accepted')
|
@@ -239,7 +239,10 @@ Reply-Text: +OK accepted
|
|
239
239
|
val.should == %Q(SendMsg aUUID
|
240
240
|
call-command: execute
|
241
241
|
execute-app-name: playback
|
242
|
-
|
242
|
+
content-type: text/plain
|
243
|
+
content-length: 13
|
244
|
+
|
245
|
+
/tmp/test.wav
|
243
246
|
|
244
247
|
)
|
245
248
|
server.send_data %Q(
|
data/spec/support/mock_server.rb
CHANGED
@@ -3,11 +3,13 @@ MockServer = Class.new
|
|
3
3
|
class ServerMock
|
4
4
|
include Celluloid::IO
|
5
5
|
|
6
|
+
finalizer :finalize
|
7
|
+
|
6
8
|
def initialize(host, port, mock_target = MockServer.new)
|
7
9
|
@server = TCPServer.new host, port
|
8
10
|
@mock_target = mock_target
|
9
11
|
@clients = []
|
10
|
-
run
|
12
|
+
async.run
|
11
13
|
end
|
12
14
|
|
13
15
|
def finalize
|
@@ -18,7 +20,7 @@ class ServerMock
|
|
18
20
|
|
19
21
|
def run
|
20
22
|
after(1) { terminate }
|
21
|
-
loop { handle_connection
|
23
|
+
loop { async.handle_connection @server.accept }
|
22
24
|
end
|
23
25
|
|
24
26
|
def handle_connection(socket)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Langfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid-io
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.13'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|