activerecord-mysql-enum 0.1.0.pre.1 → 0.1.3
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/.dependabot/config.yml +10 -0
- data/.github/workflows/gem_release.yml +38 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +13 -1
- data/Gemfile.lock +2 -2
- data/README.md +4 -2
- data/enum_column.gemspec +3 -3
- data/lib/active_record/mysql/enum/mysql_adapter.rb +22 -13
- data/lib/active_record/mysql/enum/version.rb +1 -1
- metadata +13 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 55bc597834513644a73047cc9b1df7b853d2138a8bc9d72b2414ef85d38ccc44
|
4
|
+
data.tar.gz: fb8e43c87e03d2a5be842a18f3ad82bc01481f2200ee251aca8c20bdf972a4bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d33416541bb774bc5ca50ee8abf09303a40492fe6664c1d574d466d7a202c809e45f32753e4a98f4155507dd3395e1bb46465576850a1d50fd950ee63ea5274
|
7
|
+
data.tar.gz: 922721961100bac1179f6f1aef232f7258834e516b73be14845b70fbf75f0d48243304beed0f0013d1f9d0526e76a8042864247a83fba0e3cef678ba661fec98
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
tags:
|
5
|
+
- 'v*'
|
6
|
+
- '!v*.pre*'
|
7
|
+
|
8
|
+
name: Create Release
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
name: Create Release
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- name: Get version from tag
|
16
|
+
id: tag_name
|
17
|
+
shell: bash
|
18
|
+
run: |
|
19
|
+
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
|
20
|
+
- name: Checkout code
|
21
|
+
uses: actions/checkout@v2
|
22
|
+
- name: Get Changelog Entry
|
23
|
+
id: changelog_reader
|
24
|
+
uses: mindsers/changelog-reader-action@v1
|
25
|
+
with:
|
26
|
+
version: ${{ steps.tag_name.outputs.current_version }}
|
27
|
+
path: ./CHANGELOG.md
|
28
|
+
- name: Create Release
|
29
|
+
id: create_release
|
30
|
+
uses: actions/create-release@v1
|
31
|
+
env:
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GEM_RELEASE_GIT_TOKEN }}
|
33
|
+
with:
|
34
|
+
tag_name: ${{ github.ref }}
|
35
|
+
release_name: Release ${{ github.ref }}
|
36
|
+
body: ${{ steps.changelog_reader.outputs.log_entry }}
|
37
|
+
draft: false
|
38
|
+
prerelease: false
|
data/.gitignore
ADDED
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,19 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [0.1.
|
7
|
+
## [0.1.3] - 2020-08-19
|
8
|
+
### Changed
|
9
|
+
- refactor mysql adapter
|
10
|
+
|
11
|
+
## [0.1.2] - 2020-08-18
|
12
|
+
### Changed
|
13
|
+
- fixed frozen string to reassign value instead of append
|
14
|
+
|
15
|
+
## [0.1.1] - 2020-08-18
|
16
|
+
### Added
|
17
|
+
- extended activerecord dependency to '>= 4.2', '< 7'
|
18
|
+
|
19
|
+
## [0.1.0] - 2020-08-17
|
8
20
|
### Added
|
9
21
|
- Backwards compatibility with Rails 4
|
10
22
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
This gem is an extension to ActiveRecord which enables native support of
|
4
4
|
enumerations in the database schema using the ENUM type in MySQL. Forked
|
5
|
-
and revitalized from
|
5
|
+
and revitalized from [enum_column3](https://github.com/jewlr/enum_column)
|
6
|
+
which was itself a fork of a fork of Nick Pohodnya's original gem for
|
7
|
+
Rails 3, [enum_column3](https://github.com/electronick/enum_column).
|
6
8
|
|
7
9
|
## Support
|
8
10
|
Currently this has been manually tested with Rails version 4 and 5, and works with scaffolding.
|
@@ -15,7 +17,7 @@ Currently this has been manually tested with Rails version 4 and 5, and works wi
|
|
15
17
|
## Installation
|
16
18
|
In your `Gemfile` add the following snippet
|
17
19
|
```ruby
|
18
|
-
gem 'activerecord-mysql-enum', '~> 0.1', require: '
|
20
|
+
gem 'activerecord-mysql-enum', '~> 0.1', require: 'active_record/mysql/enum'
|
19
21
|
```
|
20
22
|
|
21
23
|
## Usage
|
data/enum_column.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path("
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require "active_record/mysql/enum/version"
|
6
6
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ["development@invoca.com"]
|
12
12
|
|
13
13
|
spec.summary = "Enable enum type for the MySQL Adapter in ActiveRecord"
|
14
|
-
spec.description =
|
14
|
+
spec.description = spec.summary
|
15
15
|
spec.homepage = "http://github.com/Invoca/activerecord-mysql-enum"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
|
|
28
28
|
end
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_dependency 'activerecord', '>= 4.2', '<
|
31
|
+
spec.add_dependency 'activerecord', '>= 4.2', '< 7'
|
32
32
|
end
|
@@ -28,27 +28,35 @@ module ActiveRecord
|
|
28
28
|
#
|
29
29
|
# will generate enum('a', 'b', 'c') for :limit => [:a, :b, :c]
|
30
30
|
if Rails::VERSION::MAJOR < 5
|
31
|
-
def type_to_sql(type, limit = nil, precision = nil, scale = nil
|
31
|
+
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
|
32
32
|
if type.to_s == 'enum'
|
33
|
-
|
34
|
-
|
33
|
+
column_type_sql =
|
34
|
+
if (native_database_type = native_database_types[type])
|
35
|
+
native_database_type[:name]
|
36
|
+
else
|
37
|
+
'enum'
|
38
|
+
end
|
35
39
|
|
36
|
-
|
40
|
+
quoted_values = limit.map { |v| quote(v) }.join(',')
|
37
41
|
|
38
|
-
column_type_sql
|
42
|
+
"#{column_type_sql}(#{quoted_values})"
|
39
43
|
else
|
40
|
-
super(type, limit, precision, scale
|
44
|
+
super(type, limit, precision, scale)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
else
|
44
|
-
def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:
|
48
|
+
def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **_options) # :nodoc:
|
45
49
|
if type.to_s == 'enum'
|
46
|
-
|
47
|
-
|
50
|
+
column_type_sql =
|
51
|
+
if (native_database_type = native_database_types[type])
|
52
|
+
native_database_type[:name]
|
53
|
+
else
|
54
|
+
'enum'
|
55
|
+
end
|
48
56
|
|
49
|
-
|
57
|
+
quoted_values = limit.map { |v| quote(v) }.join(',')
|
50
58
|
|
51
|
-
column_type_sql
|
59
|
+
"#{column_type_sql}(#{quoted_values})"
|
52
60
|
else
|
53
61
|
super(type, limit: limit, precision: precision, scale: scale, unsigned: unsigned)
|
54
62
|
end
|
@@ -57,11 +65,12 @@ module ActiveRecord
|
|
57
65
|
|
58
66
|
|
59
67
|
private
|
68
|
+
|
60
69
|
def initialize_type_map(m = type_map)
|
61
70
|
super
|
62
71
|
|
63
|
-
m.register_type(
|
64
|
-
limit = sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.
|
72
|
+
m.register_type(/enum/i) do |sql_type|
|
73
|
+
limit = sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.to_sym }
|
65
74
|
ActiveRecord::Type::Enum.new(limit: limit)
|
66
75
|
end
|
67
76
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-mysql-enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pohodnya
|
8
8
|
- Invoca Development
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-08-
|
12
|
+
date: 2020-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '4.2'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '7'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '4.2'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '7'
|
34
34
|
description: Enable enum type for the MySQL Adapter in ActiveRecord
|
35
35
|
email:
|
36
36
|
- development@invoca.com
|
@@ -38,6 +38,9 @@ executables: []
|
|
38
38
|
extensions: []
|
39
39
|
extra_rdoc_files: []
|
40
40
|
files:
|
41
|
+
- ".dependabot/config.yml"
|
42
|
+
- ".github/workflows/gem_release.yml"
|
43
|
+
- ".gitignore"
|
41
44
|
- CHANGELOG.md
|
42
45
|
- Gemfile
|
43
46
|
- Gemfile.lock
|
@@ -62,7 +65,7 @@ licenses: []
|
|
62
65
|
metadata:
|
63
66
|
source_code_uri: https://github.com/Invoca/activerecord-mysql-enum
|
64
67
|
allowed_push_host: https://rubygems.org
|
65
|
-
post_install_message:
|
68
|
+
post_install_message:
|
66
69
|
rdoc_options: []
|
67
70
|
require_paths:
|
68
71
|
- lib
|
@@ -73,13 +76,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
76
|
version: '0'
|
74
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
78
|
requirements:
|
76
|
-
- - "
|
79
|
+
- - ">="
|
77
80
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
81
|
+
version: '0'
|
79
82
|
requirements: []
|
80
|
-
|
81
|
-
|
82
|
-
signing_key:
|
83
|
+
rubygems_version: 3.0.1
|
84
|
+
signing_key:
|
83
85
|
specification_version: 4
|
84
86
|
summary: Enable enum type for the MySQL Adapter in ActiveRecord
|
85
87
|
test_files: []
|