protobuf 3.2.0 → 3.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e5a341fcb307dfd13d03e56530493f316dadff4
4
- data.tar.gz: 1dde8b64fe387bd0bcd87e5823e02bec8322bf25
3
+ metadata.gz: 6806ad95dd3051a54c6bcae3940287187fd50239
4
+ data.tar.gz: 326e902f6a3c9c64cc5a40b60562a04536d4e37d
5
5
  SHA512:
6
- metadata.gz: 5511c46d74eb0e669400ab394fef865e4e1a8c0a919a967a1d1b97fba19e0dcb8073c08155b9a4fada0043bafb803adaad1d3019f3f293e367c41d9873ba6c10
7
- data.tar.gz: 9c5f985a0ab726096f1bb662e48b2a9fe78133a5d523421ccdb93b43aad6aabc1fd45cce0e7d9643c9176ff0bc2bf02f16b2b8ad82e3ab99a176539ce392acbf
6
+ metadata.gz: 22f3ac751be365b4d3a2efc6e14d2e9706049557558dae209b3c0abd0d9487b4f80c9abce743c6110721a0f1940f94c6635b7869559b8923a275e8ae2f05edaf
7
+ data.tar.gz: e2b52a93261a2577ab260afefb1ab1eea6263a9a2ad8caac31a3058253c5bf55b042403b70901c8202c276302d6270f04bf1d2d72a212c2512f4728da82588e8
@@ -19,10 +19,7 @@ module Protobuf
19
19
  # Attributes
20
20
  #
21
21
 
22
- attr_reader :default, :default_value, :deprecated, :extension,
23
- :getter_method_name, :message_class, :name, :optional,
24
- :packed, :repeated, :required, :rule, :setter_method_name,
25
- :tag, :type_class
22
+ attr_reader :message_class, :name, :options, :rule, :tag, :type_class
26
23
 
27
24
  ##
28
25
  # Class Methods
@@ -37,20 +34,13 @@ module Protobuf
37
34
  #
38
35
 
39
36
  def initialize(message_class, rule, type_class, name, tag, options)
40
- @message_class, @rule, @type_class, @name, @tag = \
41
- message_class, rule, type_class, name, tag
37
+ @message_class = message_class
38
+ @name = name
39
+ @rule = rule
40
+ @tag = tag
41
+ @type_class = type_class
42
+ @options = options
42
43
 
43
- set_rule_predicates
44
-
45
- @getter_method_name = name
46
- @setter_method_name = "#{name}="
47
- @default = options.delete(:default)
48
- @extension = options.delete(:extension)
49
- @packed = repeated? && options.delete(:packed)
50
- @deprecated = options.delete(:deprecated)
51
-
52
- set_default_value
53
- warn_excess_options(options) unless options.empty?
54
44
  validate_packed_field if packed?
55
45
  define_accessor
56
46
  end
@@ -67,18 +57,70 @@ module Protobuf
67
57
  value
68
58
  end
69
59
 
60
+ def decode(bytes)
61
+ raise NotImplementedError, "#{self.class.name}\#decode"
62
+ end
63
+
64
+ def default
65
+ options[:default]
66
+ end
67
+
68
+ def default_value
69
+ @default_value ||= case
70
+ when repeated? then ::Protobuf::Field::FieldArray.new(self).freeze
71
+ when required? then nil
72
+ when optional? then typed_default_value
73
+ end
74
+ end
75
+
76
+ def deprecated?
77
+ options.key?(:deprecated)
78
+ end
79
+
80
+ def encode(value)
81
+ raise NotImplementedError, "#{self.class.name}\#encode"
82
+ end
83
+
84
+ def extension?
85
+ options.key?(:extension)
86
+ end
87
+
70
88
  def enum?
71
89
  false
72
90
  end
73
91
 
92
+ def getter
93
+ name
94
+ end
95
+
74
96
  def message?
75
97
  false
76
98
  end
77
99
 
78
- # Decode +bytes+ and pass to +message_instance+.
100
+ def optional?
101
+ rule == :optional
102
+ end
103
+
104
+ def packed?
105
+ repeated? && options.key?(:packed)
106
+ end
107
+
108
+ def repeated?
109
+ rule == :repeated
110
+ end
111
+
112
+ def repeated_message?
113
+ repeated? && message?
114
+ end
115
+
116
+ def required?
117
+ rule == :required
118
+ end
119
+
120
+ # FIXME need to cleanup (rename) this warthog of a method.
79
121
  def set(message_instance, bytes)
80
122
  if packed?
81
- array = message_instance.__send__(getter_method_name)
123
+ array = message_instance.__send__(getter)
82
124
  method = \
83
125
  case wire_type
84
126
  when ::Protobuf::WireType::FIXED32 then :read_fixed32
@@ -93,57 +135,18 @@ module Protobuf
93
135
  else
94
136
  value = decode(bytes)
95
137
  if repeated?
96
- message_instance.__send__(getter_method_name) << value
138
+ message_instance.__send__(getter) << value
97
139
  else
98
- message_instance.__send__(setter_method_name, value)
140
+ message_instance.__send__(setter, value)
99
141
  end
100
142
  end
101
143
  end
102
144
 
103
- # Decode +bytes+ and return a field value.
104
- def decode(bytes)
105
- raise NotImplementedError, "#{self.class.name}\#decode"
106
- end
107
-
108
- # Encode +value+ and return a byte string.
109
- def encode(value)
110
- raise NotImplementedError, "#{self.class.name}\#encode"
111
- end
112
-
113
- def extension?
114
- !! extension
115
- end
116
-
117
- # Is this a repeated field?
118
- def repeated?
119
- !! repeated
120
- end
121
-
122
- # Is this a repeated message field?
123
- def repeated_message?
124
- repeated? && message?
125
- end
126
-
127
- # Is this a required field?
128
- def required?
129
- !! required
130
- end
131
-
132
- # Is this a optional field?
133
- def optional?
134
- !! optional
135
- end
136
-
137
- # Is this a deprecated field?
138
- def deprecated?
139
- !! deprecated
140
- end
141
-
142
- # Is this a packed repeated field?
143
- def packed?
144
- !! packed
145
+ def setter
146
+ @setter ||= "#{name}="
145
147
  end
146
148
 
149
+ # FIXME add packed, deprecated, extension options to to_s output
147
150
  def to_s
148
151
  "#{rule} #{type_class} #{name} = #{tag} #{default ? "[default=#{default.inspect}]" : ''}"
149
152
  end
@@ -159,6 +162,10 @@ module Protobuf
159
162
  end
160
163
  end
161
164
 
165
+ def wire_type
166
+ ::Protobuf::WireType::VARINT
167
+ end
168
+
162
169
  private
163
170
 
164
171
  ##
@@ -178,7 +185,7 @@ module Protobuf
178
185
  def define_array_getter
179
186
  field = self
180
187
  message_class.class_eval do
181
- define_method(field.getter_method_name) do
188
+ define_method(field.getter) do
182
189
  field.warn_if_deprecated
183
190
  @values[field.name] ||= ::Protobuf::Field::FieldArray.new(field)
184
191
  end
@@ -188,7 +195,7 @@ module Protobuf
188
195
  def define_array_setter
189
196
  field = self
190
197
  message_class.class_eval do
191
- define_method(field.setter_method_name) do |val|
198
+ define_method(field.setter) do |val|
192
199
  field.warn_if_deprecated
193
200
 
194
201
  if val.is_a?(Array)
@@ -214,7 +221,7 @@ module Protobuf
214
221
  def define_getter
215
222
  field = self
216
223
  message_class.class_eval do
217
- define_method(field.getter_method_name) do
224
+ define_method(field.getter) do
218
225
  field.warn_if_deprecated
219
226
  @values.fetch(field.name, field.default_value)
220
227
  end
@@ -224,7 +231,7 @@ module Protobuf
224
231
  def define_setter
225
232
  field = self
226
233
  message_class.class_eval do
227
- define_method(field.setter_method_name) do |val|
234
+ define_method(field.setter) do |val|
228
235
  field.warn_if_deprecated
229
236
 
230
237
  if val.nil? || (val.respond_to?(:empty?) && val.empty?)
@@ -238,28 +245,6 @@ module Protobuf
238
245
  end
239
246
  end
240
247
 
241
- def set_default_value
242
- @default_value = case
243
- when repeated? then ::Protobuf::Field::FieldArray.new(self).freeze
244
- when required? then nil
245
- when optional? then typed_default_value
246
- end
247
- end
248
-
249
- def set_rule_predicates
250
- case rule
251
- when :repeated then
252
- @required = @optional = false
253
- @repeated = true
254
- when :required then
255
- @repeated = @optional = false
256
- @required = true
257
- when :optional then
258
- @repeated = @required = false
259
- @optional = true
260
- end
261
- end
262
-
263
248
  def typed_default_value
264
249
  if default.nil?
265
250
  self.class.default
@@ -274,10 +259,6 @@ module Protobuf
274
259
  end
275
260
  end
276
261
 
277
- def warn_excess_options(options)
278
- warn "WARNING: Invalid options: #{options.inspect} (in #{message_class.name}##{name})"
279
- end
280
-
281
262
  end
282
263
  end
283
264
  end
@@ -40,7 +40,7 @@ module Protobuf
40
40
 
41
41
  field = self
42
42
  message_class.class_eval do
43
- define_method("#{field.getter_method_name}?") do
43
+ define_method("#{field.getter}?") do
44
44
  field.warn_if_deprecated
45
45
  @values.fetch(field.name, field.default_value)
46
46
  end
@@ -8,7 +8,7 @@ module Protobuf
8
8
  # Constants
9
9
  #
10
10
 
11
- BYTES_ENCODING = "ASCII-8BIT".freeze
11
+ BYTES_ENCODING = Encoding::BINARY
12
12
 
13
13
  ##
14
14
  # Class Methods
@@ -54,7 +54,7 @@ module Protobuf
54
54
  def define_setter
55
55
  field = self
56
56
  message_class.class_eval do
57
- define_method(field.setter_method_name) do |val|
57
+ define_method(field.setter) do |val|
58
58
  begin
59
59
  field.warn_if_deprecated
60
60
  val = "#{val}" if val.is_a?(Symbol)
@@ -4,6 +4,14 @@ module Protobuf
4
4
  module Field
5
5
  class EnumField < VarintField
6
6
 
7
+ ##
8
+ # Class Methods
9
+ #
10
+
11
+ def self.default
12
+ raise NoMethodError, "#{self}.#{__method__} must be called on an instance"
13
+ end
14
+
7
15
  ##
8
16
  # Public Instance Methods
9
17
  #
@@ -53,7 +61,7 @@ module Protobuf
53
61
  if default.is_a?(Symbol)
54
62
  type_class.const_get(default)
55
63
  else
56
- self.class.default
64
+ type_class.fetch(default) || type_class.enums.first
57
65
  end
58
66
  end
59
67
 
@@ -8,7 +8,7 @@ module Protobuf
8
8
  # Constants
9
9
  #
10
10
 
11
- ENCODING = 'UTF-8'.freeze
11
+ ENCODING = Encoding::UTF_8
12
12
 
13
13
  ##
14
14
  # Public Instance Methods
@@ -62,7 +62,7 @@ module Protobuf
62
62
  #
63
63
  def each_field
64
64
  self.class.all_fields.each do |field|
65
- value = __send__(field.name)
65
+ value = __send__(field.getter)
66
66
  yield(field, value)
67
67
  end
68
68
  end
@@ -71,7 +71,7 @@ module Protobuf
71
71
  self.class.all_fields.each do |field|
72
72
  next unless field_must_be_serialized?(field)
73
73
 
74
- value = @values[field.name]
74
+ value = @values[field.getter]
75
75
 
76
76
  if value.nil?
77
77
  raise ::Protobuf::SerializationError, "Required field #{self.class.name}##{field.name} does not have a value."
@@ -129,13 +129,13 @@ module Protobuf
129
129
 
130
130
  def [](name)
131
131
  if field = self.class.get_field(name, true)
132
- __send__(field.name)
132
+ __send__(field.getter)
133
133
  end
134
134
  end
135
135
 
136
136
  def []=(name, value)
137
137
  if field = self.class.get_field(name, true)
138
- __send__(field.setter_method_name, value) unless value.nil?
138
+ __send__(field.setter, value) unless value.nil?
139
139
  else
140
140
  unless ::Protobuf.ignore_unknown_fields?
141
141
  raise ::Protobuf::FieldNotDefinedError, name
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.2.0'
2
+ VERSION = '3.2.1'
3
3
  end
@@ -21,7 +21,6 @@ require "protobuf/version"
21
21
 
22
22
  s.add_dependency 'activesupport', '>= 3.2'
23
23
  s.add_dependency 'middleware'
24
- s.add_dependency 'multi_json'
25
24
  s.add_dependency 'thor'
26
25
 
27
26
  s.add_development_dependency 'ffi-rzmq'
@@ -11,7 +11,7 @@ describe 'protoc-gen-ruby' do
11
11
  it 'reads the serialized request bytes and outputs serialized response bytes' do
12
12
  ::IO.popen(binpath, 'w+') do |pipe|
13
13
  pipe.write(request_bytes)
14
- pipe.read(expected_response_bytes.size).should eq expected_response_bytes
14
+ expect(pipe.read(expected_response_bytes.size)).to eq expected_response_bytes
15
15
  end
16
16
  end
17
17
  end
@@ -128,7 +128,7 @@ describe ::Protobuf::CLI do
128
128
 
129
129
  it 'sets the deprecation warning flag to true' do
130
130
  described_class.start(args)
131
- expect(::Protobuf.print_deprecation_warnings?).to be_truthy
131
+ expect(::Protobuf.print_deprecation_warnings?).to be true
132
132
  end
133
133
  end
134
134
 
@@ -138,7 +138,7 @@ describe ::Protobuf::CLI do
138
138
 
139
139
  it 'sets the deprecation warning flag to false ' do
140
140
  described_class.start(args)
141
- expect(::Protobuf.print_deprecation_warnings?).to be_falsey
141
+ expect(::Protobuf.print_deprecation_warnings?).to be false
142
142
  end
143
143
  end
144
144
  end
@@ -148,7 +148,7 @@ describe ::Protobuf::CLI do
148
148
 
149
149
  it 'sets the deprecation warning flag to true' do
150
150
  described_class.start(args)
151
- expect(::Protobuf.print_deprecation_warnings?).to be_truthy
151
+ expect(::Protobuf.print_deprecation_warnings?).to be true
152
152
  end
153
153
  end
154
154
 
@@ -157,7 +157,7 @@ describe ::Protobuf::CLI do
157
157
 
158
158
  it 'sets the deprecation warning flag to false' do
159
159
  described_class.start(args)
160
- expect(::Protobuf.print_deprecation_warnings?).to be_falsey
160
+ expect(::Protobuf.print_deprecation_warnings?).to be false
161
161
  end
162
162
  end
163
163
  end
@@ -200,7 +200,7 @@ describe ::Protobuf::CLI do
200
200
 
201
201
  it 'is activated by the --workers_only switch' do
202
202
  expect(runner).to receive(:new) do |options|
203
- expect(options[:workers_only]).to be_truthy
203
+ expect(options[:workers_only]).to be true
204
204
  end.and_return(zmq_runner)
205
205
 
206
206
  described_class.start(args)
@@ -209,7 +209,7 @@ describe ::Protobuf::CLI do
209
209
  it 'is activated by PB_WORKERS_ONLY=1 ENV variable' do
210
210
  ENV['PB_WORKERS_ONLY'] = "1"
211
211
  expect(runner).to receive(:new) do |options|
212
- expect(options[:workers_only]).to be_truthy
212
+ expect(options[:workers_only]).to be true
213
213
  end.and_return(zmq_runner)
214
214
 
215
215
  described_class.start(args)
@@ -21,8 +21,8 @@ describe Protobuf::Enum do
21
21
  end
22
22
 
23
23
  describe '.aliases_allowed?' do
24
- it 'is false when the option is not set' do
25
- expect(Test::EnumTestType.aliases_allowed?).to be_falsey
24
+ it 'is nil when the option is not set' do
25
+ expect(Test::EnumTestType.aliases_allowed?).to be nil
26
26
  end
27
27
  end
28
28
 
@@ -155,15 +155,15 @@ describe Protobuf::Enum do
155
155
 
156
156
  describe '.valid_tag?' do
157
157
  context 'when tag is defined' do
158
- specify { expect(Test::EnumTestType.valid_tag?(tag)).to be_truthy }
158
+ specify { expect(Test::EnumTestType.valid_tag?(tag)).to be true }
159
159
  end
160
160
 
161
161
  context 'when tag is not defined' do
162
- specify { expect(Test::EnumTestType.valid_tag?(300)).to be_falsey }
162
+ specify { expect(Test::EnumTestType.valid_tag?(300)).to be false }
163
163
  end
164
164
 
165
165
  context 'is true for aliased enums' do
166
- specify { expect(EnumAliasTest.valid_tag?(1)).to be_truthy }
166
+ specify { expect(EnumAliasTest.valid_tag?(1)).to be true }
167
167
  end
168
168
  end
169
169
 
@@ -230,7 +230,7 @@ describe Protobuf::Enum do
230
230
 
231
231
  context 'when coercing from enum' do
232
232
  subject { Test::StatusType::PENDING }
233
- it { should eq(0) }
233
+ it { is_expected.to eq(0) }
234
234
  end
235
235
 
236
236
  context 'when coercing from integer' do
@@ -104,13 +104,13 @@ describe Protobuf::Logger do
104
104
 
105
105
  subject { MyTestClass.new }
106
106
 
107
- it { should respond_to(:log_debug) }
108
- it { should respond_to(:log_info) }
109
- it { should respond_to(:log_warn) }
110
- it { should respond_to(:log_error) }
111
- it { should respond_to(:log_fatal) }
112
- it { should respond_to(:log_add) }
113
- it { should respond_to(:log_log) }
107
+ it { is_expected.to respond_to(:log_debug) }
108
+ it { is_expected.to respond_to(:log_info) }
109
+ it { is_expected.to respond_to(:log_warn) }
110
+ it { is_expected.to respond_to(:log_error) }
111
+ it { is_expected.to respond_to(:log_fatal) }
112
+ it { is_expected.to respond_to(:log_add) }
113
+ it { is_expected.to respond_to(:log_log) }
114
114
 
115
115
  context '#log_exception' do
116
116
  it 'logs the exception message as an error and backtrace as debug' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Protobuf::Message do
@@ -126,9 +128,14 @@ describe Protobuf::Message do
126
128
  end
127
129
 
128
130
  describe '#initialize' do
129
- it "initializes the enum getter to 0" do
131
+ it "defaults to the first value listed in the enum's type definition" do
130
132
  test_enum = Test::EnumTestMessage.new
131
- expect(test_enum.non_default_enum).to eq(0)
133
+ expect(test_enum.non_default_enum).to eq(1)
134
+ end
135
+
136
+ it "defaults to a a value with a name" do
137
+ test_enum = Test::EnumTestMessage.new
138
+ expect(test_enum.non_default_enum.name).to eq(:ONE)
132
139
  end
133
140
 
134
141
  it "exposes the enum getter raw value through ! method" do
@@ -217,21 +224,21 @@ describe Protobuf::Message do
217
224
  end
218
225
 
219
226
  it "keeps utf-8 when utf-8 is input for string fields" do
220
- name = "my name\xC3"
221
- name.force_encoding("UTF-8")
227
+ name = 'my name💩'
228
+ name.force_encoding(Encoding::UTF_8)
222
229
 
223
230
  message = ::Test::Resource.new(:name => name)
224
231
  new_message = ::Test::Resource.decode(message.encode)
225
- expect(new_message.name == name).to be_truthy
232
+ expect(new_message.name == name).to be true
226
233
  end
227
234
 
228
235
  it "trims binary when binary is input for string fields" do
229
236
  name = "my name\xC3"
230
- name.force_encoding("ASCII-8BIT")
237
+ name.force_encoding(Encoding::BINARY)
231
238
 
232
239
  message = ::Test::Resource.new(:name => name)
233
240
  new_message = ::Test::Resource.decode(message.encode)
234
- expect(new_message.name == "my name").to be_truthy
241
+ expect(new_message.name == "my name").to be true
235
242
  end
236
243
  end
237
244
 
@@ -283,16 +290,16 @@ describe Protobuf::Message do
283
290
  describe "boolean predicate methods" do
284
291
  subject { Test::ResourceFindRequest.new(:name => "resource") }
285
292
 
286
- it { should respond_to(:active?) }
293
+ it { is_expected.to respond_to(:active?) }
287
294
 
288
295
  it "sets the predicate to true when the boolean value is true" do
289
296
  subject.active = true
290
- expect(subject.active?).to be_truthy
297
+ expect(subject.active?).to be true
291
298
  end
292
299
 
293
300
  it "sets the predicate to false when the boolean value is false" do
294
301
  subject.active = false
295
- expect(subject.active?).to be_falsey
302
+ expect(subject.active?).to be false
296
303
  end
297
304
 
298
305
  it "does not put predicate methods on non-boolean fields" do
@@ -304,11 +311,11 @@ describe Protobuf::Message do
304
311
  subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
305
312
 
306
313
  it "is false when the message does not have the field" do
307
- expect(subject.respond_to_and_has?(:other_field)).to be_falsey
314
+ expect(subject.respond_to_and_has?(:other_field)).to be false
308
315
  end
309
316
 
310
317
  it "is true when the message has the field" do
311
- expect(subject.respond_to_and_has?(:non_default_enum)).to be_truthy
318
+ expect(subject.respond_to_and_has?(:non_default_enum)).to be true
312
319
  end
313
320
  end
314
321
 
@@ -316,25 +323,25 @@ describe Protobuf::Message do
316
323
  subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
317
324
 
318
325
  it "is false when the message does not have the field" do
319
- expect(subject.respond_to_and_has_and_present?(:other_field)).to be_falsey
326
+ expect(subject.respond_to_and_has_and_present?(:other_field)).to be false
320
327
  end
321
328
 
322
329
  it "is false when the field is repeated and a value is not present" do
323
- expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be_falsey
330
+ expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be false
324
331
  end
325
332
 
326
333
  it "is false when the field is repeated and the value is empty array" do
327
334
  subject.repeated_enums = []
328
- expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be_falsey
335
+ expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be false
329
336
  end
330
337
 
331
338
  it "is true when the field is repeated and a value is present" do
332
339
  subject.repeated_enums = [2]
333
- expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be_truthy
340
+ expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be true
334
341
  end
335
342
 
336
343
  it "is true when the message has the field" do
337
- expect(subject.respond_to_and_has_and_present?(:non_default_enum)).to be_truthy
344
+ expect(subject.respond_to_and_has_and_present?(:non_default_enum)).to be true
338
345
  end
339
346
 
340
347
  context "#API" do
@@ -20,7 +20,7 @@ describe 'Optionable' do
20
20
 
21
21
  it 'defaults the value to true' do
22
22
  OptionableSetOptionTest.set_option(:baz_enabled)
23
- expect(OptionableSetOptionTest.get_option(:baz_enabled)).to be_truthy
23
+ expect(OptionableSetOptionTest.get_option(:baz_enabled)).to be true
24
24
  end
25
25
  end
26
26
 
@@ -15,15 +15,15 @@ describe Protobuf::Rpc::Connectors::Common do
15
15
  subject { @subject ||= common_class.new(subject_options) }
16
16
 
17
17
  context "API" do
18
- specify { expect(subject.respond_to?(:any_callbacks?)).to be_truthy }
19
- specify { expect(subject.respond_to?(:request_caller)).to be_truthy }
20
- specify { expect(subject.respond_to?(:data_callback)).to be_truthy }
21
- specify { expect(subject.respond_to?(:error)).to be_truthy }
22
- specify { expect(subject.respond_to?(:fail)).to be_truthy }
23
- specify { expect(subject.respond_to?(:complete)).to be_truthy }
24
- specify { expect(subject.respond_to?(:parse_response)).to be_truthy }
25
- specify { expect(subject.respond_to?(:verify_options!)).to be_truthy }
26
- specify { expect(subject.respond_to?(:verify_callbacks)).to be_truthy }
18
+ specify { expect(subject.respond_to?(:any_callbacks?)).to be true }
19
+ specify { expect(subject.respond_to?(:request_caller)).to be true }
20
+ specify { expect(subject.respond_to?(:data_callback)).to be true }
21
+ specify { expect(subject.respond_to?(:error)).to be true }
22
+ specify { expect(subject.respond_to?(:fail)).to be true }
23
+ specify { expect(subject.respond_to?(:complete)).to be true }
24
+ specify { expect(subject.respond_to?(:parse_response)).to be true }
25
+ specify { expect(subject.respond_to?(:verify_options!)).to be true }
26
+ specify { expect(subject.respond_to?(:verify_callbacks)).to be true }
27
27
  end
28
28
 
29
29
  describe "#any_callbacks?" do
@@ -31,7 +31,7 @@ describe Protobuf::Rpc::Connectors::Common do
31
31
  [:@complete_cb, :@success_cb, :@failure_cb].each do |cb|
32
32
  it "returns true if #{cb} is provided" do
33
33
  subject.instance_variable_set(cb, "something")
34
- expect(subject.any_callbacks?).to be_truthy
34
+ expect(subject.any_callbacks?).to be true
35
35
  end
36
36
  end
37
37
 
@@ -40,7 +40,7 @@ describe Protobuf::Rpc::Connectors::Common do
40
40
  subject.instance_variable_set(:@success_cb, nil)
41
41
  subject.instance_variable_set(:@failure_cb, nil)
42
42
 
43
- expect(subject.any_callbacks?).to be_falsey
43
+ expect(subject.any_callbacks?).to be false
44
44
  end
45
45
 
46
46
  end
@@ -60,7 +60,7 @@ describe Protobuf::Rpc::Connectors::Common do
60
60
  describe "#data_callback" do
61
61
  it "changes state to use the data callback" do
62
62
  subject.data_callback("data")
63
- expect(subject.instance_variable_get(:@used_data_callback)).to be_truthy
63
+ expect(subject.instance_variable_get(:@used_data_callback)).to be true
64
64
  end
65
65
 
66
66
  it "sets the data var when using the data_callback" do
@@ -6,10 +6,10 @@ shared_examples "a Protobuf Connector" do
6
6
 
7
7
  context "API" do
8
8
  # Check the API
9
- specify { expect(subject.respond_to?(:send_request, true)).to be_truthy }
10
- specify { expect(subject.respond_to?(:post_init, true)).to be_truthy }
11
- specify { expect(subject.respond_to?(:close_connection, true)).to be_truthy }
12
- specify { expect(subject.respond_to?(:error?, true)).to be_truthy }
9
+ specify { expect(subject.respond_to?(:send_request, true)).to be true }
10
+ specify { expect(subject.respond_to?(:post_init, true)).to be true }
11
+ specify { expect(subject.respond_to?(:close_connection, true)).to be true }
12
+ specify { expect(subject.respond_to?(:error?, true)).to be true }
13
13
  end
14
14
  end
15
15
 
@@ -18,7 +18,7 @@ describe Protobuf::Rpc::Connectors::Socket do
18
18
 
19
19
  it_behaves_like "a Protobuf Connector"
20
20
 
21
- specify { expect(described_class.include?(Protobuf::Rpc::Connectors::Common)).to be_truthy }
21
+ specify { expect(described_class.include?(Protobuf::Rpc::Connectors::Common)).to be true }
22
22
 
23
23
  context "#read_response" do
24
24
  let(:data) { "New data" }
@@ -79,7 +79,7 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
79
79
  end
80
80
 
81
81
  it "returns true" do
82
- expect(subject.send(:host_alive?, "yip.yip")).to be_truthy
82
+ expect(subject.send(:host_alive?, "yip.yip")).to be true
83
83
  end
84
84
 
85
85
  it "does not attempt a connection" do
@@ -95,19 +95,19 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
95
95
 
96
96
  it "returns true when the connection succeeds" do
97
97
  expect(TCPSocket).to receive(:new).with("huzzah.com", 3307).and_return(double(:close => nil))
98
- expect(subject.send(:host_alive?, "huzzah.com")).to be_truthy
98
+ expect(subject.send(:host_alive?, "huzzah.com")).to be true
99
99
  end
100
100
 
101
101
  it "returns false when the connection fails" do
102
102
  expect(TCPSocket).to receive(:new).with("hayoob.com", 3307).and_raise(Errno::ECONNREFUSED)
103
- expect(subject.send(:host_alive?, "hayoob.com")).to be_falsey
103
+ expect(subject.send(:host_alive?, "hayoob.com")).to be false
104
104
  end
105
105
 
106
106
  it "closes the socket" do
107
107
  socket = double("TCPSocket")
108
108
  expect(socket).to receive(:close)
109
109
  expect(TCPSocket).to receive(:new).with("absorbalof.com", 3307).and_return(socket)
110
- expect(subject.send(:host_alive?, "absorbalof.com")).to be_truthy
110
+ expect(subject.send(:host_alive?, "absorbalof.com")).to be true
111
111
  end
112
112
  end
113
113
  end
@@ -22,12 +22,12 @@ describe Protobuf::Rpc::Zmq::Server do
22
22
  describe '.running?' do
23
23
  it 'returns true if running' do
24
24
  subject.instance_variable_set(:@running, true)
25
- expect(subject.running?).to be_truthy
25
+ expect(subject.running?).to be true
26
26
  end
27
27
 
28
28
  it 'returns false if not running' do
29
29
  subject.instance_variable_set(:@running, false)
30
- expect(subject.running?).to be_falsey
30
+ expect(subject.running?).to be false
31
31
  end
32
32
  end
33
33
 
@@ -35,7 +35,7 @@ describe Protobuf::Rpc::Zmq::Server do
35
35
  it 'sets running to false' do
36
36
  subject.instance_variable_set(:@workers, [])
37
37
  subject.stop
38
- expect(subject.instance_variable_get(:@running)).to be_falsey
38
+ expect(subject.instance_variable_get(:@running)).to be false
39
39
  end
40
40
  end
41
41
  end
@@ -85,13 +85,13 @@ describe Protobuf::Rpc::Service do
85
85
 
86
86
  context 'when given name is a pre-defined rpc method' do
87
87
  it 'returns true' do
88
- expect(subject.rpc_method?(:delete)).to be_truthy
88
+ expect(subject.rpc_method?(:delete)).to be true
89
89
  end
90
90
  end
91
91
 
92
92
  context 'when given name is not a pre-defined rpc method' do
93
93
  it 'returns false' do
94
- expect(subject.rpc_method?(:zoobaboo)).to be_falsey
94
+ expect(subject.rpc_method?(:zoobaboo)).to be false
95
95
  end
96
96
  end
97
97
  end
@@ -9,13 +9,13 @@ describe ::Protobuf do
9
9
  subject { ::Protobuf.client_host }
10
10
 
11
11
  context 'when client_host is not pre-configured' do
12
- it { should eq `hostname`.chomp }
12
+ it { is_expected.to eq `hostname`.chomp }
13
13
  end
14
14
 
15
15
  context 'when client_host is pre-configured' do
16
16
  let(:hostname) { 'override.myhost.com' }
17
17
  before { ::Protobuf.client_host = hostname }
18
- it { should eq hostname }
18
+ it { is_expected.to eq hostname }
19
19
  end
20
20
  end
21
21
 
@@ -46,12 +46,12 @@ describe ::Protobuf do
46
46
  before { described_class.instance_variable_set(:@_gc_pause_server_request, nil) }
47
47
 
48
48
  it 'defaults to a false value' do
49
- expect(described_class.gc_pause_server_request?).to be_falsey
49
+ expect(described_class.gc_pause_server_request?).to be false
50
50
  end
51
51
 
52
52
  it 'is settable' do
53
53
  described_class.gc_pause_server_request = true
54
- expect(described_class.gc_pause_server_request?).to be_truthy
54
+ expect(described_class.gc_pause_server_request?).to be true
55
55
  end
56
56
  end
57
57
 
@@ -59,18 +59,18 @@ describe ::Protobuf do
59
59
  before { described_class.instance_variable_set(:@_print_deprecation_warnings, nil) }
60
60
 
61
61
  it 'defaults to a true value' do
62
- expect(described_class.print_deprecation_warnings?).to be_truthy
62
+ expect(described_class.print_deprecation_warnings?).to be true
63
63
  end
64
64
 
65
65
  it 'is settable' do
66
66
  described_class.print_deprecation_warnings = false
67
- expect(described_class.print_deprecation_warnings?).to be_falsey
67
+ expect(described_class.print_deprecation_warnings?).to be false
68
68
  end
69
69
 
70
70
  context 'when ENV["PB_IGNORE_DEPRECATIONS"] present' do
71
71
  it 'defaults to a false value' do
72
72
  ENV['PB_IGNORE_DEPRECATIONS'] = '1'
73
- expect(described_class.print_deprecation_warnings?).to be_falsey
73
+ expect(described_class.print_deprecation_warnings?).to be false
74
74
  end
75
75
  end
76
76
  end
@@ -28,7 +28,6 @@ end
28
28
  ENV.delete("PB_IGNORE_DEPRECATIONS")
29
29
 
30
30
  ::RSpec.configure do |c|
31
- c.include(::Sander6::CustomMatchers)
32
31
  c.mock_with :rspec
33
32
 
34
33
  c.before(:suite) do
@@ -1,5 +1,4 @@
1
1
  require 'support/packed_field'
2
- require 'support/tolerance_matcher'
3
2
  require 'support/server'
4
3
 
5
4
  def now
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-08-01 00:00:00.000000000 Z
14
+ date: 2014-08-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -41,20 +41,6 @@ dependencies:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
- - !ruby/object:Gem::Dependency
45
- name: multi_json
46
- requirement: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: '0'
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '0'
58
44
  - !ruby/object:Gem::Dependency
59
45
  name: thor
60
46
  requirement: !ruby/object:Gem::Requirement
@@ -368,7 +354,6 @@ files:
368
354
  - spec/support/test/resource.proto
369
355
  - spec/support/test/resource_service.rb
370
356
  - spec/support/test_app_file.rb
371
- - spec/support/tolerance_matcher.rb
372
357
  homepage: https://github.com/localshred/protobuf
373
358
  licenses:
374
359
  - WTFPL
@@ -465,5 +450,4 @@ test_files:
465
450
  - spec/support/test/resource.proto
466
451
  - spec/support/test/resource_service.rb
467
452
  - spec/support/test_app_file.rb
468
- - spec/support/tolerance_matcher.rb
469
453
  has_rdoc:
@@ -1,40 +0,0 @@
1
- #
2
- # courtesy of sander 6
3
- # - http://github.com/sander6/custom_matchers/blob/master/lib/matchers/tolerance_matchers.rb
4
- #
5
- module Sander6
6
- module CustomMatchers
7
-
8
- class ToleranceMatcher
9
- def initialize(tolerance)
10
- @tolerance = tolerance
11
- @target = 0
12
- end
13
-
14
- def of(target)
15
- @target = target
16
- self
17
- end
18
-
19
- def matches?(value)
20
- @value = value
21
- ((@target - @tolerance)..(@target + @tolerance)).include?(@value)
22
- end
23
-
24
- def failure_message
25
- "Expected #{@value.inspect} to be within #{@tolerance.inspect} of #{@target.inspect}, but it wasn't.\n" +
26
- "Difference: #{@value - @target}"
27
- end
28
-
29
- def negative_failure_message
30
- "Expected #{@value.inspect} not to be within #{@tolerance.inspect} of #{@target.inspect}, but it was.\n" +
31
- "Difference: #{@value - @target}"
32
- end
33
- end
34
-
35
- def be_within(value)
36
- Sander6::CustomMatchers::ToleranceMatcher.new(value)
37
- end
38
-
39
- end
40
- end