lucid-shopify 0.62.0 → 0.63.0

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
  SHA256:
3
- metadata.gz: e66a0c2dcd13c2a44f4200675e90d3f90199fee2a199d6be48fb52ceaffab607
4
- data.tar.gz: f9d500101e5a5cae6a1f6d5de0eac6a737d5e4b7f83127e353db267f68d0d01a
3
+ metadata.gz: 64a496caf54972765537cc4b855f189aca434633532751a0e7fea98bb2d1b88a
4
+ data.tar.gz: 233680126ea1eef07851305fdff2e33d194892a51ad61898f19c81f636224cd5
5
5
  SHA512:
6
- metadata.gz: b9ef5945b9bf554b1826b028ddca3492c106d0c661f1a4ab7c4286a0daddd6d583043c239fd71c6803b14a17c18e3449dd07f9493faed5bc0098d13da73139a1
7
- data.tar.gz: 25b6dc870fff5fbc006f1654793e1ab4a35159956c7f5361584e16ecca8ce7664c8f1254c108a40178e8682a2e81b067132e59e7f688b5365956508aea87f05f
6
+ metadata.gz: cc6206e1bffc144cfc56a0c3413196e693a52a1a998aef65368cc4ca5e513e8bbfef94601292a2b3cf96def27aa5c1ee4003dbd4afb79388de3d50c4b4088ea3
7
+ data.tar.gz: 8d546eaa76261554880a7695f1c559510d720e3f23de8c3b5baa4e23f1db885cbd2c1991c2ea7137e58dae0c1c2237612b50d1d44cefc98fb24326b3d214c91e
@@ -14,6 +14,8 @@ module Lucid
14
14
  FailedOperationError = Class.new(OperationError)
15
15
  ObsoleteOperationError = Class.new(OperationError)
16
16
 
17
+ TimeoutError = Class.new(Error)
18
+
17
19
  class Operation
18
20
  include Dry::Initializer.define -> do
19
21
  # @return [Client]
@@ -32,6 +34,11 @@ module Lucid
32
34
  # @param http [HTTP::Client]
33
35
  #
34
36
  # @yield [Enumerator<Hash>] yields each parsed line of JSONL
37
+ #
38
+ # @raise CanceledOperationError
39
+ # @raise ExpiredOperationError
40
+ # @raise FailedOperationError
41
+ # @raise ObsoleteOperationError
35
42
  def call(delay: 1, http: Container[:http], &block)
36
43
  url = loop do
37
44
  status, url = poll
@@ -71,6 +78,9 @@ module Lucid
71
78
  end
72
79
 
73
80
  # Cancel the bulk operation.
81
+ #
82
+ # @raise ObsoleteOperationError
83
+ # @raise TimeoutError
74
84
  def cancel
75
85
  begin
76
86
  client.post_graphql(credentials, <<~QUERY)
@@ -96,25 +106,24 @@ module Lucid
96
106
 
97
107
  # Poll until operation status is met.
98
108
  #
99
- # @param statuses [Array<Regexp, String>] to terminate polling on
109
+ # @param statuses [Array<String>] to terminate polling on
100
110
  # @param timeout [Integer] in seconds
101
111
  #
102
- # @raise Timeout::Error
112
+ # @raise ObsoleteOperationError
113
+ # @raise TimeoutError
103
114
  def poll_until(statuses, timeout: 60)
104
115
  Timeout.timeout(timeout) do
105
116
  loop do
106
117
  status, _ = poll
107
118
 
108
- break if statuses.any? do |expected_status|
109
- case expected_status
110
- when Regexp
111
- status.match?(expected_status)
112
- when String
113
- status == expected_status
114
- end
115
- end
119
+ break if statuses.any? { |expected_status| status == expected_status }
116
120
  end
117
121
  end
122
+ rescue Timeout::Error
123
+ raise TimeoutError, 'exceeded %s seconds polling for status %s' % [
124
+ timeout,
125
+ statuses.join(', '),
126
+ ]
118
127
  end
119
128
 
120
129
  # @return [Array(String, String | nil)] the operation status and the
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lucid
4
4
  module Shopify
5
- VERSION = '0.62.0'
5
+ VERSION = '0.63.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucid-shopify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.62.0
4
+ version: 0.63.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelsey Judson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-22 00:00:00.000000000 Z
11
+ date: 2020-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv