beefcake 0.4.0 → 0.5.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f4e5e1cfae47692b962d140248d78882d2c7f5f
4
- data.tar.gz: 5022dd602b952ccb3bfd27e73f2932a4032e2507
3
+ metadata.gz: d36ababf16022319e4fb8c312f566f814f08e316
4
+ data.tar.gz: f2e5b2510755f3c2e49ec4dd04ae5b87ce01e4fe
5
5
  SHA512:
6
- metadata.gz: b68af37acfc3a3ec1c18222781ff3281f0fff1e5310cb18eda7748d1f58d696970f92815ada66c8e9b242b187a07393b6be3e3d7932f5cf65649bb80b97154aa
7
- data.tar.gz: ced3ff677e2234915b09add7fda412cee0c2afc90fd440d75e79bf73300c9260c4122140520f59d538229bda358207459bf57f5ef5cd7085a3494b6b8dde791b
6
+ metadata.gz: 904fa81bb6175ed7ecbc6f02eebd5a17f41370439732ebc849c8e9cc173010a39a7fb495b3fe5e095d5b26c7ddea75dc2a86b8af3815f553b1883b288ae0e3e0
7
+ data.tar.gz: 335132b6e83dbd0d1045c2a07cefb5efb55fd58e32d3c30449505e2f8325fb914506e90499f235d175172318fff348d5a1c8d639335bdd1ff89d69e3f7b638e8
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
- # Beefcake (A sane Google Protocol Buffers library for Ruby)
2
- ## It's all about being Buf; ProtoBuf.
1
+ # Beefcake
3
2
 
4
- # Install
3
+ A sane Google Protocol Buffers library for Ruby. It's all about being Buf;
4
+ ProtoBuf.
5
+
6
+ ## Installation
5
7
 
6
8
  ```shell
7
- $ gem install beefcake
9
+ gem install beefcake
8
10
  ```
9
11
 
10
- # Example
12
+ ## Usage
11
13
 
12
14
  ```ruby
13
15
  require 'beefcake'
@@ -38,7 +40,7 @@ class Variety
38
40
  end
39
41
 
40
42
  # You can create a new message with hash arguments:
41
- x = Variety.new :x => 1, :y => 2
43
+ x = Variety.new(:x => 1, :y => 2)
42
44
 
43
45
  # You can set fields individually using accessor methods:
44
46
  x = Variety.new
@@ -51,12 +53,13 @@ x[:y] = 4
51
53
  x # => <Variety x: 1, y: 4>
52
54
  ```
53
55
 
54
- ## Encoding
56
+ ### Encoding
55
57
 
56
58
  Any object responding to `<<` can accept encoding
57
59
 
58
60
  ```ruby
59
- x # => <Variety x: 1, y: 2>
61
+ # see code example above for the definition of Variety
62
+ x = Variety.new(:x => 1, :y => 2)
60
63
 
61
64
  # For example, you can encode into a String:
62
65
  s = ""
@@ -73,7 +76,8 @@ x.encode.to_s # => "\b\x01\x10\x02)\0"
73
76
  ### Decoding
74
77
 
75
78
  ```ruby
76
- x # => <Variety x: 1, y: 2>
79
+ # see code example above for the definition of Variety
80
+ x = Variety.new(:x => 1, :y => 2)
77
81
 
78
82
  # You can decode from a Beefcake::Buffer
79
83
  encoded = x.encode
@@ -88,31 +92,53 @@ Variety.decoded(new_data, x)
88
92
  x # => <Variety x: 12345, y: 2, pary: [], foo: B(2)>
89
93
  ```
90
94
 
91
- # Why?
95
+ ### Generate code from `.proto` file
92
96
 
93
- Ruby deserves and needs first-class ProtoBuf support.
94
- Other libs didn't feel very "Ruby" to me and were hard to parse.
97
+ ```shell
98
+ protoc --beefcake_out output/path -I path/to/proto/files/dir path/to/file.proto
99
+ ```
95
100
 
96
- # Generate code from `.proto` file
101
+ You can set the `BEEFCAKE_NAMESPACE` variable to generate the classes under a
102
+ desired namespace. (i.e. App::Foo::Bar)
97
103
 
98
- $ protoc --beefcake_out output/path -I path/to/proto/files/dir path/to/proto/file
104
+ ## About
99
105
 
100
- You can set the BEEFCAKE_NAMESPACE variable to generate the classes under a
101
- desired namespace. (i.e. App::Foo::Bar)
106
+ Ruby deserves and needs first-class ProtoBuf support. Other libs didn't feel
107
+ very "Ruby" to me and were hard to parse.
102
108
 
103
- # Misc
109
+ This library was built with EventMachine in mind. Not just blocking-IO.
104
110
 
105
- This library was built with EventMachine in mind. Not just blocking-IO.
111
+ Source: https://github.com/protobuf-ruby/beefcake
106
112
 
107
- # Dev
113
+ ### Support Features
108
114
 
109
- Source:
115
+ * Optional fields
116
+ * Required fields
117
+ * Repeated fields
118
+ * Packed Repeated Fields
119
+ * Varint fields
120
+ * 32-bit fields
121
+ * 64-bit fields
122
+ * Length-delimited fields
123
+ * Embedded Messages
124
+ * Unknown fields are ignored (as per spec)
125
+ * Enums
126
+ * Defaults (i.e. `optional :foo, :string, :default => "bar"`)
127
+ * Varint-encoded length-delimited message streams
110
128
 
111
- $ git clone https://github.com/protobuf-ruby/beefcake.git
129
+ ### Future
112
130
 
113
- ## Testing:
131
+ * Imports
132
+ * Use package in generation
133
+ * Groups (would be nice for accessing older protos)
114
134
 
115
- $ rake test
135
+ ### Further Reading
136
+
137
+ http://code.google.com/apis/protocolbuffers/docs/encoding.html
138
+
139
+ ## Testing
140
+
141
+ rake test
116
142
 
117
143
  Beefcake conducts continuous integration on [Travis CI](http://travis-ci.org).
118
144
  The current build status for HEAD is [![Build Status](https://travis-ci.org/protobuf-ruby/beefcake.png)](https://travis-ci.org/protobuf-ruby/beefcake).
@@ -120,46 +146,16 @@ The current build status for HEAD is [![Build Status](https://travis-ci.org/prot
120
146
  All pull requests automatically trigger a build request. Please ensure that
121
147
  tests succeed.
122
148
 
123
- ## VMs:
124
-
125
149
  Currently Beefcake is tested and working on:
126
150
 
127
- * Ruby 1.8.6
128
- * Ruby 1.8.7
129
- * Ruby 1.9.2
130
- * Ruby 2.0.0
131
- * JRuby 1.5.6
132
- * Rubinius edge
133
-
134
-
135
- ## Support Features
136
-
137
- * Optional fields
138
- * Required fields
139
- * Repeated fields
140
- * Packed Repeated Fields
141
- * Varint fields
142
- * 32-bit fields
143
- * 64-bit fields
144
- * Length-delimited fields
145
- * Embedded Messages
146
- * Unknown fields are ignored (as per spec)
147
- * Enums
148
- * Defaults (i.e. `optional :foo, :string, :default => "bar"`)
149
- * Varint-encoded length-delimited message streams
150
-
151
-
152
- ## Future
153
-
154
- * Imports
155
- * Use package in generation
156
- * Groups (would be nice for accessing older protos)
157
-
158
- # Further Reading
159
-
160
- http://code.google.com/apis/protocolbuffers/docs/encoding.html
151
+ * Ruby 1.8.6
152
+ * Ruby 1.8.7
153
+ * Ruby 1.9.2
154
+ * Ruby 2.0.0
155
+ * JRuby 1.5.6
156
+ * Rubinius edge
161
157
 
162
- # Thank You
158
+ ## Thank You
163
159
 
164
- Keith Rarick (kr) for help with encoding/decoding.
165
- Aman Gupta (tmm1) for help with cross VM support and performance enhancements.
160
+ * Keith Rarick (kr) for help with encoding/decoding.
161
+ * Aman Gupta (tmm1) for help with cross VM support and performance enhancements.
data/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Beefcake Release Notes
2
2
 
3
+ # 0.5.0 - 2013-12-20
4
+
5
+ Release 0.5.0 corrects a few behaviors.
6
+
7
+ * Drastically revised README, written by Tobias "grobie" Schmidt
8
+ * Output fewer newlines in generated files, fixed by Tobias "grobie" Schmidt
9
+ * Don't crash when attempting to reencode frozen strings,
10
+ found thanks to Kyle "Aphyr" Kingsbury
11
+ * Return `nil` instead of raising a generic Ruby error when trying to
12
+ decode a zero-length buffer, fixed by Tobias "grobie" Schmidt
13
+
3
14
  # 0.4.0 - 2013-10-10
4
15
 
5
16
  Release 0.4.0 is the first with new maintainers.
data/lib/beefcake.rb CHANGED
@@ -200,6 +200,8 @@ module Beefcake
200
200
  buf = Buffer.new(buf)
201
201
  end
202
202
 
203
+ return if buf.length == 0
204
+
203
205
  n = buf.read_int64
204
206
  tmp = Buffer.new(buf.read(n))
205
207
 
@@ -105,7 +105,7 @@ module Beefcake
105
105
  end
106
106
 
107
107
  def append_string(s)
108
- actual_string = s.to_s
108
+ actual_string = thaw_string s
109
109
  if actual_string.respond_to? :force_encoding
110
110
  encoded = actual_string.force_encoding 'binary'
111
111
  else
@@ -116,6 +116,14 @@ module Beefcake
116
116
  end
117
117
  alias :append_bytes :append_string
118
118
 
119
+
120
+ private
121
+ def thaw_string(s)
122
+ if s.frozen?
123
+ s = s.dup
124
+ end
125
+ s.to_s
126
+ end
119
127
  end
120
128
 
121
129
  end
@@ -209,7 +209,6 @@ module Beefcake
209
209
  end
210
210
 
211
211
  puts "end"
212
- puts
213
212
  end
214
213
 
215
214
  def enum!(et)
@@ -1,3 +1,3 @@
1
1
  module Beefcake
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0.pre1"
3
3
  end
@@ -221,4 +221,9 @@ class BufferEncodeTest < Test::Unit::TestCase
221
221
  assert_equal "\007testing", @buf.to_s
222
222
  end
223
223
 
224
+ def test_append_frozen_string
225
+ @buf.append_string "testing".freeze
226
+ assert_equal "\007testing", @buf.to_s
227
+ end
228
+
224
229
  end
data/test/message_test.rb CHANGED
@@ -180,6 +180,10 @@ class MessageTest < Test::Unit::TestCase
180
180
  end
181
181
  end
182
182
 
183
+ def test_empty_buffer_delimited_read
184
+ assert_equal SimpleMessage.read_delimited(""), nil
185
+ end
186
+
183
187
  def test_encode_enum
184
188
  buf = Beefcake::Buffer.new
185
189
  buf.append(:int32, 2, 1)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beefcake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-10-10 00:00:00.000000000 Z
13
+ date: 2013-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -74,12 +74,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - '>='
77
+ - - '>'
78
78
  - !ruby/object:Gem::Version
79
- version: '0'
79
+ version: 1.3.1
80
80
  requirements: []
81
81
  rubyforge_project: beefcake
82
- rubygems_version: 2.1.4
82
+ rubygems_version: 2.0.14
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: A sane protobuf library for Ruby
@@ -89,3 +89,4 @@ test_files:
89
89
  - test/buffer_test.rb
90
90
  - test/generator_test.rb
91
91
  - test/message_test.rb
92
+ has_rdoc: