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 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
- Nice to have:
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
- elsif fld.rule == :repeated
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
- next if o[f.name] == false
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
 
@@ -247,7 +247,7 @@ module Beefcake
247
247
  puts out
248
248
  end
249
249
 
250
- # Determines the name for a
250
+ # Determines the name for a
251
251
  def name_for(b, mod, val)
252
252
  b.name_for(mod, val).to_s.gsub(/.*_/, "").downcase
253
253
  end
@@ -1,3 +1,3 @@
1
1
  module Beefcake
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
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-06-15 00:00:00 -07:00
18
+ date: 2011-09-01 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21