enumerate_it 3.2.0 → 3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +65 -0
- data/Appraisals +2 -2
- data/CHANGELOG.md +4 -1
- data/Gemfile.lock +47 -49
- data/README.md +6 -5
- data/enumerate_it.gemspec +2 -2
- data/gemfiles/rails_5.2.gemfile +2 -2
- data/gemfiles/rails_6.0.gemfile +2 -2
- data/gemfiles/rails_6.1.gemfile +9 -0
- data/gemfiles/rails_7.0.gemfile +9 -0
- data/lib/enumerate_it/base.rb +1 -1
- data/lib/enumerate_it/version.rb +1 -1
- data/lib/generators/enumerate_it/enum/USAGE +2 -2
- data/lib/generators/enumerate_it/enum/enum_generator.rb +1 -1
- data/lib/generators/enumerate_it/enum/templates/locale.yml +2 -2
- data/spec/enumerate_it/base_spec.rb +9 -3
- metadata +8 -11
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6622befbb458a41cdff981657448f218c412f1960189d1c103a10517ae46554
|
4
|
+
data.tar.gz: 94d6ea1c147fe0fdc4e138f8370fe397ff4152232c6bcb9f93fef4f903f9bce5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 142e44a95ba9b40c88d061c890243d3e1f742bb06d542308df63a48fbf5c664df641d432ede82d0b428b4bfd940188c410dea5fd1aafb2db607a4557a6c8acb4
|
7
|
+
data.tar.gz: 7eef4802537e07ec31e001c3c8b72cd17484916897a51b352f920b4b9870c806fc42bec0af353b007d12727b03fb70306c39d82fb1970dcc4a2f77f0b2e85a9f
|
@@ -0,0 +1,65 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
|
10
|
+
matrix:
|
11
|
+
ruby:
|
12
|
+
- 2.5
|
13
|
+
- 2.6
|
14
|
+
- 2.7
|
15
|
+
- 3.0
|
16
|
+
- 3.1
|
17
|
+
gemfile:
|
18
|
+
- gemfiles/rails_5.0.gemfile
|
19
|
+
- gemfiles/rails_5.1.gemfile
|
20
|
+
- gemfiles/rails_5.2.gemfile
|
21
|
+
- gemfiles/rails_6.0.gemfile
|
22
|
+
- gemfiles/rails_6.1.gemfile
|
23
|
+
- gemfiles/rails_7.0.gemfile
|
24
|
+
exclude:
|
25
|
+
# Rails < 6 does not support Ruby 3+:
|
26
|
+
# https://github.com/rails/rails/issues/40938#issuecomment-751357907
|
27
|
+
- ruby: 3.0
|
28
|
+
gemfile: gemfiles/rails_5.0.gemfile
|
29
|
+
- ruby: 3.0
|
30
|
+
gemfile: gemfiles/rails_5.1.gemfile
|
31
|
+
- ruby: 3.0
|
32
|
+
gemfile: gemfiles/rails_5.2.gemfile
|
33
|
+
- ruby: 3.1
|
34
|
+
gemfile: gemfiles/rails_5.0.gemfile
|
35
|
+
- ruby: 3.1
|
36
|
+
gemfile: gemfiles/rails_5.1.gemfile
|
37
|
+
- ruby: 3.1
|
38
|
+
gemfile: gemfiles/rails_5.2.gemfile
|
39
|
+
|
40
|
+
# Rails 7.0 requires Ruby 2.7+
|
41
|
+
- ruby: 2.5
|
42
|
+
gemfile: gemfiles/rails_7.0.gemfile
|
43
|
+
- ruby: 2.6
|
44
|
+
gemfile: gemfiles/rails_7.0.gemfile
|
45
|
+
|
46
|
+
env:
|
47
|
+
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
48
|
+
|
49
|
+
runs-on: ubuntu-latest
|
50
|
+
|
51
|
+
steps:
|
52
|
+
- name: Checkout
|
53
|
+
uses: actions/checkout@v3
|
54
|
+
- name: Set up Ruby
|
55
|
+
uses: ruby/setup-ruby@v1
|
56
|
+
with:
|
57
|
+
ruby-version: ${{ matrix.ruby }}
|
58
|
+
bundler-cache: true
|
59
|
+
|
60
|
+
- name: Rubocop
|
61
|
+
if: ${{ matrix.ruby == '3.1' }}
|
62
|
+
run: "bundle exec rubocop"
|
63
|
+
|
64
|
+
- name: Tests
|
65
|
+
run: bundle exec rake spec
|
data/Appraisals
CHANGED
@@ -2,9 +2,9 @@ require 'net/http'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
rails_versions = JSON.parse(Net::HTTP.get(URI('https://rubygems.org/api/v1/versions/rails.json')))
|
5
|
-
.group_by { |version| version['number'] }.keys.
|
5
|
+
.group_by { |version| version['number'] }.keys.grep_v(/rc|racecar|beta|pre/)
|
6
6
|
|
7
|
-
%w[5.0 5.1 5.2 6.0].each do |version|
|
7
|
+
%w[5.0 5.1 5.2 6.0 6.1 7.0].each do |version|
|
8
8
|
appraise "rails_#{version}" do
|
9
9
|
current_version = rails_versions
|
10
10
|
.select { |key| key.match(/\A#{version}/) }
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,77 +1,75 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
enumerate_it (3.2.
|
4
|
+
enumerate_it (3.2.3)
|
5
5
|
activesupport (>= 5.0.7.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (
|
10
|
+
activesupport (7.0.3.1)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>=
|
13
|
-
minitest (
|
14
|
-
tzinfo (~>
|
15
|
-
|
16
|
-
appraisal (2.3.0)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
appraisal (2.4.1)
|
17
16
|
bundler
|
18
17
|
rake
|
19
18
|
thor (>= 0.14.0)
|
20
|
-
ast (2.4.
|
19
|
+
ast (2.4.2)
|
21
20
|
coderay (1.1.3)
|
22
|
-
concurrent-ruby (1.1.
|
23
|
-
diff-lcs (1.
|
24
|
-
i18n (1.
|
21
|
+
concurrent-ruby (1.1.10)
|
22
|
+
diff-lcs (1.5.0)
|
23
|
+
i18n (1.12.0)
|
25
24
|
concurrent-ruby (~> 1.0)
|
25
|
+
json (2.6.2)
|
26
26
|
method_source (1.0.0)
|
27
|
-
minitest (5.
|
28
|
-
parallel (1.
|
29
|
-
parser (
|
27
|
+
minitest (5.16.3)
|
28
|
+
parallel (1.22.1)
|
29
|
+
parser (3.1.2.1)
|
30
30
|
ast (~> 2.4.1)
|
31
|
-
pry (0.
|
31
|
+
pry (0.14.1)
|
32
32
|
coderay (~> 1.1)
|
33
33
|
method_source (~> 1.0)
|
34
|
-
rainbow (3.
|
35
|
-
rake (13.0.
|
36
|
-
regexp_parser (2.
|
37
|
-
rexml (3.2.
|
38
|
-
rspec (3.
|
39
|
-
rspec-core (~> 3.
|
40
|
-
rspec-expectations (~> 3.
|
41
|
-
rspec-mocks (~> 3.
|
42
|
-
rspec-core (3.
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-expectations (3.
|
34
|
+
rainbow (3.1.1)
|
35
|
+
rake (13.0.6)
|
36
|
+
regexp_parser (2.5.0)
|
37
|
+
rexml (3.2.5)
|
38
|
+
rspec (3.11.0)
|
39
|
+
rspec-core (~> 3.11.0)
|
40
|
+
rspec-expectations (~> 3.11.0)
|
41
|
+
rspec-mocks (~> 3.11.0)
|
42
|
+
rspec-core (3.11.0)
|
43
|
+
rspec-support (~> 3.11.0)
|
44
|
+
rspec-expectations (3.11.0)
|
45
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.
|
47
|
-
rspec-mocks (3.
|
46
|
+
rspec-support (~> 3.11.0)
|
47
|
+
rspec-mocks (3.11.1)
|
48
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.
|
50
|
-
rspec-support (3.
|
51
|
-
rubocop (1.
|
49
|
+
rspec-support (~> 3.11.0)
|
50
|
+
rspec-support (3.11.0)
|
51
|
+
rubocop (1.36.0)
|
52
|
+
json (~> 2.3)
|
52
53
|
parallel (~> 1.10)
|
53
|
-
parser (>= 2.
|
54
|
+
parser (>= 3.1.2.1)
|
54
55
|
rainbow (>= 2.2.2, < 4.0)
|
55
56
|
regexp_parser (>= 1.8, < 3.0)
|
56
|
-
rexml
|
57
|
-
rubocop-ast (>= 1.
|
57
|
+
rexml (>= 3.2.5, < 4.0)
|
58
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
58
59
|
ruby-progressbar (~> 1.7)
|
59
|
-
unicode-display_width (>= 1.4.0, <
|
60
|
-
rubocop-ast (1.
|
61
|
-
parser (>=
|
62
|
-
rubocop-rake (0.
|
63
|
-
rubocop
|
64
|
-
rubocop-rspec (2.0.1)
|
60
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
61
|
+
rubocop-ast (1.21.0)
|
62
|
+
parser (>= 3.1.1.0)
|
63
|
+
rubocop-rake (0.6.0)
|
65
64
|
rubocop (~> 1.0)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
tzinfo (
|
71
|
-
|
72
|
-
unicode-display_width (
|
65
|
+
rubocop-rspec (2.12.1)
|
66
|
+
rubocop (~> 1.31)
|
67
|
+
ruby-progressbar (1.11.0)
|
68
|
+
thor (1.2.1)
|
69
|
+
tzinfo (2.0.5)
|
70
|
+
concurrent-ruby (~> 1.0)
|
71
|
+
unicode-display_width (2.2.0)
|
73
72
|
wwtd (1.4.1)
|
74
|
-
zeitwerk (2.4.2)
|
75
73
|
|
76
74
|
PLATFORMS
|
77
75
|
ruby
|
@@ -89,4 +87,4 @@ DEPENDENCIES
|
|
89
87
|
wwtd
|
90
88
|
|
91
89
|
BUNDLED WITH
|
92
|
-
2.
|
90
|
+
2.3.21
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Enumerations for Ruby with some magic powers! 🎩
|
4
4
|
|
5
|
-
[![
|
5
|
+
[![CI Status](https://github.com/lucascaton/enumerate_it/workflows/CI/badge.svg)](https://github.com/lucascaton/enumerate_it/actions?query=workflow%3ACI)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/enumerate_it.svg)](https://rubygems.org/gems/enumerate_it)
|
7
7
|
[![Code Climate](https://codeclimate.com/github/lucascaton/enumerate_it/badges/gpa.svg)](https://codeclimate.com/github/lucascaton/enumerate_it)
|
8
8
|
[![Downloads](https://img.shields.io/gem/dt/enumerate_it.svg)](https://rubygems.org/gems/enumerate_it)
|
@@ -407,7 +407,7 @@ You sure can! 😄
|
|
407
407
|
* **Rails** `5.0+`
|
408
408
|
|
409
409
|
All versions are tested via
|
410
|
-
[
|
410
|
+
[GitHub Actions](https://github.com/lucascaton/enumerate_it/blob/HEAD/.github/workflows/ci.yml).
|
411
411
|
|
412
412
|
#### Can I set a value to always be at the end of a sorted list?
|
413
413
|
|
@@ -521,18 +521,19 @@ You can also sort it by its **value** using `sort_by :value`.
|
|
521
521
|
|
522
522
|
## Changelog
|
523
523
|
|
524
|
-
Changes
|
524
|
+
Changes follows the [Semantic Versioning](https://semver.org/) specification and
|
525
|
+
you can see them on the [releases page](../../releases).
|
525
526
|
|
526
527
|
## Note on Patches/Pull Requests
|
527
528
|
|
528
529
|
* Fork the project.
|
529
530
|
* Make your feature addition or bug fix.
|
530
531
|
* Add tests for it. This is important so we don't break it in a future version unintentionally.
|
531
|
-
* [Optional] Run the tests agaist a specific Gemfile: `$ bundle exec appraisal
|
532
|
+
* [Optional] Run the tests agaist a specific Gemfile: `$ bundle exec appraisal rails_7.0 rake spec`.
|
532
533
|
* Run the tests agaist all supported versions: `$ bundle exec rake` (or `$ bundle exec wwtd`)
|
533
534
|
* Commit, but please do not mess with `Rakefile`, version, or history.
|
534
535
|
* Send a Pull Request. Bonus points for topic branches.
|
535
536
|
|
536
537
|
## Copyright
|
537
538
|
|
538
|
-
Copyright (c) 2010-
|
539
|
+
Copyright (c) 2010-2021 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
|
data/enumerate_it.gemspec
CHANGED
@@ -9,7 +9,6 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.license = 'MIT'
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split("\n")
|
12
|
-
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
13
12
|
gem.name = 'enumerate_it'
|
14
13
|
gem.require_paths = ['lib']
|
15
14
|
gem.version = EnumerateIt::VERSION
|
@@ -17,7 +16,8 @@ Gem::Specification.new do |gem|
|
|
17
16
|
|
18
17
|
gem.metadata = {
|
19
18
|
'source_code_uri' => 'https://github.com/lucascaton/enumerate_it',
|
20
|
-
'changelog_uri' => 'https://github.com/lucascaton/enumerate_it/releases'
|
19
|
+
'changelog_uri' => 'https://github.com/lucascaton/enumerate_it/releases',
|
20
|
+
'rubygems_mfa_required' => 'true'
|
21
21
|
}
|
22
22
|
|
23
23
|
gem.add_dependency 'activesupport', '>= 5.0.7.2'
|
data/gemfiles/rails_5.2.gemfile
CHANGED
data/gemfiles/rails_6.0.gemfile
CHANGED
data/lib/enumerate_it/base.rb
CHANGED
data/lib/enumerate_it/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Description:
|
2
|
-
Creates an EnumerateIt class
|
2
|
+
Creates an EnumerateIt class and its locale file
|
3
3
|
|
4
4
|
Example:
|
5
5
|
rails g enumerate_it:enum CivilStatus single married divorced widower concubinage separated stable
|
@@ -11,5 +11,5 @@ Example:
|
|
11
11
|
rails g enumerate_it:enum CivilStatus single:1 married:2 divorced:3 widower:4
|
12
12
|
|
13
13
|
This will create:
|
14
|
-
app/enumerations/civil_status.rb with `associate_values :
|
14
|
+
app/enumerations/civil_status.rb with `associate_values single: 1, married: 2, divorced: 3, widower: 4`
|
15
15
|
config/locales/civil_status.yml
|
@@ -3,7 +3,7 @@ module EnumerateIt
|
|
3
3
|
class EnumGenerator < Rails::Generators::NamedBase
|
4
4
|
source_root File.expand_path('templates', __dir__)
|
5
5
|
|
6
|
-
argument :attributes, type:
|
6
|
+
argument :attributes, type: :hash
|
7
7
|
|
8
8
|
class_option :singular, type: 'string', desc: 'Singular name for i18n'
|
9
9
|
|
@@ -178,6 +178,12 @@ describe EnumerateIt::Base do
|
|
178
178
|
expect(TestEnumeration.value_for('THIS_IS_WRONG')).to be_nil
|
179
179
|
end
|
180
180
|
end
|
181
|
+
|
182
|
+
context 'when a constant named after the received value exists as an ancestor' do
|
183
|
+
it 'returns nil' do
|
184
|
+
expect(TestEnumeration.value_for('Module')).to be_nil
|
185
|
+
end
|
186
|
+
end
|
181
187
|
end
|
182
188
|
|
183
189
|
describe '.value_from_key' do
|
@@ -302,12 +308,12 @@ describe EnumerateIt::Base do
|
|
302
308
|
end
|
303
309
|
|
304
310
|
it 'passes the given options to the validation method' do
|
305
|
-
expect(active_record_stub_class)
|
306
|
-
.to receive(:validates_presence_of).with(:bla, if: :some_method)
|
307
|
-
|
308
311
|
active_record_stub_class.class_eval do
|
309
312
|
has_enumeration_for :bla, with: TestEnumeration, required: { if: :some_method }
|
310
313
|
end
|
314
|
+
|
315
|
+
expect(active_record_stub_class)
|
316
|
+
.to have_received(:validates_presence_of).with(:bla, if: :some_method)
|
311
317
|
end
|
312
318
|
|
313
319
|
it 'does not require the attribute by default' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumerate_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cássio Marques
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-09-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -157,10 +157,10 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
+
- ".github/workflows/ci.yml"
|
160
161
|
- ".gitignore"
|
161
162
|
- ".rspec"
|
162
163
|
- ".rubocop.yml"
|
163
|
-
- ".travis.yml"
|
164
164
|
- Appraisals
|
165
165
|
- CHANGELOG.md
|
166
166
|
- Gemfile
|
@@ -173,6 +173,8 @@ files:
|
|
173
173
|
- gemfiles/rails_5.1.gemfile
|
174
174
|
- gemfiles/rails_5.2.gemfile
|
175
175
|
- gemfiles/rails_6.0.gemfile
|
176
|
+
- gemfiles/rails_6.1.gemfile
|
177
|
+
- gemfiles/rails_7.0.gemfile
|
176
178
|
- lib/enumerate_it.rb
|
177
179
|
- lib/enumerate_it/base.rb
|
178
180
|
- lib/enumerate_it/class_methods.rb
|
@@ -193,6 +195,7 @@ licenses:
|
|
193
195
|
metadata:
|
194
196
|
source_code_uri: https://github.com/lucascaton/enumerate_it
|
195
197
|
changelog_uri: https://github.com/lucascaton/enumerate_it/releases
|
198
|
+
rubygems_mfa_required: 'true'
|
196
199
|
post_install_message:
|
197
200
|
rdoc_options: []
|
198
201
|
require_paths:
|
@@ -208,14 +211,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
211
|
- !ruby/object:Gem::Version
|
209
212
|
version: '0'
|
210
213
|
requirements: []
|
211
|
-
rubygems_version: 3.
|
214
|
+
rubygems_version: 3.3.7
|
212
215
|
signing_key:
|
213
216
|
specification_version: 4
|
214
217
|
summary: Ruby Enumerations
|
215
|
-
test_files:
|
216
|
-
- spec/enumerate_it/base_spec.rb
|
217
|
-
- spec/enumerate_it_spec.rb
|
218
|
-
- spec/i18n/en.yml
|
219
|
-
- spec/i18n/pt.yml
|
220
|
-
- spec/spec_helper.rb
|
221
|
-
- spec/support/test_classes.rb
|
218
|
+
test_files: []
|
data/.travis.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
sudo: false
|
4
|
-
|
5
|
-
cache: bundler
|
6
|
-
|
7
|
-
script:
|
8
|
-
- "ruby -e \"RUBY_VERSION == '2.7.2' ? system('bundle exec rubocop') : exit(0)\""
|
9
|
-
- bundle exec rake spec
|
10
|
-
|
11
|
-
rvm:
|
12
|
-
- 2.5.8
|
13
|
-
- 2.6.6
|
14
|
-
- 2.7.2
|
15
|
-
|
16
|
-
gemfile:
|
17
|
-
- gemfiles/rails_5.0.gemfile
|
18
|
-
- gemfiles/rails_5.1.gemfile
|
19
|
-
- gemfiles/rails_5.2.gemfile
|
20
|
-
- gemfiles/rails_6.0.gemfile
|
21
|
-
|
22
|
-
addons:
|
23
|
-
code_climate:
|
24
|
-
repo_token: 60e4a18e2a4bc86a98f92847f16756876c13d1e772058a9b3296643b04a697d7
|