ar-enum 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.travis.yml +20 -18
- data/gemfiles/activerecord_6_0.gemfile +1 -1
- data/lib/ar/enum.rb +6 -2
- data/lib/ar/enum/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d19aadabd18299434e0b2d6b0575c818e50219a52dc2498d9cd2547fd1762ed
|
4
|
+
data.tar.gz: 319fd8919aa508923146bcbc06867e9547c8623903d37789c90ef9310745ff25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2126449281a5b6a2c3b26649efcb287db2da514804ac5ee38306b95f27d7caec964f1afde1d359575f2952d1c3c9fff660039e8e046c27084404f7c9705082c9
|
7
|
+
data.tar.gz: 9666be7a4612e9fa07afbb05aa1ba6f4002c8f56b199f3f102ff083a3040b685dd6f79b54b50707adecacdf29a764f1314424f7d41b1a166ea96136ab38e80b0
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,31 +1,33 @@
|
|
1
|
+
---
|
1
2
|
language: ruby
|
3
|
+
dist: xenial
|
2
4
|
addons:
|
3
|
-
postgresql: "
|
5
|
+
postgresql: "11"
|
4
6
|
apt:
|
5
7
|
packages:
|
6
|
-
- postgresql-
|
7
|
-
- postgresql-client-
|
8
|
+
- postgresql-11
|
9
|
+
- postgresql-client-11
|
8
10
|
cache: bundler
|
9
11
|
before_install:
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
- sudo
|
14
|
-
- sudo
|
12
|
+
- gem install bundler
|
13
|
+
- sudo service postgresql stop
|
14
|
+
- sed -e 's/^port.*/port = 5432/' /etc/postgresql/11/main/postgresql.conf > postgresql.conf
|
15
|
+
- sudo chown postgres postgresql.conf
|
16
|
+
- sudo mv postgresql.conf /etc/postgresql/11/main
|
17
|
+
- sudo service postgresql start 11
|
15
18
|
before_script:
|
16
|
-
- createdb test
|
17
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
18
|
-
- chmod +x ./cc-test-reporter
|
19
|
-
- "./cc-test-reporter before-build"
|
19
|
+
- createdb test
|
20
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
21
|
+
- chmod +x ./cc-test-reporter
|
22
|
+
- "./cc-test-reporter before-build"
|
20
23
|
after_script:
|
21
|
-
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
24
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
22
25
|
gemfile:
|
23
|
-
-
|
24
|
-
- gemfiles/
|
25
|
-
- gemfiles/activerecord_5_2.gemfile
|
26
|
+
- gemfiles/activerecord_6_0.gemfile
|
27
|
+
- gemfiles/activerecord_5_2.gemfile
|
26
28
|
rvm:
|
27
|
-
- 2.6.
|
28
|
-
- 2.5.
|
29
|
+
- 2.6.5
|
30
|
+
- 2.5.7
|
29
31
|
notifications:
|
30
32
|
email: false
|
31
33
|
env:
|
data/lib/ar/enum.rb
CHANGED
@@ -19,13 +19,17 @@ end
|
|
19
19
|
|
20
20
|
ActiveSupport.on_load(:active_record) do
|
21
21
|
require "active_record/connection_adapters/postgresql_adapter"
|
22
|
+
silence_warnings do
|
23
|
+
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES = ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES.dup
|
24
|
+
end
|
22
25
|
|
23
26
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(
|
24
27
|
Module.new do
|
25
28
|
def create_table_definition(*args)
|
26
29
|
ActiveRecord::Base.connection.enum_types.each do |enum|
|
27
|
-
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[enum["name"].to_sym] = {name: enum["name"]}
|
28
30
|
ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods.class_eval do
|
31
|
+
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[enum["name"].to_sym] = {name: enum["name"]}
|
32
|
+
|
29
33
|
define_method(enum["name"]) do |*names, **options|
|
30
34
|
names.each {|name| column(name, enum["name"].to_sym, options) }
|
31
35
|
end
|
@@ -53,7 +57,7 @@ ActiveSupport.on_load(:active_record) do
|
|
53
57
|
)
|
54
58
|
type_metadata = ActiveRecord::ConnectionAdapters::PostgreSQLTypeMetadata.new(type_metadata)
|
55
59
|
|
56
|
-
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[type_metadata.type] = {name: "character varying"}
|
60
|
+
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[type_metadata.type] = {name: "character varying"}
|
57
61
|
end
|
58
62
|
|
59
63
|
type_metadata
|
data/lib/ar/enum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -116,6 +116,7 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
|
+
- ".rubocop.yml"
|
119
120
|
- ".travis.yml"
|
120
121
|
- CHANGELOG.md
|
121
122
|
- CODE_OF_CONDUCT.md
|
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
152
|
- !ruby/object:Gem::Version
|
152
153
|
version: '0'
|
153
154
|
requirements: []
|
154
|
-
rubygems_version: 3.0.
|
155
|
+
rubygems_version: 3.0.3
|
155
156
|
signing_key:
|
156
157
|
specification_version: 4
|
157
158
|
summary: Add support for creating `ENUM` types in PostgreSQL with ActiveRecord
|