protip 0.33.0 → 0.35.4

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
- SHA1:
3
- metadata.gz: b00d08f38111e8b0182e50c6f4e452787d0f9168
4
- data.tar.gz: 963dc1bde387ed8308925a2185a4f9b5d5494631
2
+ SHA256:
3
+ metadata.gz: 30131e70e41b5199b3d87287c7d04cc29730965b7ee3d526b05c963a2a6782ab
4
+ data.tar.gz: 07fc8c4685f97553082dd964d6b428378a34ff356dee5dca1f5cf394fdc90164
5
5
  SHA512:
6
- metadata.gz: 736fe9fc7445f0fa83b608a142cd74001ef30b96304be7297f1653016fa795668cfc7685f0f4e2ca01047ab14fc033b41425e2f5e2ea0c5db8e9454cf850be31
7
- data.tar.gz: 0ad6ab1ff91ff83179093f5dbdc71a776632c0147687e88819894525a90aaea5cfcf08637663d3927aa46681b89c62f3ae06545b19a96eda5b77da712dc699b8
6
+ metadata.gz: 2450adaae3e28b8b711c1d96084fa3caad1e6960e48b5f4bd02fcbf17ca2ae71728fabb1618ef8c5f488211979232abec89f56c18103218d247947719ab96f15
7
+ data.tar.gz: 3a0667f59aea909f493334949bafa487d9ddf7644f8df4a0431c276b1a470b78c8b05455097b23112994ee6f9eeef650f139101494e6a00abef1cc2435759c47
@@ -1,3 +1,4 @@
1
+ require 'protip/version'
1
2
  require 'protip/client'
2
3
  require 'protip/resource'
3
4
 
@@ -69,27 +69,9 @@ module Protip
69
69
  # @param request [Net::HTTPGenericRequest] the raw request object to send
70
70
  # @return [Net::HTTPResponse] the response for the given request
71
71
  def execute_request(request)
72
- http = nil
73
72
  uri = request.uri
74
- retries = 0
75
- max_retries = 3
76
-
77
- begin
78
- unless http
79
- http = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', read_timeout: 120)
80
- end
73
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', read_timeout: 600) do |http|
81
74
  http.request request
82
- rescue Net::OpenTimeout, Net::ReadTimeout
83
- if (retries += 1) <= max_retries
84
- sleep(retries)
85
- retry
86
- else
87
- raise
88
- end
89
- ensure
90
- if http
91
- http.finish
92
- end
93
75
  end
94
76
  end
95
77
  end
@@ -281,7 +281,7 @@ module Protip
281
281
 
282
282
  def method_missing_query(name, *args)
283
283
  field = message.class.descriptor.lookup(name[0, name.length - 1])
284
- raise NoMethodError unless field
284
+ raise NoMethodError.new("No query method found for: #{name}") unless field
285
285
 
286
286
  if nil != Protip::Decorator.enum_for_field(field) && args.length == 1
287
287
  matches?(field, args[0])
@@ -19,7 +19,6 @@ require 'active_model/dirty'
19
19
 
20
20
  require 'forwardable'
21
21
 
22
- require 'protip'
23
22
  require 'protip/client'
24
23
  require 'protip/error'
25
24
  require 'protip/decorator'
@@ -78,14 +77,14 @@ module Protip
78
77
  end
79
78
 
80
79
  def transformer
81
- @transformer || ::Protip.default_transformer
80
+ defined?(@transformer) ? @transformer : ::Protip.default_transformer
82
81
  end
83
82
 
84
83
  private
85
84
 
86
85
  # Primary entry point for defining resourceful behavior.
87
86
  def resource(actions:, message:, query: nil, nested_resources: {})
88
- raise RuntimeError.new('Only one call to `resource` is allowed') if @message
87
+ raise RuntimeError.new('Only one call to `resource` is allowed') if defined?(@message) && @message
89
88
  validate_actions!(actions)
90
89
  validate_nested_resources!(nested_resources)
91
90
 
@@ -338,6 +337,18 @@ module Protip
338
337
  success
339
338
  end
340
339
 
340
+ class RecordInvalid < StandardError
341
+ end
342
+
343
+ def save!
344
+ success = save
345
+ if !success
346
+ error_messages = errors.full_messages.join(", ")
347
+ raise RecordInvalid.new("Validation failed: #{error_messages}")
348
+ end
349
+ success
350
+ end
351
+
341
352
  def persisted?
342
353
  id != nil
343
354
  end
@@ -1,4 +1,6 @@
1
1
  require 'shellwords'
2
+ require 'bundler/setup'
3
+
2
4
  namespace :protip do
3
5
  desc 'compile a single .proto file to Ruby'
4
6
  task :compile, [:filename, :proto_path, :ruby_path] do |t, args|
@@ -9,7 +11,7 @@ namespace :protip do
9
11
 
10
12
  filename = args[:filename] || raise(ArgumentError.new 'filename argument is required')
11
13
 
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}"
14
+ command = "bundle exec grpc_tools_ruby_protoc #{proto_path.map{|p| "--proto_path=#{Shellwords.escape p}"}.join ' '} --ruby_out=#{Shellwords.escape ruby_path} #{Shellwords.escape filename}"
13
15
  puts command
14
16
  system command
15
17
 
@@ -22,7 +22,7 @@ module Protip
22
22
  if !value.is_a?(::ActiveSupport::TimeWithZone) && (value.is_a?(Time) || value.is_a?(DateTime))
23
23
  value = ::ActiveSupport::TimeWithZone.new(value.to_time.utc, ::ActiveSupport::TimeZone.new('UTC'))
24
24
  end
25
- raise ArgumentError unless value.is_a?(::ActiveSupport::TimeWithZone)
25
+ raise ArgumentError.new("Expected ActiveSupport::TimeWithZone, received #{value.class.name}") unless value.is_a?(::ActiveSupport::TimeWithZone)
26
26
 
27
27
  message_class.new(
28
28
  utc_timestamp: value.to_i,
@@ -32,4 +32,4 @@ module Protip
32
32
  end
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -16,7 +16,7 @@ module Protip
16
16
  end
17
17
 
18
18
  def to_message(object, field)
19
- object = BigDecimal.new(object)
19
+ object = BigDecimal(object)
20
20
  rational = object.to_r
21
21
  field.subtype.msgclass.new(
22
22
  numerator: rational.numerator,
@@ -28,4 +28,4 @@ module Protip
28
28
  end
29
29
  end
30
30
  end
31
- end
31
+ end
@@ -25,7 +25,7 @@ module Protip
25
25
  decorator.assign_attributes(object)
26
26
  decorator.message
27
27
  else
28
- raise ArgumentError
28
+ raise ArgumentError.new("#to_message expected a Hash or an already decorated object, received #{object.class.name} for #{field.type} #{field.name}")
29
29
  end
30
30
  end
31
31
  end
@@ -50,7 +50,7 @@ module Protip
50
50
  ::Date.new(message.year, message.month, message.day)
51
51
  end
52
52
  def to_message(object, field)
53
- raise ArgumentError unless object.is_a?(::Date)
53
+ raise ArgumentError.new("Field #{field.name} expected a date, #{object.class.name} given") unless object.is_a?(::Date)
54
54
  field.subtype.msgclass.new(year: object.year, month: object.month, day: object.day)
55
55
  end
56
56
  end
@@ -77,7 +77,7 @@ module Protip
77
77
  if !object.is_a?(::ActiveSupport::TimeWithZone) && (object.is_a?(Time) || object.is_a?(DateTime))
78
78
  object = ::ActiveSupport::TimeWithZone.new(object.to_time.utc, ::ActiveSupport::TimeZone.new('UTC'))
79
79
  end
80
- raise ArgumentError unless object.is_a?(::ActiveSupport::TimeWithZone)
80
+ raise ArgumentError.new("Expected ActiveSupport::TimeWithZone, received #{object.class.name}") unless object.is_a?(::ActiveSupport::TimeWithZone)
81
81
 
82
82
  field.subtype.msgclass.new(
83
83
  utc_timestamp: object.to_i,
@@ -0,0 +1,3 @@
1
+ module Protip
2
+ VERSION = '0.35.4'
3
+ end
@@ -1,6 +1,7 @@
1
1
  require 'minitest/autorun'
2
- require 'mocha/mini_test'
2
+ require 'mocha/minitest'
3
3
  require 'webmock/minitest'
4
4
  require 'minitest/stub/const'
5
-
6
5
  require 'minitest/pride'
6
+ require 'pry-byebug'
7
+ require 'protip'
@@ -46,7 +46,7 @@ describe Protip::Resource::Associations::BelongsToPolymorphicAssociation do
46
46
  Protip::Resource::Associations::BelongsToPolymorphicAssociation.new resource_class,
47
47
  :reference, [rick_ross_association]
48
48
  end
49
- assert_match /requires an association to be defined/, error.message
49
+ assert_match(/requires an association to be defined/, error.message)
50
50
  end
51
51
 
52
52
  it 'raises an error if a belongs-to association is provided for a field outside the oneof' do
@@ -54,7 +54,7 @@ describe Protip::Resource::Associations::BelongsToPolymorphicAssociation do
54
54
  Protip::Resource::Associations::BelongsToPolymorphicAssociation.new resource_class,
55
55
  :reference, [rick_ross_association, other_association]
56
56
  end
57
- assert_match /requires an association to be defined/, error.message
57
+ assert_match(/requires an association to be defined/, error.message)
58
58
  end
59
59
 
60
60
  it 'raises an error if a duplicate belongs-to association is provided' do
@@ -62,7 +62,7 @@ describe Protip::Resource::Associations::BelongsToPolymorphicAssociation do
62
62
  Protip::Resource::Associations::BelongsToPolymorphicAssociation.new resource_class,
63
63
  :reference, [rick_ross_association, rick_ross_association, fetty_wap_association]
64
64
  end
65
- assert_match /Duplicate association/, error.message
65
+ assert_match(/Duplicate association/, error.message)
66
66
  end
67
67
 
68
68
  it 'allows the oneof ID field to be specified' do
@@ -147,4 +147,4 @@ describe Protip::Resource::Associations::BelongsToPolymorphicAssociation do
147
147
  end
148
148
  end
149
149
  end
150
- end
150
+ end
@@ -1043,7 +1043,7 @@ module Protip::ResourceTest # Namespace for internal constants
1043
1043
  send method, :association_name, bad_option: 'bad', &block
1044
1044
  end
1045
1045
  end
1046
- assert_match /bad_option/, error.message
1046
+ assert_match(/bad_option/, error.message)
1047
1047
  end
1048
1048
  end
1049
1049
  end
@@ -27,14 +27,14 @@ describe Protip::Transformers::BigDecimalTransformer do
27
27
  end
28
28
  end
29
29
  describe 'for BigDecimal arguments' do
30
- it_transforms 'integer', BigDecimal.new(104, 1)
31
- it_transforms 'fractions', BigDecimal.new(100.5, 5)
32
- it_transforms 'rational numbers', BigDecimal.new(Rational(2, 3), 3)
30
+ it_transforms 'integer', BigDecimal(104, 1)
31
+ it_transforms 'fractions', BigDecimal(100.5, 5)
32
+ it_transforms 'rational numbers', BigDecimal(Rational(2, 3), 3)
33
33
  end
34
34
 
35
35
  describe 'for non-BigDecimal arguments' do
36
- it_transforms 'integer', 3, BigDecimal.new(3, 1)
37
- it_transforms 'string', '3.3', BigDecimal.new(3.3, 2)
36
+ it_transforms 'integer', 3, BigDecimal(3, 1)
37
+ it_transforms 'string', '3.3', BigDecimal(3.3, 2)
38
38
 
39
39
  # Match standard BigDecimal behavior for floats
40
40
  it 'raises an argument error for floats' do
@@ -45,4 +45,4 @@ describe Protip::Transformers::BigDecimalTransformer do
45
45
  end
46
46
  end
47
47
  end
48
- end
48
+ end
@@ -5,7 +5,7 @@ require 'protip/transformers/default_transformer'
5
5
  describe Protip::Transformers::DefaultTransformer do
6
6
  describe '#initialize' do
7
7
  it 'initializes without errors' do
8
- transformer = Protip::Transformers::DefaultTransformer.new
8
+ Protip::Transformers::DefaultTransformer.new
9
9
  end
10
10
  end
11
- end
11
+ end
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.33.0
4
+ version: 0.35.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - AngelList
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -16,42 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
19
+ version: 4.2.10
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 5.2.0
29
+ version: 4.2.10
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: activesupport
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 5.2.0
39
+ version: 4.2.10
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: 5.2.0
41
- - !ruby/object:Gem::Dependency
42
- name: google-protobuf
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
49
+ version: 4.2.10
50
+ - - "<"
53
51
  - !ruby/object:Gem::Version
54
- version: '3.0'
52
+ version: '6.0'
55
53
  - !ruby/object:Gem::Dependency
56
54
  name: money
57
55
  requirement: !ruby/object:Gem::Requirement
@@ -72,20 +70,34 @@ dependencies:
72
70
  - - "<"
73
71
  - !ruby/object:Gem::Version
74
72
  version: '7.0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: google-protobuf
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '='
78
+ - !ruby/object:Gem::Version
79
+ version: 3.7.1
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '='
85
+ - !ruby/object:Gem::Version
86
+ version: 3.7.1
75
87
  - !ruby/object:Gem::Dependency
76
88
  name: grpc-tools
77
89
  requirement: !ruby/object:Gem::Requirement
78
90
  requirements:
79
- - - "~>"
91
+ - - '='
80
92
  - !ruby/object:Gem::Version
81
- version: '1.0'
93
+ version: 1.3.4
82
94
  type: :development
83
95
  prerelease: false
84
96
  version_requirements: !ruby/object:Gem::Requirement
85
97
  requirements:
86
- - - "~>"
98
+ - - '='
87
99
  - !ruby/object:Gem::Version
88
- version: '1.0'
100
+ version: 1.3.4
89
101
  - !ruby/object:Gem::Dependency
90
102
  name: minitest
91
103
  requirement: !ruby/object:Gem::Requirement
@@ -106,85 +118,85 @@ dependencies:
106
118
  requirements:
107
119
  - - "~>"
108
120
  - !ruby/object:Gem::Version
109
- version: '0.5'
121
+ version: '0.6'
110
122
  type: :development
111
123
  prerelease: false
112
124
  version_requirements: !ruby/object:Gem::Requirement
113
125
  requirements:
114
126
  - - "~>"
115
127
  - !ruby/object:Gem::Version
116
- version: '0.5'
128
+ version: '0.6'
117
129
  - !ruby/object:Gem::Dependency
118
130
  name: mocha
119
131
  requirement: !ruby/object:Gem::Requirement
120
132
  requirements:
121
133
  - - "~>"
122
134
  - !ruby/object:Gem::Version
123
- version: '1.1'
135
+ version: '1.11'
124
136
  type: :development
125
137
  prerelease: false
126
138
  version_requirements: !ruby/object:Gem::Requirement
127
139
  requirements:
128
140
  - - "~>"
129
141
  - !ruby/object:Gem::Version
130
- version: '1.1'
142
+ version: '1.11'
131
143
  - !ruby/object:Gem::Dependency
132
144
  name: rake
133
145
  requirement: !ruby/object:Gem::Requirement
134
146
  requirements:
135
- - - "~>"
147
+ - - ">="
136
148
  - !ruby/object:Gem::Version
137
- version: '10.0'
149
+ version: 12.3.3
138
150
  type: :development
139
151
  prerelease: false
140
152
  version_requirements: !ruby/object:Gem::Requirement
141
153
  requirements:
142
- - - "~>"
154
+ - - ">="
143
155
  - !ruby/object:Gem::Version
144
- version: '10.0'
156
+ version: 12.3.3
145
157
  - !ruby/object:Gem::Dependency
146
158
  name: simplecov
147
159
  requirement: !ruby/object:Gem::Requirement
148
160
  requirements:
149
161
  - - "~>"
150
162
  - !ruby/object:Gem::Version
151
- version: '0.10'
163
+ version: '0.18'
152
164
  type: :development
153
165
  prerelease: false
154
166
  version_requirements: !ruby/object:Gem::Requirement
155
167
  requirements:
156
168
  - - "~>"
157
169
  - !ruby/object:Gem::Version
158
- version: '0.10'
170
+ version: '0.18'
159
171
  - !ruby/object:Gem::Dependency
160
- name: pry
172
+ name: pry-byebug
161
173
  requirement: !ruby/object:Gem::Requirement
162
174
  requirements:
163
- - - "~>"
175
+ - - ">="
164
176
  - !ruby/object:Gem::Version
165
- version: '0.10'
177
+ version: '0'
166
178
  type: :development
167
179
  prerelease: false
168
180
  version_requirements: !ruby/object:Gem::Requirement
169
181
  requirements:
170
- - - "~>"
182
+ - - ">="
171
183
  - !ruby/object:Gem::Version
172
- version: '0.10'
184
+ version: '0'
173
185
  - !ruby/object:Gem::Dependency
174
186
  name: webmock
175
187
  requirement: !ruby/object:Gem::Requirement
176
188
  requirements:
177
189
  - - "~>"
178
190
  - !ruby/object:Gem::Version
179
- version: 3.3.0
191
+ version: '3'
180
192
  type: :development
181
193
  prerelease: false
182
194
  version_requirements: !ruby/object:Gem::Requirement
183
195
  requirements:
184
196
  - - "~>"
185
197
  - !ruby/object:Gem::Version
186
- version: 3.3.0
187
- description:
198
+ version: '3'
199
+ description:
188
200
  email:
189
201
  - team@angel.co
190
202
  executables: []
@@ -243,6 +255,7 @@ files:
243
255
  - lib/protip/transformers/enum_transformer.rb
244
256
  - lib/protip/transformers/primitives_transformer.rb
245
257
  - lib/protip/transformers/timestamp_transformer.rb
258
+ - lib/protip/version.rb
246
259
  - test/functional/protip/decorator_test.rb
247
260
  - test/functional/protip/resource_test.rb
248
261
  - test/test_helper.rb
@@ -264,7 +277,7 @@ homepage: https://github.com/AngelList/protip
264
277
  licenses:
265
278
  - MIT
266
279
  metadata: {}
267
- post_install_message:
280
+ post_install_message:
268
281
  rdoc_options: []
269
282
  require_paths:
270
283
  - lib
@@ -279,9 +292,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
292
  - !ruby/object:Gem::Version
280
293
  version: '0'
281
294
  requirements: []
282
- rubyforge_project:
283
- rubygems_version: 2.5.2.3
284
- signing_key:
295
+ rubygems_version: 3.0.3
296
+ signing_key:
285
297
  specification_version: 4
286
298
  summary: Resources backed by protobuf messages
287
299
  test_files: []