enumerate_it 3.2.4 → 3.3.0

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: eb83f052edf5a989af33b9734d8307c774b08504255a433ba86105b93dc71298
4
- data.tar.gz: 62282a46a5759e6e61b053ca80adeb674c1df7ffb9d392652b818e4009e94ca9
3
+ metadata.gz: 9b90c459a95ec327cbd699627f1d3138534973d110341a9578fad036b64f8fe6
4
+ data.tar.gz: f9fe475a8601491e9ebe8b908460630655109350aca3c53b7b346ce77ebcee0a
5
5
  SHA512:
6
- metadata.gz: e6c9483acab55bd80890ff5cea29c82e4a58c4ace98af47edce11244327b4d51c27d6966988d4f4a820864654576fb9c7c829a447dc1a99f45d411ce384b91ad
7
- data.tar.gz: 04f383f747ff8349c4ec58e495fd08a0b654e90bb5c5337833ee257e8122204dd6786bd2cefbaf74e7b934c06219f238f2be1ead4da7f359fa72c0e3c45a4904
6
+ metadata.gz: 7a93a55f4c43f1f18e4d3162f7de7edef091c7bf1b94b331e1251f041d9fc41d7df7ca1e36ac210eb989890e3f8f9da1a0bddc374e546decc72f9f0cbe6e8f98
7
+ data.tar.gz: 59e02b301cb593851fbd05c203a132bcbd178039538c2a5a090547d4df68f829e770d1fda80cfbd176a304b99b4239c1a0ac8c802f0cb30de44d1c2bc935b7c1
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -14,6 +14,8 @@ jobs:
14
14
  - 2.7
15
15
  - 3.0
16
16
  - 3.1
17
+ - 3.2
18
+ - 3.3
17
19
  gemfile:
18
20
  - gemfiles/rails_5.0.gemfile
19
21
  - gemfiles/rails_5.1.gemfile
@@ -21,6 +23,7 @@ jobs:
21
23
  - gemfiles/rails_6.0.gemfile
22
24
  - gemfiles/rails_6.1.gemfile
23
25
  - gemfiles/rails_7.0.gemfile
26
+ - gemfiles/rails_7.1.gemfile
24
27
  exclude:
25
28
  # Rails < 6 does not support Ruby 3+:
26
29
  # https://github.com/rails/rails/issues/40938#issuecomment-751357907
@@ -36,12 +39,28 @@ jobs:
36
39
  gemfile: gemfiles/rails_5.1.gemfile
37
40
  - ruby: 3.1
38
41
  gemfile: gemfiles/rails_5.2.gemfile
42
+ - ruby: 3.2
43
+ gemfile: gemfiles/rails_5.0.gemfile
44
+ - ruby: 3.2
45
+ gemfile: gemfiles/rails_5.1.gemfile
46
+ - ruby: 3.2
47
+ gemfile: gemfiles/rails_5.2.gemfile
48
+ - ruby: 3.3
49
+ gemfile: gemfiles/rails_5.0.gemfile
50
+ - ruby: 3.3
51
+ gemfile: gemfiles/rails_5.1.gemfile
52
+ - ruby: 3.3
53
+ gemfile: gemfiles/rails_5.2.gemfile
39
54
 
40
- # Rails 7.0 requires Ruby 2.7+
55
+ # Rails 7.x requires Ruby 2.7+
41
56
  - ruby: 2.5
42
57
  gemfile: gemfiles/rails_7.0.gemfile
58
+ - ruby: 2.5
59
+ gemfile: gemfiles/rails_7.1.gemfile
43
60
  - ruby: 2.6
44
61
  gemfile: gemfiles/rails_7.0.gemfile
62
+ - ruby: 2.6
63
+ gemfile: gemfiles/rails_7.1.gemfile
45
64
 
46
65
  env:
47
66
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
@@ -50,7 +69,7 @@ jobs:
50
69
 
51
70
  steps:
52
71
  - name: Checkout
53
- uses: actions/checkout@v3
72
+ uses: actions/checkout@v4
54
73
  - name: Set up Ruby
55
74
  uses: ruby/setup-ruby@v1
56
75
  with:
@@ -58,7 +77,7 @@ jobs:
58
77
  bundler-cache: true
59
78
 
60
79
  - name: Rubocop
61
- if: ${{ matrix.ruby == '3.1' }}
80
+ if: ${{ matrix.ruby == '3.3' }}
62
81
  run: "bundle exec rubocop"
63
82
 
64
83
  - name: Tests
data/.rubocop.yml CHANGED
@@ -14,6 +14,9 @@ AllCops:
14
14
  - 'lib/generators/enumerate_it/enum/templates/**/*'
15
15
  - 'gemfiles/vendor/**/*'
16
16
 
17
+ Gemspec/DevelopmentDependencies:
18
+ Enabled: false
19
+
17
20
  Gemspec/RequiredRubyVersion:
18
21
  Enabled: false
19
22
 
data/Appraisals CHANGED
@@ -4,15 +4,26 @@ require 'json'
4
4
  rails_versions = JSON.parse(Net::HTTP.get(URI('https://rubygems.org/api/v1/versions/rails.json')))
5
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 6.1 7.0].each do |version|
8
- appraise "rails_#{version}" do
7
+ %w[5.0 5.1 5.2 6.0 6.1 7.0 7.1].each do |rails_version|
8
+ appraise "rails_#{rails_version}" do
9
9
  current_version = rails_versions
10
- .select { |key| key.match(/\A#{version}/) }
10
+ .select { |key| key.match(/\A#{rails_version}/) }
11
11
  .max { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
12
12
 
13
13
  gem 'activesupport', "~> #{current_version}"
14
14
  gem 'activerecord', "~> #{current_version}"
15
15
 
16
- gem 'sqlite3', Gem::Version.new(version) > Gem::Version.new(5.0) ? '~> 1.4.2' : '< 1.4'
16
+ if Gem::Version.new(rails_version) <= Gem::Version.new(5.0)
17
+ gem 'sqlite3', '< 1.4'
18
+ else
19
+ # v2.x isn't yet working. See: https://github.com/sparklemotion/sqlite3-ruby/issues/529
20
+ gem 'sqlite3', '< 2'
21
+ end
22
+
23
+ # elsif Gem::Version.new(RUBY_VERSION) < '3'
24
+ # gem 'sqlite3', '< 2'
25
+ # else
26
+ # gem 'sqlite3'
27
+ # end
17
28
  end
18
29
  end
data/Gemfile.lock CHANGED
@@ -1,80 +1,113 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumerate_it (3.2.4)
4
+ enumerate_it (3.3.0)
5
5
  activesupport (>= 5.0.7.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4)
10
+ activemodel (7.1.3.2)
11
+ activesupport (= 7.1.3.2)
12
+ activerecord (7.1.3.2)
13
+ activemodel (= 7.1.3.2)
14
+ activesupport (= 7.1.3.2)
15
+ timeout (>= 0.4.0)
16
+ activesupport (7.1.3.2)
17
+ base64
18
+ bigdecimal
11
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ connection_pool (>= 2.2.5)
21
+ drb
12
22
  i18n (>= 1.6, < 2)
13
23
  minitest (>= 5.1)
24
+ mutex_m
14
25
  tzinfo (~> 2.0)
15
- appraisal (2.4.1)
26
+ appraisal (2.5.0)
16
27
  bundler
17
28
  rake
18
29
  thor (>= 0.14.0)
19
30
  ast (2.4.2)
31
+ base64 (0.2.0)
32
+ bigdecimal (3.1.7)
20
33
  coderay (1.1.3)
21
- concurrent-ruby (1.1.10)
22
- diff-lcs (1.5.0)
23
- i18n (1.12.0)
34
+ concurrent-ruby (1.2.3)
35
+ connection_pool (2.4.1)
36
+ diff-lcs (1.5.1)
37
+ drb (2.2.1)
38
+ i18n (1.14.4)
24
39
  concurrent-ruby (~> 1.0)
25
- json (2.6.2)
26
- method_source (1.0.0)
27
- minitest (5.16.3)
28
- parallel (1.22.1)
29
- parser (3.1.2.1)
40
+ json (2.7.2)
41
+ language_server-protocol (3.17.0.3)
42
+ method_source (1.1.0)
43
+ mini_portile2 (2.8.6)
44
+ minitest (5.22.3)
45
+ mutex_m (0.2.0)
46
+ parallel (1.24.0)
47
+ parser (3.3.0.5)
30
48
  ast (~> 2.4.1)
31
- pry (0.14.1)
49
+ racc
50
+ pry (0.14.2)
32
51
  coderay (~> 1.1)
33
52
  method_source (~> 1.0)
53
+ racc (1.7.3)
34
54
  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)
55
+ rake (13.2.1)
56
+ regexp_parser (2.9.0)
57
+ rexml (3.2.6)
58
+ rspec (3.13.0)
59
+ rspec-core (~> 3.13.0)
60
+ rspec-expectations (~> 3.13.0)
61
+ rspec-mocks (~> 3.13.0)
62
+ rspec-core (3.13.0)
63
+ rspec-support (~> 3.13.0)
64
+ rspec-expectations (3.13.0)
45
65
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.11.0)
47
- rspec-mocks (3.11.1)
66
+ rspec-support (~> 3.13.0)
67
+ rspec-mocks (3.13.0)
48
68
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-support (3.11.0)
51
- rubocop (1.36.0)
69
+ rspec-support (~> 3.13.0)
70
+ rspec-support (3.13.1)
71
+ rubocop (1.63.2)
52
72
  json (~> 2.3)
73
+ language_server-protocol (>= 3.17.0)
53
74
  parallel (~> 1.10)
54
- parser (>= 3.1.2.1)
75
+ parser (>= 3.3.0.2)
55
76
  rainbow (>= 2.2.2, < 4.0)
56
77
  regexp_parser (>= 1.8, < 3.0)
57
78
  rexml (>= 3.2.5, < 4.0)
58
- rubocop-ast (>= 1.20.1, < 2.0)
79
+ rubocop-ast (>= 1.31.1, < 2.0)
59
80
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 3.0)
61
- rubocop-ast (1.21.0)
62
- parser (>= 3.1.1.0)
81
+ unicode-display_width (>= 2.4.0, < 3.0)
82
+ rubocop-ast (1.31.2)
83
+ parser (>= 3.3.0.4)
84
+ rubocop-capybara (2.20.0)
85
+ rubocop (~> 1.41)
86
+ rubocop-factory_bot (2.25.1)
87
+ rubocop (~> 1.41)
63
88
  rubocop-rake (0.6.0)
64
89
  rubocop (~> 1.0)
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)
90
+ rubocop-rspec (2.29.1)
91
+ rubocop (~> 1.40)
92
+ rubocop-capybara (~> 2.17)
93
+ rubocop-factory_bot (~> 2.22)
94
+ rubocop-rspec_rails (~> 2.28)
95
+ rubocop-rspec_rails (2.28.3)
96
+ rubocop (~> 1.40)
97
+ ruby-progressbar (1.13.0)
98
+ sqlite3 (1.7.3)
99
+ mini_portile2 (~> 2.8.0)
100
+ thor (1.3.1)
101
+ timeout (0.4.1)
102
+ tzinfo (2.0.6)
70
103
  concurrent-ruby (~> 1.0)
71
- unicode-display_width (2.2.0)
72
- wwtd (1.4.1)
104
+ unicode-display_width (2.5.0)
73
105
 
74
106
  PLATFORMS
75
107
  ruby
76
108
 
77
109
  DEPENDENCIES
110
+ activerecord
78
111
  appraisal
79
112
  bundler
80
113
  enumerate_it!
@@ -84,7 +117,7 @@ DEPENDENCIES
84
117
  rubocop
85
118
  rubocop-rake
86
119
  rubocop-rspec
87
- wwtd
120
+ sqlite3 (< 2)
88
121
 
89
122
  BUNDLED WITH
90
- 2.3.21
123
+ 2.4.19
data/README.md CHANGED
@@ -529,11 +529,11 @@ you can see them on the [releases page](../../releases).
529
529
  * Fork the project.
530
530
  * Make your feature addition or bug fix.
531
531
  * Add tests for it. This is important so we don't break it in a future version unintentionally.
532
- * [Optional] Run the tests agaist a specific Gemfile: `$ bundle exec appraisal rails_7.0 rake spec`.
533
- * Run the tests agaist all supported versions: `$ bundle exec rake` (or `$ bundle exec wwtd`)
532
+ * [Optional] Run the tests against a specific Gemfile: `$ bundle exec appraisal rails_7.0 rake spec`.
533
+ * Run the tests against all supported versions: `$ bundle exec rake` (or `$ bundle exec wwtd`)
534
534
  * Commit, but please do not mess with `Rakefile`, version, or history.
535
535
  * Send a Pull Request. Bonus points for topic branches.
536
536
 
537
537
  ## Copyright
538
538
 
539
- Copyright (c) 2010-2021 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
539
+ Copyright (c) 2010-2024 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
data/enumerate_it.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
22
22
 
23
23
  gem.add_dependency 'activesupport', '>= 5.0.7.2'
24
24
 
25
+ gem.add_development_dependency 'activerecord'
25
26
  gem.add_development_dependency 'appraisal'
26
27
  gem.add_development_dependency 'bundler'
27
28
  gem.add_development_dependency 'pry'
@@ -30,5 +31,5 @@ Gem::Specification.new do |gem|
30
31
  gem.add_development_dependency 'rubocop'
31
32
  gem.add_development_dependency 'rubocop-rake'
32
33
  gem.add_development_dependency 'rubocop-rspec'
33
- gem.add_development_dependency 'wwtd'
34
+ gem.add_development_dependency 'sqlite3', '< 2'
34
35
  end
@@ -4,6 +4,6 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'activerecord', '~> 5.1.7'
6
6
  gem 'activesupport', '~> 5.1.7'
7
- gem 'sqlite3', '~> 1.4.2'
7
+ gem 'sqlite3', '< 2'
8
8
 
9
9
  gemspec path: '../'
@@ -4,6 +4,6 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'activerecord', '~> 5.2.8.1'
6
6
  gem 'activesupport', '~> 5.2.8.1'
7
- gem 'sqlite3', '~> 1.4.2'
7
+ gem 'sqlite3', '< 2'
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.6'
6
- gem 'activesupport', '~> 6.0.6'
7
- gem 'sqlite3', '~> 1.4.2'
5
+ gem 'activerecord', '~> 6.0.6.1'
6
+ gem 'activesupport', '~> 6.0.6.1'
7
+ gem 'sqlite3', '< 2'
8
8
 
9
9
  gemspec path: '../'
@@ -2,8 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 6.1.7'
6
- gem 'activesupport', '~> 6.1.7'
7
- gem 'sqlite3', '~> 1.4.2'
5
+ gem 'activerecord', '~> 6.1.7.7'
6
+ gem 'activesupport', '~> 6.1.7.7'
7
+ gem 'sqlite3', '< 2'
8
8
 
9
9
  gemspec path: '../'
@@ -2,8 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 7.0.4'
6
- gem 'activesupport', '~> 7.0.4'
7
- gem 'sqlite3', '~> 1.4.2'
5
+ gem 'activerecord', '~> 7.0.8.1'
6
+ gem 'activesupport', '~> 7.0.8.1'
7
+ gem 'sqlite3', '< 2'
8
8
 
9
9
  gemspec path: '../'
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'activerecord', '~> 7.1.3.2'
6
+ gem 'activesupport', '~> 7.1.3.2'
7
+ gem 'sqlite3', '< 2'
8
+
9
+ gemspec path: '../'
@@ -5,6 +5,7 @@ module EnumerateIt
5
5
 
6
6
  define_enumeration_class(attribute, options)
7
7
  create_enumeration_humanize_method(options[:with], attribute)
8
+ create_enumeration_key_method(options[:with], attribute)
8
9
  store_enumeration(options[:with], attribute)
9
10
 
10
11
  handle_options(attribute, options)
@@ -38,6 +39,16 @@ module EnumerateIt
38
39
  end
39
40
  end
40
41
 
42
+ def create_enumeration_key_method(klass, attribute_name)
43
+ class_eval do
44
+ define_method "#{attribute_name}_key" do
45
+ value = public_send(attribute_name)
46
+
47
+ value ? klass.key_for(value) : nil
48
+ end
49
+ end
50
+ end
51
+
41
52
  def create_helper_methods(klass, attribute_name, helpers)
42
53
  prefix_name = "#{attribute_name}_" if helpers.is_a?(Hash) && helpers[:prefix]
43
54
 
@@ -1,3 +1,3 @@
1
1
  module EnumerateIt
2
- VERSION = '3.2.4'.freeze
2
+ VERSION = '3.3.0'.freeze
3
3
  end
@@ -28,6 +28,15 @@ describe EnumerateIt do
28
28
  expect(target.foobar_humanize).to be_nil
29
29
  end
30
30
 
31
+ it 'creates the key method' do
32
+ expect(target.foobar_key).to eq(:value_2)
33
+ end
34
+
35
+ it 'if the attribute is blank, the key method returns nil' do
36
+ target.foobar = nil
37
+ expect(target.foobar_key).to be_nil
38
+ end
39
+
31
40
  it 'defaults to not creating helper methods' do
32
41
  expect(target).not_to respond_to(:value_1?)
33
42
  end
@@ -288,7 +297,7 @@ describe EnumerateIt do
288
297
  end
289
298
  end
290
299
 
291
- it 'when called, the scopes create the correct query', sqlite: true do
300
+ it 'when called, the scopes create the correct query', :sqlite do
292
301
  ActiveRecord::Schema.define { create_table :test_class_with_scopes }
293
302
 
294
303
  TestEnumeration.enumeration.each do |symbol, pair|
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,7 @@ I18n.load_path = Dir['spec/i18n/*.yml']
13
13
  RSpec.configure do |config|
14
14
  config.filter_run_when_matching :focus
15
15
 
16
- config.before(:each, sqlite: true) do
16
+ config.before(:each, :sqlite) do
17
17
  ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
18
18
  end
19
19
  end
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
4
+ version: 3.3.0
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: 2022-10-26 00:00:00.000000000 Z
12
+ date: 2024-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 5.0.7.2
28
+ - !ruby/object:Gem::Dependency
29
+ name: activerecord
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: appraisal
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -138,25 +152,26 @@ dependencies:
138
152
  - !ruby/object:Gem::Version
139
153
  version: '0'
140
154
  - !ruby/object:Gem::Dependency
141
- name: wwtd
155
+ name: sqlite3
142
156
  requirement: !ruby/object:Gem::Requirement
143
157
  requirements:
144
- - - ">="
158
+ - - "<"
145
159
  - !ruby/object:Gem::Version
146
- version: '0'
160
+ version: '2'
147
161
  type: :development
148
162
  prerelease: false
149
163
  version_requirements: !ruby/object:Gem::Requirement
150
164
  requirements:
151
- - - ">="
165
+ - - "<"
152
166
  - !ruby/object:Gem::Version
153
- version: '0'
167
+ version: '2'
154
168
  description: Enumerations for Ruby with some magic powers!
155
169
  email:
156
170
  executables: []
157
171
  extensions: []
158
172
  extra_rdoc_files: []
159
173
  files:
174
+ - ".github/dependabot.yml"
160
175
  - ".github/workflows/ci.yml"
161
176
  - ".gitignore"
162
177
  - ".rspec"
@@ -175,6 +190,7 @@ files:
175
190
  - gemfiles/rails_6.0.gemfile
176
191
  - gemfiles/rails_6.1.gemfile
177
192
  - gemfiles/rails_7.0.gemfile
193
+ - gemfiles/rails_7.1.gemfile
178
194
  - lib/enumerate_it.rb
179
195
  - lib/enumerate_it/base.rb
180
196
  - lib/enumerate_it/class_methods.rb
@@ -211,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
227
  - !ruby/object:Gem::Version
212
228
  version: '0'
213
229
  requirements: []
214
- rubygems_version: 3.3.7
230
+ rubygems_version: 3.5.3
215
231
  signing_key:
216
232
  specification_version: 4
217
233
  summary: Ruby Enumerations