beefcake 0.4.0 → 0.5.0.pre1
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.
- checksums.yaml +4 -4
- data/README.md +58 -62
- data/RELEASE_NOTES.md +11 -0
- data/lib/beefcake.rb +2 -0
- data/lib/beefcake/buffer/encode.rb +9 -1
- data/lib/beefcake/generator.rb +0 -1
- data/lib/beefcake/version.rb +1 -1
- data/test/buffer_encode_test.rb +5 -0
- data/test/message_test.rb +4 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d36ababf16022319e4fb8c312f566f814f08e316
|
4
|
+
data.tar.gz: f2e5b2510755f3c2e49ec4dd04ae5b87ce01e4fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 904fa81bb6175ed7ecbc6f02eebd5a17f41370439732ebc849c8e9cc173010a39a7fb495b3fe5e095d5b26c7ddea75dc2a86b8af3815f553b1883b288ae0e3e0
|
7
|
+
data.tar.gz: 335132b6e83dbd0d1045c2a07cefb5efb55fd58e32d3c30449505e2f8325fb914506e90499f235d175172318fff348d5a1c8d639335bdd1ff89d69e3f7b638e8
|
data/README.md
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
# Beefcake
|
2
|
-
## It's all about being Buf; ProtoBuf.
|
1
|
+
# Beefcake
|
3
2
|
|
4
|
-
|
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
|
-
|
9
|
+
gem install beefcake
|
8
10
|
```
|
9
11
|
|
10
|
-
|
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
|
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
|
-
|
56
|
+
### Encoding
|
55
57
|
|
56
58
|
Any object responding to `<<` can accept encoding
|
57
59
|
|
58
60
|
```ruby
|
59
|
-
|
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
|
-
|
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
|
-
|
95
|
+
### Generate code from `.proto` file
|
92
96
|
|
93
|
-
|
94
|
-
|
97
|
+
```shell
|
98
|
+
protoc --beefcake_out output/path -I path/to/proto/files/dir path/to/file.proto
|
99
|
+
```
|
95
100
|
|
96
|
-
|
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
|
-
|
104
|
+
## About
|
99
105
|
|
100
|
-
|
101
|
-
|
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
|
-
|
109
|
+
This library was built with EventMachine in mind. Not just blocking-IO.
|
104
110
|
|
105
|
-
|
111
|
+
Source: https://github.com/protobuf-ruby/beefcake
|
106
112
|
|
107
|
-
|
113
|
+
### Support Features
|
108
114
|
|
109
|
-
|
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
|
-
|
129
|
+
### Future
|
112
130
|
|
113
|
-
|
131
|
+
* Imports
|
132
|
+
* Use package in generation
|
133
|
+
* Groups (would be nice for accessing older protos)
|
114
134
|
|
115
|
-
|
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 [](https://travis-ci.org/protobuf-ruby/beefcake).
|
@@ -120,46 +146,16 @@ The current build status for HEAD is [
|
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
|
-
|
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
@@ -105,7 +105,7 @@ module Beefcake
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def append_string(s)
|
108
|
-
actual_string = 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
|
data/lib/beefcake/generator.rb
CHANGED
data/lib/beefcake/version.rb
CHANGED
data/test/buffer_encode_test.rb
CHANGED
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
|
+
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-
|
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:
|
79
|
+
version: 1.3.1
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project: beefcake
|
82
|
-
rubygems_version: 2.
|
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:
|