osc-ruby 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -6
- data/VERSION +1 -1
- data/examples/broadcast_client.rb +21 -0
- data/lib/osc-ruby.rb +1 -0
- data/lib/osc-ruby/argument_factory.rb +8 -0
- data/lib/osc-ruby/broadcast_client.rb +18 -0
- data/lib/osc-ruby/osc_packet.rb +17 -6
- data/lib/osc-ruby/osc_types.rb +7 -2
- data/spec/builders/message_builder.rb +5 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/address_pattern_spec.rb +37 -38
- data/spec/unit/message_builder_spec.rb +5 -5
- data/spec/unit/message_spec.rb +12 -12
- data/spec/unit/network_packet_spec.rb +9 -9
- data/spec/unit/osc_complex_packets_spec.rb +7 -7
- data/spec/unit/osc_packet_unknown_type_spec.rb +15 -0
- data/spec/unit/osc_simple_packets_spec.rb +24 -14
- data/spec/unit/osc_types_spec.rb +6 -0
- data/spec/unit/parsers/argument_parser_spec.rb +12 -0
- metadata +17 -22
- checksums.yaml +0 -7
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "rake/testtask"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
t.rcov = false
|
7
|
-
t.rspec_opts = ["--colour", "--format", "documentation"]
|
3
|
+
Rake::TestTask.new(:spec) do |t|
|
4
|
+
t.libs << "spec"
|
5
|
+
t.pattern = "spec/**/*_spec.rb"
|
8
6
|
end
|
9
7
|
|
8
|
+
task :default => :spec
|
9
|
+
|
10
10
|
require 'rdoc/task'
|
11
11
|
RDoc::Task.new do |rdoc|
|
12
12
|
if File.exist?('VERSION')
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib')
|
2
|
+
require 'osc-ruby'
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'eventmachine'
|
6
|
+
require 'osc-ruby/em_server'
|
7
|
+
|
8
|
+
@server = OSC::EMServer.new( 3333 )
|
9
|
+
@client = OSC::BroadcastClient.new( 3333 )
|
10
|
+
|
11
|
+
@server.add_method '/greeting' do | message |
|
12
|
+
puts "#{message.ip_address}:#{message.ip_port} -- #{message.address} -- #{message.to_a}"
|
13
|
+
end
|
14
|
+
|
15
|
+
Thread.new do
|
16
|
+
@server.run
|
17
|
+
end
|
18
|
+
|
19
|
+
@client.send( OSC::Message.new( "/greeting" , "hullo!" ))
|
20
|
+
|
21
|
+
sleep( 3 )
|
data/lib/osc-ruby.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module OSC
|
2
|
+
class BroadcastClient
|
3
|
+
|
4
|
+
BROADCAST_ADDRESS = '<broadcast>'
|
5
|
+
|
6
|
+
attr_reader :port
|
7
|
+
|
8
|
+
def initialize(port)
|
9
|
+
@port = port
|
10
|
+
@so = UDPSocket.new
|
11
|
+
@so.setsockopt Socket::SOL_SOCKET, Socket::SO_BROADCAST, true
|
12
|
+
end
|
13
|
+
|
14
|
+
def send(mesg)
|
15
|
+
@so.send(mesg.encode, 0, BROADCAST_ADDRESS, @port)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/osc-ruby/osc_packet.rb
CHANGED
@@ -2,6 +2,8 @@ require File.join( File.dirname( __FILE__ ), 'network_packet')
|
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
4
|
module OSC
|
5
|
+
class UnknownType < StandardError; end
|
6
|
+
|
5
7
|
class OSCPacket
|
6
8
|
|
7
9
|
def self.messages_from_network( string, ip_info=nil )
|
@@ -45,10 +47,11 @@ module OSC
|
|
45
47
|
def initialize( string )
|
46
48
|
@packet = NetworkPacket.new( string )
|
47
49
|
|
48
|
-
@types = { "i" => lambda{ OSCInt32.new(
|
49
|
-
"f" => lambda{ OSCFloat32.new(
|
50
|
-
"
|
51
|
-
"
|
50
|
+
@types = { "i" => lambda{ OSCInt32.new( get_int32 ) },
|
51
|
+
"f" => lambda{ OSCFloat32.new( get_float32 ) },
|
52
|
+
"d" => lambda{ OSCDouble64.new( get_double64 )},
|
53
|
+
"s" => lambda{ OSCString.new( get_string ) },
|
54
|
+
"b" => lambda{ OSCBlob.new( get_blob )}
|
52
55
|
}
|
53
56
|
end
|
54
57
|
|
@@ -93,7 +96,9 @@ module OSC
|
|
93
96
|
args = []
|
94
97
|
|
95
98
|
tags.scan(/./) do | tag |
|
96
|
-
|
99
|
+
type_handler = @types[tag]
|
100
|
+
raise( UnknownType, "Unknown OSC type: #{tag}" ) unless type_handler
|
101
|
+
args << type_handler.call
|
97
102
|
end
|
98
103
|
args
|
99
104
|
end
|
@@ -112,6 +117,12 @@ module OSC
|
|
112
117
|
f
|
113
118
|
end
|
114
119
|
|
120
|
+
def get_double64
|
121
|
+
f = @packet.getn(8).unpack('G')[0]
|
122
|
+
@packet.skip_padding
|
123
|
+
f
|
124
|
+
end
|
125
|
+
|
115
126
|
def get_blob
|
116
127
|
l = @packet.getn(4).unpack('N')[0]
|
117
128
|
b = @packet.getn(l)
|
@@ -127,4 +138,4 @@ module OSC
|
|
127
138
|
"\x00"
|
128
139
|
end
|
129
140
|
end
|
130
|
-
end
|
141
|
+
end
|
data/lib/osc-ruby/osc_types.rb
CHANGED
@@ -8,7 +8,12 @@ module OSC
|
|
8
8
|
|
9
9
|
class OSCFloat32 < OSCArgument
|
10
10
|
def tag() 'f' end
|
11
|
-
def encode() [@val].pack('g').force_encoding("BINARY") end
|
11
|
+
def encode() [@val].pack('g').force_encoding("BINARY") end
|
12
|
+
end
|
13
|
+
|
14
|
+
class OSCDouble64 < OSCArgument
|
15
|
+
def tag() 'd' end
|
16
|
+
def encode() [@val].pack('G').force_encoding("BINARY") end
|
12
17
|
end
|
13
18
|
|
14
19
|
class OSCString < OSCArgument
|
@@ -20,4 +25,4 @@ module OSC
|
|
20
25
|
def tag() 'b' end
|
21
26
|
def encode() padding([@val.size].pack('N') + @val).force_encoding("BINARY") end
|
22
27
|
end
|
23
|
-
end
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,80 +15,79 @@ describe OSC::AddressPattern do
|
|
15
15
|
it "should match anything if the pattern is nil" do
|
16
16
|
ap = OSC::AddressPattern.new( nil )
|
17
17
|
|
18
|
-
ap.match?( "/some/nonsense").
|
19
|
-
ap.match?( "/completely.different").
|
18
|
+
ap.match?( "/some/nonsense" ).must_equal true
|
19
|
+
ap.match?( "/completely.different" ).must_equal true
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should match based on a regex" do
|
23
23
|
ap = OSC::AddressPattern.new( /hi/ )
|
24
24
|
|
25
|
-
ap.match?( '/hi' ).
|
26
|
-
ap.match?( '/hidden' ).
|
25
|
+
ap.match?( '/hi' ).must_equal true
|
26
|
+
ap.match?( '/hidden' ).must_equal true
|
27
27
|
|
28
|
-
ap.match?( '/bye' ).
|
28
|
+
ap.match?( '/bye' ).must_equal false
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should return a regex if the pattern is a string" do
|
32
32
|
ap = OSC::AddressPattern.new( "/hi" )
|
33
33
|
|
34
|
-
ap.match?('/hi').
|
34
|
+
ap.match?( '/hi' ).must_equal true
|
35
35
|
|
36
|
-
ap.match?(' /hi').
|
37
|
-
ap.match?('/ahi').
|
38
|
-
ap.match?( '/hidden' ).
|
39
|
-
ap.match?( '/bye' ).
|
36
|
+
ap.match?( ' /hi' ).must_equal false
|
37
|
+
ap.match?( '/ahi' ).must_equal false
|
38
|
+
ap.match?( '/hidden' ).must_equal false
|
39
|
+
ap.match?( '/bye' ).must_equal false
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should match with question mark" do
|
43
43
|
ap = OSC::AddressPattern.new( "/h?l" )
|
44
44
|
|
45
|
-
ap.match?('/hal').
|
46
|
-
ap.match?('/hel').
|
47
|
-
ap.match?('/hil').
|
48
|
-
ap.match?('/hol').
|
49
|
-
ap.match?('/hul').
|
50
|
-
ap.match?('/hub').
|
45
|
+
ap.match?( '/hal' ).must_equal true
|
46
|
+
ap.match?( '/hel' ).must_equal true
|
47
|
+
ap.match?( '/hil' ).must_equal true
|
48
|
+
ap.match?( '/hol' ).must_equal true
|
49
|
+
ap.match?( '/hul' ).must_equal true
|
50
|
+
ap.match?( '/hub' ).must_equal false
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should match with *" do
|
54
54
|
ap = OSC::AddressPattern.new( "/believ*d" )
|
55
55
|
|
56
|
-
ap.match?('/believd').
|
57
|
-
ap.match?('/believed').
|
58
|
-
ap.match?('/believeeed').
|
59
|
-
ap.match?('/believaeeeioud').
|
60
|
-
ap.match?('/believaeeeioud').
|
56
|
+
ap.match?( '/believd' ).must_equal true
|
57
|
+
ap.match?( '/believed' ).must_equal true
|
58
|
+
ap.match?( '/believeeed' ).must_equal true
|
59
|
+
ap.match?( '/believaeeeioud' ).must_equal true
|
60
|
+
ap.match?( '/believaeeeioud' ).must_equal true
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should match with []" do
|
64
64
|
ap = OSC::AddressPattern.new( "/believ[aeiou]d" )
|
65
65
|
|
66
|
-
ap.match?('/believad').
|
67
|
-
ap.match?('/believed').
|
68
|
-
ap.match?('/believid').
|
69
|
-
ap.match?('/believod').
|
70
|
-
ap.match?('/believud').
|
71
|
-
ap.match?('/believkd').
|
66
|
+
ap.match?( '/believad' ).must_equal true
|
67
|
+
ap.match?( '/believed' ).must_equal true
|
68
|
+
ap.match?( '/believid' ).must_equal true
|
69
|
+
ap.match?( '/believod' ).must_equal true
|
70
|
+
ap.match?( '/believud' ).must_equal true
|
71
|
+
ap.match?( '/believkd' ).must_equal false
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should match with [!]" do
|
75
75
|
ap = OSC::AddressPattern.new( "/believ[!aeiou]d" )
|
76
76
|
|
77
|
-
ap.match?('/believad').
|
78
|
-
ap.match?('/believed').
|
79
|
-
ap.match?('/believid').
|
80
|
-
ap.match?('/believod').
|
81
|
-
ap.match?('/believud').
|
82
|
-
ap.match?('/believkd').
|
83
|
-
ap.match?('/believzd').
|
77
|
+
ap.match?( '/believad' ).must_equal false
|
78
|
+
ap.match?( '/believed' ).must_equal false
|
79
|
+
ap.match?( '/believid' ).must_equal false
|
80
|
+
ap.match?( '/believod' ).must_equal false
|
81
|
+
ap.match?( '/believud' ).must_equal false
|
82
|
+
ap.match?( '/believkd' ).must_equal true
|
83
|
+
ap.match?( '/believzd' ).must_equal true
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should match with {}" do
|
87
87
|
ap = OSC::AddressPattern.new( "/{hi,bye}" )
|
88
88
|
|
89
|
-
ap.match?('/hi').
|
90
|
-
ap.match?('/bye').
|
91
|
-
ap.match?('/greetings').
|
89
|
+
ap.match?( '/hi' ).must_equal true
|
90
|
+
ap.match?( '/bye' ).must_equal true
|
91
|
+
ap.match?( '/greetings' ).must_equal false
|
92
92
|
end
|
93
|
-
|
94
93
|
end
|
@@ -8,28 +8,28 @@ describe MessageBuilder do
|
|
8
8
|
|
9
9
|
it "encodes just the address" do
|
10
10
|
mesg = @builder.with_address("/hi")
|
11
|
-
mesg.build.encode.
|
11
|
+
mesg.build.encode.must_equal binary_string("/hi\000,\000\000\000")
|
12
12
|
end
|
13
13
|
|
14
14
|
it "encodes single int values" do
|
15
15
|
mesg = @builder.with_address("/hi").
|
16
16
|
with_int(33)
|
17
17
|
|
18
|
-
mesg.build.encode.
|
18
|
+
mesg.build.encode.must_equal binary_string("/hi\000,i\000\000\000\000\000!")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "encodes single string values" do
|
22
22
|
mesg = @builder.with_address("/hi").
|
23
23
|
with_string("hello")
|
24
24
|
|
25
|
-
mesg.build.encode.
|
25
|
+
mesg.build.encode.must_equal binary_string("/hi\000,s\000\000hello\000\000\000")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "encodes single float values" do
|
29
29
|
mesg = @builder.with_address("/hi").
|
30
30
|
with_float(3.14159)
|
31
31
|
|
32
|
-
mesg.build.encode.
|
32
|
+
mesg.build.encode.must_equal binary_string("/hi\000,f\000\000@I\017\320")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "encodes multiple floats" do
|
@@ -37,7 +37,7 @@ describe MessageBuilder do
|
|
37
37
|
with_float(3.14159).
|
38
38
|
with_float(4.5)
|
39
39
|
|
40
|
-
mesg.build.encode.
|
40
|
+
mesg.build.encode.must_equal [47, 104, 105, 0, 44, 102, 102, 0, 64, 73, 15, 208, 64, 144, 0, 0].pack("C*")
|
41
41
|
end
|
42
42
|
|
43
43
|
def binary_string(string)
|
data/spec/unit/message_spec.rb
CHANGED
@@ -15,42 +15,42 @@ describe OSC::Message do
|
|
15
15
|
describe "basic traits" do
|
16
16
|
it "should have no arguments if you define none" do
|
17
17
|
m = OSC::Message.new( "/hi" )
|
18
|
-
m.to_a.
|
18
|
+
m.to_a.must_equal []
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should accept int arguments" do
|
22
22
|
m = OSC::Message.new( "/hi", 42 )
|
23
|
-
m.to_a.
|
24
|
-
m.tags.
|
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
28
|
m = OSC::Message.new( "/hi", "42" )
|
29
|
-
m.to_a.
|
30
|
-
m.tags.
|
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
34
|
m = OSC::Message.new( "/hi", 42.001 )
|
35
|
-
m.to_a.
|
36
|
-
m.tags.
|
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
42
|
m = OSC::Message.new( "/hi", 42 ).encode
|
43
|
-
m.encoding.to_s.
|
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
47
|
m = OSC::Message.new( "/hi", "42" ).encode
|
48
|
-
m.encoding.to_s.
|
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
52
|
m = OSC::Message.new( "/hi", 3.14159 ).encode
|
53
|
-
m.encoding.to_s.
|
53
|
+
m.encoding.to_s.must_equal "ASCII-8BIT"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -66,8 +66,8 @@ describe OSC::Message do
|
|
66
66
|
it "should know equality" do
|
67
67
|
@message2 = @builder.build
|
68
68
|
|
69
|
-
@message.object_id.
|
70
|
-
@message.
|
69
|
+
@message.object_id.wont_equal @message2.object_id
|
70
|
+
@message.must_equal @message2
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -8,30 +8,30 @@ describe OSC::NetworkPacket do
|
|
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.
|
15
|
+
@simple.rem.must_equal 3
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be able to skip positions" do
|
19
19
|
@simple.skip( 1 )
|
20
|
-
@simple.rem.
|
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.
|
25
|
-
@simple.getc.
|
26
|
-
@simple.getc.
|
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).
|
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.
|
35
|
+
@simple.getc.encoding.to_s.must_equal "ASCII-8BIT"
|
36
36
|
end
|
37
37
|
end
|
@@ -9,31 +9,31 @@ describe OSC::OSCPacket do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should have three messages" do
|
12
|
-
@messages.
|
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.
|
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
23
|
|
24
|
-
args[0].
|
25
|
-
args[1].
|
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].
|
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
35
|
|
36
|
-
args[0].
|
37
|
-
args[1].
|
36
|
+
args[0].must_equal( "fseq" )
|
37
|
+
args[1].must_equal(-1)
|
38
38
|
end
|
39
39
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__) , '..', 'spec_helper' )
|
2
|
+
|
3
|
+
describe OSC::OSCPacket do
|
4
|
+
|
5
|
+
it 'something' do
|
6
|
+
class OSC::BadType < OSC::OSCInt32; def tag() 'Z'; end end
|
7
|
+
sent_msg = OSC::Message.new( "/badtype", OSC::BadType.new( 42 ) )
|
8
|
+
|
9
|
+
lambda do
|
10
|
+
OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
11
|
+
end.must_raise OSC::UnknownType
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -25,7 +25,7 @@ describe OSC::OSCPacket do
|
|
25
25
|
|
26
26
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
27
27
|
|
28
|
-
msg.first.address.
|
28
|
+
msg.first.address.must_equal @address
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should decode the int arg of a simple message from the network data" do
|
@@ -33,7 +33,7 @@ describe OSC::OSCPacket do
|
|
33
33
|
|
34
34
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
35
35
|
|
36
|
-
msg.first.to_a.
|
36
|
+
msg.first.to_a.must_equal [@first_int]
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should decode two int args" do
|
@@ -41,7 +41,7 @@ describe OSC::OSCPacket do
|
|
41
41
|
|
42
42
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
43
43
|
|
44
|
-
msg.first.to_a.
|
44
|
+
msg.first.to_a.must_equal [@first_int, @second_int]
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should decode address with float arg" do
|
@@ -49,18 +49,18 @@ describe OSC::OSCPacket do
|
|
49
49
|
|
50
50
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
51
51
|
|
52
|
-
msg.first.to_a[0].
|
52
|
+
msg.first.to_a[0].must_be_close_to( @first_float, 0.001 )
|
53
53
|
end
|
54
54
|
|
55
55
|
|
56
56
|
it "should decode address with two float args" do
|
57
|
-
sent_msg = @builder.with_float( @first_float ).with_float( @second_float).build
|
57
|
+
sent_msg = @builder.with_float( @first_float ).with_float( @second_float ).build
|
58
58
|
|
59
59
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
60
60
|
|
61
61
|
args = msg.first.to_a
|
62
|
-
args.first.
|
63
|
-
args[1].
|
62
|
+
args.first.must_be_close_to( @first_float, 0.001 )
|
63
|
+
args[1].must_be_close_to( @second_float, 0.001 )
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should decode address with string arg" do
|
@@ -68,7 +68,7 @@ describe OSC::OSCPacket do
|
|
68
68
|
|
69
69
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
70
70
|
|
71
|
-
msg.first.to_a.
|
71
|
+
msg.first.to_a.must_equal [@first_string]
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should decode address with multiple string args" do
|
@@ -76,8 +76,8 @@ describe OSC::OSCPacket do
|
|
76
76
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
77
77
|
|
78
78
|
args = msg.first.to_a
|
79
|
-
args[0].
|
80
|
-
args[1].
|
79
|
+
args[0].must_equal @first_string
|
80
|
+
args[1].must_equal @second_string
|
81
81
|
end
|
82
82
|
|
83
83
|
|
@@ -91,9 +91,9 @@ describe OSC::OSCPacket do
|
|
91
91
|
|
92
92
|
args = msg.first.to_a
|
93
93
|
|
94
|
-
args[0].
|
95
|
-
args[1].
|
96
|
-
args[2].
|
94
|
+
args[0].must_equal( @first_int )
|
95
|
+
args[1].must_be_close_to( @second_float, 0.001 )
|
96
|
+
args[2].must_equal( @first_string )
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should decode messages with blobs" do
|
@@ -103,6 +103,16 @@ describe OSC::OSCPacket do
|
|
103
103
|
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
104
104
|
|
105
105
|
args = msg.first.to_a
|
106
|
-
args.first.
|
106
|
+
args.first.must_equal( @first_blob )
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should decode messages with double64 types" do
|
110
|
+
pi = 3.14159
|
111
|
+
|
112
|
+
sent_msg = @builder.with_double( pi ).build
|
113
|
+
msg = OSC::OSCPacket.messages_from_network( sent_msg.encode )
|
114
|
+
|
115
|
+
args = msg.first.to_a
|
116
|
+
args.first.must_be_close_to( pi, 0.001 )
|
107
117
|
end
|
108
118
|
end
|
data/spec/unit/osc_types_spec.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# require File.join( File.dirname(__FILE__) , '..', '..', 'spec_helper' )
|
2
|
+
|
3
|
+
# describe OSC::ArgumentParser do
|
4
|
+
# it "can parse streams that contain integer arguments" do
|
5
|
+
# int_value = 1024
|
6
|
+
# int32_stream = OSC::InputStream.new(OSC::Int32.new(int_value).encode)
|
7
|
+
|
8
|
+
# result = OSC::Int32Parser.new(int32_stream).parse
|
9
|
+
|
10
|
+
# result.should == int_value
|
11
|
+
# end
|
12
|
+
# end
|
metadata
CHANGED
@@ -1,29 +1,16 @@
|
|
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.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Colin Harris
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rspec
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
12
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
27
14
|
description: This OSC gem originally created by Tadayoshi Funaba has been updated
|
28
15
|
for ruby 2.0/1.9/JRuby compatibility
|
29
16
|
email: qzzzq1@gmail.com
|
@@ -34,8 +21,11 @@ files:
|
|
34
21
|
- Rakefile
|
35
22
|
- VERSION
|
36
23
|
- LICENSE
|
24
|
+
- examples/broadcast_client.rb
|
37
25
|
- examples/event_machine_server.rb
|
38
26
|
- lib/osc-ruby/address_pattern.rb
|
27
|
+
- lib/osc-ruby/argument_factory.rb
|
28
|
+
- lib/osc-ruby/broadcast_client.rb
|
39
29
|
- lib/osc-ruby/bundle.rb
|
40
30
|
- lib/osc-ruby/client.rb
|
41
31
|
- lib/osc-ruby/core_ext/numeric.rb
|
@@ -57,30 +47,33 @@ files:
|
|
57
47
|
- spec/unit/network_packet_spec.rb
|
58
48
|
- spec/unit/osc_argument_spec.rb
|
59
49
|
- spec/unit/osc_complex_packets_spec.rb
|
50
|
+
- spec/unit/osc_packet_unknown_type_spec.rb
|
60
51
|
- spec/unit/osc_simple_packets_spec.rb
|
61
52
|
- spec/unit/osc_types_spec.rb
|
53
|
+
- spec/unit/parsers/argument_parser_spec.rb
|
62
54
|
homepage: http://github.com/aberant/osc-ruby
|
63
55
|
licenses: []
|
64
|
-
metadata: {}
|
65
56
|
post_install_message:
|
66
57
|
rdoc_options: []
|
67
58
|
require_paths:
|
68
59
|
- lib
|
69
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
70
62
|
requirements:
|
71
|
-
- - '>='
|
63
|
+
- - ! '>='
|
72
64
|
- !ruby/object:Gem::Version
|
73
65
|
version: '0'
|
74
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
75
68
|
requirements:
|
76
|
-
- - '>='
|
69
|
+
- - ! '>='
|
77
70
|
- !ruby/object:Gem::Version
|
78
71
|
version: '0'
|
79
72
|
requirements: []
|
80
73
|
rubyforge_project:
|
81
|
-
rubygems_version:
|
74
|
+
rubygems_version: 1.8.24
|
82
75
|
signing_key:
|
83
|
-
specification_version:
|
76
|
+
specification_version: 3
|
84
77
|
summary: a ruby client for the OSC protocol
|
85
78
|
test_files:
|
86
79
|
- spec/builders/message_builder.rb
|
@@ -92,5 +85,7 @@ test_files:
|
|
92
85
|
- spec/unit/network_packet_spec.rb
|
93
86
|
- spec/unit/osc_argument_spec.rb
|
94
87
|
- spec/unit/osc_complex_packets_spec.rb
|
88
|
+
- spec/unit/osc_packet_unknown_type_spec.rb
|
95
89
|
- spec/unit/osc_simple_packets_spec.rb
|
96
90
|
- spec/unit/osc_types_spec.rb
|
91
|
+
- spec/unit/parsers/argument_parser_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 2b6e50d421b58c68e16b4d82d132f25e15b0338b
|
4
|
-
data.tar.gz: 8875e8b6aa9cf1af663291b248c5708695ed1448
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: c814bfa20121cb7a835159546c858b9f6d3370c6158e067c17df7ceeb379608c98242375ef5b776488cd35efe4c7df1a25b3439c2a97c01eed7799be7daf15c8
|
7
|
-
data.tar.gz: 576b0fcabd35b30da9cdfad8477d788ddec610fc455b796a4322483a1b3917a3f26f332e8536cc0b6dd534a3ea2c6b63b75a5cb5f22e1262944e309aed16c091
|