ruby-protocol-buffers 1.3.0 → 1.3.1
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.
- data/.gitignore +6 -5
- data/.travis.yml +20 -0
- data/Gemfile +5 -1
- data/Gemfile.no_varint +4 -0
- data/README.md +7 -0
- data/Rakefile +3 -18
- data/lib/protocol_buffers.rb +3 -3
- data/lib/protocol_buffers/compiler.rb +7 -0
- data/lib/protocol_buffers/compiler/descriptor.pb.rb +63 -30
- data/lib/protocol_buffers/compiler/descriptor.proto +252 -25
- data/lib/protocol_buffers/compiler/file_descriptor_to_ruby.rb +7 -1
- data/lib/protocol_buffers/runtime/decoder.rb +18 -2
- data/lib/protocol_buffers/runtime/encoder.rb +17 -2
- data/lib/protocol_buffers/runtime/field.rb +14 -3
- data/lib/protocol_buffers/runtime/varint.rb +42 -36
- data/lib/protocol_buffers/version.rb +3 -0
- data/ruby-protocol-buffers.gemspec +22 -21
- data/spec/compiler_spec.rb +22 -0
- data/spec/fields_spec.rb +54 -16
- data/spec/proto_files/featureful.pb.rb +76 -0
- data/spec/proto_files/packed.pb.rb +37 -0
- data/spec/proto_files/packed.proto +30 -0
- data/spec/proto_files/simple.pb.rb +23 -0
- data/spec/runtime_spec.rb +211 -164
- data/spec/spec_helper.rb +24 -7
- data/tasks/rspec.rake +7 -0
- data/tasks/yard.rake +6 -0
- metadata +34 -6
- data/VERSION +0 -1
- data/ext/extconf.disabled.rb +0 -3
- data/ext/varint.c +0 -65
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'rubygems'
|
3
2
|
require 'rspec'
|
4
3
|
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start
|
6
|
+
|
7
|
+
require 'protocol_buffers'
|
8
|
+
|
5
9
|
# These are a couple of classes used by tests
|
6
10
|
class SignedIntTest < ::ProtocolBuffers::Message
|
7
11
|
required :int32, :test_member, 1
|
@@ -43,7 +47,7 @@ def validate_pbr(klass, value, suppress_output = false)
|
|
43
47
|
puts " encoded length: #{encoded_string.length}"
|
44
48
|
puts " parsing encoded_string"
|
45
49
|
end
|
46
|
-
|
50
|
+
|
47
51
|
decode_pbr = nil;
|
48
52
|
begin
|
49
53
|
decode_pbr = klass.parse encoded_string
|
@@ -55,7 +59,7 @@ def validate_pbr(klass, value, suppress_output = false)
|
|
55
59
|
end
|
56
60
|
return false
|
57
61
|
end
|
58
|
-
|
62
|
+
|
59
63
|
if decode_pbr
|
60
64
|
unless suppress_output
|
61
65
|
puts " decoded value: #{decode_pbr.test_member}"
|
@@ -70,7 +74,7 @@ def validate_pbr(klass, value, suppress_output = false)
|
|
70
74
|
puts " decoded value inspect : #{decode_pbr.test_member.inspect}"
|
71
75
|
puts " passed value inspect : #{value.inspect}"
|
72
76
|
end
|
73
|
-
|
77
|
+
|
74
78
|
# Ruby 1.8 Strings don't have encodings
|
75
79
|
if decode_pbr.test_member.respond_to?("encoding")
|
76
80
|
unless suppress_output
|
@@ -79,11 +83,11 @@ def validate_pbr(klass, value, suppress_output = false)
|
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
82
|
-
|
86
|
+
|
83
87
|
unless suppress_output
|
84
88
|
puts " GOOD COMPARE" if decode_pbr.test_member == value
|
85
89
|
end
|
86
|
-
|
90
|
+
|
87
91
|
decode_pbr.test_member == value
|
88
92
|
end
|
89
93
|
end
|
@@ -94,5 +98,18 @@ def to_hex_string ss
|
|
94
98
|
yy.join(' ')
|
95
99
|
end
|
96
100
|
|
101
|
+
def has_compiler?
|
102
|
+
ProtocolBuffers::Compiler.available?
|
103
|
+
end
|
104
|
+
|
97
105
|
RSpec.configure do |config|
|
106
|
+
config.after(:each) do
|
107
|
+
# clear our namespaces
|
108
|
+
Object.send(:remove_const, :Simple) if defined?(Simple)
|
109
|
+
Object.send(:remove_const, :Featureful) if defined?(Featureful)
|
110
|
+
Object.send(:remove_const, :Foo) if defined?(Foo)
|
111
|
+
Object.send(:remove_const, :TehUnknown) if defined?(TehUnknown)
|
112
|
+
Object.send(:remove_const, :TehUnknown2) if defined?(TehUnknown2)
|
113
|
+
Object.send(:remove_const, :TehUnknown3) if defined?(TehUnknown3)
|
114
|
+
end
|
98
115
|
end
|
data/tasks/rspec.rake
ADDED
data/tasks/yard.rake
ADDED
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-protocol-buffers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brian Palmer
|
9
|
+
- Benedikt Böhm
|
9
10
|
- Rob Marable
|
10
11
|
- Paulo Luis Franchini Casaretto
|
11
12
|
autorequire:
|
12
13
|
bindir: bin
|
13
14
|
cert_chain: []
|
14
|
-
date: 2013-
|
15
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
18
|
name: autotest-standalone
|
@@ -62,7 +63,23 @@ dependencies:
|
|
62
63
|
- !ruby/object:Gem::Version
|
63
64
|
version: '0'
|
64
65
|
- !ruby/object:Gem::Dependency
|
65
|
-
name:
|
66
|
+
name: rake-compiler
|
67
|
+
requirement: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
type: :development
|
74
|
+
prerelease: false
|
75
|
+
version_requirements: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: simplecov
|
66
83
|
requirement: !ruby/object:Gem::Requirement
|
67
84
|
none: false
|
68
85
|
requirements:
|
@@ -112,6 +129,7 @@ dependencies:
|
|
112
129
|
description:
|
113
130
|
email:
|
114
131
|
- brian@codekitchen.net
|
132
|
+
- bb@xnull.de
|
115
133
|
executables:
|
116
134
|
- ruby-protoc
|
117
135
|
extensions: []
|
@@ -120,12 +138,13 @@ extra_rdoc_files:
|
|
120
138
|
files:
|
121
139
|
- .document
|
122
140
|
- .gitignore
|
141
|
+
- .travis.yml
|
123
142
|
- Changelog.md
|
124
143
|
- Gemfile
|
144
|
+
- Gemfile.no_varint
|
125
145
|
- LICENSE
|
126
146
|
- README.md
|
127
147
|
- Rakefile
|
128
|
-
- VERSION
|
129
148
|
- bin/ruby-protoc
|
130
149
|
- debian/changelog
|
131
150
|
- debian/compatability
|
@@ -134,8 +153,6 @@ files:
|
|
134
153
|
- debian/protocol_buffers.rb
|
135
154
|
- debian/rules
|
136
155
|
- examples/json_protobuf.rb
|
137
|
-
- ext/extconf.disabled.rb
|
138
|
-
- ext/varint.c
|
139
156
|
- lib/protocol_buffers.rb
|
140
157
|
- lib/protocol_buffers/compiler.rb
|
141
158
|
- lib/protocol_buffers/compiler/descriptor.pb.rb
|
@@ -151,6 +168,7 @@ files:
|
|
151
168
|
- lib/protocol_buffers/runtime/message.rb
|
152
169
|
- lib/protocol_buffers/runtime/service.rb
|
153
170
|
- lib/protocol_buffers/runtime/varint.rb
|
171
|
+
- lib/protocol_buffers/version.rb
|
154
172
|
- ruby-protocol-buffers.gemspec
|
155
173
|
- spec/compiler_spec.rb
|
156
174
|
- spec/fields_spec.rb
|
@@ -158,8 +176,12 @@ files:
|
|
158
176
|
- spec/nil_bugs_spec.rb
|
159
177
|
- spec/proto_files/depends.proto
|
160
178
|
- spec/proto_files/dotted_package.proto
|
179
|
+
- spec/proto_files/featureful.pb.rb
|
161
180
|
- spec/proto_files/featureful.proto
|
162
181
|
- spec/proto_files/no_package.proto
|
182
|
+
- spec/proto_files/packed.pb.rb
|
183
|
+
- spec/proto_files/packed.proto
|
184
|
+
- spec/proto_files/simple.pb.rb
|
163
185
|
- spec/proto_files/simple.proto
|
164
186
|
- spec/proto_files/top_level_enum.proto
|
165
187
|
- spec/proto_files/under_score_package.proto
|
@@ -167,6 +189,8 @@ files:
|
|
167
189
|
- spec/spec.opts
|
168
190
|
- spec/spec_helper.rb
|
169
191
|
- spec/unicode_string_spec.rb
|
192
|
+
- tasks/rspec.rake
|
193
|
+
- tasks/yard.rake
|
170
194
|
homepage: https://github.com/mozy/ruby-protocol-buffers
|
171
195
|
licenses: []
|
172
196
|
post_install_message:
|
@@ -198,8 +222,12 @@ test_files:
|
|
198
222
|
- spec/nil_bugs_spec.rb
|
199
223
|
- spec/proto_files/depends.proto
|
200
224
|
- spec/proto_files/dotted_package.proto
|
225
|
+
- spec/proto_files/featureful.pb.rb
|
201
226
|
- spec/proto_files/featureful.proto
|
202
227
|
- spec/proto_files/no_package.proto
|
228
|
+
- spec/proto_files/packed.pb.rb
|
229
|
+
- spec/proto_files/packed.proto
|
230
|
+
- spec/proto_files/simple.pb.rb
|
203
231
|
- spec/proto_files/simple.proto
|
204
232
|
- spec/proto_files/top_level_enum.proto
|
205
233
|
- spec/proto_files/under_score_package.proto
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.3.0
|
data/ext/extconf.disabled.rb
DELETED
data/ext/varint.c
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
#include "ruby.h"
|
2
|
-
|
3
|
-
static VALUE Protobuf, Varint;
|
4
|
-
static ID getbyte, putbyte;
|
5
|
-
|
6
|
-
static VALUE varint_encode(VALUE module, VALUE io, VALUE int_valV)
|
7
|
-
{
|
8
|
-
/* unsigned for the bit shifting ops */
|
9
|
-
unsigned long long int_val = (unsigned long long)NUM2LL(int_valV);
|
10
|
-
unsigned char byte;
|
11
|
-
while (1) {
|
12
|
-
byte = int_val & 0x7f;
|
13
|
-
int_val >>= 7;
|
14
|
-
if (int_val == 0) {
|
15
|
-
rb_funcall(io, putbyte, 1, INT2FIX(byte));
|
16
|
-
return Qnil;
|
17
|
-
} else {
|
18
|
-
rb_funcall(io, putbyte, 1, INT2FIX(byte | 0x80));
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
static VALUE varint_decode(VALUE module, VALUE io)
|
24
|
-
{
|
25
|
-
unsigned long long int_val = 0;
|
26
|
-
unsigned shift = 0;
|
27
|
-
unsigned char byte;
|
28
|
-
|
29
|
-
while (1) {
|
30
|
-
if (shift >= 64) {
|
31
|
-
rb_raise(rb_eArgError, "too many bytes when decoding varint");
|
32
|
-
}
|
33
|
-
byte = (unsigned char)FIX2INT(rb_funcall(io, getbyte, 0));
|
34
|
-
int_val |= ((unsigned long long)(byte & 0x7f)) << shift;
|
35
|
-
shift += 7;
|
36
|
-
if ((byte & 0x80) == 0) {
|
37
|
-
/* return ULL2NUM(int_val); */
|
38
|
-
return LL2NUM((long long)int_val);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
void Init_ruby_protobufs()
|
44
|
-
{
|
45
|
-
Protobuf = rb_define_module("Protobuf");
|
46
|
-
Varint = rb_define_module_under(Protobuf, "Varint");
|
47
|
-
|
48
|
-
VALUE zero = INT2FIX(0);
|
49
|
-
VALUE test_io = rb_class_new_instance(1, &zero,
|
50
|
-
rb_const_get(rb_cObject, rb_intern("IO")));
|
51
|
-
|
52
|
-
/* hackish way to support both 1.8.6 and 1.8.7+ */
|
53
|
-
getbyte = rb_intern("getbyte");
|
54
|
-
if (!rb_respond_to(test_io, getbyte)) {
|
55
|
-
getbyte = rb_intern("getc");
|
56
|
-
}
|
57
|
-
|
58
|
-
/* TODO: check the api docs -- what happens to test_io here?
|
59
|
-
* does it just leak? */
|
60
|
-
|
61
|
-
putbyte = rb_intern("putc");
|
62
|
-
|
63
|
-
rb_define_module_function(Varint, "encode", varint_encode, 2);
|
64
|
-
rb_define_module_function(Varint, "decode", varint_decode, 1);
|
65
|
-
}
|