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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a54d82e43a9a464a702d1ae91d4b6385ef552b82f82127f87f44fe0acbfd575
4
- data.tar.gz: 4f2e18464838d1d4344da9e3c7b94bd0730ea40f72a10fe74c567c94a1f5f6e6
3
+ metadata.gz: a7f528476d6e0fa1112414541f038267d739480909a599028bed57543b370b0c
4
+ data.tar.gz: 35ec7c8859f85f8438bd8151926a2318fcb110c0c544dba3f81d9cd0539b30c6
5
5
  SHA512:
6
- metadata.gz: c5ff08f6bfa25022171fd18384cc810b1b26576937160e734489019984092752cf5ac0455ea01355140fe8dc32f563b90295f6175dc51bec40eaf3791784b6e0
7
- data.tar.gz: b9e7dee6cc3843192e3233606fb7d63f3bf4bf1868913327048087fb96877254196dae85ada2e33a23a6d7c19c23f6182a343aade9d94c7c46e3c6290fef67c0
6
+ metadata.gz: 47bea8a078e40b841f3a23b038aeb83133e82bd44b161a846c5c37722e23dff2c458e59cf1e216d4d5820d5698faf9b534bed6faf3b25c0e6ca18732f464a265
7
+ data.tar.gz: ed3a0378482870c82efa549e835face2ab358a2e8b83dbdb12c448a218b2f27cc19af3981eae800d35a7722fae8c32eadc18d5add061d59d2858c63507cd489e
@@ -5,7 +5,7 @@ inherit_mode:
5
5
  - Exclude
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.6
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
- Metrics/LineLength:
21
+ Layout/LineLength:
22
22
  Max: 100
23
23
 
24
24
  Metrics/BlockLength:
25
25
  Exclude:
26
26
  - 'spec/**/*'
27
27
 
28
- Layout/AlignHash:
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'
@@ -5,13 +5,14 @@ sudo: false
5
5
  cache: bundler
6
6
 
7
7
  script:
8
- - "ruby -e \"RUBY_VERSION == '2.6.4' ? system('bundle exec rubocop') : exit(0)\""
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.7
13
- - 2.5.6
14
- - 2.6.4
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
- # Rails 6 requires Ruby 2.5+
26
- - rvm: 2.4.7
27
- gemfile: gemfiles/rails_6.0.gemfile
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:
@@ -1,69 +1,71 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumerate_it (3.0.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.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.1, >= 2.1.8)
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.5)
22
+ concurrent-ruby (1.1.6)
23
23
  diff-lcs (1.3)
24
- i18n (1.6.0)
24
+ i18n (1.8.2)
25
25
  concurrent-ruby (~> 1.0)
26
- jaro_winkler (1.5.3)
26
+ jaro_winkler (1.5.4)
27
27
  method_source (0.9.2)
28
- minitest (5.11.3)
29
- parallel (1.17.0)
30
- parser (2.6.4.1)
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 (12.3.3)
37
- rspec (3.8.0)
38
- rspec-core (~> 3.8.0)
39
- rspec-expectations (~> 3.8.0)
40
- rspec-mocks (~> 3.8.0)
41
- rspec-core (3.8.2)
42
- rspec-support (~> 3.8.0)
43
- rspec-expectations (3.8.4)
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.8.0)
46
- rspec-mocks (3.8.1)
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.8.0)
49
- rspec-support (3.8.2)
50
- rubocop (0.74.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.6)
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.35.0)
58
- rubocop (>= 0.60.0)
59
+ rubocop-rspec (1.38.1)
60
+ rubocop (>= 0.68.1)
59
61
  ruby-progressbar (1.10.1)
60
- thor (0.20.3)
62
+ thor (1.0.1)
61
63
  thread_safe (0.3.6)
62
- tzinfo (1.2.5)
64
+ tzinfo (1.2.6)
63
65
  thread_safe (~> 0.1)
64
- unicode-display_width (1.6.0)
65
- wwtd (1.4.0)
66
- zeitwerk (2.1.10)
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.0.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-2019 Cássio Marques and Lucas Caton
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 to define enumerations outside the class that uses them?
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-2019 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
538
+ Copyright (c) 2010-2020 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
@@ -2,8 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 5.2.3'
6
- gem 'activesupport', '~> 5.2.3'
5
+ gem 'activerecord', '~> 5.2.4.1'
6
+ gem 'activesupport', '~> 5.2.4.1'
7
7
  gem 'sqlite3', '~> 1.4.1'
8
8
 
9
9
  gemspec path: '../'
@@ -2,8 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 6.0.0'
6
- gem 'activesupport', '~> 6.0.0'
5
+ gem 'activerecord', '~> 6.0.2.1'
6
+ gem 'activesupport', '~> 6.0.2.1'
7
7
  gem 'sqlite3', '~> 1.4.1'
8
8
 
9
9
  gemspec path: '../'
@@ -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.map { |k, v| [k, v.first] }.to_h
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
@@ -1,3 +1,3 @@
1
1
  module EnumerateIt
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.1.0.rc1'.freeze
3
3
  end
@@ -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 = []
@@ -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.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: 2019-09-21 00:00:00.000000000 Z
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: '0'
196
+ version: 1.3.1
197
197
  requirements: []
198
198
  rubygems_version: 3.0.3
199
199
  signing_key: