enumerate_it 3.0.0 → 3.1.0.rc1
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 +4 -4
- data/.rubocop.yml +12 -3
- data/.travis.yml +11 -7
- data/Gemfile.lock +33 -31
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/gemfiles/rails_5.2.gemfile +2 -2
- data/gemfiles/rails_6.0.gemfile +2 -2
- data/lib/enumerate_it/base.rb +7 -5
- data/lib/enumerate_it/version.rb +1 -1
- data/spec/enumerate_it/base_spec.rb +10 -0
- data/spec/spec_helper.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7f528476d6e0fa1112414541f038267d739480909a599028bed57543b370b0c
|
|
4
|
+
data.tar.gz: 35ec7c8859f85f8438bd8151926a2318fcb110c0c544dba3f81d9cd0539b30c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47bea8a078e40b841f3a23b038aeb83133e82bd44b161a846c5c37722e23dff2c458e59cf1e216d4d5820d5698faf9b534bed6faf3b25c0e6ca18732f464a265
|
|
7
|
+
data.tar.gz: ed3a0378482870c82efa549e835face2ab358a2e8b83dbdb12c448a218b2f27cc19af3981eae800d35a7722fae8c32eadc18d5add061d59d2858c63507cd489e
|
data/.rubocop.yml
CHANGED
|
@@ -5,7 +5,7 @@ inherit_mode:
|
|
|
5
5
|
- Exclude
|
|
6
6
|
|
|
7
7
|
AllCops:
|
|
8
|
-
TargetRubyVersion: 2.
|
|
8
|
+
TargetRubyVersion: 2.4
|
|
9
9
|
DisplayCopNames: true
|
|
10
10
|
|
|
11
11
|
Exclude:
|
|
@@ -18,14 +18,14 @@ Gemspec/RequiredRubyVersion:
|
|
|
18
18
|
Layout/EndAlignment:
|
|
19
19
|
Enabled: false
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Layout/LineLength:
|
|
22
22
|
Max: 100
|
|
23
23
|
|
|
24
24
|
Metrics/BlockLength:
|
|
25
25
|
Exclude:
|
|
26
26
|
- 'spec/**/*'
|
|
27
27
|
|
|
28
|
-
Layout/
|
|
28
|
+
Layout/HashAlignment:
|
|
29
29
|
EnforcedColonStyle: table
|
|
30
30
|
EnforcedLastArgumentHashStyle: ignore_implicit
|
|
31
31
|
|
|
@@ -47,6 +47,15 @@ Style/Documentation:
|
|
|
47
47
|
Style/GuardClause:
|
|
48
48
|
MinBodyLength: 3
|
|
49
49
|
|
|
50
|
+
Style/HashEachMethods:
|
|
51
|
+
Enabled: true
|
|
52
|
+
|
|
53
|
+
Style/HashTransformKeys:
|
|
54
|
+
Enabled: true
|
|
55
|
+
|
|
56
|
+
Style/HashTransformValues:
|
|
57
|
+
Enabled: true
|
|
58
|
+
|
|
50
59
|
Naming/PredicateName:
|
|
51
60
|
Exclude:
|
|
52
61
|
- 'lib/enumerate_it/class_methods.rb'
|
data/.travis.yml
CHANGED
|
@@ -5,13 +5,14 @@ sudo: false
|
|
|
5
5
|
cache: bundler
|
|
6
6
|
|
|
7
7
|
script:
|
|
8
|
-
- "ruby -e \"RUBY_VERSION == '2.
|
|
8
|
+
- "ruby -e \"RUBY_VERSION == '2.7.0' ? system('bundle exec rubocop') : exit(0)\""
|
|
9
9
|
- bundle exec rake spec
|
|
10
10
|
|
|
11
11
|
rvm:
|
|
12
|
-
- 2.4.
|
|
13
|
-
- 2.5.
|
|
14
|
-
- 2.6.
|
|
12
|
+
- 2.4.9
|
|
13
|
+
- 2.5.7
|
|
14
|
+
- 2.6.5
|
|
15
|
+
- 2.7.0
|
|
15
16
|
|
|
16
17
|
gemfile:
|
|
17
18
|
- gemfiles/rails_4.2.gemfile
|
|
@@ -22,9 +23,12 @@ gemfile:
|
|
|
22
23
|
|
|
23
24
|
matrix:
|
|
24
25
|
exclude:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
# Rails 4.2 isn't compatible with Ruby 2.7+
|
|
27
|
+
- rvm: 2.7.0
|
|
28
|
+
gemfile: gemfiles/rails_4.2.gemfile
|
|
29
|
+
# Rails 6 requires Ruby 2.5+
|
|
30
|
+
- rvm: 2.4.9
|
|
31
|
+
gemfile: gemfiles/rails_6.0.gemfile
|
|
28
32
|
|
|
29
33
|
addons:
|
|
30
34
|
code_climate:
|
data/Gemfile.lock
CHANGED
|
@@ -1,69 +1,71 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
enumerate_it (3.0.
|
|
4
|
+
enumerate_it (3.1.0.rc1)
|
|
5
5
|
activesupport (>= 4.2.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
activesupport (6.0.
|
|
10
|
+
activesupport (6.0.2.1)
|
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
12
12
|
i18n (>= 0.7, < 2)
|
|
13
13
|
minitest (~> 5.1)
|
|
14
14
|
tzinfo (~> 1.1)
|
|
15
|
-
zeitwerk (~> 2.
|
|
15
|
+
zeitwerk (~> 2.2)
|
|
16
16
|
appraisal (2.2.0)
|
|
17
17
|
bundler
|
|
18
18
|
rake
|
|
19
19
|
thor (>= 0.14.0)
|
|
20
20
|
ast (2.4.0)
|
|
21
21
|
coderay (1.1.2)
|
|
22
|
-
concurrent-ruby (1.1.
|
|
22
|
+
concurrent-ruby (1.1.6)
|
|
23
23
|
diff-lcs (1.3)
|
|
24
|
-
i18n (1.
|
|
24
|
+
i18n (1.8.2)
|
|
25
25
|
concurrent-ruby (~> 1.0)
|
|
26
|
-
jaro_winkler (1.5.
|
|
26
|
+
jaro_winkler (1.5.4)
|
|
27
27
|
method_source (0.9.2)
|
|
28
|
-
minitest (5.
|
|
29
|
-
parallel (1.
|
|
30
|
-
parser (2.
|
|
28
|
+
minitest (5.14.0)
|
|
29
|
+
parallel (1.19.1)
|
|
30
|
+
parser (2.7.0.4)
|
|
31
31
|
ast (~> 2.4.0)
|
|
32
32
|
pry (0.12.2)
|
|
33
33
|
coderay (~> 1.1.0)
|
|
34
34
|
method_source (~> 0.9.0)
|
|
35
35
|
rainbow (3.0.0)
|
|
36
|
-
rake (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
rspec-
|
|
40
|
-
rspec-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
rake (13.0.1)
|
|
37
|
+
rexml (3.2.4)
|
|
38
|
+
rspec (3.9.0)
|
|
39
|
+
rspec-core (~> 3.9.0)
|
|
40
|
+
rspec-expectations (~> 3.9.0)
|
|
41
|
+
rspec-mocks (~> 3.9.0)
|
|
42
|
+
rspec-core (3.9.1)
|
|
43
|
+
rspec-support (~> 3.9.1)
|
|
44
|
+
rspec-expectations (3.9.0)
|
|
44
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
-
rspec-support (~> 3.
|
|
46
|
-
rspec-mocks (3.
|
|
46
|
+
rspec-support (~> 3.9.0)
|
|
47
|
+
rspec-mocks (3.9.1)
|
|
47
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
-
rspec-support (~> 3.
|
|
49
|
-
rspec-support (3.
|
|
50
|
-
rubocop (0.
|
|
49
|
+
rspec-support (~> 3.9.0)
|
|
50
|
+
rspec-support (3.9.2)
|
|
51
|
+
rubocop (0.80.1)
|
|
51
52
|
jaro_winkler (~> 1.5.1)
|
|
52
53
|
parallel (~> 1.10)
|
|
53
|
-
parser (>= 2.
|
|
54
|
+
parser (>= 2.7.0.1)
|
|
54
55
|
rainbow (>= 2.2.2, < 4.0)
|
|
56
|
+
rexml
|
|
55
57
|
ruby-progressbar (~> 1.7)
|
|
56
58
|
unicode-display_width (>= 1.4.0, < 1.7)
|
|
57
|
-
rubocop-rspec (1.
|
|
58
|
-
rubocop (>= 0.
|
|
59
|
+
rubocop-rspec (1.38.1)
|
|
60
|
+
rubocop (>= 0.68.1)
|
|
59
61
|
ruby-progressbar (1.10.1)
|
|
60
|
-
thor (0.
|
|
62
|
+
thor (1.0.1)
|
|
61
63
|
thread_safe (0.3.6)
|
|
62
|
-
tzinfo (1.2.
|
|
64
|
+
tzinfo (1.2.6)
|
|
63
65
|
thread_safe (~> 0.1)
|
|
64
|
-
unicode-display_width (1.6.
|
|
65
|
-
wwtd (1.4.
|
|
66
|
-
zeitwerk (2.
|
|
66
|
+
unicode-display_width (1.6.1)
|
|
67
|
+
wwtd (1.4.1)
|
|
68
|
+
zeitwerk (2.3.0)
|
|
67
69
|
|
|
68
70
|
PLATFORMS
|
|
69
71
|
ruby
|
|
@@ -80,4 +82,4 @@ DEPENDENCIES
|
|
|
80
82
|
wwtd
|
|
81
83
|
|
|
82
84
|
BUNDLED WITH
|
|
83
|
-
2.
|
|
85
|
+
2.1.4
|
data/LICENSE
CHANGED
|
@@ -2,7 +2,7 @@ LICENSE
|
|
|
2
2
|
|
|
3
3
|
The MIT License
|
|
4
4
|
|
|
5
|
-
Copyright (c) 2010-
|
|
5
|
+
Copyright (c) 2010-2020 Cássio Marques and Lucas Caton
|
|
6
6
|
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
8
8
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
|
@@ -391,7 +391,7 @@ Remember that you can add validations to any kind of class and not only `ActiveR
|
|
|
391
391
|
|
|
392
392
|
## FAQ
|
|
393
393
|
|
|
394
|
-
#### Why
|
|
394
|
+
#### Why define enumerations outside the class that uses them?
|
|
395
395
|
|
|
396
396
|
* It's clearer.
|
|
397
397
|
* You can add behaviour to the enumeration class.
|
|
@@ -535,4 +535,4 @@ Changes are maintained under [Releases page](https://github.com/lucascaton/enume
|
|
|
535
535
|
|
|
536
536
|
## Copyright
|
|
537
537
|
|
|
538
|
-
Copyright (c) 2010-
|
|
538
|
+
Copyright (c) 2010-2020 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
|
data/gemfiles/rails_5.2.gemfile
CHANGED
data/gemfiles/rails_6.0.gemfile
CHANGED
data/lib/enumerate_it/base.rb
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
require 'forwardable'
|
|
2
|
+
|
|
1
3
|
module EnumerateIt
|
|
2
4
|
class Base
|
|
3
5
|
class << self
|
|
6
|
+
extend Forwardable
|
|
7
|
+
|
|
4
8
|
attr_reader :sort_mode
|
|
5
9
|
|
|
10
|
+
def_delegators :enumeration, :keys, :each_key
|
|
11
|
+
|
|
6
12
|
def associate_values(*args)
|
|
7
13
|
values = values_hash(args)
|
|
8
14
|
|
|
@@ -22,7 +28,7 @@ module EnumerateIt
|
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
def to_h
|
|
25
|
-
sorted_map.
|
|
31
|
+
sorted_map.transform_values(&:first)
|
|
26
32
|
end
|
|
27
33
|
|
|
28
34
|
def enumeration
|
|
@@ -74,10 +80,6 @@ module EnumerateIt
|
|
|
74
80
|
(enumeration[key.to_sym] || []).first
|
|
75
81
|
end
|
|
76
82
|
|
|
77
|
-
def keys
|
|
78
|
-
enumeration.keys
|
|
79
|
-
end
|
|
80
|
-
|
|
81
83
|
def key_for(value)
|
|
82
84
|
enumeration.map { |e| e[0] if e[1][0] == value }.compact.first
|
|
83
85
|
end
|
data/lib/enumerate_it/version.rb
CHANGED
|
@@ -85,6 +85,16 @@ describe EnumerateIt::Base do
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
describe '.each_key' do
|
|
89
|
+
it "yields each enumeration's key" do
|
|
90
|
+
keys = []
|
|
91
|
+
TestEnumeration.each_key do |key|
|
|
92
|
+
keys << key
|
|
93
|
+
end
|
|
94
|
+
expect(keys).to eq(%i[value_1 value_2 value_3])
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
88
98
|
describe '.each_value' do
|
|
89
99
|
it "yields each enumeration's value" do
|
|
90
100
|
values = []
|
data/spec/spec_helper.rb
CHANGED
|
@@ -5,7 +5,7 @@ require 'enumerate_it'
|
|
|
5
5
|
require 'active_support/all'
|
|
6
6
|
require 'active_record'
|
|
7
7
|
|
|
8
|
-
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
|
8
|
+
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
|
9
9
|
|
|
10
10
|
I18n.config.enforce_available_locales = false
|
|
11
11
|
I18n.load_path = Dir['spec/i18n/*.yml']
|
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.0.
|
|
4
|
+
version: 3.1.0.rc1
|
|
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: 2020-03-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -191,9 +191,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
191
191
|
version: 2.4.7
|
|
192
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
requirements:
|
|
194
|
-
- - "
|
|
194
|
+
- - ">"
|
|
195
195
|
- !ruby/object:Gem::Version
|
|
196
|
-
version:
|
|
196
|
+
version: 1.3.1
|
|
197
197
|
requirements: []
|
|
198
198
|
rubygems_version: 3.0.3
|
|
199
199
|
signing_key:
|