osc-ruby 1.1.3 → 1.1.4
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 +5 -5
- data/VERSION +1 -1
- data/lib/osc-ruby.rb +0 -2
- data/lib/osc-ruby/address_pattern.rb +34 -32
- data/lib/osc-ruby/bundle.rb +14 -12
- data/lib/osc-ruby/em_server.rb +22 -22
- data/lib/osc-ruby/message.rb +18 -15
- data/lib/osc-ruby/network_packet.rb +14 -13
- data/lib/osc-ruby/osc_argument.rb +15 -5
- data/lib/osc-ruby/osc_packet.rb +26 -27
- data/lib/osc-ruby/osc_types.rb +36 -11
- data/lib/osc-ruby/server.rb +31 -32
- data/spec/builders/message_builder.rb +25 -26
- data/spec/unit/address_pattern_spec.rb +49 -49
- data/spec/unit/message_builder_spec.rb +19 -21
- data/spec/unit/message_bundle_spec.rb +1 -1
- data/spec/unit/message_spec.rb +27 -27
- data/spec/unit/network_packet_spec.rb +18 -18
- data/spec/unit/osc_argument_spec.rb +2 -2
- data/spec/unit/osc_complex_packets_spec.rb +16 -16
- data/spec/unit/osc_packet_unknown_type_spec.rb +3 -8
- data/spec/unit/osc_simple_packets_spec.rb +37 -43
- data/spec/unit/osc_types_spec.rb +6 -6
- metadata +4 -4
data/spec/unit/message_spec.rb
CHANGED
@@ -8,66 +8,66 @@
|
|
8
8
|
# @simple_with_two_string_args = "/hi\000,ss\000greetings\000\000\000how are you?\000\000\000\000"
|
9
9
|
# @simple_with_int_float_string = "/hi\000,ifs\000\000\000\000\000\000\000*B\004\n=greetings\000\000\000"
|
10
10
|
|
11
|
-
require File.join(
|
11
|
+
require File.join(File.dirname(__FILE__) , '..', 'spec_helper')
|
12
12
|
|
13
13
|
|
14
14
|
describe OSC::Message do
|
15
15
|
describe "basic traits" do
|
16
16
|
it "should have no arguments if you define none" do
|
17
|
-
m = OSC::Message.new(
|
18
|
-
m.to_a.must_equal
|
17
|
+
m = OSC::Message.new("/hi")
|
18
|
+
_(m.to_a).must_equal([])
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should accept int arguments" do
|
22
|
-
m = OSC::Message.new(
|
23
|
-
m.to_a.must_equal
|
24
|
-
m.tags.must_equal
|
22
|
+
m = OSC::Message.new("/hi", 42)
|
23
|
+
_(m.to_a).must_equal([42])
|
24
|
+
_(m.tags).must_equal("i")
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should accept string arguments" do
|
28
|
-
m = OSC::Message.new(
|
29
|
-
m.to_a.must_equal
|
30
|
-
m.tags.must_equal
|
28
|
+
m = OSC::Message.new("/hi", "42")
|
29
|
+
_(m.to_a).must_equal(["42"])
|
30
|
+
_(m.tags).must_equal("s")
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should accept float arguments" do
|
34
|
-
m = OSC::Message.new(
|
35
|
-
m.to_a.must_equal
|
36
|
-
m.tags.must_equal
|
34
|
+
m = OSC::Message.new("/hi", 42.001)
|
35
|
+
_(m.to_a).must_equal([42.001])
|
36
|
+
_(m.tags).must_equal("f")
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
describe "message output encoding" do
|
41
41
|
it "integer arguments output binary/ascii string" do
|
42
|
-
m = OSC::Message.new(
|
43
|
-
m.encoding.to_s.must_equal
|
42
|
+
m = OSC::Message.new("/hi", 42).encode
|
43
|
+
_(m.encoding.to_s).must_equal("ASCII-8BIT")
|
44
44
|
end
|
45
45
|
|
46
46
|
it "string arguments output binary/ascii string" do
|
47
|
-
m = OSC::Message.new(
|
48
|
-
m.encoding.to_s.must_equal
|
47
|
+
m = OSC::Message.new("/hi", "42").encode
|
48
|
+
_(m.encoding.to_s).must_equal("ASCII-8BIT")
|
49
49
|
end
|
50
50
|
|
51
51
|
it "float arguments output binary/ascii string" do
|
52
|
-
m = OSC::Message.new(
|
53
|
-
m.encoding.to_s.must_equal
|
52
|
+
m = OSC::Message.new("/hi", 3.14159).encode
|
53
|
+
_(m.encoding.to_s).must_equal("ASCII-8BIT")
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "more interesting traits" do
|
58
58
|
before :each do
|
59
59
|
@builder = MessageBuilder.new
|
60
|
-
@builder.with_int(
|
61
|
-
with_int(
|
62
|
-
|
60
|
+
@builder.with_int(42).
|
61
|
+
with_int(33)
|
62
|
+
|
63
63
|
@message = @builder.build
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
it "should know equality" do
|
67
67
|
@message2 = @builder.build
|
68
|
-
|
69
|
-
@message.object_id.wont_equal
|
70
|
-
@message.must_equal
|
68
|
+
|
69
|
+
_(@message.object_id).wont_equal(@message2.object_id)
|
70
|
+
_(@message).must_equal(@message2)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
require File.join(
|
1
|
+
require File.join(File.dirname(__FILE__) , '..', 'spec_helper')
|
2
2
|
|
3
3
|
|
4
4
|
describe OSC::NetworkPacket do
|
5
5
|
before :each do
|
6
|
-
@empty = OSC::NetworkPacket.new(
|
7
|
-
@simple = OSC::NetworkPacket.new(
|
6
|
+
@empty = OSC::NetworkPacket.new("")
|
7
|
+
@simple = OSC::NetworkPacket.new("abc")
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should know if it's at the end of the stream" do
|
11
|
-
@empty.eof
|
11
|
+
_(@empty.eof?).must_equal(true)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should know the remainder in the stream" do
|
15
|
-
@simple.rem.must_equal
|
15
|
+
_(@simple.rem).must_equal(3)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should be able to skip positions" do
|
19
|
-
@simple.skip(
|
20
|
-
@simple.rem.must_equal
|
19
|
+
@simple.skip(1)
|
20
|
+
_(@simple.rem).must_equal(2)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should be able to get a character from the stream" do
|
24
|
-
@simple.getc.must_equal
|
25
|
-
@simple.getc.must_equal
|
26
|
-
@simple.getc.must_equal
|
27
|
-
@simple.eof
|
24
|
+
_(@simple.getc).must_equal(?a)
|
25
|
+
_(@simple.getc).must_equal(?b)
|
26
|
+
_(@simple.getc).must_equal(?c)
|
27
|
+
_(@simple.eof?).must_equal(true)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "should be able to get a number of characters from the stream" do
|
31
|
-
@simple.getn(3).must_equal
|
31
|
+
_(@simple.getn(3)).must_equal("abc")
|
32
32
|
end
|
33
33
|
|
34
34
|
it "outputs characters with ASCII/BINARY encoding" do
|
35
|
-
@simple.getc.encoding.to_s.must_equal
|
35
|
+
_(@simple.getc.encoding.to_s).must_equal("ASCII-8BIT")
|
36
36
|
end
|
37
37
|
end
|
@@ -4,36 +4,36 @@ require File.join( File.dirname(__FILE__) , '..', 'spec_helper' )
|
|
4
4
|
describe OSC::OSCPacket do
|
5
5
|
before :each do
|
6
6
|
@complex_packet = "#bundle\000\316\034\315T\000\003\030\370\000\000\000$/tuio/2Dobj\000,ss\000source\000\000simulator\000\000\000\000\000\000\030/tuio/2Dobj\000,s\000\000alive\000\000\000\000\000\000\034/tuio/2Dobj\000,si\000fseq\000\000\000\000\377\377\377\377"
|
7
|
-
|
8
|
-
@messages = OSC::OSCPacket.messages_from_network(
|
7
|
+
|
8
|
+
@messages = OSC::OSCPacket.messages_from_network(@complex_packet)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should have three messages" do
|
12
|
-
@messages.size.must_equal
|
12
|
+
_(@messages.size).must_equal(3)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should have the propper address for the messages" do
|
16
16
|
3.times do |i|
|
17
|
-
@messages[i].address.must_equal("/tuio/2Dobj")
|
17
|
+
_(@messages[i].address).must_equal("/tuio/2Dobj")
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it "should have a first message with two strings" do
|
22
22
|
args = @messages[0].to_a
|
23
|
-
|
24
|
-
args[0].must_equal(
|
25
|
-
args[1].must_equal(
|
23
|
+
|
24
|
+
_(args[0]).must_equal("source")
|
25
|
+
_(args[1]).must_equal("simulator")
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should have a second message with one string" do
|
29
29
|
args = @messages[1].to_a
|
30
|
-
args[0].must_equal(
|
30
|
+
_(args[0]).must_equal("alive")
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should have a third message with a string and an int" do
|
34
34
|
args = @messages[2].to_a
|
35
|
-
|
36
|
-
args[0].must_equal(
|
37
|
-
args[1].must_equal(-1)
|
35
|
+
|
36
|
+
_(args[0]).must_equal("fseq")
|
37
|
+
_(args[1]).must_equal(-1)
|
38
38
|
end
|
39
39
|
end
|
@@ -1,15 +1,10 @@
|
|
1
|
-
require File.join(
|
1
|
+
require File.join(File.dirname(__FILE__) , '..', 'spec_helper')
|
2
2
|
|
3
3
|
describe OSC::OSCPacket do
|
4
|
-
|
5
4
|
it 'something' do
|
6
5
|
class OSC::BadType < OSC::OSCInt32; def tag() 'Z'; end end
|
7
|
-
sent_msg = OSC::Message.new(
|
8
|
-
|
9
|
-
lambda do
|
10
|
-
OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
11
|
-
end.must_raise OSC::UnknownType
|
6
|
+
sent_msg = OSC::Message.new("/badtype", OSC::BadType.new(42))
|
12
7
|
|
8
|
+
_ {OSC::OSCPacket.messages_from_network(sent_msg.encode)}.must_raise OSC::UnknownType
|
13
9
|
end
|
14
|
-
|
15
10
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.join(
|
1
|
+
require File.join(File.dirname(__FILE__) , '..', 'spec_helper')
|
2
2
|
|
3
3
|
|
4
4
|
describe OSC::OSCPacket do
|
@@ -17,102 +17,96 @@ describe OSC::OSCPacket do
|
|
17
17
|
@second_blob = "tis another fake blob"
|
18
18
|
|
19
19
|
@builder = MessageBuilder.new
|
20
|
-
@builder.with_address(
|
20
|
+
@builder.with_address(@address)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should decode the address of a simple message from the network data" do
|
24
24
|
sent_msg = @builder.build
|
25
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
25
26
|
|
26
|
-
msg
|
27
|
-
|
28
|
-
msg.first.address.must_equal @address
|
27
|
+
_(msg.first.address).must_equal(@address)
|
29
28
|
end
|
30
29
|
|
31
30
|
it "should decode the int arg of a simple message from the network data" do
|
32
|
-
sent_msg = @builder.with_int(
|
33
|
-
|
34
|
-
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
31
|
+
sent_msg = @builder.with_int(@first_int).build
|
32
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
35
33
|
|
36
|
-
msg.first.to_a.must_equal
|
34
|
+
_(msg.first.to_a).must_equal([@first_int])
|
37
35
|
end
|
38
36
|
|
39
37
|
it "should decode two int args" do
|
40
|
-
sent_msg = @builder.with_int(
|
41
|
-
|
42
|
-
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
38
|
+
sent_msg = @builder.with_int(@first_int ).with_int( @second_int).build
|
39
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
43
40
|
|
44
|
-
msg.first.to_a.must_equal
|
41
|
+
_(msg.first.to_a).must_equal([@first_int, @second_int])
|
45
42
|
end
|
46
43
|
|
47
44
|
it "should decode address with float arg" do
|
48
|
-
sent_msg = @builder.with_float(
|
45
|
+
sent_msg = @builder.with_float(@first_float).build
|
46
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
49
47
|
|
50
|
-
msg
|
51
|
-
|
52
|
-
msg.first.to_a[0].must_be_close_to( @first_float, 0.001 )
|
48
|
+
_(msg.first.to_a[0]).must_be_close_to(@first_float, 0.001)
|
53
49
|
end
|
54
50
|
|
55
51
|
|
56
52
|
it "should decode address with two float args" do
|
57
|
-
sent_msg = @builder.with_float(
|
58
|
-
|
59
|
-
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
53
|
+
sent_msg = @builder.with_float(@first_float).with_float(@second_float).build
|
54
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
60
55
|
|
61
56
|
args = msg.first.to_a
|
62
|
-
args.first.must_be_close_to(
|
63
|
-
args[1].must_be_close_to(
|
57
|
+
_(args.first).must_be_close_to(@first_float, 0.001)
|
58
|
+
_(args[1]).must_be_close_to(@second_float, 0.001)
|
64
59
|
end
|
65
60
|
|
66
61
|
it "should decode address with string arg" do
|
67
|
-
sent_msg = @builder.with_string(
|
68
|
-
|
69
|
-
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
62
|
+
sent_msg = @builder.with_string(@first_string).build
|
63
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
70
64
|
|
71
|
-
msg.first.to_a.must_equal
|
65
|
+
_(msg.first.to_a).must_equal([@first_string])
|
72
66
|
end
|
73
67
|
|
74
68
|
it "should decode address with multiple string args" do
|
75
|
-
sent_msg = @builder.with_string(
|
76
|
-
msg = OSC::OSCPacket.messages_from_network(
|
69
|
+
sent_msg = @builder.with_string(@first_string).with_string(@second_string).build
|
70
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
77
71
|
|
78
72
|
args = msg.first.to_a
|
79
|
-
args[0].must_equal
|
80
|
-
args[1].must_equal
|
73
|
+
_(args[0]).must_equal(@first_string)
|
74
|
+
_(args[1]).must_equal(@second_string)
|
81
75
|
end
|
82
76
|
|
83
77
|
|
84
78
|
it "should decode messages with three different types of args" do
|
85
|
-
sent_msg = @builder.with_int(
|
86
|
-
with_float(
|
87
|
-
with_string(
|
79
|
+
sent_msg = @builder.with_int(@first_int).
|
80
|
+
with_float(@second_float).
|
81
|
+
with_string(@first_string).
|
88
82
|
build
|
89
83
|
|
90
|
-
msg = OSC::OSCPacket.messages_from_network(
|
84
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
91
85
|
|
92
86
|
args = msg.first.to_a
|
93
87
|
|
94
|
-
args[0].must_equal(
|
95
|
-
args[1].must_be_close_to(
|
96
|
-
args[2].must_equal(
|
88
|
+
_(args[0]).must_equal(@first_int)
|
89
|
+
_(args[1]).must_be_close_to(@second_float, 0.001)
|
90
|
+
_(args[2]).must_equal(@first_string)
|
97
91
|
end
|
98
92
|
|
99
93
|
it "should decode messages with blobs" do
|
100
|
-
sent_msg = @builder.with_blob(
|
94
|
+
sent_msg = @builder.with_blob(@first_blob).build
|
101
95
|
|
102
96
|
|
103
|
-
msg = OSC::OSCPacket.messages_from_network(
|
97
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
104
98
|
|
105
99
|
args = msg.first.to_a
|
106
|
-
args.first.must_equal(
|
100
|
+
_(args.first).must_equal(@first_blob)
|
107
101
|
end
|
108
102
|
|
109
103
|
it "should decode messages with double64 types" do
|
110
104
|
pi = 3.14159
|
111
105
|
|
112
|
-
sent_msg = @builder.with_double(
|
113
|
-
msg = OSC::OSCPacket.messages_from_network(
|
106
|
+
sent_msg = @builder.with_double(pi).build
|
107
|
+
msg = OSC::OSCPacket.messages_from_network(sent_msg.encode)
|
114
108
|
|
115
109
|
args = msg.first.to_a
|
116
|
-
args.first.must_be_close_to(
|
110
|
+
_(args.first).must_be_close_to(pi, 0.001)
|
117
111
|
end
|
118
112
|
end
|
data/spec/unit/osc_types_spec.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
require File.join(
|
1
|
+
require File.join(File.dirname(__FILE__) , '..', 'spec_helper')
|
2
2
|
|
3
3
|
describe OSC::OSCInt32 do
|
4
4
|
it "should not blow up" do
|
5
|
-
OSC::OSCInt32.new
|
5
|
+
OSC::OSCInt32.new(1)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
describe OSC::OSCFloat32 do
|
10
10
|
it "should not blow up" do
|
11
|
-
OSC::OSCFloat32.new
|
11
|
+
OSC::OSCFloat32.new(1.0)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe OSC::OSCDouble64 do
|
16
16
|
it "should not blow up" do
|
17
|
-
OSC::OSCDouble64.new
|
17
|
+
OSC::OSCDouble64.new(1.0)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe OSC::OSCString do
|
22
22
|
it "should not blow up" do
|
23
|
-
OSC::OSCString.new
|
23
|
+
OSC::OSCString.new("1")
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe OSC::OSCBlob do
|
28
28
|
it "should not blow up" do
|
29
|
-
OSC::OSCBlob.new
|
29
|
+
OSC::OSCBlob.new(1)
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osc-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Harris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This OSC gem originally created by Tadayoshi Funaba has been updated
|
14
|
-
for ruby 2.
|
14
|
+
for ruby 2.0/1.9/JRuby compatibility
|
15
15
|
email: qzzzq1@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.5.2.3
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: a ruby client for the OSC protocol
|