protobuf 3.7.0.pre1 → 3.7.0.pre2

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: 2572788305cda35ff4cc6fde499167d9658d080b
4
- data.tar.gz: 941f6a8239dbc36d8bc3e299dd07f37986c0bc11
3
+ metadata.gz: 4eb324f0fa537308f4f06735a42fe4a73f1483e4
4
+ data.tar.gz: e1067403611fd86bf86b064115cbd42651aa68d5
5
5
  SHA512:
6
- metadata.gz: bc704397840f6e029fdc8b7a7cff5cc659ab077998e0f688f1babcbd55473155bf626e953ef7d88fdf17192b38d26256d571284c0c7e028e047b4c59131b138f
7
- data.tar.gz: 684348b64a203f308076e1c41f6c76d4442cf7d5edd529a68016139f1cec83a98e37a71c854254fa8edef41a9cf536672708bb8cfb3e0acc4f99ceff108a66d2
6
+ metadata.gz: 74422c44f167336cb16897fbe21c77eb89f663f5e4217759eff2499ef2889fffd05529f49ef1586378927b23919f7d97d41bc69b9e187694a72366ddb2bff234
7
+ data.tar.gz: 9a5436e3e9ead8917e9cff660674494a31e6522d4ba53b9ea31c6ad1643b946507dc947c5878678eda997ae2c70543e71923e7b2727b8801c527754bdc71dac4
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Stable (3.x)
2
2
 
3
+ 3.7.0 (pre2)
4
+ -----------
5
+ - BUG: Track if a repeated field has been deliberately set (#325)
6
+
3
7
  3.7.0 (pre1)
4
8
  -----------
5
9
  - BUG: Revert to old behavior for setting repeated fields to nil
@@ -16,6 +20,10 @@
16
20
  - Refresh google/protobuf/descriptor.{proto,pb.rb}
17
21
  - Properly encode and decode negative enum values.
18
22
 
23
+ 3.6.9
24
+ --------
25
+ - Make protobuf serivce directory pluggable.
26
+
19
27
  3.6.7
20
28
  -----
21
29
  - An issue was reported with the encode memoization added in #293 with using any array modification
@@ -176,7 +176,7 @@ module Protobuf
176
176
  def define_accessor(simple_field_name, fully_qualified_field_name)
177
177
  message_class.class_eval do
178
178
  define_method("#{simple_field_name}!") do
179
- @values[fully_qualified_field_name]
179
+ @values[fully_qualified_field_name] if field?(fully_qualified_field_name)
180
180
  end
181
181
  end
182
182
 
@@ -94,7 +94,11 @@ module Protobuf
94
94
  def field?(name)
95
95
  field = self.class.get_field(name, true)
96
96
  return false if field.nil?
97
- @values.key?(field.fully_qualified_name)
97
+ if field.repeated?
98
+ @values.key?(field.fully_qualified_name) && @values[field.fully_qualified_name].present?
99
+ else
100
+ @values.key?(field.fully_qualified_name)
101
+ end
98
102
  end
99
103
  ::Protobuf.deprecator.define_deprecated_methods(self, :has_field? => :field?)
100
104
 
@@ -226,7 +226,7 @@ module Protobuf
226
226
 
227
227
  # Alias for ::Protobuf::Rpc::ServiceDirectory.instance
228
228
  def service_directory
229
- ::Protobuf::Rpc::ServiceDirectory.instance
229
+ ::Protobuf::Rpc.service_directory
230
230
  end
231
231
 
232
232
  def snd_timeout
@@ -9,6 +9,14 @@ require 'protobuf/rpc/dynamic_discovery.pb'
9
9
 
10
10
  module Protobuf
11
11
  module Rpc
12
+ def self.service_directory
13
+ @service_directory ||= ::Protobuf::Rpc::ServiceDirectory.instance
14
+ end
15
+
16
+ def self.service_directory=(directory)
17
+ @service_directory = directory
18
+ end
19
+
12
20
  class ServiceDirectory
13
21
  include ::Singleton
14
22
  include ::Protobuf::Logging
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.7.0.pre1'
2
+ VERSION = '3.7.0.pre2'
3
3
  end
@@ -476,6 +476,25 @@ RSpec.describe Protobuf::Message do
476
476
  message = ::Test::Resource.new(:ext_is_searchable => false)
477
477
  expect(message.ext_is_searchable!).to be(false)
478
478
  end
479
+
480
+ it 'returns nil for an unset repeated field that has only be read' do
481
+ message = ::Test::Resource.new
482
+ expect(message.repeated_enum!).to be_nil
483
+ message.repeated_enum
484
+ expect(message.repeated_enum!).to be_nil
485
+ end
486
+
487
+ it 'returns value for an unset repeated field has been read and appended to' do
488
+ message = ::Test::Resource.new
489
+ message.repeated_enum << 1
490
+ expect(message.repeated_enum!).to eq([1])
491
+ end
492
+
493
+ it 'returns value for an unset repeated field has been explicitly set' do
494
+ message = ::Test::Resource.new
495
+ message.repeated_enum = [1]
496
+ expect(message.repeated_enum!).to eq([1])
497
+ end
479
498
  end
480
499
  end
481
500
 
@@ -562,6 +581,31 @@ RSpec.describe Protobuf::Message do
562
581
  message = ::Test::Resource.new(ext_field => false)
563
582
  expect(message.field?(100)).to be(true)
564
583
  end
584
+
585
+ it 'returns false for repeated field that has been read from' do
586
+ message = ::Test::Resource.new
587
+ expect(message.field?(:repeated_enum)).to be(false)
588
+ message.repeated_enum
589
+ expect(message.field?(:repeated_enum)).to be(false)
590
+ end
591
+
592
+ it 'returns true for a repeated field that has been read from and appended to' do
593
+ message = ::Test::Resource.new
594
+ message.repeated_enum << 1
595
+ expect(message.field?(:repeated_enum)).to be(true)
596
+ end
597
+
598
+ it 'returns true for a repeated field that has been set with the setter' do
599
+ message = ::Test::Resource.new
600
+ message.repeated_enum = [1]
601
+ expect(message.field?(:repeated_enum)).to be(true)
602
+ end
603
+
604
+ it 'returns false for a repeated field that has been replaced with []' do
605
+ message = ::Test::Resource.new
606
+ message.repeated_enum.replace([])
607
+ expect(message.field?(:repeated_enum)).to be(false)
608
+ end
565
609
  end
566
610
 
567
611
  describe '.get_field' do
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.7.0.pre1
4
+ version: 3.7.0.pre2
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: 2016-05-17 00:00:00.000000000 Z
14
+ date: 2016-06-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport