terminal-shop 2.1.0 → 2.1.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
  SHA256:
3
- metadata.gz: fc09a5779386790999a7439865ea22d8e82c09d0048c9116ff0d55a74f9f14ca
4
- data.tar.gz: 15901e6cbfb87f75a4e4c662b22c8de824518353b81529bc6dc14b65b3d84325
3
+ metadata.gz: 54c0b0033036302e9ea998b80699f3a8947a0438aa0354013d3f43830b5b29a9
4
+ data.tar.gz: 545054c9b181d799dc8c1f0a420a095149d156b0dc789af5dd7c729247b3010d
5
5
  SHA512:
6
- metadata.gz: 15e48a9e13e6a2ff9afe005aa2663e2c3fd19b2f35490277d2eb4e2578bcc3eb8a26e0693efdc32f03700f485adfaa43bd4c52f87ee11dc3ae4b900fb1940d69
7
- data.tar.gz: 4842e7a98db1fe06a240c121366ad656064e9bca721ffee7c56ecaf12882913aafb9e3785f9078d2b11912f9b5ed59c4479bdc69b9b8a7adb86eaf2acd180ce2
6
+ metadata.gz: 6506991e3b923b599db1c2872edb5301d461f35f2bb1efd018472f6b318b1d06a2f5a577a05e76693eb1639de8262d8fd564c87e7ef186eb08f9c8d2a3010556
7
+ data.tar.gz: 7c7e72acd2d2de78683b47a85e6ab89e471d2ad51d005355fae9adc1f699c774fb5f06f5993473e6a203c0bbbb5ca6bda264ac2cd5127546ccd90d1cc04aec21
data/README.md CHANGED
@@ -15,7 +15,7 @@ The underlying REST API documentation can be found on [terminal.shop](https://te
15
15
  To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
16
16
 
17
17
  ```ruby
18
- gem "terminal-shop", "~> 2.0.0"
18
+ gem "terminal-shop", "~> 2.1.0"
19
19
  ```
20
20
 
21
21
  To fetch an initial copy of the gem:
@@ -17,7 +17,7 @@ module TerminalShop
17
17
 
18
18
  # rubocop:disable Style/MutableConstant
19
19
  # @type [Hash{Symbol=>String}]
20
- ENVIRONMENTS = {production: "https://api.terminal.shop/", dev: "https://api.dev.terminal.shop/"}
20
+ ENVIRONMENTS = {production: "https://api.terminal.shop", dev: "https://api.dev.terminal.shop"}
21
21
  # rubocop:enable Style/MutableConstant
22
22
 
23
23
  # @return [String]
@@ -74,8 +74,8 @@ module TerminalShop
74
74
  #
75
75
  # Each environment maps to a different base URL:
76
76
  #
77
- # - `production` corresponds to `https://api.terminal.shop/`
78
- # - `dev` corresponds to `https://api.dev.terminal.shop/`
77
+ # - `production` corresponds to `https://api.terminal.shop`
78
+ # - `dev` corresponds to `https://api.dev.terminal.shop`
79
79
  #
80
80
  # @param base_url [String, nil] Override the default base URL for the API, e.g., `"https://api.example.com/v2/"`
81
81
  #
@@ -54,7 +54,7 @@ module TerminalShop
54
54
  #
55
55
  # @yieldparam [String]
56
56
  # @return [Net::HTTPGenericRequest]
57
- def build_request(request, &)
57
+ def build_request(request, &blk)
58
58
  method, url, headers, body = request.fetch_values(:method, :url, :headers, :body)
59
59
  req = Net::HTTPGenericRequest.new(
60
60
  method.to_s.upcase,
@@ -70,13 +70,13 @@ module TerminalShop
70
70
  nil
71
71
  in String
72
72
  req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"]
73
- req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
73
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &blk)
74
74
  in StringIO
75
75
  req["content-length"] ||= body.size.to_s unless req["transfer-encoding"]
76
- req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
76
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &blk)
77
77
  in IO | Enumerator
78
78
  req["transfer-encoding"] ||= "chunked" unless req["content-length"]
79
- req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
79
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &blk)
80
80
  end
81
81
 
82
82
  req
@@ -31,7 +31,9 @@ module TerminalShop
31
31
  # @param other [Object]
32
32
  #
33
33
  # @return [Boolean]
34
- def ==(other) = other.is_a?(TerminalShop::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type
34
+ def ==(other)
35
+ other.is_a?(TerminalShop::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type
36
+ end
35
37
 
36
38
  # @api private
37
39
  #
@@ -101,7 +101,9 @@ module TerminalShop
101
101
  end
102
102
  rescue StandardError
103
103
  cls = self.class.name.split("::").last
104
+ # rubocop:disable Layout/LineLength
104
105
  message = "Failed to parse #{cls}.#{__method__} from #{value.class} to #{target.inspect}. To get the unparsed API response, use #{cls}[:#{__method__}]."
106
+ # rubocop:enable Layout/LineLength
105
107
  raise TerminalShop::ConversionError.new(message)
106
108
  end
107
109
  end
@@ -212,14 +214,13 @@ module TerminalShop
212
214
  instance = new
213
215
  data = instance.to_h
214
216
 
217
+ # rubocop:disable Metrics/BlockLength
215
218
  fields.each do |name, field|
216
219
  mode, required, target = field.fetch_values(:mode, :required, :type)
217
220
  api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const)
218
221
 
219
222
  unless val.key?(api_name)
220
- if const != TerminalShop::Util::OMIT
221
- exactness[:yes] += 1
222
- elsif required && mode != :dump
223
+ if required && mode != :dump && const == TerminalShop::Util::OMIT
223
224
  exactness[nilable ? :maybe : :no] += 1
224
225
  else
225
226
  exactness[:yes] += 1
@@ -245,6 +246,7 @@ module TerminalShop
245
246
  end
246
247
  data.store(name, converted)
247
248
  end
249
+ # rubocop:enable Metrics/BlockLength
248
250
 
249
251
  keys.each { data.store(_1, val.fetch(_1)) }
250
252
  instance
@@ -36,7 +36,7 @@ module TerminalShop
36
36
  # @param blk [Proc]
37
37
  #
38
38
  # @return [void]
39
- def auto_paging_each(&) = (raise NotImplementedError)
39
+ def auto_paging_each(&blk) = (raise NotImplementedError)
40
40
 
41
41
  # @return [Enumerable]
42
42
  def to_enum = super(:auto_paging_each)
@@ -46,7 +46,9 @@ module TerminalShop
46
46
  # @param other [Object]
47
47
  #
48
48
  # @return [Boolean]
49
- def ==(other) = other.is_a?(TerminalShop::HashOf) && other.nilable? == nilable? && other.item_type == item_type
49
+ def ==(other)
50
+ other.is_a?(TerminalShop::HashOf) && other.nilable? == nilable? && other.item_type == item_type
51
+ end
50
52
 
51
53
  # @api private
52
54
  #
@@ -99,7 +99,9 @@ module TerminalShop
99
99
  #
100
100
  # @return [Boolean]
101
101
  def ==(other)
102
+ # rubocop:disable Layout/LineLength
102
103
  other.is_a?(Module) && other.singleton_class <= TerminalShop::Union && other.derefed_variants == derefed_variants
104
+ # rubocop:enable Layout/LineLength
103
105
  end
104
106
 
105
107
  # @api private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TerminalShop
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.1"
5
5
  end
data/lib/terminal-shop.rb CHANGED
@@ -1,21 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # We already ship the preferred sorbet manifests in the package itself.
4
- # `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
5
- if Object.const_defined?(:Tapioca) && caller.chain([$0]).chain(ARGV).grep(/tapioca/)
6
- Warning.warn(
7
- <<~WARN
8
- \n
9
- ⚠️ skipped loading of "terminal-shop" gem under `tapioca`.
10
-
11
- This message is normal and expected if you are running a `tapioca` command, and does not impact `.rbi` generation.
12
- \n
13
- WARN
14
- )
15
- return
16
- end
17
-
18
3
  # Standard libraries.
4
+ require "English"
19
5
  require "cgi"
20
6
  require "date"
21
7
  require "erb"
@@ -30,6 +16,21 @@ require "stringio"
30
16
  require "time"
31
17
  require "uri"
32
18
 
19
+ # We already ship the preferred sorbet manifests in the package itself.
20
+ # `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
21
+ if Object.const_defined?(:Tapioca) && caller.chain([$PROGRAM_NAME]).chain(ARGV).grep(/tapioca/)
22
+ Warning.warn(
23
+ <<~WARN
24
+ \n
25
+ ⚠️ skipped loading of "terminal-shop" gem under `tapioca`.
26
+
27
+ This message is normal and expected if you are running a `tapioca` command, and does not impact `.rbi` generation.
28
+ \n
29
+ WARN
30
+ )
31
+ return
32
+ end
33
+
33
34
  # Gems.
34
35
  require "connection_pool"
35
36
 
data/manifest.yaml CHANGED
@@ -1,4 +1,5 @@
1
1
  dependencies:
2
+ - English
2
3
  - cgi
3
4
  - date
4
5
  - erb
@@ -12,7 +12,7 @@ module TerminalShop
12
12
 
13
13
  ENVIRONMENTS =
14
14
  T.let(
15
- {production: "https://api.terminal.shop/", dev: "https://api.dev.terminal.shop/"},
15
+ {production: "https://api.terminal.shop", dev: "https://api.dev.terminal.shop"},
16
16
  T::Hash[Symbol, String]
17
17
  )
18
18
 
@@ -79,8 +79,8 @@ module TerminalShop
79
79
  #
80
80
  # Each environment maps to a different base URL:
81
81
  #
82
- # - `production` corresponds to `https://api.terminal.shop/`
83
- # - `dev` corresponds to `https://api.dev.terminal.shop/`
82
+ # - `production` corresponds to `https://api.terminal.shop`
83
+ # - `dev` corresponds to `https://api.dev.terminal.shop`
84
84
  environment: nil,
85
85
  # Override the default base URL for the API, e.g., `"https://api.example.com/v2/"`
86
86
  base_url: nil,
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module TerminalShop
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.1"
5
5
  end
@@ -9,8 +9,8 @@ module TerminalShop
9
9
  DEFAULT_MAX_RETRY_DELAY: Float
10
10
 
11
11
  ENVIRONMENTS: {
12
- production: "https://api.terminal.shop/",
13
- dev: "https://api.dev.terminal.shop/"
12
+ production: "https://api.terminal.shop",
13
+ dev: "https://api.dev.terminal.shop"
14
14
  }
15
15
 
16
16
  attr_reader bearer_token: String
@@ -1,3 +1,3 @@
1
1
  module TerminalShop
2
- VERSION: "2.0.0"
2
+ VERSION: "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal-shop
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terminal