protip 0.30.8 → 0.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/protip/error.rb +1 -1
  3. data/lib/protip/{extensions.rb → extensions_pb.rb} +0 -0
  4. data/lib/protip/messages/active_support/time_with_zone_pb.rb +19 -0
  5. data/lib/protip/messages/{array.rb → array_pb.rb} +0 -0
  6. data/lib/protip/messages/{big_decimal_value.rb → big_decimal_value_pb.rb} +0 -0
  7. data/lib/protip/messages/{currency.rb → currency_pb.rb} +0 -0
  8. data/lib/protip/messages/{errors.rb → errors_pb.rb} +0 -0
  9. data/lib/protip/messages/{money.rb → money_pb.rb} +1 -1
  10. data/lib/protip/messages/{range.rb → range_pb.rb} +0 -0
  11. data/lib/protip/messages/{repeated_wrappers.rb → repeated_wrappers_pb.rb} +1 -1
  12. data/lib/protip/messages/{test.rb → test_pb.rb} +2 -2
  13. data/lib/protip/messages/{types.rb → types_pb.rb} +0 -0
  14. data/lib/protip/messages/{wrappers.rb → wrappers_pb.rb} +1 -1
  15. data/lib/protip/messages_pb.rb +18 -0
  16. data/lib/protip/resource.rb +2 -14
  17. data/lib/protip/tasks/compile.rake +2 -2
  18. data/test/functional/protip/decorator_test.rb +2 -2
  19. data/test/functional/protip/resource_test.rb +1 -1
  20. data/test/unit/protip/decorator_test.rb +1 -1
  21. data/test/unit/protip/resource/associations/belongs_to_polymorphic_association_test.rb +3 -2
  22. data/test/unit/protip/resource_test.rb +19 -6
  23. data/test/unit/protip/transformers/big_decimal_transformer_test.rb +1 -1
  24. data/test/unit/protip/transformers/deprecated_transformer_test.rb +1 -1
  25. data/test/unit/protip/transformers/enum_transformer_test.rb +1 -1
  26. data/test/unit/protip/transformers/primitives_transformer_test.rb +2 -2
  27. data/test/unit/protip/transformers/timestamp_transformer_test.rb +1 -1
  28. metadata +56 -27
  29. data/lib/protip/messages.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b700562f8cedc2912054670d12c0c41a5ad3f84
4
- data.tar.gz: 0d7570c79be4b391c252482d161aa10acf739fc1
3
+ metadata.gz: 942ae2f8166273c93dda19be2e9e27252bc508fc
4
+ data.tar.gz: e47259c27cca062b7b72052a1e20fcdd6505c2ff
5
5
  SHA512:
6
- metadata.gz: 42fdc7f6b8a8b18128edae66d2af7d62f7e83ac7556bfd3dd4ebaabe26161daecde74932762f39da43fee776225cc66257240668bbbb16611c6c733f65ac3cfa
7
- data.tar.gz: f58984dd3bbc99af11bee730cc577fca94e1623c1b282c17b32ea0f292b7095086835a53f544d641625af5313538d22edd331c993214dc69acc62283b3e62afa
6
+ metadata.gz: 2e2c0c8055391b79e00fbb3ef947316a7ad8fc6140c6cf9ed5f13f1dc3c45aedeb5ae897cab55dc1cb08c34343244054b7b2b425831d9619f453228e7ab92b0c
7
+ data.tar.gz: 16684e44a0768fa4fed229ce553621b4b265760c0698b076d0d9e012418000dde423f3fc6e79c047dd67bfe29268ddff52d780750a55c462a3521bb225425c1f
@@ -1,6 +1,6 @@
1
1
  # Runtime exceptions for the library (protip/messages/errors defines the messages backing resource errors).
2
2
 
3
- require 'protip/messages/errors'
3
+ require 'protip/messages/errors_pb'
4
4
 
5
5
  module Protip
6
6
  class Error < RuntimeError
@@ -0,0 +1,19 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: protip/messages/active_support/time_with_zone.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_message "protip.messages.ActiveSupport.TimeWithZone" do
8
+ optional :utc_timestamp, :int64, 1
9
+ optional :time_zone_name, :string, 2
10
+ end
11
+ end
12
+
13
+ module Protip
14
+ module Messages
15
+ module ActiveSupport
16
+ TimeWithZone = Google::Protobuf::DescriptorPool.generated_pool.lookup("protip.messages.ActiveSupport.TimeWithZone").msgclass
17
+ end
18
+ end
19
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
- require 'protip/messages/currency'
6
+ require 'protip/messages/currency_pb'
7
7
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
8
  add_message "protip.messages.Money" do
9
9
  optional :amount_cents, :int64, 1
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
- require 'protip/extensions'
6
+ require 'protip/extensions_pb'
7
7
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
8
  add_message "protip.messages.RepeatedDouble" do
9
9
  repeated :values, :double, 1
@@ -3,8 +3,8 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
- require 'protip/messages/repeated_wrappers'
7
- require 'protip/messages/wrappers'
6
+ require 'protip/messages/repeated_wrappers_pb'
7
+ require 'protip/messages/wrappers_pb'
8
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
9
  add_message "protip.messages.EnumTest" do
10
10
  optional :enum, :message, 1, "protip.messages.EnumValue"
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
- require 'protip/extensions'
6
+ require 'protip/extensions_pb'
7
7
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
8
  add_message "protip.messages.EnumValue" do
9
9
  optional :value, :int32, 1
@@ -0,0 +1,18 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: protip/messages.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'protip/messages/array_pb'
7
+ require 'protip/messages/big_decimal_value_pb'
8
+ require 'protip/messages/currency_pb'
9
+ require 'protip/messages/errors_pb'
10
+ require 'protip/messages/money_pb'
11
+ require 'protip/messages/range_pb'
12
+ require 'protip/messages/repeated_wrappers_pb'
13
+ require 'protip/messages/types_pb'
14
+ require 'protip/messages/wrappers_pb'
15
+ require 'protip/messages/active_support/time_with_zone_pb'
16
+ Google::Protobuf::DescriptorPool.generated_pool.build do
17
+ end
18
+
@@ -25,7 +25,7 @@ require 'protip/error'
25
25
  require 'protip/decorator'
26
26
  require 'protip/transformers/default_transformer'
27
27
 
28
- require 'protip/messages/array'
28
+ require 'protip/messages/array_pb'
29
29
 
30
30
  require 'protip/resource/creatable'
31
31
  require 'protip/resource/updateable'
@@ -302,19 +302,7 @@ module Protip
302
302
  keys.each do |key|
303
303
  old_value = old_attributes[key]
304
304
  new_value = message[key]
305
- begin
306
- changed = !(old_value.class == new_value.class && old_value == new_value)
307
- rescue TypeError => e
308
-
309
- # Workaround for a protip bug when comparing messages with
310
- # nested messages where the left side is non-nil and the
311
- # right side is nil.
312
- if e.message == 'wrong argument type nil (expected Message)'
313
- changed = true
314
- else
315
- raise e
316
- end
317
- end
305
+ changed = !(old_value.class == new_value.class && old_value == new_value)
318
306
 
319
307
  if changed
320
308
  send "#{key}_will_change!"
@@ -9,14 +9,14 @@ namespace :protip do
9
9
 
10
10
  filename = args[:filename] || raise(ArgumentError.new 'filename argument is required')
11
11
 
12
- command = "protoc #{proto_path.map{|p| "--proto_path=#{Shellwords.escape p}"}.join ' '} --ruby_out=#{Shellwords.escape ruby_path} #{Shellwords.escape filename}"
12
+ command = "grpc_tools_ruby_protoc #{proto_path.map{|p| "--proto_path=#{Shellwords.escape p}"}.join ' '} --ruby_out=#{Shellwords.escape ruby_path} #{Shellwords.escape filename}"
13
13
  puts command
14
14
  system command
15
15
 
16
16
  ## ridiculous hack around missing options in Ruby, remove when https://github.com/google/protobuf/issues/1198 is resolved
17
17
  package_match = File.read(filename).match(/package "?([a-zA-Z0-9\.]+)"?;/)
18
18
  package = (package_match ? package_match[1] : nil)
19
- ruby_file = filename.gsub(/^#{proto_path.first}\/?/, "#{ruby_path}/").gsub(/proto$/, 'rb') # Relies on a relative filename and proto path, which protoc requires anyway at this point
19
+ ruby_file = filename.gsub(/^#{proto_path.first}\/?/, "#{ruby_path}/").gsub(/\.proto$/, '_pb.rb') # Relies on a relative filename and proto path, which protoc requires anyway at this point
20
20
  raise "cannot find generated Ruby file (#{ruby_file})" unless File.exists?(ruby_file)
21
21
 
22
22
  # Push/pop message names as we move through the protobuf file
@@ -4,9 +4,9 @@ require 'protip/decorator'
4
4
  require 'protip/transformers/default_transformer'
5
5
 
6
6
  require 'google/protobuf'
7
- require 'google/protobuf/wrappers'
7
+ require 'google/protobuf/wrappers_pb'
8
8
 
9
- require 'protip/messages/test' # For the enum hack
9
+ require 'protip/messages/test_pb' # For the enum hack
10
10
 
11
11
  # Tests the whole decoration/transformation process with the default
12
12
  # transformer, using well-known types and other transformable message
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  require 'protip'
4
- require 'google/protobuf/wrappers'
4
+ require 'google/protobuf/wrappers_pb'
5
5
 
6
6
  describe 'Protip::Resource (functional)' do
7
7
 
@@ -437,7 +437,7 @@ describe Protip::Decorator do
437
437
 
438
438
  it 'returns nil for messages that have not been set' do
439
439
  transformer.expects(:to_object).never
440
- assert_equal nil, decorator.inner_blank
440
+ assert_nil decorator.inner_blank
441
441
  end
442
442
 
443
443
  it 'returns the underlying assigned value for oneof fields' do
@@ -141,8 +141,9 @@ describe Protip::Resource::Associations::BelongsToPolymorphicAssociation do
141
141
 
142
142
  association.write(resource, nil)
143
143
 
144
- assert_nil resource.rick_ross_id
145
- assert_nil resource.fetty_wap_id
144
+ assert_nil resource.message.reference_id
145
+ assert resource.rick_ross_id.blank?
146
+ assert resource.fetty_wap_id.blank?
146
147
  end
147
148
  end
148
149
  end
@@ -571,8 +571,13 @@ module Protip::ResourceTest # Namespace for internal constants
571
571
  returns(72)
572
572
 
573
573
  transformer.stubs(:to_object).
574
- with(double_nested_message_class.any_instance, anything).
575
- returns(100)
574
+ # Convert any +double_nested_message+ (with the correct
575
+ # associated field) to the same value, since we don't
576
+ # really care about testing it.
577
+ with do |value, field|
578
+ value.is_a?(double_nested_message_class) &&
579
+ field.name == 'double_nested_message'
580
+ end.returns(100)
576
581
  end
577
582
  it 'marks messages as changed if they are changed as Ruby values' do
578
583
  setter.set nested_message: 42
@@ -602,18 +607,26 @@ module Protip::ResourceTest # Namespace for internal constants
602
607
  refute resource.string_changed?, 'field was marked as changed'
603
608
  end
604
609
 
605
- # Test our workaround for a protobuf bug when comparing
606
- # messages with sub-messages that are non-nil on the left,
607
- # nil on the right.
608
- it 'recognizes when double-nested messages are changed to nil values' do
610
+ # Test that we don't trigger an old protobuf bug when
611
+ # comparing messages with sub-messages that are non-nil on
612
+ # the left, nil on the right. (We used to work around this
613
+ # bug explicitly in our equality check, now just leaving the
614
+ # test in to make sure it doesn't come back.)
615
+ it 'recognizes_when_double-nested_messages_are_changed_to_nil_values' do
609
616
  # Initially the field should have its nested message set.
610
617
  resource.message.double_nested_message = double_nested_message_class.new(
611
618
  nested_message: nested_message_class.new(number: 10)
612
619
  )
613
620
 
621
+ # Sanity check
622
+ refute resource.double_nested_message_changed?
623
+
614
624
  # Then give it a field with a nil nested message to
615
625
  # trigger the protobuf bug.
616
626
  setter.set double_nested_message: double_nested_message_class.new
627
+
628
+ # Sanity check
629
+ assert resource.double_nested_message_changed?
617
630
  end
618
631
  end
619
632
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
  require 'protip/transformers/big_decimal_transformer'
3
3
 
4
- require 'protip/messages'
4
+ require 'protip/messages_pb'
5
5
 
6
6
  describe Protip::Transformers::BigDecimalTransformer do
7
7
  let(:transformer) { Protip::Transformers::BigDecimalTransformer.new }
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  require 'protip/transformers/deprecated_transformer'
4
4
 
5
- require 'protip/messages'
5
+ require 'protip/messages_pb'
6
6
 
7
7
  describe Protip::Transformers::DeprecatedTransformer do
8
8
  let(:transformer) { Protip::Transformers::DeprecatedTransformer.new }
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  require 'protip/transformers/enum_transformer'
4
4
 
5
- require 'protip/messages'
5
+ require 'protip/messages_pb'
6
6
 
7
7
  describe Protip::Transformers::EnumTransformer do
8
8
  let(:transformer) { Protip::Transformers::EnumTransformer.new }
@@ -3,8 +3,8 @@ require 'base64'
3
3
 
4
4
  require 'protip/transformers/primitives_transformer'
5
5
 
6
- require 'google/protobuf/wrappers'
7
- require 'protip/messages'
6
+ require 'google/protobuf/wrappers_pb'
7
+ require 'protip/messages/errors_pb'
8
8
 
9
9
  describe ::Protip::Transformers::PrimitivesTransformer do
10
10
  let(:transformer) { ::Protip::Transformers::PrimitivesTransformer.new }
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
  require 'protip/transformers/timestamp_transformer'
3
- require 'google/protobuf/timestamp'
3
+ require 'google/protobuf/timestamp_pb'
4
4
 
5
5
  describe Protip::Transformers::TimestampTransformer do
6
6
  let(:transformer) { Protip::Transformers::TimestampTransformer.new }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.8
4
+ version: 0.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AngelList
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-02 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -17,9 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
- - - "<="
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.0'
22
+ version: '6.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +27,9 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.0.0
30
- - - "<="
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.0'
32
+ version: '6.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -37,9 +37,9 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 3.0.0
40
- - - "<="
40
+ - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '5.0'
42
+ version: '6.0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,23 +47,23 @@ dependencies:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 3.0.0
50
- - - "<="
50
+ - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '5.0'
52
+ version: '6.0'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: google-protobuf
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - '='
57
+ - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 3.0.0.alpha.5.0.5.1
59
+ version: '3.0'
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '='
64
+ - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: 3.0.0.alpha.5.0.5.1
66
+ version: '3.0'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: money
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -84,6 +84,20 @@ dependencies:
84
84
  - - "<"
85
85
  - !ruby/object:Gem::Version
86
86
  version: '7.0'
87
+ - !ruby/object:Gem::Dependency
88
+ name: grpc-tools
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '1.0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '1.0'
87
101
  - !ruby/object:Gem::Dependency
88
102
  name: minitest
89
103
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +168,20 @@ dependencies:
154
168
  - - "~>"
155
169
  - !ruby/object:Gem::Version
156
170
  version: '0.10'
171
+ - !ruby/object:Gem::Dependency
172
+ name: pry
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '0.10'
178
+ type: :development
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - "~>"
183
+ - !ruby/object:Gem::Version
184
+ version: '0.10'
157
185
  - !ruby/object:Gem::Dependency
158
186
  name: webmock
159
187
  requirement: !ruby/object:Gem::Requirement
@@ -195,19 +223,20 @@ files:
195
223
  - lib/protip/client.rb
196
224
  - lib/protip/decorator.rb
197
225
  - lib/protip/error.rb
198
- - lib/protip/extensions.rb
199
- - lib/protip/messages.rb
226
+ - lib/protip/extensions_pb.rb
200
227
  - lib/protip/messages/active_support/time_with_zone.rb
201
- - lib/protip/messages/array.rb
202
- - lib/protip/messages/big_decimal_value.rb
203
- - lib/protip/messages/currency.rb
204
- - lib/protip/messages/errors.rb
205
- - lib/protip/messages/money.rb
206
- - lib/protip/messages/range.rb
207
- - lib/protip/messages/repeated_wrappers.rb
208
- - lib/protip/messages/test.rb
209
- - lib/protip/messages/types.rb
210
- - lib/protip/messages/wrappers.rb
228
+ - lib/protip/messages/active_support/time_with_zone_pb.rb
229
+ - lib/protip/messages/array_pb.rb
230
+ - lib/protip/messages/big_decimal_value_pb.rb
231
+ - lib/protip/messages/currency_pb.rb
232
+ - lib/protip/messages/errors_pb.rb
233
+ - lib/protip/messages/money_pb.rb
234
+ - lib/protip/messages/range_pb.rb
235
+ - lib/protip/messages/repeated_wrappers_pb.rb
236
+ - lib/protip/messages/test_pb.rb
237
+ - lib/protip/messages/types_pb.rb
238
+ - lib/protip/messages/wrappers_pb.rb
239
+ - lib/protip/messages_pb.rb
211
240
  - lib/protip/resource.rb
212
241
  - lib/protip/resource/associations/association.rb
213
242
  - lib/protip/resource/associations/belongs_to_association.rb
@@ -266,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
295
  version: '0'
267
296
  requirements: []
268
297
  rubyforge_project:
269
- rubygems_version: 2.5.1
298
+ rubygems_version: 2.4.5
270
299
  signing_key:
271
300
  specification_version: 4
272
301
  summary: Resources backed by protobuf messages
@@ -1,18 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: protip/messages.proto
3
-
4
- require 'google/protobuf'
5
-
6
- require 'protip/messages/array'
7
- require 'protip/messages/big_decimal_value'
8
- require 'protip/messages/currency'
9
- require 'protip/messages/errors'
10
- require 'protip/messages/money'
11
- require 'protip/messages/range'
12
- require 'protip/messages/repeated_wrappers'
13
- require 'protip/messages/types'
14
- require 'protip/messages/wrappers'
15
- require 'protip/messages/active_support/time_with_zone'
16
- Google::Protobuf::DescriptorPool.generated_pool.build do
17
- end
18
-