enumerize 2.0.0 → 2.7.0
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 +5 -5
- data/.github/workflows/ruby.yml +75 -0
- data/CHANGELOG.md +117 -3
- data/Gemfile +3 -3
- data/Gemfile.global +5 -9
- data/Gemfile.mongo_mapper +2 -2
- data/Gemfile.rails60 +6 -0
- data/Gemfile.rails61 +6 -0
- data/Gemfile.rails70 +9 -0
- data/Gemfile.railsmaster +5 -0
- data/README.md +210 -92
- data/Rakefile +9 -3
- data/enumerize.gemspec +1 -1
- data/lib/enumerize/activemodel.rb +47 -0
- data/lib/enumerize/activerecord.rb +92 -6
- data/lib/enumerize/attribute.rb +19 -11
- data/lib/enumerize/attribute_map.rb +2 -0
- data/lib/enumerize/base.rb +22 -18
- data/lib/enumerize/hooks/formtastic.rb +4 -1
- data/lib/enumerize/hooks/sequel_dataset.rb +2 -0
- data/lib/enumerize/hooks/simple_form.rb +4 -1
- data/lib/enumerize/hooks/uniqueness.rb +5 -1
- data/lib/enumerize/integrations/rails_admin.rb +3 -1
- data/lib/enumerize/integrations/rspec/matcher.rb +7 -2
- data/lib/enumerize/integrations/rspec.rb +3 -0
- data/lib/enumerize/module.rb +2 -0
- data/lib/enumerize/module_attributes.rb +2 -0
- data/lib/enumerize/mongoid.rb +23 -0
- data/lib/enumerize/predicatable.rb +3 -1
- data/lib/enumerize/predicates.rb +16 -0
- data/lib/enumerize/scope/activerecord.rb +16 -0
- data/lib/enumerize/scope/mongoid.rb +15 -0
- data/lib/enumerize/scope/sequel.rb +16 -0
- data/lib/enumerize/sequel.rb +9 -4
- data/lib/enumerize/set.rb +2 -0
- data/lib/enumerize/utils.rb +12 -0
- data/lib/enumerize/value.rb +14 -15
- data/lib/enumerize/version.rb +3 -1
- data/lib/enumerize.rb +9 -0
- data/lib/sequel/plugins/enumerize.rb +18 -0
- data/spec/enumerize/integrations/rspec/matcher_spec.rb +13 -10
- data/spec/spec_helper.rb +2 -0
- data/test/activemodel_test.rb +114 -0
- data/test/activerecord_test.rb +327 -78
- data/test/attribute_map_test.rb +9 -7
- data/test/attribute_test.rb +37 -34
- data/test/base_test.rb +117 -65
- data/test/formtastic_test.rb +25 -0
- data/test/module_attributes_test.rb +10 -8
- data/test/mongo_mapper_test.rb +20 -11
- data/test/mongoid_test.rb +52 -23
- data/test/multiple_test.rb +27 -19
- data/test/predicates_test.rb +51 -29
- data/test/rails_admin_test.rb +8 -6
- data/test/sequel_test.rb +228 -177
- data/test/set_test.rb +29 -27
- data/test/simple_form_test.rb +25 -0
- data/test/support/mock_controller.rb +6 -0
- data/test/support/shared_enums.rb +43 -0
- data/test/support/view_test_helper.rb +14 -1
- data/test/test_helper.rb +10 -0
- data/test/value_test.rb +59 -31
- metadata +16 -7
- data/.travis.yml +0 -18
- data/Gemfile.rails42 +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a2c0c71e8e7b38b6ec3eb0e0f53429a21465bd1dcea61ea87761a497fa9f55ab
|
4
|
+
data.tar.gz: b2803acb5138d2a471ddf84cbcc8b5b3fde56507e8f6db7135ea7ea6f50f5f98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb1506ba0eed847bf0e8f09df719ad06f88034b3f58988046bad0f36ecbcabf8e43f8b31f2e38160f15cf0d7886667fbc36a59b91b73f85a6b09efd6d925877
|
7
|
+
data.tar.gz: 4e927b95541a1cd89584d65c7abc5bd1ab7b0fdcda8abaa7e9c53c7b0b4c0e928c5a2055e0c160ffd0e1b295f276d534909f0411c0c6ea35342ee10f2dca9380
|
@@ -0,0 +1,75 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-20.04
|
12
|
+
services:
|
13
|
+
mongodb:
|
14
|
+
image: mongo:latest
|
15
|
+
ports:
|
16
|
+
- 27017:27017
|
17
|
+
postgres:
|
18
|
+
image: postgres:12
|
19
|
+
env:
|
20
|
+
POSTGRES_USER: postgres
|
21
|
+
POSTGRES_PASSWORD: postgres
|
22
|
+
ports:
|
23
|
+
- 5432:5432
|
24
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
25
|
+
mysql:
|
26
|
+
image: mysql:5.6
|
27
|
+
env:
|
28
|
+
MYSQL_ROOT_PASSWORD: mysql
|
29
|
+
ports:
|
30
|
+
- 3306:3306
|
31
|
+
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
|
32
|
+
strategy:
|
33
|
+
fail-fast: false
|
34
|
+
matrix:
|
35
|
+
ruby-version: ['2.7', '3.0', '3.1']
|
36
|
+
test: ['minitest', 'rspec']
|
37
|
+
gemfile:
|
38
|
+
- Gemfile
|
39
|
+
- Gemfile.rails60
|
40
|
+
- Gemfile.rails61
|
41
|
+
- Gemfile.rails70
|
42
|
+
- Gemfile.railsmaster
|
43
|
+
- Gemfile.mongo_mapper
|
44
|
+
db:
|
45
|
+
- sqlite3
|
46
|
+
- postgresql
|
47
|
+
- mysql2
|
48
|
+
exclude:
|
49
|
+
- gemfile: Gemfile.mongo_mapper
|
50
|
+
db: postgresql
|
51
|
+
- ruby-version: '3.0'
|
52
|
+
gemfile: Gemfile
|
53
|
+
- ruby-version: '3.1'
|
54
|
+
gemfile: Gemfile
|
55
|
+
- ruby-version: '3.0'
|
56
|
+
gemfile: Gemfile.mongo_mapper
|
57
|
+
- ruby-version: '3.1'
|
58
|
+
gemfile: Gemfile.mongo_mapper
|
59
|
+
env:
|
60
|
+
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
61
|
+
DB: "${{ matrix.db }}"
|
62
|
+
TEST_FRAMEWORK: "${{ matrix.test }}"
|
63
|
+
steps:
|
64
|
+
- uses: actions/checkout@v2
|
65
|
+
- name: Set up Ruby
|
66
|
+
uses: ruby/setup-ruby@v1
|
67
|
+
with:
|
68
|
+
ruby-version: ${{ matrix.ruby-version }}
|
69
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
70
|
+
- name: Run tests
|
71
|
+
run: bundle exec rake
|
72
|
+
env:
|
73
|
+
POSTGRES_USER: postgres
|
74
|
+
POSTGRES_PASSWORD: postgres
|
75
|
+
MYSQL_ROOT_PASSWORD: mysql
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,123 @@
|
|
1
|
-
##
|
1
|
+
## 2.7.0 (July 7, 2023)
|
2
|
+
|
3
|
+
### bug fix
|
4
|
+
|
5
|
+
* Warn about already defined predicate methods only when we generate predicate methods with `predicate: true` (by [@nashby](https://github.com/nashby))
|
6
|
+
* Define `Type#cast` instead of deserialize to fix serialization issue. (by [@nashby](https://github.com/nashby))
|
7
|
+
* Fix `Undefined method 'enumerize' for RSpec::ExampleGroups` (by [@softwaregravy](https://github.com/softwaregravy))
|
8
|
+
|
9
|
+
### enchancements
|
10
|
+
|
11
|
+
* Add support for procs as `i18n_scope` option value. (by [@nashby](https://github.com/nashby))
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
enumerize :color, in: %w[green blue], i18n_scope: proc { |value| "color" }
|
15
|
+
```
|
16
|
+
|
17
|
+
## 2.6.1 (March 17, 2023)
|
18
|
+
|
19
|
+
### bug fix
|
20
|
+
|
21
|
+
* Require rspec/matchers in enumerize matcher to fix rspec extensions load issue.
|
22
|
+
* Fix Ruby 2.7 issue with initializer without keyword args.
|
23
|
+
|
24
|
+
## 2.6.0 (March 7, 2023)
|
25
|
+
|
26
|
+
### enhancements
|
27
|
+
|
28
|
+
* Add `Enumerize::Attribute#value?`. This new method prevents the following breakage
|
29
|
+
when autocorrecting with Performance/InefficientHashSearch cop. (by [@koic](https://github.com/koic))
|
30
|
+
* Allow usage of kwargs with inheritance in Ruby 3.x. Support only Ruby 2.7+. (by [@mortik](https://github.com/mortik))
|
31
|
+
|
32
|
+
## 2.5.0 (December 24, 2021)
|
2
33
|
|
3
34
|
### enhancements
|
4
35
|
|
36
|
+
* Add support for Rails 7.0.0.alpha. (by [@f-mer](https://github.com/f-mer))
|
37
|
+
* Add support for negative shallow scopes. (by [@nashby](https://github.com/nashby))
|
38
|
+
|
39
|
+
## 2.4.0 (December 12, 2020)
|
40
|
+
|
41
|
+
### enhancements
|
42
|
+
|
43
|
+
* Show warning when enumerized value name conflicts with existing object's methods. (by [@aki77](https://github.com/aki77))
|
44
|
+
* Add RSpec support for shallow scopes. (by [@nashby](https://github.com/nashby))
|
45
|
+
* Drop support for Ruby older than 2.5. Support only Ruby 2.5+. (by [@nashby](https://github.com/nashby))
|
46
|
+
* Drop support for Rails 4. Support only Rails 5.2+. (by [@nashby](https://github.com/nashby))
|
47
|
+
* Add support for Rails 6.1 (by [@y-yagi](https://github.com/y-yagi))
|
48
|
+
|
5
49
|
### bug fix
|
6
50
|
|
51
|
+
* Fix exception when using predicate methods on enumerized value transformed into invalid value. (by [@guigs](https://github.com/guigs))
|
52
|
+
* Fix issue with RSpec#with_predicates matcher when custom values are used as attribute. (by [@nashby](https://github.com/nashby))
|
53
|
+
|
54
|
+
## 2.3.1 (May 2, 2019)
|
55
|
+
|
56
|
+
### enhancements
|
57
|
+
|
58
|
+
* Add ability to skip validations by passing `:skip_validations` option. (by [@chumakoff](https://github.com/chumakoff))
|
59
|
+
* Add option `scope: shallow` to extend scopes based on enumerized attribute values (by [@moofkit](https://github.com/moofkit/))
|
60
|
+
|
61
|
+
### bug fix
|
62
|
+
|
63
|
+
* Fix issue with ActiveRecord and Mongoid `reload` method when enumberized attributes weren't synced from DB. (by [@nashby](https://github.com/nashby) and [@FunkyloverOne](https://github.com/FunkyloverOne))
|
64
|
+
* Fix issue with ActiveRecord `reload` method not working for ActiveRecord::Store attributes due to `1b776c`. (by [@rickcsong](https://github.com/rickcsong))
|
65
|
+
|
66
|
+
## 2.2.2 (March 6, 2018)
|
67
|
+
|
68
|
+
### bug fix
|
69
|
+
|
70
|
+
* Support non-ActiveModel objects in SimpleForm/Formtastic integration. (by [@nashby](https://github.com/nashby))
|
71
|
+
|
72
|
+
## 2.2.1 (February 15, 2018)
|
73
|
+
|
74
|
+
### bug fix
|
75
|
+
|
76
|
+
* Fix issue with SimpleForm/Formtastic forms without object. (by [@nashby](https://github.com/nashby))
|
77
|
+
|
78
|
+
## 2.2.0 (February 13, 2018)
|
79
|
+
|
80
|
+
### enhancements
|
81
|
+
|
82
|
+
* Add integration with active_interaction. (by [@runephilosof](https://github.com/runephilosof))
|
83
|
+
* Allow using `plugin :enumerize` with Sequel. (by [@jnylen](https://github.com/jnylen))
|
84
|
+
* Support ActiveModel::Attributes from Rails 5.2. (by [@troter](https://github.com/troter))
|
85
|
+
* Support Sequel 5.2.0. (by [@troter](https://github.com/troter))
|
86
|
+
|
87
|
+
### bug fix
|
88
|
+
|
89
|
+
* Fix RailsAdmin integration when enumerated field used on edit form and enumerated value wasn't set. (by [@nashby](https://github.com/nashby))
|
90
|
+
* Fallback to a raw passed value instead of nil if AR type can't find value in the attribute. (by [@nashby](https://github.com/nashby))
|
91
|
+
|
92
|
+
## 2.1.2 (May 18, 2017)
|
93
|
+
|
94
|
+
### bug fix
|
95
|
+
|
96
|
+
* Support YAML serialization for the custom AR type. (by [@lest](https://github.com/lest))
|
97
|
+
|
98
|
+
## 2.1.1 (May 1, 2017)
|
99
|
+
|
100
|
+
### enhancements
|
101
|
+
|
102
|
+
* Run tests with multiple DBs (SQLite and PostgreSQL). (by [tkawa](https://github.com/tkawa))
|
103
|
+
|
104
|
+
### bug fix
|
105
|
+
|
106
|
+
* Support deserialize and Rails 4.2 methods in the custom AR::Type class. (by [@lest](https://github.com/lest))
|
107
|
+
* Support dumping custom AR type to JSON. (by [@lest](https://github.com/lest))
|
108
|
+
|
109
|
+
## 2.1.0 (March 31, 2017)
|
110
|
+
|
111
|
+
### enhancements
|
112
|
+
|
113
|
+
* Support Active Record types serialization. (by [@lest](https://github.com/lest))
|
114
|
+
|
115
|
+
## 2.0.1 (October 18, 2016)
|
116
|
+
|
117
|
+
### bug fix
|
118
|
+
|
119
|
+
* Support enumerized attributes in #update_all on relation objects. (by [@lest](https://github.com/lest))
|
120
|
+
|
7
121
|
## 2.0.0 (August 10, 2016)
|
8
122
|
|
9
123
|
### enhancements
|
@@ -12,11 +126,11 @@
|
|
12
126
|
* Drop support for Rails 4.0 and 4.1. Support only Rails 4.2 and newer. (by [@lest](https://github.com/lest))
|
13
127
|
* Support Rails 5.0. (by [@nashby](https://github.com/nashby) and [@lest](https://github.com/lest))
|
14
128
|
* Allow to pass enumerize values to `ActiveRecord#update_all` (by [@DmitryTsepelev](https://github.com/DmitryTsepelev) and [@ianwhite](https://github.com/ianwhite))
|
15
|
-
|
129
|
+
|
16
130
|
```ruby
|
17
131
|
User.update_all(status: :blocked)
|
18
132
|
```
|
19
|
-
|
133
|
+
|
20
134
|
### bug fix
|
21
135
|
|
22
136
|
* Rescue MissingAttributeError on attribute writing. (by [@embs](https://github.com/embs))
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
eval_gemfile('Gemfile.global')
|
2
2
|
|
3
3
|
gem 'minitest', '~> 5.8'
|
4
|
-
gem 'rails', '5.
|
5
|
-
gem '
|
6
|
-
gem '
|
4
|
+
gem 'rails', '~> 5.2.4', require: false
|
5
|
+
gem 'mongoid'
|
6
|
+
gem 'sqlite3', '~> 1.5', :platform => [:ruby, :mswin, :mingw]
|
data/Gemfile.global
CHANGED
@@ -3,17 +3,13 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
gem 'rake'
|
6
|
-
gem 'rspec', :require => false
|
7
6
|
|
8
|
-
|
9
|
-
gem '
|
10
|
-
|
11
|
-
platforms :rbx do
|
12
|
-
gem 'rubysl', '~> 2.0'
|
13
|
-
gem 'psych'
|
14
|
-
gem 'rubinius-developer_tools'
|
15
|
-
gem 'rubysl-test-unit'
|
7
|
+
if ENV['TEST_FRAMEWORK'] == 'rspec'
|
8
|
+
gem 'rspec', :require => false
|
16
9
|
end
|
17
10
|
|
11
|
+
gem 'pg', '~> 1.2.3', :platform => [:ruby, :mswin, :mingw]
|
12
|
+
gem 'sequel'
|
18
13
|
gem 'simple_form'
|
19
14
|
gem 'formtastic'
|
15
|
+
gem 'mysql2'
|
data/Gemfile.mongo_mapper
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
eval_gemfile('Gemfile.global')
|
2
2
|
|
3
3
|
gem 'minitest', '~> 5.8'
|
4
|
-
gem 'rails', '
|
5
|
-
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
4
|
+
gem 'rails', '~> 5.2.4', :require => false
|
6
5
|
gem 'mongo_mapper'
|
6
|
+
gem 'sqlite3', '~> 1.3.6', :platform => [:ruby, :mswin, :mingw]
|
data/Gemfile.rails60
ADDED
data/Gemfile.rails61
ADDED
data/Gemfile.rails70
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
eval_gemfile('Gemfile.global')
|
2
|
+
|
3
|
+
gem 'minitest', '~> 5.8'
|
4
|
+
gem 'rails', github: 'rails/rails', branch: '7-0-stable', require: false
|
5
|
+
|
6
|
+
# TODO: Mongoid doesn't support Rails 7 yet. Uncomment when it's fixed https://jira.mongodb.org/browse/MONGOID-5193
|
7
|
+
# gem 'mongoid', github: 'mongodb/mongoid'
|
8
|
+
|
9
|
+
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|