beefcake 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -2
- data/lib/beefcake.rb +3 -3
- data/lib/beefcake/generator.rb +1 -1
- data/lib/beefcake/version.rb +1 -1
- data/test/message_test.rb +7 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -100,10 +100,27 @@ Currently Beefcake is tested and working on:
|
|
100
100
|
* JRuby 1.5.6
|
101
101
|
* Rubinius edge
|
102
102
|
|
103
|
-
## Future
|
104
103
|
|
105
|
-
|
104
|
+
## Support Features
|
105
|
+
|
106
|
+
* Optional fields
|
107
|
+
* Required fields
|
108
|
+
* Repeated fields
|
109
|
+
* Packed Repeated Fields
|
110
|
+
* Varint fields
|
111
|
+
* 32-bit fields
|
112
|
+
* 64-bit fields
|
113
|
+
* Length delemited fields
|
114
|
+
* Embeded Messages
|
115
|
+
* Unknown fields are ignored (as per spec)
|
116
|
+
* Enums
|
117
|
+
* Defaults (i.e. `optional :foo, :string, :default => "bar"`)
|
118
|
+
|
119
|
+
|
120
|
+
## Future
|
106
121
|
|
122
|
+
* Imports
|
123
|
+
* Use package in generation
|
107
124
|
* Groups (would be nice for accessing older protos)
|
108
125
|
|
109
126
|
# Further Reading
|
data/lib/beefcake.rb
CHANGED
@@ -161,7 +161,7 @@ module Beefcake
|
|
161
161
|
while tmp.length > 0
|
162
162
|
o[fld.name] << tmp.read(fld.type)
|
163
163
|
end
|
164
|
-
|
164
|
+
elsif fld.rule == :repeated
|
165
165
|
val = buf.read(fld.type)
|
166
166
|
(o[fld.name] ||= []) << val
|
167
167
|
else
|
@@ -172,7 +172,7 @@ module Beefcake
|
|
172
172
|
|
173
173
|
# Set defaults
|
174
174
|
fields.values.each do |f|
|
175
|
-
|
175
|
+
next if o[f.name] == false
|
176
176
|
o[f.name] ||= f.opts[:default]
|
177
177
|
end
|
178
178
|
|
@@ -208,7 +208,7 @@ module Beefcake
|
|
208
208
|
end
|
209
209
|
|
210
210
|
def ==(o)
|
211
|
-
return false if o == nil
|
211
|
+
return false if (o == nil) || (o == false)
|
212
212
|
fields.values.all? {|fld| self[fld.name] == o[fld.name] }
|
213
213
|
end
|
214
214
|
|
data/lib/beefcake/generator.rb
CHANGED
data/lib/beefcake/version.rb
CHANGED
data/test/message_test.rb
CHANGED
@@ -343,6 +343,13 @@ class MessageTest < Test::Unit::TestCase
|
|
343
343
|
assert_equal "<CompositeMessage encodable: <SimpleMessage a: 1>>", msg.inspect
|
344
344
|
end
|
345
345
|
|
346
|
+
def test_decode_nested_types
|
347
|
+
msg = CompositeMessage.new(:encodable => SimpleMessage.new(:a => 1))
|
348
|
+
enc = msg.encode
|
349
|
+
dec = CompositeMessage.decode(enc)
|
350
|
+
assert_equal "<CompositeMessage encodable: <SimpleMessage a: 1>>", dec.inspect
|
351
|
+
end
|
352
|
+
|
346
353
|
def test_to_hash
|
347
354
|
msg = SimpleMessage.new :a => 1
|
348
355
|
exp = { :a => 1 }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beefcake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Blake Mizerany
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|