protobuf 2.7.11 → 2.7.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ec668a441b215626889c81b6488fbb722e413cbc
4
+ data.tar.gz: 39d03c378294a8205404b21424aa9c66eb05e95d
5
+ SHA512:
6
+ metadata.gz: 5e10279b2fdb399cbbe358d1acd6fa32d2cc29865ceb960cfc3d79247b5dee9f2657503c7ee2b9e61bc28977c48847ecfa726ef442c2963559d424fb6c659365
7
+ data.tar.gz: 94a7266d6e6014906f65304614df869c3fa21fad026a529186460889dde64fb9e9cef52b521dd6df11b74c624f19d58bc2a715a72c7a21fa1acf5508a59d1fb3
@@ -18,8 +18,9 @@ module Protobuf
18
18
  end
19
19
 
20
20
  def decode(bytes)
21
- bytes.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
22
- bytes
21
+ bytes_to_decode = bytes.dup
22
+ bytes_to_decode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
23
+ bytes_to_decode
23
24
  end
24
25
 
25
26
  def define_setter
@@ -46,11 +47,12 @@ module Protobuf
46
47
  end
47
48
 
48
49
  def encode(value)
49
- value = value.serialize_to_string if value.is_a?(::Protobuf::Message)
50
- value.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
50
+ value_to_encode = value.dup
51
+ value_to_encode = value.serialize_to_string if value.is_a?(::Protobuf::Message)
52
+ value_to_encode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
51
53
 
52
- string_size = ::Protobuf::Field::VarintField.encode(value.size)
53
- string_size << value
54
+ string_size = ::Protobuf::Field::VarintField.encode(value_to_encode.size)
55
+ string_size << value_to_encode
54
56
  end
55
57
 
56
58
  def wire_type
@@ -6,17 +6,18 @@ module Protobuf
6
6
  ENCODING = 'UTF-8'.freeze
7
7
 
8
8
  def decode(bytes)
9
- bytes.force_encoding(::Protobuf::Field::StringField::ENCODING)
10
- bytes
9
+ bytes_to_decode = bytes.dup
10
+ bytes_to_decode.force_encoding(::Protobuf::Field::StringField::ENCODING)
11
+ bytes_to_decode
11
12
  end
12
13
 
13
14
  def encode(value)
14
- # TODO: make replace character configurable?
15
- value.encode!(::Protobuf::Field::StringField::ENCODING, :invalid => :replace, :undef => :replace, :replace => "")
16
- value.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
15
+ value_to_encode = value.dup
16
+ value_to_encode.encode!(::Protobuf::Field::StringField::ENCODING, :invalid => :replace, :undef => :replace, :replace => "")
17
+ value_to_encode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
17
18
 
18
- string_size = ::Protobuf::Field::VarintField.encode(value.size)
19
- string_size << value
19
+ string_size = ::Protobuf::Field::VarintField.encode(value_to_encode.size)
20
+ string_size << value_to_encode
20
21
  end
21
22
  end
22
23
  end
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.7.11'
2
+ VERSION = '2.7.12'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe ::Protobuf::Field::StringField do
6
+
7
+ describe '#encode' do
8
+ context 'when a repeated string field contains frozen strings' do
9
+ it 'does not raise an encoding error' do
10
+ expect {
11
+ frozen_strings = [ "foo".freeze, "bar".freeze, "baz".freeze ]
12
+ ::Test::ResourceFindRequest.new(:name => 'resource', :widgets => frozen_strings).serialize_to_string
13
+ }.not_to raise_error
14
+ end
15
+ end
16
+
17
+ context 'when a repeated bytes field contains frozen strings' do
18
+ it 'does not raise an encoding error' do
19
+ expect {
20
+ frozen_strings = [ "foo".freeze, "bar".freeze, "baz".freeze ]
21
+ ::Test::ResourceFindRequest.new(:name => 'resource', :widget_bytes => frozen_strings).serialize_to_string
22
+ }.not_to raise_error
23
+ end
24
+ end
25
+
26
+ it 'does not alter string values after encoding multiple times' do
27
+ source_string = "foo"
28
+ proto = ::Test::Resource.new(:name => source_string)
29
+ proto.serialize_to_string
30
+ proto.name.should eq source_string
31
+ proto.serialize_to_string
32
+ proto.name.should eq source_string
33
+ end
34
+
35
+ it 'does not alter unicode string values after encoding multiple times' do
36
+ source_string = "¢"
37
+ proto = ::Test::Resource.new(:name => source_string)
38
+ proto.serialize_to_string
39
+ proto.name.should eq source_string
40
+ proto.serialize_to_string
41
+ proto.name.should eq source_string
42
+ end
43
+ end
44
+
45
+
46
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.11
5
- prerelease:
4
+ version: 2.7.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - BJ Neilsen
@@ -10,214 +9,188 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-06-17 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: ffi
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: multi_json
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: thor
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :runtime
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: eventmachine
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - '>='
85
75
  - !ruby/object:Gem::Version
86
76
  version: '0'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - '>='
93
82
  - !ruby/object:Gem::Version
94
83
  version: '0'
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: ffi-rzmq
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
- - - ! '>='
88
+ - - '>='
101
89
  - !ruby/object:Gem::Version
102
90
  version: '0'
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
- - - ! '>='
95
+ - - '>='
109
96
  - !ruby/object:Gem::Version
110
97
  version: '0'
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: pry
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
- - - ! '>='
102
+ - - '>='
117
103
  - !ruby/object:Gem::Version
118
104
  version: '0'
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
- - - ! '>='
109
+ - - '>='
125
110
  - !ruby/object:Gem::Version
126
111
  version: '0'
127
112
  - !ruby/object:Gem::Dependency
128
113
  name: pry-nav
129
114
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
115
  requirements:
132
- - - ! '>='
116
+ - - '>='
133
117
  - !ruby/object:Gem::Version
134
118
  version: '0'
135
119
  type: :development
136
120
  prerelease: false
137
121
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
122
  requirements:
140
- - - ! '>='
123
+ - - '>='
141
124
  - !ruby/object:Gem::Version
142
125
  version: '0'
143
126
  - !ruby/object:Gem::Dependency
144
127
  name: rake
145
128
  requirement: !ruby/object:Gem::Requirement
146
- none: false
147
129
  requirements:
148
- - - ! '>='
130
+ - - '>='
149
131
  - !ruby/object:Gem::Version
150
132
  version: '0'
151
133
  type: :development
152
134
  prerelease: false
153
135
  version_requirements: !ruby/object:Gem::Requirement
154
- none: false
155
136
  requirements:
156
- - - ! '>='
137
+ - - '>='
157
138
  - !ruby/object:Gem::Version
158
139
  version: '0'
159
140
  - !ruby/object:Gem::Dependency
160
141
  name: rake-compiler
161
142
  requirement: !ruby/object:Gem::Requirement
162
- none: false
163
143
  requirements:
164
- - - ! '>='
144
+ - - '>='
165
145
  - !ruby/object:Gem::Version
166
146
  version: '0'
167
147
  type: :development
168
148
  prerelease: false
169
149
  version_requirements: !ruby/object:Gem::Requirement
170
- none: false
171
150
  requirements:
172
- - - ! '>='
151
+ - - '>='
173
152
  - !ruby/object:Gem::Version
174
153
  version: '0'
175
154
  - !ruby/object:Gem::Dependency
176
155
  name: rspec
177
156
  requirement: !ruby/object:Gem::Requirement
178
- none: false
179
157
  requirements:
180
- - - ! '>='
158
+ - - '>='
181
159
  - !ruby/object:Gem::Version
182
160
  version: '0'
183
161
  type: :development
184
162
  prerelease: false
185
163
  version_requirements: !ruby/object:Gem::Requirement
186
- none: false
187
164
  requirements:
188
- - - ! '>='
165
+ - - '>='
189
166
  - !ruby/object:Gem::Version
190
167
  version: '0'
191
168
  - !ruby/object:Gem::Dependency
192
169
  name: simplecov
193
170
  requirement: !ruby/object:Gem::Requirement
194
- none: false
195
171
  requirements:
196
- - - ! '>='
172
+ - - '>='
197
173
  - !ruby/object:Gem::Version
198
174
  version: '0'
199
175
  type: :development
200
176
  prerelease: false
201
177
  version_requirements: !ruby/object:Gem::Requirement
202
- none: false
203
178
  requirements:
204
- - - ! '>='
179
+ - - '>='
205
180
  - !ruby/object:Gem::Version
206
181
  version: '0'
207
182
  - !ruby/object:Gem::Dependency
208
183
  name: yard
209
184
  requirement: !ruby/object:Gem::Requirement
210
- none: false
211
185
  requirements:
212
- - - ! '>='
186
+ - - '>='
213
187
  - !ruby/object:Gem::Version
214
188
  version: '0'
215
189
  type: :development
216
190
  prerelease: false
217
191
  version_requirements: !ruby/object:Gem::Requirement
218
- none: false
219
192
  requirements:
220
- - - ! '>='
193
+ - - '>='
221
194
  - !ruby/object:Gem::Version
222
195
  version: '0'
223
196
  description: Google Protocol Buffers v2.4.1 Serialization and RPC implementation for
@@ -414,6 +387,7 @@ files:
414
387
  - spec/lib/protobuf/enum_spec.rb
415
388
  - spec/lib/protobuf/enum_value_spec.rb
416
389
  - spec/lib/protobuf/field/int32_field_spec.rb
390
+ - spec/lib/protobuf/field/string_field_spec.rb
417
391
  - spec/lib/protobuf/logger_spec.rb
418
392
  - spec/lib/protobuf/message_spec.rb
419
393
  - spec/lib/protobuf/rpc/client_spec.rb
@@ -492,33 +466,26 @@ files:
492
466
  - test/test_types.rb
493
467
  homepage: https://github.com/localshred/protobuf
494
468
  licenses: []
469
+ metadata: {}
495
470
  post_install_message:
496
471
  rdoc_options: []
497
472
  require_paths:
498
473
  - lib
499
474
  required_ruby_version: !ruby/object:Gem::Requirement
500
- none: false
501
475
  requirements:
502
- - - ! '>='
476
+ - - '>='
503
477
  - !ruby/object:Gem::Version
504
478
  version: '0'
505
- segments:
506
- - 0
507
- hash: -1094122154149890359
508
479
  required_rubygems_version: !ruby/object:Gem::Requirement
509
- none: false
510
480
  requirements:
511
- - - ! '>='
481
+ - - '>='
512
482
  - !ruby/object:Gem::Version
513
483
  version: '0'
514
- segments:
515
- - 0
516
- hash: -1094122154149890359
517
484
  requirements: []
518
485
  rubyforge_project:
519
- rubygems_version: 1.8.23
486
+ rubygems_version: 2.1.2
520
487
  signing_key:
521
- specification_version: 3
488
+ specification_version: 4
522
489
  summary: Google Protocol Buffers v2.4.1 Serialization and RPC implementation for Ruby.
523
490
  test_files:
524
491
  - spec/benchmark/tasks.rb
@@ -530,6 +497,7 @@ test_files:
530
497
  - spec/lib/protobuf/enum_spec.rb
531
498
  - spec/lib/protobuf/enum_value_spec.rb
532
499
  - spec/lib/protobuf/field/int32_field_spec.rb
500
+ - spec/lib/protobuf/field/string_field_spec.rb
533
501
  - spec/lib/protobuf/logger_spec.rb
534
502
  - spec/lib/protobuf/message_spec.rb
535
503
  - spec/lib/protobuf/rpc/client_spec.rb