glia-errors 0.11.11 → 0.13.0

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
2
  SHA256:
3
- metadata.gz: 171865a0d5dbbd2469f022baecf691da4593a50765bbd6032b64641316208d93
4
- data.tar.gz: 4f5520230499c9cdb90ec3276c6092408b04f3d9b3a3574d72100504f6d0d653
3
+ metadata.gz: 75bb40adb6fce2b0a2b5388d30c01d281a87722926709b3a1297a327e5cfb450
4
+ data.tar.gz: d8404ba18f6e9b45035989ae6d22491014b476721195bec83e9217c94114c8c7
5
5
  SHA512:
6
- metadata.gz: a86c2deacb6b53bb3af9701fd2eebe946a11537560dca47230c0b521653e162bf5d452a1d245a8d6d7c12b98a1ebe6d0e290a6de324841d3f476242542b180b3
7
- data.tar.gz: cfde2dbd2c1cc7c973c3b9c335dc536e314619844835abe199b2c49f3e1ef6361185ef5bbca7a05ef3e4fe8899df62be08f2d0d7492de66b518d1db11c2c3482
6
+ metadata.gz: c6892d2c4db86ff5baf559d797255fc3cc5d8617330777c7123cc22be4795bc3a1dff13a2672faa14f75ac659f05f40bd12df18ad3e77b5e396571eaa0a2dddc
7
+ data.tar.gz: 517bbdd25581e00d43da36bc96f19113270fa56535068e5019d3306489e04ff300477197a392bdd0adbfc13535159d1cda17069e3924b659bc3c1439dff5e09d
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
+ gem 'dry-validation', '~> 1.8'
7
8
  gem 'prettier', '~> 0.22'
8
9
  gem 'rake', '~> 13.0'
9
10
  gem 'rspec', '~> 3.10'
@@ -11,9 +12,3 @@ gem 'rubocop', '~> 1.5'
11
12
  gem 'rubocop-rake', '~> 0.5'
12
13
  gem 'rubocop-rspec', '~> 2.0'
13
14
  gem 'super_diff'
14
-
15
- group :test do
16
- gem 'appraisal'
17
- end
18
-
19
- gem 'dry-validation', '~> 1.8'
data/Gemfile.lock CHANGED
@@ -6,10 +6,6 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- appraisal (2.3.0)
10
- bundler
11
- rake
12
- thor (>= 0.14.0)
13
9
  ast (2.4.2)
14
10
  attr_extras (6.2.5)
15
11
  concurrent-ruby (1.1.10)
@@ -90,7 +86,6 @@ GEM
90
86
  attr_extras (>= 6.2.4)
91
87
  diff-lcs
92
88
  patience_diff
93
- thor (1.0.1)
94
89
  unicode-display_width (2.1.0)
95
90
 
96
91
  PLATFORMS
@@ -98,7 +93,6 @@ PLATFORMS
98
93
  x86_64-darwin-19
99
94
 
100
95
  DEPENDENCIES
101
- appraisal
102
96
  dry-validation (~> 1.8)
103
97
  glia-errors!
104
98
  prettier (~> 0.22)
data/README.md CHANGED
@@ -31,9 +31,7 @@ glia_error = Glia::Errors::ResourceNotFoundError.new(resource: :engagement)
31
31
 
32
32
  #### Create Glia error from `dry-validation` result
33
33
 
34
- Currently 2 `dry-validation` versions are supported:
35
- * `v0` up to `0.13`
36
- * `v1` up to `1.8`
34
+ Supports `dry-validation` from `1.6.x` to `1.8.x`
37
35
 
38
36
  ```ruby
39
37
  schema = Dry::Validation.Schema do
@@ -115,27 +113,10 @@ A Github Action will push the `.gem` file to [rubygems.org](https://rubygems.org
115
113
 
116
114
  ### Testing
117
115
 
118
- Glia errors support multiple versions of `dry-validation` and tests are run against each supported major version.
119
- Under the hood we use `Appraisal` gem which generals additional gemfiles for each of the versions.
120
-
121
- To run all tests use:
122
-
123
116
  ```
124
117
  bundle exec rake test
125
118
  ```
126
119
 
127
- To run tests only for `dry-validation` v1:
128
-
129
- ```
130
- bundle exec rake test_dry_validation_v1
131
- ```
132
-
133
- To run tests only for `dry-validation` v0:
134
-
135
- ```
136
- bundle exec rake test_dry_validation_v0
137
- ```
138
-
139
120
  ### Formatting
140
121
 
141
122
  ```
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ RuboCop::RakeTask.new do |task|
11
11
  task.requires << 'rubocop-rspec'
12
12
  end
13
13
 
14
- task default: %i[lint test]
14
+ task default: %i[lint spec]
15
15
 
16
16
  task :lint do
17
17
  sh "rubocop && rbprettier --check '**/*.rb'"
@@ -20,26 +20,3 @@ end
20
20
  task :format do
21
21
  sh "rbprettier --write '**/*.rb'"
22
22
  end
23
-
24
- task :install_test_deps do
25
- sh 'bundle exec appraisal install'
26
- end
27
-
28
- ruby_major_version = RUBY_VERSION.split('.').first.to_i
29
-
30
- # dry-validation 0.x won't load in Ruby 3
31
- if ruby_major_version < 3
32
- task test: %i[test_dry_validation_v1 test_dry_validation_v0]
33
- else
34
- task test: :test_dry_validation_v1
35
- end
36
-
37
- task test_dry_validation_v1: :install_test_deps do
38
- sh 'bundle exec appraisal dry_validation_v1 rspec'
39
- end
40
-
41
- if ruby_major_version < 3
42
- task test_dry_validation_v0: :install_test_deps do
43
- sh 'bundle exec appraisal dry_validation_v0 rspec --tag dry_validation_v0'
44
- end
45
- end
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.11'
8
+ spec.version = '0.13.0'
9
9
  spec.authors = ['Glia TechMovers']
10
10
  spec.email = ['techmovers@glia.com']
11
11
 
@@ -120,7 +120,8 @@ module Glia
120
120
  'is missing' => MISSING_VALUE_ERROR,
121
121
  # Custom format errors
122
122
  'must be in E.164 format' => INVALID_FORMAT_ERROR,
123
- 'must be up to 25 symbol string that contains only 1-7 digits and commas' => INVALID_FORMAT_ERROR,
123
+ 'must be up to 25 symbol string that contains 1-7 digits or hashes and any number of commas' =>
124
+ INVALID_FORMAT_ERROR,
124
125
  'must be a valid email' => INVALID_FORMAT_ERROR
125
126
  }.freeze
126
127
 
data/lib/glia/errors.rb CHANGED
@@ -11,13 +11,14 @@ module Glia
11
11
  module Errors
12
12
  def self.from_dry_validation_result(result, custom_error_map = {})
13
13
  dry_validation_version = Gem.loaded_specs['dry-validation'].version
14
- if dry_validation_version < Gem::Version.new('1.0')
15
- Mapper.from_dry_validation_result(result.output, result.errors, custom_error_map)
16
- elsif dry_validation_version <= Gem::Version.new('2.0')
17
- Mapper.from_dry_validation_result(result.to_h, result.errors.to_h, custom_error_map)
18
- else
14
+
15
+ # When updating supported version ensure that if new version contains new dry-validation new validations
16
+ # that they are correctly mapped to Glia errors in mapper.rb
17
+ unless dry_validation_version >= Gem::Version.new('1.0') && dry_validation_version < Gem::Version.new('1.9')
19
18
  raise 'Unsupported dry-validation version'
20
19
  end
20
+
21
+ Mapper.from_dry_validation_result(result.to_h, result.errors.to_h, custom_error_map)
21
22
  end
22
23
  end
23
24
  end
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.11
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-11 00:00:00.000000000 Z
11
+ date: 2022-11-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email:
@@ -24,13 +24,10 @@ files:
24
24
  - ".rubocop.yml"
25
25
  - ".ruby-version"
26
26
  - ".travis.yml"
27
- - Appraisals
28
27
  - Gemfile
29
28
  - Gemfile.lock
30
29
  - README.md
31
30
  - Rakefile
32
- - gemfiles/dry_validation_v0.gemfile
33
- - gemfiles/dry_validation_v1.gemfile
34
31
  - glia-errors.gemspec
35
32
  - lib/glia/errors.rb
36
33
  - lib/glia/errors/client_errors.rb
data/Appraisals DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ruby_major_version = RUBY_VERSION.split('.').first.to_i
4
-
5
- if ruby_major_version < 3
6
- appraise 'dry_validation_v0' do
7
- gem 'dry-container', '~> 0.8.0'
8
- gem 'dry-core', '~> 0.5.0'
9
- gem 'dry-validation', '~> 0.13.0'
10
- end
11
- end
12
-
13
- appraise 'dry_validation_v1' do
14
- gem 'dry-validation', '~> 1.8'
15
- end
@@ -1,20 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "prettier", "~> 0.22"
6
- gem "rake", "~> 13.0"
7
- gem "rspec", "~> 3.10"
8
- gem "rubocop", "~> 1.5"
9
- gem "rubocop-rake", "~> 0.5"
10
- gem "rubocop-rspec", "~> 2.0"
11
- gem "super_diff"
12
- gem "dry-validation", "~> 0.13.0"
13
- gem "dry-container", "~> 0.8.0"
14
- gem "dry-core", "~> 0.5.0"
15
-
16
- group :test do
17
- gem "appraisal"
18
- end
19
-
20
- gemspec path: "../"
@@ -1,18 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "prettier", "~> 0.22"
6
- gem "rake", "~> 13.0"
7
- gem "rspec", "~> 3.10"
8
- gem "rubocop", "~> 1.5"
9
- gem "rubocop-rake", "~> 0.5"
10
- gem "rubocop-rspec", "~> 2.0"
11
- gem "super_diff"
12
- gem "dry-validation", "~> 1.8"
13
-
14
- group :test do
15
- gem "appraisal"
16
- end
17
-
18
- gemspec path: "../"