Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
pushed to gemcutter; autospec friendly specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Macario Ortega authored and Macario Ortega committed Jan 17, 2010
1 parent cb3c126 commit 0bbde03
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
pkg
8 changes: 5 additions & 3 deletions README.rdoc
@@ -1,13 +1,13 @@
= ruby-osc

http://github.com/maca/ruby-osc

Concise OSC implementation for Ruby

* 1.9.1 and jRuby compatible
* Complies with OSC 1.0 specification
* Uses EventMachine for networking and lightweight soft-real-time bundle scheduling

http://github.com/maca/ruby-osc

== SYNOPSIS:

require 'rubygems'
Expand Down Expand Up @@ -46,8 +46,10 @@ eventmachine

== INSTALL:

sudo gem install maca-ruby-osc –source http://gems.github.com
sudo gem install ruby-osc –-source http://gemcutter.org

Although I prefer not to use sudo: http://dev.innovationfactory.nl/2009/10/26/never-use-sudo-gem-install-again/

== TODO:

- OSC 1.1 compatibility mode
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-osc/bundle.rb
Expand Up @@ -26,7 +26,7 @@ def self.decode string
string.gsub! /^#bundle\000/, ''
t1, t2, content_str = string.unpack('N2a*')

timetag = Time.at(t1 + t2 / (2**32.0) - 2208988800) rescue nil
timetag = Time.at(t1 + t2 / (2**32.0) - 2_208_988_800) rescue nil
scanner = StringScanner.new content_str
args = []

Expand Down
21 changes: 13 additions & 8 deletions ruby-osc.gemspec
Expand Up @@ -6,32 +6,37 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Macario Ortega"]
s.date = %q{2009-08-30}
s.date = %q{2010-01-17}
s.description = %q{}
s.email = ["macarui@gmail.com"]
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "examples/localtest.rb", "lib/ruby-osc.rb", "lib/ruby-osc/bundle.rb", "lib/ruby-osc/client.rb", "lib/ruby-osc/message.rb", "lib/ruby-osc/server.rb", "ruby-osc.gemspec", "spec/bundle_spec.rb", "spec/message_spec.rb", "spec/server_spec.rb", "spec/spec_helper.rb"]
s.has_rdoc = true
s.homepage = %q{Concise OSC client for Ruby}
s.homepage = %q{http://github.com/maca/ruby-osc}
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{ruby-osc}
s.rubygems_version = %q{1.3.1}
s.rubygems_version = %q{1.3.5}
s.summary = %q{}

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
s.specification_version = 3

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<eventmachine>, [">= 0.12.8"])
s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
s.add_development_dependency(%q<rubyforge>, [">= 2.0.3"])
s.add_development_dependency(%q<gemcutter>, [">= 0.3.0"])
s.add_development_dependency(%q<hoe>, [">= 2.5.0"])
else
s.add_dependency(%q<eventmachine>, [">= 0.12.8"])
s.add_dependency(%q<hoe>, [">= 2.3.2"])
s.add_dependency(%q<rubyforge>, [">= 2.0.3"])
s.add_dependency(%q<gemcutter>, [">= 0.3.0"])
s.add_dependency(%q<hoe>, [">= 2.5.0"])
end
else
s.add_dependency(%q<eventmachine>, [">= 0.12.8"])
s.add_dependency(%q<hoe>, [">= 2.3.2"])
s.add_dependency(%q<rubyforge>, [">= 2.0.3"])
s.add_dependency(%q<gemcutter>, [">= 0.3.0"])
s.add_dependency(%q<hoe>, [">= 2.5.0"])
end
end
14 changes: 7 additions & 7 deletions spec/bundle_spec.rb
Expand Up @@ -23,7 +23,7 @@
end

describe 'Encode/decode' do
shared_examples_for 'Encodable' do
shared_examples_for 'Encodable Bundle' do
it "should encode" do
@bundle.encode.should == @expected
end
Expand All @@ -47,31 +47,31 @@
@bundle = Bundle.new
@expected = "#bundle\000\000\000\000\000\000\000\000\001"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Bundle'
end

describe 'Empty bundle with timetag' do
before do
@bundle = Bundle.new Time.at(1251420949.16959)
@expected = [35, 98, 117, 110, 100, 108, 101, 0, 206, 65, 169, 149, 43, 106, 64, 0].pack('C*')
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Bundle'
end

describe 'Bundle with timetag and messages' do
before do
@bundle = Bundle.new Time.at(946702800), Message.new('/bar/foo', 4, 3, 2, 1), Message.new('/foo/bar', 1, 2, 3, 4)
@expected = [35, 98, 117, 110, 100, 108, 101, 0, 188, 24, 8, 80, 0, 0, 0, 0, 0, 0, 0, 36, 47, 98, 97, 114, 47, 102, 111, 111, 0, 0, 0, 0, 44, 105, 105, 105, 105, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 36, 47, 102, 111, 111, 47, 98, 97, 114, 0, 0, 0, 0, 44, 105, 105, 105, 105, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4].pack('C*')
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Bundle'
end

describe 'Nested bundles' do
before do
@bundle = Bundle.new( nil, Bundle.new(nil, Message.new('/a')), Message.new('/b') )
@expected = "#bundle\000\000\000\000\000\000\000\000\001\000\000\000\034#bundle\000\000\000\000\000\000\000\000\001\000\000\000\b/a\000\000,\000\000\000\000\000\000\b/b\000\000,\000\000\000"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Bundle'
end

describe 'Complex blob' do
Expand All @@ -80,7 +80,7 @@
@bundle = Bundle.new nil, Message.new('/d_recv', Blob.new(data), 0)
@expected = [35, 98, 117, 110, 100, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 76, 47, 100, 95, 114, 101, 99, 118, 0, 44, 98, 105, 0, 0, 0, 0, 56, 83, 67, 103, 102, 0, 0, 0, 1, 0, 1, 4, 104, 111, 108, 97, 0, 2, 67, 220, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 83, 105, 110, 79, 115, 99, 2, 0, 2, 0, 1, 0, 0, 255, 255, 0, 0, 255, 255, 0, 1, 2, 0, 0, 0, 0, 0, 0].pack('C*')
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Bundle'
end

describe 'Complex blob 2' do
Expand All @@ -89,7 +89,7 @@
@bundle = Bundle.new nil, Message.new('/d_recv', Blob.new(data), 0)
@expected = [35, 98, 117, 110, 100, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 124, 47, 100, 95, 114, 101, 99, 118, 0, 44, 98, 105, 0, 0, 0, 1, 101, 83, 67, 103, 102, 0, 0, 0, 1, 0, 1, 2, 97, 109, 0, 7, 0, 0, 0, 0, 63, 0, 0, 0, 63, 128, 0, 0, 64, 0, 0, 0, 194, 198, 0, 0, 64, 160, 0, 0, 192, 128, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 103, 97, 116, 101, 0, 0, 9, 112, 111, 114, 116, 97, 100, 111, 114, 97, 0, 1, 10, 109, 111, 100, 117, 108, 97, 100, 111, 114, 97, 0, 2, 3, 97, 109, 112, 0, 3, 0, 8, 7, 67, 111, 110, 116, 114, 111, 108, 1, 0, 0, 0, 4, 0, 0, 1, 1, 1, 1, 6, 83, 105, 110, 79, 115, 99, 1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 2, 255, 255, 0, 0, 1, 6, 77, 117, 108, 65, 100, 100, 1, 0, 3, 0, 1, 0, 0, 0, 1, 0, 0, 255, 255, 0, 1, 255, 255, 0, 1, 1, 6, 83, 105, 110, 79, 115, 99, 2, 0, 2, 0, 1, 0, 0, 0, 0, 0, 1, 255, 255, 0, 0, 2, 12, 66, 105, 110, 97, 114, 121, 79, 112, 85, 71, 101, 110, 2, 0, 2, 0, 1, 0, 2, 0, 3, 0, 0, 0, 2, 0, 0, 2, 6, 69, 110, 118, 71, 101, 110, 1, 0, 17, 0, 1, 0, 0, 0, 0, 0, 0, 255, 255, 0, 2, 255, 255, 0, 0, 255, 255, 0, 2, 255, 255, 0, 3, 255, 255, 0, 0, 255, 255, 0, 3, 255, 255, 0, 2, 255, 255, 0, 4, 255, 255, 0, 2, 255, 255, 0, 3, 255, 255, 0, 5, 255, 255, 0, 6, 255, 255, 0, 0, 255, 255, 0, 3, 255, 255, 0, 5, 255, 255, 0, 6, 1, 12, 66, 105, 110, 97, 114, 121, 79, 112, 85, 71, 101, 110, 2, 0, 2, 0, 1, 0, 2, 0, 4, 0, 0, 0, 5, 0, 0, 2, 3, 79, 117, 116, 2, 0, 2, 0, 0, 0, 0, 255, 255, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].pack('C*')
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Bundle'
end

it 'Should raise OSC::DecodeError with bad encoded bundle' do
Expand Down
20 changes: 10 additions & 10 deletions spec/message_spec.rb
Expand Up @@ -65,7 +65,7 @@
end

describe 'Encode/decode' do
shared_examples_for 'Encodable' do
shared_examples_for 'Encodable Message' do
it "should encode" do
@message.encode.should == @expected
end
Expand All @@ -88,63 +88,63 @@
@message = Message.new('/foo/bar/long/very/long/long/long/address')
@expected = "/foo/bar/long/very/long/long/long/address\000\000\000,\000\000\000"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end

describe 'Integer' do
before do
@message = Message.new('/foo/barz', 2)
@expected = "/foo/barz\000\000\000,i\000\000\000\000\000\002"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end

describe 'Negative Integer' do
before do
@message = Message.new('/foo/barz', -2)
@expected = "/foo/barz\000\000\000,i\000\000\377\377\377\376"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end

describe 'Float' do
before do
@message = Message.new('/foo/bar', 1.10000002384186)
@expected = [47, 102, 111, 111, 47, 98, 97, 114, 0, 0, 0, 0, 44, 102, 0, 0, 63, 140, 204, 205].pack('C*')
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end

describe 'Negative Float' do
before do
@message = Message.new('/foo/bar', -1.10000002384186)
@expected = [47, 102, 111, 111, 47, 98, 97, 114, 0, 0, 0, 0, 44, 102, 0, 0, 191, 140, 204, 205].pack('C*')
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end

describe 'String' do
before do
@message = Message.new('/foo/bar', 'a string to encode')
@expected = "/foo/bar\000\000\000\000,s\000\000a string to encode\000\000"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end

describe 'Multiple types' do
before do
@message = Message.new('/foo/barzzz', 2, 1.44000005722046, 'basho')
@expected = [47, 102, 111, 111, 47, 98, 97, 114, 122, 122, 122, 0, 44, 105, 102, 115, 0, 0, 0, 0, 0, 0, 0, 2, 63, 184, 81, 236, 98, 97, 115, 104, 111, 0, 0, 0].pack('C*')
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end

describe 'Blob' do
before do
@message = Message.new('/foo/bar', Blob.new('test blob'))
@expected = "/foo/bar\000\000\000\000,b\000\000\000\000\000\ttest blob\000\000\000"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'

it "should raise if size doesn't correspond and return empty message" do
lambda do
Expand All @@ -158,7 +158,7 @@
@message = Message.new('/bar/foo', 4, 3, 2, 1)
@expected = "/bar/foo\000\000\000\000,iiii\000\000\000\000\000\000\004\000\000\000\003\000\000\000\002\000\000\000\001"
end
it_should_behave_like 'Encodable'
it_should_behave_like 'Encodable Message'
end
end
end

0 comments on commit 0bbde03

Please sign in to comment.