arpie 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ describe "BytesBinaryType" do
11
11
  ]
12
12
  }
13
13
 
14
- it_should_behave_like "Binary Tests with data"
14
+ include_examples "Binary Tests with data"
15
15
  end
16
16
 
17
17
  describe "virtual length" do subject {
@@ -24,7 +24,7 @@ describe "BytesBinaryType" do
24
24
  ]
25
25
  }
26
26
 
27
- it_should_behave_like "Binary Tests with data"
27
+ include_examples "Binary Tests with data"
28
28
  end
29
29
 
30
30
  describe "length as virtual should not update the virtual" do subject {
@@ -37,7 +37,7 @@ describe "BytesBinaryType" do
37
37
  ]
38
38
  }
39
39
 
40
- it_should_behave_like "Binary Tests with data"
40
+ include_examples "Binary Tests with data"
41
41
 
42
42
  it "does not change virtuals on data change" do
43
43
  dd, b = @c.from(@d + "xxyzz")
@@ -46,4 +46,17 @@ describe "BytesBinaryType" do
46
46
  dd.to.should == expect
47
47
  end
48
48
  end
49
+
50
+ describe "NULL-terminated strings" do subject {
51
+ [
52
+ Class.new(Arpie::Binary) do
53
+ field :s, :nstring
54
+ field :d, :uint8
55
+ end,
56
+ ["abcd", 4].pack("Z* C")
57
+ ]
58
+ }
59
+
60
+ include_examples "Binary Tests with data"
61
+ end
49
62
  end
@@ -0,0 +1,27 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ require 'eventmachine'
4
+
5
+ describe 'Eventmachine usecase' do
6
+ specify do
7
+ $m = nil
8
+
9
+ EM::run {
10
+ EM::start_server "127.0.0.1", 19400, Arpie::EventMachine::ArpieProtocol,
11
+ Arpie::SeparatorProtocol.new do |proto|
12
+ def proto.receive(message)
13
+ $m = message
14
+ EventMachine::stop_event_loop
15
+ end
16
+ end
17
+
18
+ EM::connect "127.0.0.1", 19400, Arpie::EventMachine::ArpieProtocol,
19
+ Arpie::SeparatorProtocol.new do |proto|
20
+
21
+ proto.send("hi")
22
+ end
23
+ }
24
+
25
+ $m.should == "hi"
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ EXPATH = File.dirname(__FILE__) + "/../examples"
2
+
3
+ describe "examples" do
4
+ for rb in Dir[EXPATH + "/*.rb"] do
5
+ describe rb do specify {
6
+ ret = `ruby -I#{File.dirname(__FILE__) + "/../lib"} #{rb}`
7
+ $?.should == 0
8
+ ret.strip.should == "ih"
9
+ } end
10
+ end
11
+ end
@@ -15,11 +15,11 @@ describe FixedBinaryType do
15
15
  end
16
16
 
17
17
  it "should raise error on mismatch in #from" do
18
- proc { subject.from("aaa", :value => "aaaa") }.should raise_error StreamError
18
+ proc { subject.from("aaa", :value => "aaaa") }.should raise_error Arpie::EIncomplete
19
19
  end
20
20
 
21
21
  it "raises error on mismatch in #to" do
22
- proc { subject.to("aaa", :value => "aaaa") }.should raise_error StreamError
22
+ proc { subject.to("aaa", :value => "aaaa") }.should raise_error Arpie::StreamError
23
23
  end
24
24
 
25
25
  it "raiseserror on missing option" do
@@ -30,5 +30,14 @@ describe "ListBinaryType" do
30
30
  it "raises EIncomplete when partial data remains" do
31
31
  proc { Outer.from [8, 0, 1, 2, 3, 4, 5, 6, 7, 4, 1, 2 ].pack("C*") }.should raise_error Arpie::EIncomplete
32
32
  end
33
+
34
+ it "fails on invalid length specification" do
35
+ klass = Class.new(Arpie::Binary) do
36
+ list :maxonly, :of => :char,
37
+ :sizeof => :int8
38
+ end
39
+
40
+ proc { klass.from("\xff") }.should raise_error StreamError
41
+ end
33
42
  end
34
43
  end
@@ -36,7 +36,7 @@ class Merger < Arpie::Protocol
36
36
  end
37
37
 
38
38
  describe "Merger::Splitter::Sized" do subject { [Splitter, Arpie::SizedProtocol] }
39
- it_should_behave_like "ProtocolChainSetup"
39
+ include_examples "ProtocolChainSetup"
40
40
 
41
41
  it "should split messages correctly" do
42
42
  chain_write(t = 'test')
@@ -48,7 +48,7 @@ describe "Merger::Splitter::Sized" do subject { [Splitter, Arpie::SizedProtocol]
48
48
  end
49
49
 
50
50
  describe "Merger::Splitter::Sized" do subject { [Merger, Splitter, Arpie::SizedProtocol] }
51
- it_should_behave_like "ProtocolChainSetup"
51
+ include_examples "ProtocolChainSetup"
52
52
 
53
53
  it "should assemble split messages correctly" do
54
54
  chain_write(t = 'test')
@@ -57,7 +57,7 @@ describe "Merger::Splitter::Sized" do subject { [Merger, Splitter, Arpie::SizedP
57
57
  end
58
58
 
59
59
  describe "Merger::BufferedSplitter::Sized" do subject { [Merger, BufferedSplitter, Arpie::SizedProtocol] }
60
- it_should_behave_like "ProtocolChainSetup"
60
+ include_examples "ProtocolChainSetup"
61
61
 
62
62
  it "should re-read io for more data if assembly fails" do
63
63
  @chain.write_message(@w, "split")
@@ -1,11 +1,12 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
- describe "ProtocolChain", :shared => true do
4
- it_should_behave_like "ProtocolChainSetup"
3
+ shared_examples "ProtocolChain" do
4
+ include_examples "ProtocolChainSetup"
5
5
 
6
6
  it "should convert without io correctly" do
7
7
  v = @chain.to @testdata_a
8
- @chain.from(v).should == [@testdata_a]
8
+ from = @chain.from(v[0])
9
+ from[0].should == @testdata_a
9
10
  end
10
11
 
11
12
  it "should read written binary data correctly" do
@@ -40,8 +41,11 @@ describe "ProtocolChain", :shared => true do
40
41
  end
41
42
 
42
43
  it "should read messages greater than MTU correctly" do
43
- chain_write(message = (@testdata_a * (Arpie::MTU + 10)))
44
- chain_read.should == message
44
+ unless @testdata_a.is_a?(Array)
45
+ message = @testdata_a * (Arpie::MTU + 10)
46
+ chain_write(message)
47
+ chain_read.should == message
48
+ end
45
49
  end
46
50
 
47
51
  it "should not fail on interleaved io streams" do
@@ -54,8 +58,8 @@ describe "ProtocolChain", :shared => true do
54
58
  end
55
59
  end
56
60
 
57
- describe "ObjectProtocolChain", :shared => true do
58
- it_should_behave_like "ProtocolChain"
61
+ shared_examples "ObjectProtocolChain" do
62
+ include_examples "ProtocolChain"
59
63
  # Now, lets try some variations.
60
64
 
61
65
  it "should read written objects correctly" do
@@ -69,8 +73,8 @@ describe "ObjectProtocolChain", :shared => true do
69
73
  end
70
74
  end
71
75
 
72
- describe "RPCProtocolChain", :shared => true do
73
- it_should_behave_like "RPCProtocolChainSetup"
76
+ shared_examples "RPCProtocolChain" do
77
+ include_examples "RPCProtocolChainSetup"
74
78
 
75
79
  it "should send namespace-less RPC calls correctly encoded" do
76
80
  call = Arpie::RPCall.new(nil, 'meth', [1, 2, 3])
@@ -101,56 +105,29 @@ end
101
105
  # Now, lets try some variations.
102
106
 
103
107
  describe "Sized" do subject { [Arpie::SizedProtocol] }
104
- it_should_behave_like "ProtocolChain"
108
+ include_examples "ProtocolChain"
105
109
  end
106
110
 
107
111
  describe "Sized::Sized" do subject { [Arpie::SizedProtocol, Arpie::SizedProtocol] }
108
- it_should_behave_like "ProtocolChain"
112
+ include_examples "ProtocolChain"
109
113
  end
110
114
 
111
115
  describe "Sized::Marshal::Sized" do subject { [Arpie::SizedProtocol, Arpie::MarshalProtocol, Arpie::SizedProtocol] }
112
- it_should_behave_like "ProtocolChain"
116
+ include_examples "ProtocolChain"
113
117
  end
114
118
 
115
119
  describe "Zlib::Marshal::Sized" do subject { [Arpie::ZlibProtocol, Arpie::MarshalProtocol, Arpie::SizedProtocol] }
116
- it_should_behave_like "ProtocolChain"
120
+ include_examples "ProtocolChain"
117
121
  end
118
122
 
119
123
  # Shellwords is a bit of a special case, because it only encodes arrays.
120
124
  describe "Shellwords::Separator" do subject { [Arpie::ShellwordsProtocol, Arpie::SeparatorProtocol] }
121
- it_should_behave_like "ProtocolChain"
125
+ include_examples "ProtocolChain"
122
126
  before do
123
127
  @testdata_a, @testdata_b = ['I am test', '1'], ['I am test', '2']
124
128
  end
125
129
  end
126
130
 
127
- describe "HTTPTest" do subject { [Arpie::HTTPClientTestProtocol] }
128
- it_should_behave_like "ProtocolChain"
129
- end
130
-
131
- describe "HTTPTest" do subject { [Arpie::HTTPServerTestProtocol] }
132
- it_should_behave_like "ProtocolChain"
133
- end
134
-
135
- describe "YAML" do subject { [Arpie::YAMLProtocol] }
136
- it_should_behave_like "ObjectProtocolChain"
131
+ describe "YAML::Sized" do subject { [Arpie::YAMLProtocol, Arpie::SizedProtocol] }
132
+ include_examples "ObjectProtocolChain"
137
133
  end
138
-
139
- describe "XMLRPC::Sized" do subject {
140
- [
141
- [Arpie::XMLRPCClientProtocol, Arpie::SizedProtocol],
142
- [Arpie::XMLRPCServerProtocol, Arpie::SizedProtocol]
143
- ]
144
- }
145
- it_should_behave_like "RPCProtocolChain"
146
- end
147
-
148
- describe "XMLRPC::HTTPTest" do subject {
149
- [
150
- [Arpie::XMLRPCClientProtocol, Arpie::HTTPClientTestProtocol],
151
- [Arpie::XMLRPCServerProtocol, Arpie::HTTPServerTestProtocol]
152
- ]
153
- }
154
- it_should_behave_like "RPCProtocolChain"
155
- end
156
-
@@ -8,7 +8,7 @@ unless Object.const_defined?('Arpie')
8
8
  end
9
9
  include Arpie
10
10
 
11
- describe "IO Mockup", :shared => true do
11
+ shared_examples "IO Mockup" do
12
12
  before do
13
13
  @r, @w = IO.pipe
14
14
  end
@@ -30,8 +30,8 @@ describe "IO Mockup", :shared => true do
30
30
  end
31
31
  end
32
32
 
33
- describe "ProtocolChainSetup", :shared => true do
34
- it_should_behave_like "IO Mockup"
33
+ shared_examples "ProtocolChainSetup" do
34
+ include_examples "IO Mockup"
35
35
 
36
36
  before do
37
37
  @chain = Arpie::ProtocolChain.new(* subject.map {|x| x.new })
@@ -46,8 +46,8 @@ describe "ProtocolChainSetup", :shared => true do
46
46
  end
47
47
  end
48
48
 
49
- describe "RPCProtocolChainSetup", :shared => true do
50
- it_should_behave_like "IO Mockup"
49
+ shared_examples "RPCProtocolChainSetup" do
50
+ include_examples "IO Mockup"
51
51
 
52
52
  before do
53
53
  @client = Arpie::ProtocolChain.new(* subject[0].map {|x| x.new })
@@ -59,15 +59,16 @@ end
59
59
 
60
60
 
61
61
 
62
- describe "Binary Setup", :shared => true do
62
+ shared_examples "Binary Setup" do
63
+ end
64
+
65
+ shared_examples "Binary Tests" do
66
+ include_examples "Binary Setup"
67
+
63
68
  before do
64
69
  @c = subject[0]
65
70
  @d = subject[1]
66
71
  end
67
- end
68
-
69
- describe "Binary Tests", :shared => true do
70
- it_should_behave_like "Binary Setup"
71
72
 
72
73
  it "reads and packs the given example binary" do
73
74
  dd, b = @c.from(@d)
@@ -75,8 +76,8 @@ describe "Binary Tests", :shared => true do
75
76
  end
76
77
  end
77
78
 
78
- describe "Binary Tests with data", :shared => true do
79
- it_should_behave_like "Binary Tests"
79
+ shared_examples "Binary Tests with data" do
80
+ include_examples "Binary Tests"
80
81
 
81
82
  it "should raise EIncomplete when not enough data is available" do
82
83
  proc { @c.from("")}.should raise_error Arpie::EIncomplete
metadata CHANGED
@@ -1,102 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: arpie
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Bernhard Stoeckner
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-08-25 00:00:00 +02:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: uuidtools
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.0.0
24
- version:
25
- description: A high-performing layered networking protocol framework. Simple to use, simple to extend.
26
- email: elven@swordcoast.net
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Toolkit for handling binary data, network protocols, file formats, and
15
+ similar
16
+ email:
17
+ - le@e-ix.net
27
18
  executables: []
28
-
29
19
  extensions: []
30
-
31
- extra_rdoc_files:
32
- - README
33
- - COPYING
34
- - BINARY_SPEC
35
- files:
36
- - COPYING
37
- - README
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - .yardopts
24
+ - BINARY.rdoc
25
+ - Gemfile
26
+ - LICENCE
27
+ - PROTOCOLS.rdoc
28
+ - README.rdoc
38
29
  - Rakefile
39
- - spec/protocol_merge_and_split_spec.rb
40
- - spec/protocol_spec.rb
41
- - spec/bytes_binary_type_spec.rb
42
- - spec/fixed_binary_type_spec.rb
43
- - spec/list_binary_type_spec.rb
44
- - spec/spec.opts
45
- - spec/rcov.opts
46
- - spec/spec_helper.rb
47
- - spec/binary_spec.rb
48
- - spec/client_server_spec.rb
49
- - lib/arpie/xmlrpc.rb
50
- - lib/arpie/proxy.rb
51
- - lib/arpie/server.rb
30
+ - arpie.gemspec
31
+ - examples/em.rb
32
+ - lib/arpie.rb
52
33
  - lib/arpie/binary.rb
53
- - lib/arpie/protocol.rb
54
- - lib/arpie/error.rb
55
- - lib/arpie/client.rb
56
- - lib/arpie/binary_types.rb
57
34
  - lib/arpie/binary/bytes_type.rb
58
35
  - lib/arpie/binary/fixed_type.rb
59
36
  - lib/arpie/binary/list_type.rb
60
37
  - lib/arpie/binary/pack_type.rb
61
- - lib/arpie.rb
62
- - tools/protocol_benchmark.rb
63
- - tools/benchmark.rb
64
- - BINARY_SPEC
65
- has_rdoc: true
66
- homepage: http://arpie.elv.es
38
+ - lib/arpie/binary_types.rb
39
+ - lib/arpie/em.rb
40
+ - lib/arpie/error.rb
41
+ - lib/arpie/protocol.rb
42
+ - lib/arpie/version.rb
43
+ - spec/binary_spec.rb
44
+ - spec/bytes_binary_type_spec.rb
45
+ - spec/em_spec.rb
46
+ - spec/examples_spec.rb
47
+ - spec/fixed_binary_type_spec.rb
48
+ - spec/list_binary_type_spec.rb
49
+ - spec/protocol_merge_and_split_spec.rb
50
+ - spec/protocol_spec.rb
51
+ - spec/rcov.opts
52
+ - spec/spec.opts
53
+ - spec/spec_helper.rb
54
+ homepage: https://github.com/elven/arpie
67
55
  licenses: []
68
-
69
- post_install_message:
70
- rdoc_options:
71
- - --quiet
72
- - --line-numbers
73
- - --inline-source
74
- - --title
75
- - "arpie: A high-performing layered networking protocol framework. Simple to use, simple to extend."
76
- - --main
77
- - README
78
- - --exclude
79
- - ^(examples|extras)/
80
- require_paths:
56
+ post_install_message: ! "\n You have installed arpie 0.1.0 or greater. This breaks\n
57
+ \ compatibility with previous versions (0.0.x).\n\n Specifically, it removes
58
+ all client/server code, and\n XMLRPC integration, since EventMachine and similar
59
+ does\n all that in a much cleaner and more efficient way.\n "
60
+ rdoc_options: []
61
+ require_paths:
81
62
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: 1.8.4
87
- version:
88
- required_rubygems_version: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: "0"
93
- version:
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
94
75
  requirements: []
95
-
96
- rubyforge_project: arpie
97
- rubygems_version: 1.3.4
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.23
98
78
  signing_key:
99
79
  specification_version: 3
100
- summary: A high-performing layered networking protocol framework. Simple to use, simple to extend.
101
- test_files: []
102
-
80
+ summary: Toolkit for handling binary data, network protocols, file formats, and similar
81
+ test_files:
82
+ - spec/binary_spec.rb
83
+ - spec/bytes_binary_type_spec.rb
84
+ - spec/em_spec.rb
85
+ - spec/examples_spec.rb
86
+ - spec/fixed_binary_type_spec.rb
87
+ - spec/list_binary_type_spec.rb
88
+ - spec/protocol_merge_and_split_spec.rb
89
+ - spec/protocol_spec.rb
90
+ - spec/rcov.opts
91
+ - spec/spec.opts
92
+ - spec/spec_helper.rb
93
+ has_rdoc: