glia-errors 0.11.10 → 0.11.11

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: 182a479821307d1d9b7fd5b1ba47ee4bbeb5cb8c69c6e58963d387b8b383b92b
4
- data.tar.gz: 988265708f5ed2a46d14a05c39ec2b526f27ef540959f5d234a749cb7290c8b5
3
+ metadata.gz: 171865a0d5dbbd2469f022baecf691da4593a50765bbd6032b64641316208d93
4
+ data.tar.gz: 4f5520230499c9cdb90ec3276c6092408b04f3d9b3a3574d72100504f6d0d653
5
5
  SHA512:
6
- metadata.gz: c83b5503cd6904ac367f1afbebcdf9e45a380bdaacb28d0ff10a414ef68cffd2d7ea8dbf227b1577427108c5ced9a636c5cf4fe71500adbfe20a2981e5fccf5b
7
- data.tar.gz: 594b6ab2e41d8219cfe587db80e5c04684b780f7c9eb74dcc90289c84ccd2ecfcf49a942ba74ce64d042b5039895a7c9831397682933131284496d030c281e33
6
+ metadata.gz: a86c2deacb6b53bb3af9701fd2eebe946a11537560dca47230c0b521653e162bf5d452a1d245a8d6d7c12b98a1ebe6d0e290a6de324841d3f476242542b180b3
7
+ data.tar.gz: cfde2dbd2c1cc7c973c3b9c335dc536e314619844835abe199b2c49f3e1ef6361185ef5bbca7a05ef3e4fe8899df62be08f2d0d7492de66b518d1db11c2c3482
data/.prettierrc CHANGED
@@ -1 +1 @@
1
- printWidth: 100
1
+ printWidth: 120
data/Appraisals CHANGED
@@ -4,6 +4,7 @@ ruby_major_version = RUBY_VERSION.split('.').first.to_i
4
4
 
5
5
  if ruby_major_version < 3
6
6
  appraise 'dry_validation_v0' do
7
+ gem 'dry-container', '~> 0.8.0'
7
8
  gem 'dry-core', '~> 0.5.0'
8
9
  gem 'dry-validation', '~> 0.13.0'
9
10
  end
data/README.md CHANGED
@@ -106,6 +106,11 @@ else
106
106
  end
107
107
  ```
108
108
 
109
+ ## Releasing a new version
110
+
111
+ A new version is created when a change is merged into the master branch that changes the version number in `glia-errors.gemspec`.
112
+ A Github Action will push the `.gem` file to [rubygems.org](https://rubygems.org)
113
+
109
114
  ## Contributing
110
115
 
111
116
  ### Testing
@@ -10,6 +10,7 @@ gem "rubocop-rake", "~> 0.5"
10
10
  gem "rubocop-rspec", "~> 2.0"
11
11
  gem "super_diff"
12
12
  gem "dry-validation", "~> 0.13.0"
13
+ gem "dry-container", "~> 0.8.0"
13
14
  gem "dry-core", "~> 0.5.0"
14
15
 
15
16
  group :test do
data/glia-errors.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'glia-errors'
8
- spec.version = '0.11.10'
8
+ spec.version = '0.11.11'
9
9
  spec.authors = ['Glia TechMovers']
10
10
  spec.email = ['techmovers@glia.com']
11
11
 
@@ -62,11 +62,7 @@ module Glia
62
62
 
63
63
  def initialize(field:, format: nil, message: nil)
64
64
  default_message =
65
- if format
66
- "has invalid format, required format is #{humanize_format(format)}"
67
- else
68
- 'has invalid format'
69
- end
65
+ format ? "has invalid format, required format is #{humanize_format(format)}" : 'has invalid format'
70
66
  super(
71
67
  type: INVALID_FORMAT_ERROR,
72
68
  ref: create_ref(INVALID_FORMAT_ERROR),
@@ -261,9 +257,7 @@ module Glia
261
257
  class RouteNotFoundError < Error
262
258
  def initialize(message: nil)
263
259
  super(
264
- type: ROUTE_NOT_FOUND_ERROR,
265
- ref: create_ref(ROUTE_NOT_FOUND_ERROR),
266
- message: message || 'Route not found'
260
+ type: ROUTE_NOT_FOUND_ERROR, ref: create_ref(ROUTE_NOT_FOUND_ERROR), message: message || 'Route not found'
267
261
  )
268
262
  end
269
263
  end
@@ -281,9 +275,7 @@ module Glia
281
275
  class CarrierError < Error
282
276
  def initialize(message: nil)
283
277
  super(
284
- type: CARRIER_ERROR,
285
- ref: create_ref(CARRIER_ERROR),
286
- message: message || 'Downstream carrier issue occurred'
278
+ type: CARRIER_ERROR, ref: create_ref(CARRIER_ERROR), message: message || 'Downstream carrier issue occurred'
287
279
  )
288
280
  end
289
281
  end
@@ -417,6 +409,25 @@ module Glia
417
409
  end
418
410
  end
419
411
 
412
+ class ItemsOverlapError < Error
413
+ def initialize(overlapping_item_indexes:, message: nil)
414
+ raise ArgumentError, 'overlapping_item_indexes value must be list' unless overlapping_item_indexes.is_a?(Array)
415
+
416
+ raise ArgumentError, 'at least 2 overlapping item indexes are required' if overlapping_item_indexes.size < 2
417
+
418
+ overlapping_item_indexes.each do |value|
419
+ raise ArgumentError, 'overlapping_item_indexes values must be integers' unless value.is_a?(Integer)
420
+ end
421
+
422
+ super(
423
+ type: ITEMS_OVERLAP_ERROR,
424
+ ref: create_ref(ITEMS_OVERLAP_ERROR),
425
+ message: message || 'Items must not overlap each other',
426
+ error_details: { overlapping_item_indexes: overlapping_item_indexes }
427
+ )
428
+ end
429
+ end
430
+
420
431
  # rubocop:enable Style/Documentation
421
432
  end
422
433
  end
@@ -16,9 +16,7 @@ module Glia
16
16
  end
17
17
 
18
18
  def to_h
19
- {
20
- type: type, ref: ref, message: message, error_details: error_details_to_h(@error_details)
21
- }.compact
19
+ { type: type, ref: ref, message: message, error_details: error_details_to_h(@error_details) }.compact
22
20
  end
23
21
 
24
22
  private
@@ -27,9 +25,7 @@ module Glia
27
25
  return details if primitive?(details)
28
26
 
29
27
  if details.is_a?(Hash)
30
- details.keys.each_with_object({}) do |field, hash|
31
- hash[field] = error_details_to_h(details[field])
32
- end
28
+ details.keys.each_with_object({}) { |field, hash| hash[field] = error_details_to_h(details[field]) }
33
29
  elsif details.is_a?(Array)
34
30
  details.map { |error| error_details_to_h(error) }
35
31
  elsif details.respond_to?(:to_h)
@@ -40,8 +36,7 @@ module Glia
40
36
  end
41
37
 
42
38
  def primitive?(details)
43
- details.nil? ||
44
- [TrueClass, FalseClass, String, Integer, Float, Symbol].include?(details.class)
39
+ details.nil? || [TrueClass, FalseClass, String, Integer, Float, Symbol].include?(details.class)
45
40
  end
46
41
 
47
42
  def create_ref(type)
@@ -34,8 +34,8 @@ module Glia
34
34
  FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR = 'facebook_access_token_not_permanent_error'
35
35
  OAUTH_CODE_EXPIRED_ERROR = 'oauth_code_expired_error'
36
36
  OAUTH_CODE_ALREADY_USED_ERROR = 'oauth_code_already_used_error'
37
- APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR =
38
- 'apple_business_chat_business_used_by_other_site_error'
37
+ APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR = 'apple_business_chat_business_used_by_other_site_error'
38
+ ITEMS_OVERLAP_ERROR = 'items_overlap_error'
39
39
 
40
40
  # Server errors
41
41
  INTERNAL_SERVER_ERROR = 'internal_server_error'
@@ -12,8 +12,7 @@ module Glia
12
12
  InvalidTypeError::Types::ARRAY
13
13
  when 'must be an integer', 'must be Integer'
14
14
  InvalidTypeError::Types::INTEGER
15
- when 'must be a number', 'must be a float', 'must be a decimal', 'must be Float',
16
- 'must be BigDecimal'
15
+ when 'must be a number', 'must be a float', 'must be a decimal', 'must be Float', 'must be BigDecimal'
17
16
  InvalidTypeError::Types::NUMBER
18
17
  when 'must be a hash', 'must be Hash'
19
18
  InvalidTypeError::Types::OBJECT
@@ -39,11 +38,7 @@ module Glia
39
38
  # so we are separating them ourselves
40
39
  INVALID_NUMBER_OR_VALUE_ERROR =
41
40
  lambda do |field, value, _message|
42
- if value.is_a?(String)
43
- InvalidValueError.new(field: field)
44
- else
45
- InvalidNumberError.new(field: field)
46
- end
41
+ value.is_a?(String) ? InvalidValueError.new(field: field) : InvalidNumberError.new(field: field)
47
42
  end
48
43
 
49
44
  INVALID_DATE_FORMAT =
@@ -125,8 +120,7 @@ module Glia
125
120
  'is missing' => MISSING_VALUE_ERROR,
126
121
  # Custom format errors
127
122
  'must be in E.164 format' => INVALID_FORMAT_ERROR,
128
- 'must be up to 25 symbol string that contains only 1-7 digits and commas' =>
129
- INVALID_FORMAT_ERROR,
123
+ 'must be up to 25 symbol string that contains only 1-7 digits and commas' => INVALID_FORMAT_ERROR,
130
124
  'must be a valid email' => INVALID_FORMAT_ERROR
131
125
  }.freeze
132
126
 
@@ -146,9 +140,7 @@ module Glia
146
140
  # This is not needed for the `else` case as dry-validation already provides an array.
147
141
  [from_dry_validation_result_rec(field_value, field_messages, error_map)]
148
142
  else
149
- field_messages.map do |message|
150
- from_dry_validation_error(field, field_value, message, error_map)
151
- end
143
+ field_messages.map { |message| from_dry_validation_error(field, field_value, message, error_map) }
152
144
  end
153
145
  end
154
146
  InputValidationError.new(error_details: error_details)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glia-errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.10
4
+ version: 0.11.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-10 00:00:00.000000000 Z
11
+ date: 2022-10-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email:
@@ -39,11 +39,11 @@ files:
39
39
  - lib/glia/errors/mapper.rb
40
40
  - lib/glia/errors/naming.rb
41
41
  - lib/glia/errors/server_errors.rb
42
- homepage:
42
+ homepage:
43
43
  licenses:
44
44
  - MIT
45
45
  metadata: {}
46
- post_install_message:
46
+ post_install_message:
47
47
  rdoc_options: []
48
48
  require_paths:
49
49
  - lib
@@ -61,8 +61,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  requirements: []
64
- rubygems_version: 3.3.7
65
- signing_key:
64
+ rubygems_version: 3.1.2
65
+ signing_key:
66
66
  specification_version: 4
67
67
  summary: Glia REST API errors
68
68
  test_files: []