enumerize 0.8.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +73 -0
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +210 -0
- data/Gemfile +4 -21
- data/Gemfile.global +12 -0
- data/Gemfile.mongo_mapper +6 -0
- data/Gemfile.rails60 +6 -0
- data/Gemfile.rails61 +6 -0
- data/Gemfile.rails70 +9 -0
- data/Gemfile.railsmaster +5 -0
- data/README.md +366 -73
- data/Rakefile +4 -4
- data/enumerize.gemspec +2 -1
- data/lib/enumerize/activemodel.rb +47 -0
- data/lib/enumerize/activerecord.rb +102 -27
- data/lib/enumerize/attribute.rb +59 -15
- data/lib/enumerize/attribute_map.rb +2 -0
- data/lib/enumerize/base.rb +32 -17
- data/lib/enumerize/hooks/formtastic.rb +7 -9
- data/lib/enumerize/hooks/sequel_dataset.rb +17 -0
- data/lib/enumerize/hooks/simple_form.rb +9 -12
- data/lib/enumerize/hooks/uniqueness.rb +7 -8
- data/lib/enumerize/integrations/rails_admin.rb +3 -1
- data/lib/enumerize/integrations/rspec/matcher.rb +112 -26
- 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 +36 -0
- data/lib/enumerize/predicatable.rb +10 -17
- data/lib/enumerize/predicates.rb +5 -1
- data/lib/enumerize/scope/activerecord.rb +53 -0
- data/lib/enumerize/scope/mongoid.rb +50 -0
- data/lib/enumerize/scope/sequel.rb +56 -0
- data/lib/enumerize/sequel.rb +62 -0
- data/lib/enumerize/set.rb +20 -8
- data/lib/enumerize/utils.rb +12 -0
- data/lib/enumerize/value.rb +20 -20
- data/lib/enumerize/version.rb +3 -1
- data/lib/enumerize.rb +33 -2
- data/lib/sequel/plugins/enumerize.rb +18 -0
- data/spec/enumerize/integrations/rspec/matcher_spec.rb +261 -0
- data/spec/spec_helper.rb +30 -0
- data/test/activemodel_test.rb +114 -0
- data/test/activerecord_test.rb +434 -58
- data/test/attribute_map_test.rb +9 -7
- data/test/attribute_test.rb +52 -23
- data/test/base_test.rb +118 -66
- data/test/formtastic_test.rb +28 -12
- data/test/module_attributes_test.rb +10 -8
- data/test/mongo_mapper_test.rb +26 -11
- data/test/mongoid_test.rb +100 -15
- data/test/multiple_test.rb +41 -12
- data/test/predicates_test.rb +34 -26
- data/test/rails_admin_test.rb +8 -6
- data/test/sequel_test.rb +342 -0
- data/test/set_test.rb +42 -26
- data/test/simple_form_test.rb +25 -1
- data/test/support/mock_controller.rb +6 -0
- data/test/support/shared_enums.rb +43 -0
- data/test/support/view_test_helper.rb +18 -1
- data/test/test_helper.rb +33 -2
- data/test/value_test.rb +79 -28
- metadata +51 -12
- data/.travis.yml +0 -19
- data/Gemfile.rails4 +0 -23
- data/lib/enumerize/form_helper.rb +0 -23
- data/test/rspec_matcher_test.rb +0 -76
- data/test/rspec_spec.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 07d568d0eb005ebea8b0ded7cb260d6c7792b1d676bd46f8441c7e33445e366c
|
4
|
+
data.tar.gz: b811acb983e8fac641fb2b9f9340089e8fd6149b1431af7f12446cb5203c39e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b68609dbbc3eede78b640395ef59bf149f1bf00d7b55f2b03a1397430f4e8816bd6a19bdfe06151e28fb1a64a9595fe48893810b015899b00d4991af6539f5d7
|
7
|
+
data.tar.gz: 3999ab755693815c52779ca0124f6aec629a1dd639c41d33330211b0948f6f9d4aa3d79a3f20713bb99a508afa5b7e2b776a0465fe0c3c5a3c250043bbdfc0aa
|
@@ -0,0 +1,73 @@
|
|
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
|
+
gemfile:
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.rails60
|
39
|
+
- Gemfile.rails61
|
40
|
+
- Gemfile.rails70
|
41
|
+
- Gemfile.railsmaster
|
42
|
+
- Gemfile.mongo_mapper
|
43
|
+
db:
|
44
|
+
- sqlite3
|
45
|
+
- postgresql
|
46
|
+
- mysql2
|
47
|
+
exclude:
|
48
|
+
- gemfile: Gemfile.mongo_mapper
|
49
|
+
db: postgresql
|
50
|
+
- ruby-version: '3.0'
|
51
|
+
gemfile: Gemfile
|
52
|
+
- ruby-version: '3.1'
|
53
|
+
gemfile: Gemfile
|
54
|
+
- ruby-version: '3.0'
|
55
|
+
gemfile: Gemfile.mongo_mapper
|
56
|
+
- ruby-version: '3.1'
|
57
|
+
gemfile: Gemfile.mongo_mapper
|
58
|
+
env:
|
59
|
+
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
60
|
+
DB: "${{ matrix.db }}"
|
61
|
+
steps:
|
62
|
+
- uses: actions/checkout@v2
|
63
|
+
- name: Set up Ruby
|
64
|
+
uses: ruby/setup-ruby@v1
|
65
|
+
with:
|
66
|
+
ruby-version: ${{ matrix.ruby-version }}
|
67
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
68
|
+
- name: Run tests
|
69
|
+
run: bundle exec rake
|
70
|
+
env:
|
71
|
+
POSTGRES_USER: postgres
|
72
|
+
POSTGRES_PASSWORD: postgres
|
73
|
+
MYSQL_ROOT_PASSWORD: mysql
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,213 @@
|
|
1
|
+
## 2.6.1 (March 17, 2023)
|
2
|
+
|
3
|
+
### bug fix
|
4
|
+
|
5
|
+
* Require rspec/matchers in enumerize matcher to fix rspec extensions load issue.
|
6
|
+
* Fix Ruby 2.7 issue with initializer without keyword args.
|
7
|
+
|
8
|
+
## 2.6.0 (March 7, 2023)
|
9
|
+
|
10
|
+
### enhancements
|
11
|
+
|
12
|
+
* Add `Enumerize::Attribute#value?`. This new method prevents the following breakage
|
13
|
+
when autocorrecting with Performance/InefficientHashSearch cop. (by [@koic](https://github.com/koic))
|
14
|
+
* Allow usage of kwargs with inheritance in Ruby 3.x. Support only Ruby 2.7+. (by [@mortik](https://github.com/mortik))
|
15
|
+
|
16
|
+
## 2.5.0 (December 24, 2021)
|
17
|
+
|
18
|
+
### enhancements
|
19
|
+
|
20
|
+
* Add support for Rails 7.0.0.alpha. (by [@f-mer](https://github.com/f-mer))
|
21
|
+
* Add support for negative shallow scopes. (by [@nashby](https://github.com/nashby))
|
22
|
+
|
23
|
+
## 2.4.0 (December 12, 2020)
|
24
|
+
|
25
|
+
### enhancements
|
26
|
+
|
27
|
+
* Show warning when enumerized value name conflicts with existing object's methods. (by [@aki77](https://github.com/aki77))
|
28
|
+
* Add RSpec support for shallow scopes. (by [@nashby](https://github.com/nashby))
|
29
|
+
* Drop support for Ruby older than 2.5. Support only Ruby 2.5+. (by [@nashby](https://github.com/nashby))
|
30
|
+
* Drop support for Rails 4. Support only Rails 5.2+. (by [@nashby](https://github.com/nashby))
|
31
|
+
* Add support for Rails 6.1 (by [@y-yagi](https://github.com/y-yagi))
|
32
|
+
|
33
|
+
### bug fix
|
34
|
+
|
35
|
+
* Fix exception when using predicate methods on enumerized value transformed into invalid value. (by [@guigs](https://github.com/guigs))
|
36
|
+
* Fix issue with RSpec#with_predicates matcher when custom values are used as attribute. (by [@nashby](https://github.com/nashby))
|
37
|
+
|
38
|
+
## 2.3.1 (May 2, 2019)
|
39
|
+
|
40
|
+
### enhancements
|
41
|
+
|
42
|
+
* Add ability to skip validations by passing `:skip_validations` option. (by [@chumakoff](https://github.com/chumakoff))
|
43
|
+
* Add option `scope: shallow` to extend scopes based on enumerized attribute values (by [@moofkit](https://github.com/moofkit/))
|
44
|
+
|
45
|
+
### bug fix
|
46
|
+
|
47
|
+
* 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))
|
48
|
+
* Fix issue with ActiveRecord `reload` method not working for ActiveRecord::Store attributes due to `1b776c`. (by [@rickcsong](https://github.com/rickcsong))
|
49
|
+
|
50
|
+
## 2.2.2 (March 6, 2018)
|
51
|
+
|
52
|
+
### bug fix
|
53
|
+
|
54
|
+
* Support non-ActiveModel objects in SimpleForm/Formtastic integration. (by [@nashby](https://github.com/nashby))
|
55
|
+
|
56
|
+
## 2.2.1 (February 15, 2018)
|
57
|
+
|
58
|
+
### bug fix
|
59
|
+
|
60
|
+
* Fix issue with SimpleForm/Formtastic forms without object. (by [@nashby](https://github.com/nashby))
|
61
|
+
|
62
|
+
## 2.2.0 (February 13, 2018)
|
63
|
+
|
64
|
+
### enhancements
|
65
|
+
|
66
|
+
* Add integration with active_interaction. (by [@runephilosof](https://github.com/runephilosof))
|
67
|
+
* Allow using `plugin :enumerize` with Sequel. (by [@jnylen](https://github.com/jnylen))
|
68
|
+
* Support ActiveModel::Attributes from Rails 5.2. (by [@troter](https://github.com/troter))
|
69
|
+
* Support Sequel 5.2.0. (by [@troter](https://github.com/troter))
|
70
|
+
|
71
|
+
### bug fix
|
72
|
+
|
73
|
+
* Fix RailsAdmin integration when enumerated field used on edit form and enumerated value wasn't set. (by [@nashby](https://github.com/nashby))
|
74
|
+
* 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))
|
75
|
+
|
76
|
+
## 2.1.2 (May 18, 2017)
|
77
|
+
|
78
|
+
### bug fix
|
79
|
+
|
80
|
+
* Support YAML serialization for the custom AR type. (by [@lest](https://github.com/lest))
|
81
|
+
|
82
|
+
## 2.1.1 (May 1, 2017)
|
83
|
+
|
84
|
+
### enhancements
|
85
|
+
|
86
|
+
* Run tests with multiple DBs (SQLite and PostgreSQL). (by [tkawa](https://github.com/tkawa))
|
87
|
+
|
88
|
+
### bug fix
|
89
|
+
|
90
|
+
* Support deserialize and Rails 4.2 methods in the custom AR::Type class. (by [@lest](https://github.com/lest))
|
91
|
+
* Support dumping custom AR type to JSON. (by [@lest](https://github.com/lest))
|
92
|
+
|
93
|
+
## 2.1.0 (March 31, 2017)
|
94
|
+
|
95
|
+
### enhancements
|
96
|
+
|
97
|
+
* Support Active Record types serialization. (by [@lest](https://github.com/lest))
|
98
|
+
|
99
|
+
## 2.0.1 (October 18, 2016)
|
100
|
+
|
101
|
+
### bug fix
|
102
|
+
|
103
|
+
* Support enumerized attributes in #update_all on relation objects. (by [@lest](https://github.com/lest))
|
104
|
+
|
105
|
+
## 2.0.0 (August 10, 2016)
|
106
|
+
|
107
|
+
### enhancements
|
108
|
+
|
109
|
+
* Drop support for Ruby older than 2.2. Support only Ruby 2.2+. (by [@nashby](https://github.com/nashby))
|
110
|
+
* Drop support for Rails 4.0 and 4.1. Support only Rails 4.2 and newer. (by [@lest](https://github.com/lest))
|
111
|
+
* Support Rails 5.0. (by [@nashby](https://github.com/nashby) and [@lest](https://github.com/lest))
|
112
|
+
* Allow to pass enumerize values to `ActiveRecord#update_all` (by [@DmitryTsepelev](https://github.com/DmitryTsepelev) and [@ianwhite](https://github.com/ianwhite))
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
User.update_all(status: :blocked)
|
116
|
+
```
|
117
|
+
|
118
|
+
### bug fix
|
119
|
+
|
120
|
+
* Rescue MissingAttributeError on attribute writing. (by [@embs](https://github.com/embs))
|
121
|
+
* Fix presence validation for multiple attributes when the list contains a blank string. (by [@smoriwaki](https://github.com/smoriwaki))
|
122
|
+
* Replace deprecated alias_method_chain with Module#prepend. (by [@koenpunt](https://github.com/koenpunt) and [@akm](https://github.com/akm))
|
123
|
+
* Make it compatible with `globalize` gem. (by [@falm](https://github.com/falm))
|
124
|
+
* Prevent method getter from being called when no default_value is being set. (by [@arjan0307](https://github.com/arjan0307))
|
125
|
+
|
126
|
+
## 1.1.1 (January 25, 2016)
|
127
|
+
|
128
|
+
### bug fix
|
129
|
+
|
130
|
+
* Fix exception when using predicate methods and enumerized values have dash in it. (by [@nashby](https://github.com/nashby))
|
131
|
+
|
132
|
+
## 1.1.0 (November 15, 2015)
|
133
|
+
|
134
|
+
### enhancements
|
135
|
+
* Add Sequel support. (by [@mrbrdo](https://github.com/mrbrdo))
|
136
|
+
* Add qualifiers to RSpec matcher. (by [@maurogeorge](https://github.com/maurogeorge))
|
137
|
+
* Support hash in the RSpec matcher. (by [@maurogeorge](https://github.com/maurogeorge))
|
138
|
+
|
139
|
+
### bug fix
|
140
|
+
|
141
|
+
## 1.0.0 (August 2, 2015)
|
142
|
+
|
143
|
+
### enhancements
|
144
|
+
* Add `texts` method for getting an array of text values of the enumerized field with multiple type. (by [@huynhquancam](https://github.com/huynhquancam))
|
145
|
+
* Drop Rails 3.2 support. (by [@nashby](https://github.com/nashby))
|
146
|
+
|
147
|
+
### bug fix
|
148
|
+
|
149
|
+
* Fix conflicts when Active Record and Mongoid are used at the same time. (by [@matsu911](https://github.com/matsu911))
|
150
|
+
|
151
|
+
## 0.11.0 (March 29, 2015) ##
|
152
|
+
|
153
|
+
### enhancements
|
154
|
+
* Add ability to set default value for enumerized field with multiple type. (by [@nashby](https://github.com/nashby))
|
155
|
+
* Support Rails 4.2. (by [@lest](https://github.com/lest))
|
156
|
+
|
157
|
+
### bug fix
|
158
|
+
* Use Mongoid's `:in` method for generated scopes, fix chained scopes. (by [@nashby](https://github.com/nashby))
|
159
|
+
* Use `after_initialize` callback to set default value in Mongoid documents. (by [@nashby](https://github.com/nashby))
|
160
|
+
|
161
|
+
## 0.10.1 (March 4, 2015) ##
|
162
|
+
|
163
|
+
### bug fix
|
164
|
+
|
165
|
+
* Use method_missing instead of defining singleton class methods to allow Marshal serialization (by [@lest](https://github.com/lest))
|
166
|
+
|
167
|
+
## 0.10.0 (February 17, 2015) ##
|
168
|
+
|
169
|
+
### enhancements
|
170
|
+
|
171
|
+
* Add scopes support to mongoid documents (by [@nashby](https://github.com/nashby))
|
172
|
+
* Use underscore.humanize in #text to make use of Inflector acronyms (by [@mintuhouse](https://github.com/mintuhouse))
|
173
|
+
* Raise an exception when :scope option is used together with :multiple option (by [@maurogeorge](https://github.com/maurogeorge))
|
174
|
+
* Use alias_method_chain instead of overriding Class#inherited (by [@yuroyoro](https://github.com/yuroyoro))
|
175
|
+
* Shortcut methods to retrieve enumerize values (by [@CyborgMaster](https://github.com/CyborgMaster))
|
176
|
+
* Extend equality operator to support comparing with symbols and custom values (e.g. integers) (by [@CyborgMaster](https://github.com/CyborgMaster))
|
177
|
+
|
178
|
+
## 0.9.0 (December 11, 2014) ##
|
179
|
+
|
180
|
+
### enhancements
|
181
|
+
|
182
|
+
* Add :value_class option (by [@lest](https://github.com/lest))
|
183
|
+
* Use 'defaults' scope in the localization file for the attributes that used across several models. This will help to avoid conflicting keys with model names and attribute names. Example:
|
184
|
+
|
185
|
+
```yml
|
186
|
+
en:
|
187
|
+
enumerize:
|
188
|
+
defaults:
|
189
|
+
sex:
|
190
|
+
male: Male
|
191
|
+
female: Female
|
192
|
+
```
|
193
|
+
|
194
|
+
You still can use the old solution without "default" scope:
|
195
|
+
|
196
|
+
```yml
|
197
|
+
en:
|
198
|
+
enumerize:
|
199
|
+
sex:
|
200
|
+
male: Male
|
201
|
+
female: Female
|
202
|
+
```
|
203
|
+
(by [@nashby](https://github.com/nashby))
|
204
|
+
|
205
|
+
### bug fix
|
206
|
+
* Store values for validation using string keys (by [@nagyt234](https://github.com/nagyt234))
|
207
|
+
* Store custom values for multiple attributes (by [@lest](https://github.com/lest))
|
208
|
+
* Support validations after using AR#becomes (by [@lest](https://github.com/lest))
|
209
|
+
* Do not try to set attribute for not selected attributes (by [@dany1468](https://github.com/dany1468))
|
210
|
+
|
1
211
|
## 0.8.0 (March 4, 2014) ##
|
2
212
|
|
3
213
|
### enhancements
|
data/Gemfile
CHANGED
@@ -1,23 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'rake'
|
6
|
-
gem 'minitest', '~> 4.1'
|
7
|
-
gem 'rspec', :require => false
|
8
|
-
|
9
|
-
gem 'rails', '~> 3.2.0', :require => false
|
10
|
-
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
11
|
-
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
12
|
-
|
13
|
-
platforms :rbx do
|
14
|
-
gem 'rubysl', '~> 2.0'
|
15
|
-
gem 'psych'
|
16
|
-
gem 'rubinius-developer_tools'
|
17
|
-
gem 'rubysl-test-unit'
|
18
|
-
end
|
1
|
+
eval_gemfile('Gemfile.global')
|
19
2
|
|
3
|
+
gem 'minitest', '~> 5.8'
|
4
|
+
gem 'rails', '~> 5.2.4', require: false
|
20
5
|
gem 'mongoid'
|
21
|
-
gem '
|
22
|
-
gem 'simple_form'
|
23
|
-
gem 'formtastic'
|
6
|
+
gem 'sqlite3', '~> 1.5', :platform => [:ruby, :mswin, :mingw]
|
data/Gemfile.global
ADDED
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]
|