array_enum 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b351f8ef6ab75778ff9f71e7a9c1a67f409277dcaf644eb5a3d3d8ca1538e81
4
- data.tar.gz: e2885b84818083a62aa7b65cbf9aa8be594400f417c0edaf2509cfd0a7cf32f1
3
+ metadata.gz: b4f3ef7689bbd8ab0f1fd27d9c1157e40764fd6f991217f64937f903e058753d
4
+ data.tar.gz: 377266d5f7da9332e61bc7cc825e5db419a76d2c2193b13474027c83fb3b18ef
5
5
  SHA512:
6
- metadata.gz: 206999b4a7e1598a9688cf5041d3a28192cb95cd54efbbf3a7f2ead8dba17f7e34d8e1a909a7a11ff8a3ed5112f5aa070bcebf7975c87ea545082e9bc7deb649
7
- data.tar.gz: 0fe06f8ebf0b611b8f025db7d8d9971254413f92880cef4d1045f15a220d8d52c812141578fc8556e69d7e1a671c8bfb1e769d7fb8386e6c3552b6992a4afc46
6
+ metadata.gz: 06404fcc83bf4b4b1a3ddc3718f1cee0f260a0572c97955e1b0184005950df32f2149e2175e55d20cb8e7f562e905e081fe1499a6007d8d9f22f16cf3f52a3b1
7
+ data.tar.gz: fd070af7976fdf52f4f5a6672e51172afa51a781e80a07ddf6f4f9a9183249cdf42dd52b61ad92f4cdb284cfa6adc487bf64ef2c41d52ac75e3e7c4d06365534
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ services:
9
+ postgres:
10
+ image: postgres:11
11
+ ports:
12
+ - 5432:5432
13
+ env:
14
+ POSTGRES_PASSWORD: ""
15
+
16
+ steps:
17
+ - name: Install libraries
18
+ run: |
19
+ sudo apt-get update
20
+ sudo apt-get install -y libpq-dev postgresql-client
21
+
22
+ - name: Configure database
23
+ run: |
24
+ echo "PostgreSQL"
25
+ psql -h localhost -c 'create database "array_enum_test";' -U postgres
26
+
27
+ - uses: actions/checkout@v1
28
+
29
+ - name: Set up Ruby
30
+ uses: actions/setup-ruby@v1
31
+ with:
32
+ ruby-version: 2.6.x
33
+
34
+ - name: Build and test
35
+ run: |
36
+ gem install bundler
37
+ bundle install --jobs 4 --retry 3
38
+ bundle exec rake test
@@ -1,33 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- array_enum (1.1.0)
4
+ array_enum (1.2.0)
5
5
  activemodel
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (5.2.3)
11
- activesupport (= 5.2.3)
12
- activerecord (5.2.3)
13
- activemodel (= 5.2.3)
14
- activesupport (= 5.2.3)
15
- arel (>= 9.0)
16
- activesupport (5.2.3)
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)
17
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
17
  i18n (>= 0.7, < 2)
19
18
  minitest (~> 5.1)
20
19
  tzinfo (~> 1.1)
21
- arel (9.0.0)
20
+ zeitwerk (~> 2.1, >= 2.1.8)
22
21
  concurrent-ruby (1.1.5)
23
22
  i18n (1.6.0)
24
23
  concurrent-ruby (~> 1.0)
25
24
  minitest (5.11.3)
26
25
  pg (1.1.4)
27
- rake (12.3.2)
26
+ rake (12.3.3)
28
27
  thread_safe (0.3.6)
29
28
  tzinfo (1.2.5)
30
29
  thread_safe (~> 0.1)
30
+ zeitwerk (2.1.9)
31
31
 
32
32
  PLATFORMS
33
33
  ruby
@@ -41,4 +41,4 @@ DEPENDENCIES
41
41
  rake (>= 10.0)
42
42
 
43
43
  BUNDLED WITH
44
- 1.17.3
44
+ 2.0.2
data/README.md CHANGED
@@ -43,6 +43,8 @@ class CreateUser
43
43
  attr_accessor :favourite_colors
44
44
 
45
45
  validates :favourite_colors, subset: ["green", "blue"]
46
+ # or:
47
+ # validates :favourite_colors, subset: { in: ->(record) { Color.pluck(:name) } }
46
48
  end
47
49
 
48
50
  CreateUser.new(favourite_colors: ["black"]).valid? # => false
@@ -50,8 +52,6 @@ CreateUser.new(favourite_colors: ["black"]).valid? # => false
50
52
 
51
53
  ## Development
52
54
 
53
- [![Build Status](https://travis-ci.com/freeletics/array_enum.svg?branch=master)](https://travis-ci.com/freeletics/array_enum)
54
-
55
55
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
56
 
57
57
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -1,6 +1,6 @@
1
1
  require "array_enum/version"
2
2
  require "array_enum/subset_validator"
3
- require "array_enum/railtie" if defined?(Rails)
3
+ require "array_enum/railtie" if defined?(Rails::Railtie)
4
4
  require "active_support/hash_with_indifferent_access"
5
5
  require "active_support/core_ext/string/inflections"
6
6
 
@@ -3,7 +3,9 @@ require "active_model/validator"
3
3
  class ArrayEnum::SubsetValidator < ActiveModel::EachValidator
4
4
  def validate_each(record, attribute, value)
5
5
  wrapped_value = [value].flatten # Handles nil value
6
- diff = wrapped_value.reject { |element| delimiter.include?(element) }
6
+ subset = delimiter.respond_to?(:call) ? delimiter.call(record) : delimiter
7
+
8
+ diff = wrapped_value.reject { |element| subset.include?(element) }
7
9
 
8
10
  unless diff.empty?
9
11
  record.errors.add(attribute, :inclusion, options.except(:in, :within).merge!(value: diff))
@@ -1,3 +1,3 @@
1
1
  module ArrayEnum
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: array_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojciech Wnętrzak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-25 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -103,8 +103,8 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
+ - ".github/workflows/ci.yml"
106
107
  - ".gitignore"
107
- - ".travis.yml"
108
108
  - Gemfile
109
109
  - Gemfile.lock
110
110
  - LICENSE.txt
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubygems_version: 3.0.4
141
+ rubygems_version: 3.0.6
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: String to integer mapping for PostgreSQL array columns.
@@ -1,16 +0,0 @@
1
- dist: xenial
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.3
6
-
7
- addons:
8
- postgresql: "10"
9
-
10
- before_script:
11
- - psql -c 'create database "array_enum_test";' -U postgres
12
-
13
- script: "bundle exec rake"
14
-
15
- notifications:
16
- disabled: true