activerecord-pg_enum 0.2.1 → 0.3.0

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
- SHA256:
3
- metadata.gz: b054a50be2905bc27d33ea19f01be2dca1c435ee12097cf887442b181fc7d2a4
4
- data.tar.gz: a06db65579894edded448f85e16bd436de2d51a09d8a5f647389cb193d28ecbe
2
+ SHA1:
3
+ metadata.gz: 375facb22f785682bbc48ddd221c8fd2ccd7c1d5
4
+ data.tar.gz: 61d7656a02c14feb0e6d591dbb3ecd15839a6154
5
5
  SHA512:
6
- metadata.gz: 2dbc6fee1995ef05d75acb20c0cf03639bca2b753788ba91df098268d914f286c3b04b34639bae6984bbe0ebb9948d9196b84ae07defcc953a485b70a08370b6
7
- data.tar.gz: f04459faaae97d771aa60e44cb0ca2d13e983f3bff36f7eef3f71401997746d54516eb216e25666e1618755b46aef9248636a4b263e6a6af09b505ebb75c767e
6
+ metadata.gz: dcd88c40ee6625cdf4120e06def40dcdbe5573ccebb77f710e62bfa037222d896a64762798a6ba8736bbbf7e89702633771f20671f92cd63c7a603a5c7cc6293
7
+ data.tar.gz: be1393454674cd111816dc113902d4240cbd0ff0a10e5cd4441dbe87fa1daaf98920eaf20ece41e5a494802a2e0c33c6b79e766261320f4920334eb33be2d61e
data/.travis.yml CHANGED
@@ -1,22 +1,28 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.1
5
- - 2.2
6
- - 2.5
4
+ - 2.2.2
5
+ - 2.5.0
7
6
  gemfile:
8
- - gemfiles/5.2.gemfile
7
+ - gemfiles/5.0.gemfile
9
8
  - gemfiles/5.1.gemfile
9
+ - gemfiles/5.2.gemfile
10
10
  - gemfiles/edge.gemfile
11
11
  matrix:
12
12
  exclude:
13
- - rvm: 2.1
13
+ - rvm: 2.5.0
14
+ gemfile: gemfiles/5.0.gemfile
15
+ - rvm: 2.5.0
16
+ gemfile: gemfiles/5.1.gemfile
17
+ - rvm: 2.5.0
14
18
  gemfile: gemfiles/5.2.gemfile
19
+ - rvm: 2.2.2
20
+ gemfile: gemfiles/edge.gemfile
15
21
  allow_failures:
16
22
  - gemfile: gemfiles/edge.gemfile
17
23
  services:
18
24
  - postgresql
19
- before_install: gem install bundler -v 1.15.4
25
+ before_install: gem install bundler -v 1.17.3
20
26
  script: "bundle exec rake spec"
21
27
  env:
22
28
  global:
data/Appraisals CHANGED
@@ -6,6 +6,11 @@ appraise "5.1" do
6
6
  gem "activerecord", ">= 5.1.0", "< 5.2.0"
7
7
  end
8
8
 
9
+ appraise "5.0" do
10
+ gem "activerecord", ">= 5.0.0", "< 5.1.0"
11
+ gem "i18n", "1.5.1"
12
+ end
13
+
9
14
  appraise "edge" do
10
15
  gem "rails", git: "https://github.com/rails/rails.git", branch: "master"
11
16
  end
data/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.0] - 2019-03-03
10
+ - Support for 5.0 and 5.1
11
+ - Change travis config to test against oldest supported version of ruby
12
+
13
+ ## [0.2.1] - 2019-02-22
14
+ - Fixed a bug in the `SchemaDumper` output
15
+
9
16
  ## [0.2.0] - 2018-08-18
10
17
  ### Changed
11
18
  - Change API of `create_enum` to take two arguments instead, the name and an array of values
data/README.md CHANGED
@@ -6,7 +6,9 @@ This will allow you to use enum columns in your database without replacing `sche
6
6
 
7
7
  ## Version support
8
8
 
9
- Currently only Rails 5.2 is supported. Support for previous versions going back to 4.1 are planned.
9
+ I intend to support every version of Rails that supports `enum`, which was introduced in 4.1.
10
+
11
+ Currently Rails 5.0 through 6.0 are supported.
10
12
 
11
13
  ## Installation
12
14
 
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  spec.add_dependency "pg"
28
- spec.add_dependency "activerecord", ">= 5.1.0"
28
+ spec.add_dependency "activerecord", ">= 5.0.0"
29
29
  spec.add_dependency "activesupport"
30
30
 
31
31
  spec.add_development_dependency "appraisal"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", ">= 5.0.0", "< 5.1.0"
6
+ gem "i18n", "1.5.1"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ activerecord-pg_enum (0.3.0)
5
+ activerecord (>= 5.0.0)
6
+ activesupport
7
+ pg
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activemodel (5.0.7.1)
13
+ activesupport (= 5.0.7.1)
14
+ activerecord (5.0.7.1)
15
+ activemodel (= 5.0.7.1)
16
+ activesupport (= 5.0.7.1)
17
+ arel (~> 7.0)
18
+ activesupport (5.0.7.1)
19
+ concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ i18n (>= 0.7, < 2)
21
+ minitest (~> 5.1)
22
+ tzinfo (~> 1.1)
23
+ appraisal (2.2.0)
24
+ bundler
25
+ rake
26
+ thor (>= 0.14.0)
27
+ arel (7.1.4)
28
+ coderay (1.1.2)
29
+ concurrent-ruby (1.1.4)
30
+ diff-lcs (1.3)
31
+ i18n (1.5.1)
32
+ concurrent-ruby (~> 1.0)
33
+ method_source (0.9.2)
34
+ minitest (5.11.3)
35
+ pg (1.1.4)
36
+ pry (0.12.2)
37
+ coderay (~> 1.1.0)
38
+ method_source (~> 0.9.0)
39
+ rake (10.5.0)
40
+ rspec (3.8.0)
41
+ rspec-core (~> 3.8.0)
42
+ rspec-expectations (~> 3.8.0)
43
+ rspec-mocks (~> 3.8.0)
44
+ rspec-core (3.8.0)
45
+ rspec-support (~> 3.8.0)
46
+ rspec-expectations (3.8.2)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.8.0)
49
+ rspec-mocks (3.8.0)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.8.0)
52
+ rspec-support (3.8.0)
53
+ thor (0.20.3)
54
+ thread_safe (0.3.6)
55
+ tzinfo (1.2.5)
56
+ thread_safe (~> 0.1)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ activerecord (>= 5.0.0, < 5.1.0)
63
+ activerecord-pg_enum!
64
+ appraisal
65
+ bundler (~> 1.15)
66
+ i18n (= 1.5.1)
67
+ pry
68
+ rake (~> 10.0)
69
+ rspec (~> 3.0)
70
+
71
+ BUNDLED WITH
72
+ 1.17.3
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (0.2.0)
5
- activerecord (>= 5.1.0)
4
+ activerecord-pg_enum (0.3.0)
5
+ activerecord (>= 5.0.0)
6
6
  activesupport
7
7
  pg
8
8
 
@@ -32,7 +32,7 @@ GEM
32
32
  concurrent-ruby (~> 1.0)
33
33
  method_source (0.9.0)
34
34
  minitest (5.11.3)
35
- pg (1.0.0)
35
+ pg (1.1.4)
36
36
  pry (0.11.3)
37
37
  coderay (~> 1.1.0)
38
38
  method_source (~> 0.9.0)
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (0.2.0)
5
- activerecord (>= 5.1.0)
4
+ activerecord-pg_enum (0.3.0)
5
+ activerecord (>= 5.0.0)
6
6
  activesupport
7
7
  pg
8
8
 
@@ -32,7 +32,7 @@ GEM
32
32
  concurrent-ruby (~> 1.0)
33
33
  method_source (0.9.0)
34
34
  minitest (5.11.3)
35
- pg (1.0.0)
35
+ pg (1.1.4)
36
36
  pry (0.11.3)
37
37
  coderay (~> 1.1.0)
38
38
  method_source (~> 0.9.0)
@@ -66,8 +66,8 @@ GIT
66
66
  PATH
67
67
  remote: ..
68
68
  specs:
69
- activerecord-pg_enum (0.2.0)
70
- activerecord (>= 5.1.0)
69
+ activerecord-pg_enum (0.3.0)
70
+ activerecord (>= 5.0.0)
71
71
  activesupport
72
72
  pg
73
73
 
@@ -103,7 +103,7 @@ GEM
103
103
  nio4r (2.3.1)
104
104
  nokogiri (1.8.4)
105
105
  mini_portile2 (~> 2.3.0)
106
- pg (1.0.0)
106
+ pg (1.1.4)
107
107
  pry (0.11.3)
108
108
  coderay (~> 1.1.0)
109
109
  method_source (~> 0.9.0)
@@ -7,7 +7,6 @@ require "active_support/lazy_load_hooks"
7
7
  ActiveSupport.on_load(:active_record) do
8
8
  require "active_record/pg_enum/command_recorder"
9
9
  require "active_record/pg_enum/postgresql_adapter"
10
- require "active_record/pg_enum/schema_dumper"
11
10
  require "active_record/pg_enum/schema_statements"
12
11
  require "active_record/pg_enum/helper"
13
12
 
@@ -16,7 +15,13 @@ ActiveSupport.on_load(:active_record) do
16
15
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES.merge!(enum: { name: "enum" })
17
16
 
18
17
  if ar_version >= Gem::Version.new("5.2.0")
18
+ require "active_record/pg_enum/schema_dumper"
19
19
  ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend ActiveRecord::PGEnum::SchemaDumper
20
+ else
21
+ require "active_record/pg_enum/4.2/column_dumper"
22
+ require "active_record/pg_enum/4.2/schema_dumper"
23
+ ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnDumper.prepend ActiveRecord::PGEnum::ColumnDumper
24
+ ActiveRecord::SchemaDumper.prepend ActiveRecord::PGEnum::SchemaDumper
20
25
  end
21
26
 
22
27
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include ActiveRecord::PGEnum::PostgreSQLAdapter
@@ -0,0 +1,13 @@
1
+ module ActiveRecord
2
+ module PGEnum
3
+ module ColumnDumper
4
+ def column_spec(column)
5
+ if column.type == :enum
6
+ return ["column", [column.sql_type.inspect, prepare_column_options(column)]]
7
+ end
8
+
9
+ super
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ module ActiveRecord
2
+ module PGEnum
3
+ module SchemaDumper
4
+ private
5
+
6
+ def extensions(stream)
7
+ super
8
+ enums(stream)
9
+ end
10
+
11
+ def enums(stream)
12
+ return unless (enum_types = @connection.enum_types).any?
13
+
14
+ stream.puts " # These are custom enum types that must be created before they can be used in the schema definition"
15
+
16
+ enum_types.each do |name, definition|
17
+ stream.puts %Q{ create_enum "#{name}", %w[#{definition.join(" ")}]}
18
+ end
19
+
20
+ stream.puts
21
+ end
22
+
23
+ # Takes a column specification in Object form and serializes it into a String.
24
+ def format_colspec(colspec)
25
+ case colspec
26
+ when String
27
+ colspec
28
+ when Array
29
+ colspec.map { |value| format_colspec(value) }.select(&:present?).join(", ")
30
+ else
31
+ super
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -23,10 +23,10 @@ module ActiveRecord
23
23
  # Gathers the arguments needed for the column line inside the create_table block.
24
24
  def column_spec(column)
25
25
  if column.type == :enum
26
- ["column", [column.sql_type.inspect, prepare_column_options(column)]]
27
- else
28
- super
26
+ return ["column", [column.sql_type.inspect, prepare_column_options(column)]]
29
27
  end
28
+
29
+ super
30
30
  end
31
31
 
32
32
  # Takes a column specification in Object form and serializes it into a String.
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module PGEnum
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-pg_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Lassek
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-22 00:00:00.000000000 Z
11
+ date: 2019-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 5.1.0
33
+ version: 5.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 5.1.0
40
+ version: 5.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +143,8 @@ files:
143
143
  - bin/console
144
144
  - bin/setup
145
145
  - gemfiles/.bundle/config
146
+ - gemfiles/5.0.gemfile
147
+ - gemfiles/5.0.gemfile.lock
146
148
  - gemfiles/5.1.gemfile
147
149
  - gemfiles/5.1.gemfile.lock
148
150
  - gemfiles/5.2.gemfile
@@ -150,6 +152,8 @@ files:
150
152
  - gemfiles/edge.gemfile
151
153
  - gemfiles/edge.gemfile.lock
152
154
  - lib/active_record/pg_enum.rb
155
+ - lib/active_record/pg_enum/4.2/column_dumper.rb
156
+ - lib/active_record/pg_enum/4.2/schema_dumper.rb
153
157
  - lib/active_record/pg_enum/command_recorder.rb
154
158
  - lib/active_record/pg_enum/helper.rb
155
159
  - lib/active_record/pg_enum/postgresql_adapter.rb
@@ -177,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
181
  version: '0'
178
182
  requirements: []
179
183
  rubyforge_project:
180
- rubygems_version: 2.7.7
184
+ rubygems_version: 2.4.5
181
185
  signing_key:
182
186
  specification_version: 4
183
187
  summary: Integrate PostgreSQL's enumerated types with the Rails enum feature