assignable_values 0.14.0 → 0.16.2

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: dd2475ca27683328810e810b40276043bf60b442c621be57f29885e58647183a
4
- data.tar.gz: f3e17c9e48ce5e73faf2dfe3b3529b8275c603beef2551c6b3d83cac01a3343e
3
+ metadata.gz: b9fa8864bca68f5d9a2c7199bd08a2c3f97bb46cc3e40b0b7860c62d9bb563bb
4
+ data.tar.gz: fe00de9f990305f33905cbd8b0dcaf9fc318521b4378c344aa33bc94a536b63b
5
5
  SHA512:
6
- metadata.gz: d2f513338f30247aba1d2b8f436266e3f8865c3c367a0367268131f4f61df7ee80a21e049a4a96b7ce65e90e38068ee759ca6829e23e620635d4595cfa6cc825
7
- data.tar.gz: be46b3706a7fc5fece9c43b4ac47164ae9b1cd67a43227707c6182d8ae5755eed601aed0f79d25a5fbfdca88519df64f1323104999265725f0992fb6662417f5
6
+ metadata.gz: 815643f34c5d95f2ed47ae5ebdec2dd31c7da83ae1ded589efebf6409789bf30f002315d94468a5e8c14f2f64412fbae025f8a0dec7c057a66826417282a0ca9
7
+ data.tar.gz: 500c291826c51db9bfad4d3f222052a1b0e3c2cd59260a7db2f9ee58368d5574734cf58db92c42ec6aa34f1c5a5657d57919e8e1df2c97b05da4b4e69bb9d384
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.3.8
@@ -1,63 +1,80 @@
1
1
  language: ruby
2
2
 
3
+ dist: trusty
4
+
3
5
  rvm:
4
6
  - 1.8.7
5
7
  - 2.1.8
6
- - 2.3.1
8
+ - 2.3.8
7
9
  - 2.4.2
10
+ - 2.5.3
8
11
 
9
12
  gemfile:
10
- - gemfiles/Gemfile.2.3
11
- - gemfiles/Gemfile.3.2
12
- - gemfiles/Gemfile.4.2
13
- - gemfiles/Gemfile.5.0
14
- - gemfiles/Gemfile.5.1
15
- - gemfiles/Gemfile.5.1.pg
13
+ - Gemfile.2.3
14
+ - Gemfile.3.2
15
+ - Gemfile.4.2
16
+ - Gemfile.5.0
17
+ - Gemfile.5.1
18
+ - Gemfile.5.1.pg
19
+ - Gemfile.6.0.pg
16
20
 
17
21
  matrix:
18
22
  exclude:
19
- - gemfile: gemfiles/Gemfile.2.3
23
+ - gemfile: Gemfile.2.3
20
24
  rvm: 2.1.8
21
- - gemfile: gemfiles/Gemfile.2.3
22
- rvm: 2.3.1
23
- - gemfile: gemfiles/Gemfile.2.3
25
+ - gemfile: Gemfile.2.3
26
+ rvm: 2.3.8
27
+ - gemfile: Gemfile.2.3
24
28
  rvm: 2.4.2
25
- - gemfile: gemfiles/Gemfile.3.2
26
- rvm: 2.3.1
27
- - gemfile: gemfiles/Gemfile.3.2
29
+ - gemfile: Gemfile.2.3
30
+ rvm: 2.5.3
31
+ - gemfile: Gemfile.3.2
32
+ rvm: 2.3.8
33
+ - gemfile: Gemfile.3.2
28
34
  rvm: 2.4.2
29
- - gemfile: gemfiles/Gemfile.4.2
35
+ - gemfile: Gemfile.3.2
36
+ rvm: 2.5.3
37
+ - gemfile: Gemfile.4.2
30
38
  rvm: 1.8.7
31
- - gemfile: gemfiles/Gemfile.4.2
39
+ - gemfile: Gemfile.4.2
32
40
  rvm: 2.4.2
33
- - gemfile: gemfiles/Gemfile.5.0
41
+ - gemfile: Gemfile.4.2
42
+ rvm: 2.5.3
43
+ - gemfile: Gemfile.5.0
44
+ rvm: 1.8.7
45
+ - gemfile: Gemfile.5.0
34
46
  rvm: 2.1.8
35
- - gemfile: gemfiles/Gemfile.5.0
47
+ - gemfile: Gemfile.5.1
36
48
  rvm: 1.8.7
37
- - gemfile: gemfiles/Gemfile.5.1
49
+ - gemfile: Gemfile.5.1
38
50
  rvm: 2.1.8
39
- - gemfile: gemfiles/Gemfile.5.1
51
+ - gemfile: Gemfile.5.1.pg
40
52
  rvm: 1.8.7
41
- - gemfile: gemfiles/Gemfile.5.1.pg
53
+ - gemfile: Gemfile.5.1.pg
42
54
  rvm: 2.1.8
43
- - gemfile: gemfiles/Gemfile.5.1.pg
55
+ - gemfile: Gemfile.6.0.pg
44
56
  rvm: 1.8.7
57
+ - gemfile: Gemfile.6.0.pg
58
+ rvm: 2.1.8
59
+ - gemfile: Gemfile.6.0.pg
60
+ rvm: 2.3.8
61
+ - gemfile: Gemfile.6.0.pg
62
+ rvm: 2.4.2
63
+
64
+ addons:
65
+ postgresql: "9.4"
45
66
 
46
67
  sudo: false
47
68
 
48
69
  cache: bundler
49
70
 
50
- notifications:
51
- email:
52
- - fail@makandra.de
53
-
54
71
  before_script:
55
72
  - psql -c 'create database assignable_values_test;' -U postgres
56
73
  - mysql -e 'create database IF NOT EXISTS assignable_values_test;'
57
74
 
58
75
  install:
59
76
  # Old Travis CI bundler explodes when lockfile version doesn't match recently bumped version
60
- - gem install bundler --version='=1.12.5'
77
+ - gem install bundler --version='=1.17.3'
61
78
  # This is the default Travis CI install step
62
79
  - bundle install --jobs=3 --retry=3 --deployment --path=${BUNDLE_PATH:-vendor/bundle}
63
80
 
@@ -6,11 +6,45 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
6
6
 
7
7
  ### Breaking changes
8
8
 
9
- -
9
+ ### Compatible changes
10
+
11
+ ## 0.16.2 - 2020-10-06
12
+
13
+ ### Compatible changes
14
+
15
+ - when given a scope, do not load all records to memory during validation
16
+
17
+ ## 0.16.1 - 2019-05-14
18
+
19
+ ### Compatible changes
20
+
21
+ - add tests for Rails 6
22
+ - Humanized assignable value methods now also take the include_old_values option (fixes #25)
23
+
24
+
25
+ ## 0.16.0 - 2019-02-20
26
+
27
+ ### Breaking changes
28
+
29
+ - fix arity bug
30
+
31
+
32
+ ## 0.15.1 - 2018-11-05
33
+
34
+ ### Compatible changes
35
+
36
+ - Add `#humanized_values` for the `multiple: true` case.
37
+
38
+
39
+ ## 0.15.0 - 2018-10-26
40
+
41
+ ### Breaking changes
42
+
43
+ - `#humanized_values` is deprecated, in favour of `#humanized_assignablevalues`
10
44
 
11
45
  ### Compatible changes
12
46
 
13
- -
47
+ - `#humanized_value(value)` and `#humanized_assignable_values` now also works for the `multiple: true` case
14
48
 
15
49
 
16
50
  ## 0.14.0 - 2018-09-17
data/Gemfile CHANGED
@@ -1 +1 @@
1
- ./gemfiles/Gemfile.4.2
1
+ ./Gemfile.4.2
@@ -13,4 +13,4 @@ gem 'rspec_candy'
13
13
  gem 'gemika'
14
14
 
15
15
  # Gem under test
16
- gem 'assignable_values', :path => '..'
16
+ gem 'assignable_values', :path => '.'
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ..
2
+ remote: .
3
3
  specs:
4
- assignable_values (0.14.0)
4
+ assignable_values (0.16.2)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -13,4 +13,4 @@ gem 'rspec_candy'
13
13
  gem 'gemika'
14
14
 
15
15
  # Gem under test
16
- gem 'assignable_values', :path => '..'
16
+ gem 'assignable_values', :path => '.'
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ..
2
+ remote: .
3
3
  specs:
4
- assignable_values (0.14.0)
4
+ assignable_values (0.16.2)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -13,4 +13,4 @@ gem 'rspec_candy'
13
13
  gem 'gemika'
14
14
 
15
15
  # Gem under test
16
- gem 'assignable_values', :path => '..'
16
+ gem 'assignable_values', :path => '.'
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ..
2
+ remote: .
3
3
  specs:
4
- assignable_values (0.14.0)
4
+ assignable_values (0.16.2)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -13,4 +13,4 @@ gem 'rspec_candy'
13
13
  gem 'gemika'
14
14
 
15
15
  # Gem under test
16
- gem 'assignable_values', :path => '..'
16
+ gem 'assignable_values', :path => '.'
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ..
2
+ remote: .
3
3
  specs:
4
- assignable_values (0.14.0)
4
+ assignable_values (0.16.2)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -13,4 +13,4 @@ gem 'rspec_candy'
13
13
  gem 'gemika'
14
14
 
15
15
  # Gem under test
16
- gem 'assignable_values', :path => '..'
16
+ gem 'assignable_values', :path => '.'
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ..
2
+ remote: .
3
3
  specs:
4
- assignable_values (0.14.0)
4
+ assignable_values (0.16.2)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -65,4 +65,4 @@ DEPENDENCIES
65
65
  rspec_candy
66
66
 
67
67
  BUNDLED WITH
68
- 1.16.4
68
+ 1.17.3
@@ -13,4 +13,4 @@ gem 'rspec_candy'
13
13
  gem 'gemika'
14
14
 
15
15
  # Gem under test
16
- gem 'assignable_values', :path => '..'
16
+ gem 'assignable_values', :path => '.'
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ..
2
+ remote: .
3
3
  specs:
4
- assignable_values (0.14.0)
4
+ assignable_values (0.16.2)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Runtime dependencies
4
+ gem 'activerecord', '~>6.0.0'
5
+ gem 'i18n'
6
+ gem 'pg', '<1'
7
+
8
+ # Development dependencies
9
+ gem 'rake'
10
+ gem 'database_cleaner'
11
+ gem 'rspec'
12
+ gem 'rspec_candy'
13
+ gem 'gemika'
14
+
15
+ # Gem under test
16
+ gem 'assignable_values', :path => '.'
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ assignable_values (0.16.2)
5
+ activerecord (>= 2.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (6.0.0)
11
+ activesupport (= 6.0.0)
12
+ activerecord (6.0.0)
13
+ activemodel (= 6.0.0)
14
+ activesupport (= 6.0.0)
15
+ activesupport (6.0.0)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 0.7, < 2)
18
+ minitest (~> 5.1)
19
+ tzinfo (~> 1.1)
20
+ zeitwerk (~> 2.1, >= 2.1.8)
21
+ concurrent-ruby (1.1.5)
22
+ database_cleaner (1.7.0)
23
+ diff-lcs (1.3)
24
+ gemika (0.3.4)
25
+ i18n (1.6.0)
26
+ concurrent-ruby (~> 1.0)
27
+ minitest (5.11.3)
28
+ pg (0.21.0)
29
+ rake (12.3.2)
30
+ rspec (3.8.0)
31
+ rspec-core (~> 3.8.0)
32
+ rspec-expectations (~> 3.8.0)
33
+ rspec-mocks (~> 3.8.0)
34
+ rspec-core (3.8.0)
35
+ rspec-support (~> 3.8.0)
36
+ rspec-expectations (3.8.2)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-mocks (3.8.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-support (3.8.0)
43
+ rspec_candy (0.5.1)
44
+ rspec
45
+ sneaky-save
46
+ sneaky-save (0.1.3)
47
+ activerecord (>= 3.2.0)
48
+ thread_safe (0.3.6)
49
+ tzinfo (1.2.5)
50
+ thread_safe (~> 0.1)
51
+ zeitwerk (2.1.9)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ activerecord (~> 6.0.0)
58
+ assignable_values!
59
+ database_cleaner
60
+ gemika
61
+ i18n
62
+ pg (< 1)
63
+ rake
64
+ rspec
65
+ rspec_candy
66
+
67
+ BUNDLED WITH
68
+ 1.17.3
@@ -1 +1 @@
1
- ./gemfiles/Gemfile.4.2.lock
1
+ ./Gemfile.4.2.lock
data/README.md CHANGED
@@ -5,7 +5,7 @@ assignable_values - Enums on vitamins [![Build Status](https://secure.travis-ci.
5
5
 
6
6
  We carefully enhanced the core enum functionality with small tweaks that are useful for web forms, internationalized applications and common authorization patterns.
7
7
 
8
- `assignable_values` is tested with Rails 2.3, 3.2, 4.2 and 5.0 on Ruby 1.8.7, 2.1 and 2.3.
8
+ `assignable_values` is tested with Rails 2.3, 3.2, 4.2, 5.1 and 6.0 (beta) on Ruby 1.8.7, 2.1, 2.3, 2.4 and 2.5.
9
9
 
10
10
 
11
11
  Restricting scalar attributes
@@ -65,13 +65,13 @@ Or you can retrieve the humanized version of any given value by passing it as an
65
65
 
66
66
  You can obtain a list of all assignable values with their humanizations:
67
67
 
68
- song.humanized_genres.size # => 3
69
- song.humanized_genres.first.value # => "pop"
70
- song.humanized_genres.first.humanized # => "Pop music"
68
+ song.humanized_assignable_genres.size # => 3
69
+ song.humanized_assignable_genres.first.value # => "pop"
70
+ song.humanized_assignable_genres.first.humanized # => "Pop music"
71
71
 
72
72
  A good way to populate a `<select>` tag with pairs of internal values and human labels is to use the `collection_select` helper from Rails:
73
73
 
74
- form.collection_select :genre, form.object.humanized_genres, :value, :humanized
74
+ form.collection_select :genre, form.object.humanized_assignable_genres, :value, :humanized
75
75
 
76
76
 
77
77
  ### Defining default values
@@ -91,7 +91,7 @@ The default is applied to new records:
91
91
  Defaults can be procs:
92
92
 
93
93
  class Song < ActiveRecord::Base
94
- assignable_values_for :genre, default: proc { Date.today.year } do
94
+ assignable_values_for :year, default: proc { Date.today.year } do
95
95
  1980 .. 2011
96
96
  end
97
97
  end
@@ -166,7 +166,7 @@ This is to prevent records from becoming invalid as the list of assignable value
166
166
 
167
167
  ### Array values
168
168
 
169
- Assignable values can also be used for array values. This works when you use Rails 5+ and PostgreSQL with an array column, or with ActiveRecord's `serialize`.
169
+ Assignable values can also be used for array values. This works when you use Rails 5+ and PostgreSQL with an array column, or on older Rails versions and other databases using ActiveRecord's `serialize`.
170
170
 
171
171
  To validate array values, pass `multiple: true`:
172
172
 
@@ -182,6 +182,13 @@ end
182
182
 
183
183
  In this case, every *subset* of the given values is valid, for example `['pop', 'electronic']`.
184
184
 
185
+ For humanization, you can still use
186
+
187
+ ```
188
+ song.humanized_genre('pop') # => "Pop music"
189
+ song.humanized_assignable_genres.last.humanized # => "Electronic music"
190
+ ```
191
+
185
192
 
186
193
  Restricting belongs_to associations
187
194
  -----------------------------------
@@ -198,7 +205,7 @@ You can restrict `belongs_to` associations in the same manner as scalar attribut
198
205
 
199
206
  end
200
207
 
201
- Listing and validating als works the same:
208
+ Listing and validating also works the same:
202
209
 
203
210
  chicane = Artist.create!(name: 'Chicane', signed: true)
204
211
  lt2 = Artist.create!(name: 'LT2', signed: false)
@@ -342,16 +349,19 @@ Development
342
349
 
343
350
  There are tests in `spec`. We only accept PRs with tests. To run tests:
344
351
 
345
- - Install Ruby 2.1.8
346
- - Create a local test database `assignable_values_test` in both MySQL and PostgreSQL
347
- - Copy `spec/support/database.sample.yml` to `spec/support/database.yml` and enter your local credentials for the test database
352
+ - Install Ruby 2.3.8
353
+ - Create a local test database `assignable_values_test` in both MySQL and PostgreSQL (see
354
+ `.travis.yml` for commands to do so)
355
+ - Copy `spec/support/database.sample.yml` to `spec/support/database.yml` and enter your local
356
+ credentials for the test databases (postgres entry is not required if you are using a socket
357
+ connection)
348
358
  - Install development dependencies using `bundle install`
349
- - Run tests using `bundle exec rspec`
359
+ - Run tests using `bundle exec rake current_rspec`
350
360
 
351
361
  We recommend to test large changes against multiple versions of Ruby and multiple dependency sets. Supported combinations are configured in `.travis.yml`. We provide some rake tasks to help with this:
352
362
 
353
- - Install development dependencies using `bundle matrix:install`
354
- - Run tests using `bundle matrix:spec`
363
+ - Install development dependencies using `bundle exec rake matrix:install`
364
+ - Run tests using `bundle exec rake matrix:spec`
355
365
 
356
366
  Note that we have configured Travis CI to automatically run tests in all supported Ruby versions and dependency sets after each push. We will only merge pull requests after a green Travis build.
357
367