lite-errors 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.fasterer.yml +19 -0
- data/.gitignore +11 -0
- data/.rspec +4 -0
- data/.rubocop.yml +22 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +92 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/Rakefile +8 -0
- data/_config.yml +1 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/lite/errors.rb +5 -0
- data/lib/lite/errors/messages.rb +126 -0
- data/lib/lite/errors/version.rb +7 -0
- data/lite-errors.gemspec +47 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 236ce284b55e8fb17579794dd0ca284984b704247aeb9ea851fee63d4d6f889c
|
4
|
+
data.tar.gz: febe41cb7f6f8cccfbb81bcd7a52c8cf871f4afb39eeef6469b93d531402ecb1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ed7f3dfa023d44e685f3739797d0508c2be16ed79cc8b1fb9219b508efd99cff82a11774a763eb920072a246410d1d796a9e4686af4903ba05caa3ea4ddf3083
|
7
|
+
data.tar.gz: acba5684831c8a132e5dcfcc63b85900e4761b410e6274de66c6c892ecbf940a6d138f7589f6aeecf8584ae06e5900835eeb239cb90d64f87bdd99b547b56a00
|
data/.fasterer.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
speedups:
|
2
|
+
block_vs_symbol_to_proc: true
|
3
|
+
each_with_index_vs_while: false
|
4
|
+
fetch_with_argument_vs_block: true
|
5
|
+
for_loop_vs_each: true
|
6
|
+
getter_vs_attr_reader: true
|
7
|
+
gsub_vs_tr: true
|
8
|
+
hash_merge_bang_vs_hash_brackets: true
|
9
|
+
keys_each_vs_each_key: true
|
10
|
+
map_flatten_vs_flat_map: true
|
11
|
+
module_eval: true
|
12
|
+
proc_call_vs_yield: true
|
13
|
+
rescue_vs_respond_to: true
|
14
|
+
reverse_each_vs_reverse_each: true
|
15
|
+
select_first_vs_detect: true
|
16
|
+
select_last_vs_reverse_detect: true
|
17
|
+
setter_vs_attr_writer: true
|
18
|
+
shuffle_first_vs_sample: true
|
19
|
+
sort_vs_sort_by: true
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.6
|
6
|
+
DisplayCopNames: true
|
7
|
+
DisplayStyleGuide: true
|
8
|
+
LineLength:
|
9
|
+
Max: 100
|
10
|
+
Layout/EmptyLinesAroundBlockBody:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/**/*'
|
13
|
+
Layout/EmptyLinesAroundClassBody:
|
14
|
+
EnforcedStyle: empty_lines
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Exclude:
|
17
|
+
- 'spec/**/**/*'
|
18
|
+
- '*.gemspec'
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
Style/ExpandPathArguments:
|
22
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
rvm:
|
6
|
+
- 2.5
|
7
|
+
- 2.6
|
8
|
+
- ruby-head
|
9
|
+
matrix:
|
10
|
+
fast_finish: true
|
11
|
+
allow_failures:
|
12
|
+
- rvm: ruby-head
|
13
|
+
before_install:
|
14
|
+
- gem update --system
|
15
|
+
- gem install bundler
|
16
|
+
install:
|
17
|
+
- bundle install --jobs=3 --retry=3
|
18
|
+
script:
|
19
|
+
- bundle exec rspec
|
20
|
+
# - bundle exec fasterer
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [1.0.0] - 2019-06-24
|
10
|
+
### Added
|
11
|
+
- Initial project version
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at j.gomez@drexed.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lite-errors (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
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)
|
18
|
+
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)
|
24
|
+
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)
|
33
|
+
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)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.8.0)
|
50
|
+
rspec-mocks (3.8.1)
|
51
|
+
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)
|
56
|
+
parallel (~> 1.10)
|
57
|
+
parser (>= 2.6)
|
58
|
+
rainbow (>= 2.2.2, < 4.0)
|
59
|
+
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)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
bundler
|
82
|
+
fasterer
|
83
|
+
lite-errors!
|
84
|
+
rake
|
85
|
+
reek
|
86
|
+
rspec
|
87
|
+
rubocop
|
88
|
+
rubocop-performance
|
89
|
+
rubocop-rspec
|
90
|
+
|
91
|
+
BUNDLED WITH
|
92
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Juan Gomez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Lite::Errors
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/lite-errors.svg)](http://badge.fury.io/rb/lite-errors)
|
4
|
+
[![Build Status](https://travis-ci.org/drexed/lite-errors.svg?branch=master)](https://travis-ci.org/drexed/lite-errors)
|
5
|
+
|
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.
|
8
|
+
|
9
|
+
**NOTE:** If you are coming from `ActiveErrors`, please read the [port](#port) section.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'lite-errors'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install lite-errors
|
26
|
+
|
27
|
+
## Table of Contents
|
28
|
+
|
29
|
+
* [Port](#port)
|
30
|
+
* [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`.
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
class Shipment
|
42
|
+
|
43
|
+
def errors
|
44
|
+
@errors ||= Lite::Errors::Messages.new
|
45
|
+
end
|
46
|
+
|
47
|
+
def messages
|
48
|
+
@errors.full_messages
|
49
|
+
end
|
50
|
+
|
51
|
+
def process
|
52
|
+
ShipmentItem.each do |item|
|
53
|
+
item.add_to_box!
|
54
|
+
rescue Shipment::OutOfStock => e
|
55
|
+
errors.add(item.name, :out_of_stock)
|
56
|
+
rescue Shipment::DoesNotExist => e
|
57
|
+
errors[item.name] = I18n.t('errors.does_not_exist')
|
58
|
+
rescue ActiveRecord::RecordInvalid
|
59
|
+
errors.merge!(item.errors)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
## Development
|
67
|
+
|
68
|
+
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.
|
69
|
+
|
70
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lite-errors. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
79
|
+
|
80
|
+
## Code of Conduct
|
81
|
+
|
82
|
+
Everyone interacting in the Lite::Errors project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lite-errors/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-leap-day
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'lite/errors'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/lite/errors.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Errors
|
5
|
+
class Messages
|
6
|
+
|
7
|
+
attr_reader :errors
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@errors = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](key)
|
14
|
+
return [] unless key?(key)
|
15
|
+
|
16
|
+
@errors[key]
|
17
|
+
end
|
18
|
+
|
19
|
+
def []=(key, value)
|
20
|
+
@errors[key] ||= []
|
21
|
+
@errors[key] << value
|
22
|
+
@errors[key].uniq!
|
23
|
+
end
|
24
|
+
|
25
|
+
alias add []=
|
26
|
+
|
27
|
+
def added?(key, val)
|
28
|
+
return false unless key?(key)
|
29
|
+
|
30
|
+
@errors[key].include?(val)
|
31
|
+
end
|
32
|
+
|
33
|
+
alias of_kind? added?
|
34
|
+
|
35
|
+
def clear
|
36
|
+
@errors.clear
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(key)
|
40
|
+
@errors.delete(key)
|
41
|
+
end
|
42
|
+
|
43
|
+
# :nocov:
|
44
|
+
def each
|
45
|
+
@errors.each_key do |key|
|
46
|
+
@errors[key].each { |val| yield(key, val) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
# :nocov:
|
50
|
+
|
51
|
+
def empty?
|
52
|
+
@errors.empty?
|
53
|
+
end
|
54
|
+
|
55
|
+
alias blank? empty?
|
56
|
+
|
57
|
+
def full_message(key, value)
|
58
|
+
"#{key} #{value}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def full_messages
|
62
|
+
@errors.each_with_object([]) do |(key, arr), memo|
|
63
|
+
arr.each { |val| memo << full_message(key, val) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
alias to_a full_messages
|
68
|
+
|
69
|
+
def full_messages_for(key)
|
70
|
+
return [] unless key?(key)
|
71
|
+
|
72
|
+
@errors[key].map { |val| full_message(key, val) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def key?(key)
|
76
|
+
@errors.key?(key)
|
77
|
+
end
|
78
|
+
|
79
|
+
alias has_key? key?
|
80
|
+
alias include? key?
|
81
|
+
|
82
|
+
def keys
|
83
|
+
@errors.keys
|
84
|
+
end
|
85
|
+
|
86
|
+
def merge!(hash)
|
87
|
+
@errors.merge!(hash) do |_, arr1, arr2|
|
88
|
+
arr3 = arr1 + arr2
|
89
|
+
arr3.uniq!
|
90
|
+
arr3
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def present?
|
95
|
+
!blank?
|
96
|
+
end
|
97
|
+
|
98
|
+
def size
|
99
|
+
@errors.size
|
100
|
+
end
|
101
|
+
|
102
|
+
alias count size
|
103
|
+
|
104
|
+
def slice!(key)
|
105
|
+
delete(key)
|
106
|
+
@errors
|
107
|
+
end
|
108
|
+
|
109
|
+
def to_hash(full_messages = false)
|
110
|
+
return @errors unless full_messages
|
111
|
+
|
112
|
+
@errors.each_with_object({}) do |(key, arr), memo|
|
113
|
+
memo[key] = arr.map { |val| full_message(key, val) }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
alias messages to_hash
|
118
|
+
alias as_json to_hash
|
119
|
+
|
120
|
+
def values
|
121
|
+
@errors.values
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
data/lite-errors.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'lite/errors/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'lite-errors'
|
9
|
+
spec.version = Lite::Errors::VERSION
|
10
|
+
spec.authors = ['Juan Gomez']
|
11
|
+
spec.email = %w[j.gomez@drexed.com]
|
12
|
+
|
13
|
+
spec.summary = 'Build ActiveModel::Errors like errors in Ruby'
|
14
|
+
spec.homepage = 'http://drexed.github.io/lite-errors'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata.merge(
|
21
|
+
'allowed_push_host' => 'https://rubygems.org',
|
22
|
+
'changelog_uri' => 'https://github.com/drexed/lite-errors/blob/master/CHANGELOG.md',
|
23
|
+
'homepage_uri' => spec.homepage,
|
24
|
+
'source_code_uri' => 'https://github.com/drexed/lite-errors'
|
25
|
+
)
|
26
|
+
else
|
27
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
28
|
+
'public gem pushes.'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Specify which files should be added to the gem when it is released.
|
32
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
33
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
34
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
35
|
+
end
|
36
|
+
spec.bindir = 'exe'
|
37
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
+
spec.require_paths = %w[lib]
|
39
|
+
|
40
|
+
spec.add_development_dependency 'bundler'
|
41
|
+
spec.add_development_dependency 'fasterer'
|
42
|
+
spec.add_development_dependency 'rake'
|
43
|
+
spec.add_development_dependency 'rspec'
|
44
|
+
spec.add_development_dependency 'rubocop'
|
45
|
+
spec.add_development_dependency 'rubocop-performance'
|
46
|
+
spec.add_development_dependency 'rubocop-rspec'
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lite-errors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juan Gomez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fasterer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
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'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- j.gomez@drexed.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".fasterer.yml"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CHANGELOG.md
|
124
|
+
- CODE_OF_CONDUCT.md
|
125
|
+
- Gemfile
|
126
|
+
- Gemfile.lock
|
127
|
+
- LICENSE.txt
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- _config.yml
|
131
|
+
- bin/console
|
132
|
+
- bin/setup
|
133
|
+
- lib/lite/errors.rb
|
134
|
+
- lib/lite/errors/messages.rb
|
135
|
+
- lib/lite/errors/version.rb
|
136
|
+
- lite-errors.gemspec
|
137
|
+
homepage: http://drexed.github.io/lite-errors
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubygems_version: 3.0.4
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: Build ActiveModel::Errors like errors in Ruby
|
160
|
+
test_files: []
|