lite-errors 1.0.0 → 1.2.1

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: 236ce284b55e8fb17579794dd0ca284984b704247aeb9ea851fee63d4d6f889c
4
- data.tar.gz: febe41cb7f6f8cccfbb81bcd7a52c8cf871f4afb39eeef6469b93d531402ecb1
3
+ metadata.gz: b4e55e67121bd0714d5d257f6dc8f18594bc6574be342f690e7ca7ca1a13ab6a
4
+ data.tar.gz: 598621346197312d6592bf5b89646cd2f5d4c21266cd0a835acb9e13fbc7740f
5
5
  SHA512:
6
- metadata.gz: ed7f3dfa023d44e685f3739797d0508c2be16ed79cc8b1fb9219b508efd99cff82a11774a763eb920072a246410d1d796a9e4686af4903ba05caa3ea4ddf3083
7
- data.tar.gz: acba5684831c8a132e5dcfcc63b85900e4761b410e6274de66c6c892ecbf940a6d138f7589f6aeecf8584ae06e5900835eeb239cb90d64f87bdd99b547b56a00
6
+ metadata.gz: 13dc4a2f02b602c63a2a123501b32412f4b3a56a43b057cadb030cbda55c79bba2dac9617e88dbdacecfed4d0f1930ead827bd23ef7469c418f738d69010a4ef
7
+ data.tar.gz: db7e8f0e084c1312ccd8b7c2591460f237430f253755fcd7dec5c6d442f31d29ada32bd60a1849eee2f8076ce9b68041a4d876809d48c698fc592fc85a3b78df
data/.rubocop.yml CHANGED
@@ -1,21 +1,37 @@
1
1
  require:
2
2
  - rubocop-performance
3
+ - rubocop-rake
3
4
  - rubocop-rspec
4
5
  AllCops:
5
- TargetRubyVersion: 2.6
6
+ TargetRubyVersion: 3.0
7
+ NewCops: enable
6
8
  DisplayCopNames: true
7
9
  DisplayStyleGuide: true
8
- LineLength:
9
- Max: 100
10
+ Gemspec/RequiredRubyVersion:
11
+ Enabled: false
12
+ Layout/EmptyLinesAroundAttributeAccessor:
13
+ Enabled: true
10
14
  Layout/EmptyLinesAroundBlockBody:
11
15
  Exclude:
12
16
  - 'spec/**/**/*'
13
17
  Layout/EmptyLinesAroundClassBody:
14
- EnforcedStyle: empty_lines
18
+ EnforcedStyle: empty_lines_except_namespace
19
+ Layout/EmptyLinesAroundModuleBody:
20
+ EnforcedStyle: empty_lines_except_namespace
21
+ Layout/LineLength:
22
+ Max: 100
23
+ Layout/SpaceAroundMethodCallOperator:
24
+ Enabled: true
25
+ Lint/RaiseException:
26
+ Enabled: true
27
+ Lint/StructNewOverride:
28
+ Enabled: true
15
29
  Metrics/BlockLength:
16
30
  Exclude:
17
31
  - 'spec/**/**/*'
18
32
  - '*.gemspec'
33
+ Style/ArgumentsForwarding:
34
+ Enabled: false
19
35
  Style/Documentation:
20
36
  Enabled: false
21
37
  Style/ExpandPathArguments:
data/.travis.yml CHANGED
@@ -1,20 +1,25 @@
1
- ---
2
1
  sudo: false
3
2
  language: ruby
4
3
  cache: bundler
5
4
  rvm:
6
- - 2.5
7
- - 2.6
8
- - ruby-head
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
8
+ - ruby-head
9
9
  matrix:
10
10
  fast_finish: true
11
11
  allow_failures:
12
- - rvm: ruby-head
12
+ - rvm: ruby-head
13
13
  before_install:
14
- - gem update --system
15
- - gem install bundler
14
+ - gem update --system
15
+ - gem install bundler
16
16
  install:
17
- - bundle install --jobs=3 --retry=3
17
+ - bundle install --jobs=3 --retry=3
18
18
  script:
19
- - bundle exec rspec
20
- # - bundle exec fasterer
19
+ - bundle exec rspec
20
+ - bundle exec rubocop
21
+ # - bundle exec fasterer
22
+ notifications:
23
+ email: false
24
+ slack:
25
+ secure: CYSB+0IcRuv8gars8cBZHz046TCYUpijTZj/Z1FsaF7JRe0QP3XlcaPC9bowc0utXitMRuW1E1h9VbmtmN5NP2gNNj93xfIMUorhEUUiyfruYqQb/lq9IxLC113WppFXT31MXgmk7cpsEx8uxagPURFZpaicURK/MiW1af3D2o3snvJqxAVe8XQGJt3IUj2xteYqPJO1G1Zbk5MFK0J53BIPWB8Mm2wV9NwNcRkJ6szuiIB35tLrcGjfQljayfOWUq+Bj2IuChDfMlcH8no+79m/+7XL7/Kao6S/zmaIA26uURyZdDkyeHr8fX6hlraOv8XKf6FZ8XqSSfJ/8vC2DX/ooausdvJ3cNAf9iaxURyqNeisiQ6IsQtr+70KvXW8Ko5V1Y8fh/nIy9L7swgIkh9n7Gb9lWNL15DNxPU0Ooaqm85qGpoHH7wVmf5565YXdClSwXqk/js/6ZmKri//35PlrxiGAm7sDuIqbwz4aIY+tVfQeT/dcuHZ6lAb2/eMd3WGxj+TqSQHok+1cla8l8T+xuMS6Mw81aur8bwUT+aiWMnbQrR0BnItG8bUEG2Ha8LukluBbT7Jdlv5fE0jWeg9TgqZ09uKGsarc2FkeWHSqF1627HCsPLWEQEYx7unMK5bmOtgl9lJE1MmpZ0wWHjg4IOhWsbhqvYz1iUNWc0=
data/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.1] - 2021-07-22
10
+ ### Changed
11
+ - Improved setup
12
+
13
+ ## [1.2.0] - 2021-07-19
14
+ ### Added
15
+ - Added Ruby 3.0 support
16
+
17
+ ## [1.1.0] - 2021-06-03
18
+ ### Added
19
+ - Added methods for Rails 6.1 changes
20
+
21
+ ## [1.0.1] - 2019-06-24
22
+ ### Added
23
+ - Added ruby 2.7 support
24
+ ### Changed
25
+ - Changed `slice!` method to accept multiple args
26
+
9
27
  ## [1.0.0] - 2019-06-24
10
28
  ### Added
11
29
  - Initial project version
data/Gemfile.lock CHANGED
@@ -1,78 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-errors (1.0.0)
4
+ lite-errors (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.0)
10
- axiom-types (0.1.1)
11
- descendants_tracker (~> 0.0.4)
12
- ice_nine (~> 0.11.0)
13
- thread_safe (~> 0.3, >= 0.3.1)
14
- codeclimate-engine-rb (0.4.1)
15
- virtus (~> 1.0)
16
- coercible (1.0.0)
17
- descendants_tracker (~> 0.0.1)
9
+ ast (2.4.2)
18
10
  colorize (0.8.1)
19
- descendants_tracker (0.0.4)
20
- thread_safe (~> 0.3, >= 0.3.1)
21
- diff-lcs (1.3)
22
- equalizer (0.0.11)
23
- fasterer (0.5.1)
11
+ diff-lcs (1.4.4)
12
+ fasterer (0.9.0)
24
13
  colorize (~> 0.7)
25
- ruby_parser (>= 3.13.0)
26
- ice_nine (0.11.2)
27
- jaro_winkler (1.5.3)
28
- kwalify (0.7.2)
29
- parallel (1.17.0)
30
- parser (2.6.3.0)
31
- ast (~> 2.4.0)
32
- psych (3.1.0)
14
+ ruby_parser (>= 3.14.1)
15
+ parallel (1.20.1)
16
+ parser (3.0.2.0)
17
+ ast (~> 2.4.1)
33
18
  rainbow (3.0.0)
34
- rake (12.3.2)
35
- reek (5.4.0)
36
- codeclimate-engine-rb (~> 0.4.0)
37
- kwalify (~> 0.7.0)
38
- parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
39
- psych (~> 3.1.0)
40
- rainbow (>= 2.0, < 4.0)
41
- rspec (3.8.0)
42
- rspec-core (~> 3.8.0)
43
- rspec-expectations (~> 3.8.0)
44
- rspec-mocks (~> 3.8.0)
45
- rspec-core (3.8.1)
46
- rspec-support (~> 3.8.0)
47
- rspec-expectations (3.8.4)
19
+ rake (13.0.6)
20
+ regexp_parser (2.1.1)
21
+ rexml (3.2.5)
22
+ rspec (3.10.0)
23
+ rspec-core (~> 3.10.0)
24
+ rspec-expectations (~> 3.10.0)
25
+ rspec-mocks (~> 3.10.0)
26
+ rspec-core (3.10.1)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-expectations (3.10.1)
48
29
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-mocks (3.8.1)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-mocks (3.10.2)
51
32
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-support (3.8.2)
54
- rubocop (0.71.0)
55
- jaro_winkler (~> 1.5.1)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-support (3.10.2)
35
+ rubocop (1.18.3)
56
36
  parallel (~> 1.10)
57
- parser (>= 2.6)
37
+ parser (>= 3.0.0.0)
58
38
  rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 1.8, < 3.0)
40
+ rexml
41
+ rubocop-ast (>= 1.7.0, < 2.0)
59
42
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 1.7)
61
- rubocop-performance (1.4.0)
62
- rubocop (>= 0.71.0)
63
- rubocop-rspec (1.33.0)
64
- rubocop (>= 0.60.0)
65
- ruby-progressbar (1.10.1)
66
- ruby_parser (3.13.1)
67
- sexp_processor (~> 4.9)
68
- sexp_processor (4.12.1)
69
- thread_safe (0.3.6)
70
- unicode-display_width (1.6.0)
71
- virtus (1.0.5)
72
- axiom-types (~> 0.1)
73
- coercible (~> 1.0)
74
- descendants_tracker (~> 0.0, >= 0.0.3)
75
- equalizer (~> 0.0, >= 0.0.9)
43
+ unicode-display_width (>= 1.4.0, < 3.0)
44
+ rubocop-ast (1.8.0)
45
+ parser (>= 3.0.1.1)
46
+ rubocop-performance (1.11.4)
47
+ rubocop (>= 1.7.0, < 2.0)
48
+ rubocop-ast (>= 0.4.0)
49
+ rubocop-rake (0.6.0)
50
+ rubocop (~> 1.0)
51
+ rubocop-rspec (2.4.0)
52
+ rubocop (~> 1.0)
53
+ rubocop-ast (>= 1.1.0)
54
+ ruby-progressbar (1.11.0)
55
+ ruby_parser (3.16.0)
56
+ sexp_processor (~> 4.15, >= 4.15.1)
57
+ sexp_processor (4.15.3)
58
+ unicode-display_width (2.0.0)
76
59
 
77
60
  PLATFORMS
78
61
  ruby
@@ -82,11 +65,11 @@ DEPENDENCIES
82
65
  fasterer
83
66
  lite-errors!
84
67
  rake
85
- reek
86
68
  rspec
87
69
  rubocop
88
70
  rubocop-performance
71
+ rubocop-rake
89
72
  rubocop-rspec
90
73
 
91
74
  BUNDLED WITH
92
- 2.0.1
75
+ 2.2.24
data/README.md CHANGED
@@ -4,7 +4,10 @@
4
4
  [![Build Status](https://travis-ci.org/drexed/lite-errors.svg?branch=master)](https://travis-ci.org/drexed/lite-errors)
5
5
 
6
6
  Lite::Errors provides an API for generating and accessing error messages.
7
- There are few handy methods for interacting with errors so we encourage you to look through the lib files.
7
+ The API is ~90% compatible with `ActiveModel::Errors` except that it returns
8
+ hashes instead of error objects (use Rails =< 6.0 documentation). There are
9
+ few extra handy methods for interacting with errors so we encourage you to
10
+ look through the lib files.
8
11
 
9
12
  **NOTE:** If you are coming from `ActiveErrors`, please read the [port](#port) section.
10
13
 
@@ -26,14 +29,8 @@ Or install it yourself as:
26
29
 
27
30
  ## Table of Contents
28
31
 
29
- * [Port](#port)
30
32
  * [Usage](#usage)
31
-
32
- ## Port
33
-
34
- `Lite::Errors` is compatible port of [ActiveErrors](https://github.com/drexed/active_errors).
35
-
36
- Switching is as easy as renaming `ActiveError::Messages` to `Lite::Errors::Messages`.
33
+ * [Port](#port)
37
34
 
38
35
  ## Usage
39
36
 
@@ -63,6 +60,12 @@ class Shipment
63
60
  end
64
61
  ```
65
62
 
63
+ ## Port
64
+
65
+ `Lite::Errors` is a compatible port of [ActiveErrors](https://github.com/drexed/active_errors).
66
+
67
+ Switching is as easy as renaming `ActiveError::Messages` to `Lite::Errors::Messages`.
68
+
66
69
  ## Development
67
70
 
68
71
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/lite/errors.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[version messages].each do |name|
4
- require "lite/errors/#{name}"
5
- end
3
+ require 'lite/errors/version'
4
+ require 'lite/errors/messages'
@@ -16,6 +16,8 @@ module Lite
16
16
  @errors[key]
17
17
  end
18
18
 
19
+ alias messages_for []
20
+
19
21
  def []=(key, value)
20
22
  @errors[key] ||= []
21
23
  @errors[key] << value
@@ -83,6 +85,8 @@ module Lite
83
85
  @errors.keys
84
86
  end
85
87
 
88
+ alias attribute_names keys
89
+
86
90
  def merge!(hash)
87
91
  @errors.merge!(hash) do |_, arr1, arr2|
88
92
  arr3 = arr1 + arr2
@@ -101,11 +105,12 @@ module Lite
101
105
 
102
106
  alias count size
103
107
 
104
- def slice!(key)
105
- delete(key)
108
+ def slice!(*keys)
109
+ keys.each { |key| delete(key) }
106
110
  @errors
107
111
  end
108
112
 
113
+ # rubocop:disable Style/OptionalBooleanParameter
109
114
  def to_hash(full_messages = false)
110
115
  return @errors unless full_messages
111
116
 
@@ -113,8 +118,10 @@ module Lite
113
118
  memo[key] = arr.map { |val| full_message(key, val) }
114
119
  end
115
120
  end
121
+ # rubocop:enable Style/OptionalBooleanParameter
116
122
 
117
123
  alias messages to_hash
124
+ alias group_by_attribute to_hash
118
125
  alias as_json to_hash
119
126
 
120
127
  def values
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Lite
4
4
  module Errors
5
- VERSION ||= '1.0.0'
5
+
6
+ VERSION = '1.2.1'
7
+
6
8
  end
7
9
  end
data/lite-errors.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  )
26
26
  else
27
27
  raise 'RubyGems 2.0 or newer is required to protect against ' \
28
- 'public gem pushes.'
28
+ 'public gem pushes.'
29
29
  end
30
30
 
31
31
  # Specify which files should be added to the gem when it is released.
@@ -43,5 +43,6 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency 'rspec'
44
44
  spec.add_development_dependency 'rubocop'
45
45
  spec.add_development_dependency 'rubocop-performance'
46
+ spec.add_development_dependency 'rubocop-rake'
46
47
  spec.add_development_dependency 'rubocop-rspec'
47
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-24 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rubocop-rspec
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +122,7 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
- description:
125
+ description:
112
126
  email:
113
127
  - j.gomez@drexed.com
114
128
  executables: []
@@ -138,7 +152,7 @@ homepage: http://drexed.github.io/lite-errors
138
152
  licenses:
139
153
  - MIT
140
154
  metadata: {}
141
- post_install_message:
155
+ post_install_message:
142
156
  rdoc_options: []
143
157
  require_paths:
144
158
  - lib
@@ -153,8 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
167
  - !ruby/object:Gem::Version
154
168
  version: '0'
155
169
  requirements: []
156
- rubygems_version: 3.0.4
157
- signing_key:
170
+ rubygems_version: 3.2.24
171
+ signing_key:
158
172
  specification_version: 4
159
173
  summary: Build ActiveModel::Errors like errors in Ruby
160
174
  test_files: []