beefcake 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -161,21 +161,18 @@ module Beefcake
161
161
  while tmp.length > 0
162
162
  o[fld.name] << tmp.read(fld.type)
163
163
  end
164
-
165
- next
166
- end
167
-
168
- val = buf.read(fld.type)
169
- if fld.rule == :repeated
164
+ elsif fld.rule == :repeated
165
+ val = buf.read(fld.type)
170
166
  (o[fld.name] ||= []) << val
171
167
  else
168
+ val = buf.read(fld.type)
172
169
  o[fld.name] = val
173
170
  end
174
-
175
171
  end
176
172
 
177
173
  # Set defaults
178
174
  fields.values.each do |f|
175
+ next if o[f.name] == false
179
176
  o[f.name] ||= f.opts[:default]
180
177
  end
181
178
 
@@ -1,3 +1,3 @@
1
1
  module Beefcake
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -82,6 +82,12 @@ class RepeatedNestedMessage
82
82
  repeated :simple, SimpleMessage, 1
83
83
  end
84
84
 
85
+ class BoolMessage
86
+ include Beefcake::Message
87
+
88
+ required :bool, :bool, 1
89
+ end
90
+
85
91
  class MessageTest < Test::Unit::TestCase
86
92
  B = Beefcake::Buffer
87
93
 
@@ -172,6 +178,13 @@ class MessageTest < Test::Unit::TestCase
172
178
  end
173
179
  end
174
180
 
181
+ def test_decode_required_bool
182
+ msg = BoolMessage.new :bool => false
183
+ enc = msg.encode
184
+ dec = BoolMessage.decode(enc)
185
+ assert_equal false, dec.bool
186
+ end
187
+
175
188
  def test_encode_repeated_field
176
189
  buf = Beefcake::Buffer.new
177
190
 
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: 23
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 4
10
+ version: 0.3.4
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-06-03 00:00:00 -07:00
18
+ date: 2011-06-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21