enum_type 2.1.2 → 2.2.1

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
- SHA1:
3
- metadata.gz: 9a3e4e56b190e7bafd870a8d85d36f2d510db511
4
- data.tar.gz: 7b6ed07e741a01450e0546ed39dbcf9ec76295e9
2
+ SHA256:
3
+ metadata.gz: 89bc30e3e226b181141db43882f5fab69b0535a3440fe11e2abd2a2682a68fd5
4
+ data.tar.gz: e0ee22403862c1f77000691cd0e0a01f1c0757690f8154332f019d1632dfc442
5
5
  SHA512:
6
- metadata.gz: 98cd180bedacbf7233eb4bc7e87eb1211dc00407cc0e6614602e1b3c9094e49eb2b684a24c17ab38ac8483c003f6fbcae140046fd4857bf9d9c17b2f1452a20d
7
- data.tar.gz: 1c8d026cbd98ef6d02406c2c868cfb06b8da813fbd41d4448353a8c5194acac59d0af4ffe0285d1339b8f5784944064fdb3aa8b79d2bd8368fa87d656727ea5e
6
+ metadata.gz: cc1b7a7596e279ce9d59f32e9eededb064bb756023a6a4331dd9dde97f2147c7362752ada6ef3bd8431cc875f3a6a0a9c3d0927128a838e0bc7950b1db9f0b3b
7
+ data.tar.gz: cf62c7272e2aa16ea21bb7f9c8d23b6280cbe0f463085161c9234fcdfbab0c630d4837543114a3022a76a407bc7acd58c06fefd287b0098f25c2cc6179717c37
data/.rspec CHANGED
@@ -1 +1,2 @@
1
- -cfs
1
+ --color
2
+ --format documentation
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.4.2
data/Gemfile CHANGED
@@ -1,18 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # DEPENDENCIES
4
- gem 'activerecord', '>= 4.0', require: 'active_record'
5
- gem 'activesupport', '>= 4.0', require: 'active_support/core_ext/object/try'
4
+ gem 'rails', '~> 4'
6
5
 
7
6
  group :development do
8
7
  # DEVELOPMENT
9
8
  gem 'jeweler'
10
9
  gem 'yard'
11
- gem 'RedCloth', require: 'redcloth'
10
+ gem 'redcarpet', require: nil
12
11
 
13
12
  # TEST
14
13
  gem 'rspec'
15
- gem 'factory_girl'
16
- platform(:mri) { gem 'pg' }
17
- platform(:jruby) { gem 'activerecord-jdbcpostgresql-adapter' }
14
+ gem 'factory_bot'
15
+ gem 'pg', platform: :mri
16
+ gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
18
17
  end
data/Gemfile.lock CHANGED
@@ -1,108 +1,183 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- RedCloth (4.2.9)
5
- RedCloth (4.2.9-java)
6
- activemodel (4.0.1)
7
- activesupport (= 4.0.1)
8
- builder (~> 3.1.0)
9
- activerecord (4.0.1)
10
- activemodel (= 4.0.1)
11
- activerecord-deprecated_finders (~> 1.0.2)
12
- activesupport (= 4.0.1)
13
- arel (~> 4.0.0)
14
- activerecord-deprecated_finders (1.0.3)
15
- activerecord-jdbc-adapter (1.3.2)
4
+ actionmailer (4.2.10)
5
+ actionpack (= 4.2.10)
6
+ actionview (= 4.2.10)
7
+ activejob (= 4.2.10)
8
+ mail (~> 2.5, >= 2.5.4)
9
+ rails-dom-testing (~> 1.0, >= 1.0.5)
10
+ actionpack (4.2.10)
11
+ actionview (= 4.2.10)
12
+ activesupport (= 4.2.10)
13
+ rack (~> 1.6)
14
+ rack-test (~> 0.6.2)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (4.2.10)
18
+ activesupport (= 4.2.10)
19
+ builder (~> 3.1)
20
+ erubis (~> 2.7.0)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activejob (4.2.10)
24
+ activesupport (= 4.2.10)
25
+ globalid (>= 0.3.0)
26
+ activemodel (4.2.10)
27
+ activesupport (= 4.2.10)
28
+ builder (~> 3.1)
29
+ activerecord (4.2.10)
30
+ activemodel (= 4.2.10)
31
+ activesupport (= 4.2.10)
32
+ arel (~> 6.0)
33
+ activerecord-jdbc-adapter (50.0)
16
34
  activerecord (>= 2.2)
17
- activerecord-jdbcpostgresql-adapter (1.3.2)
18
- activerecord-jdbc-adapter (~> 1.3.2)
19
- jdbc-postgres (>= 9.1)
20
- activesupport (4.0.1)
21
- i18n (~> 0.6, >= 0.6.4)
22
- minitest (~> 4.2)
23
- multi_json (~> 1.3)
24
- thread_safe (~> 0.1)
25
- tzinfo (~> 0.3.37)
26
- addressable (2.3.5)
27
- arel (4.0.1)
28
- atomic (1.1.14)
29
- atomic (1.1.14-java)
30
- builder (3.1.4)
31
- diff-lcs (1.2.5)
32
- factory_girl (4.3.0)
35
+ activerecord-jdbcpostgresql-adapter (50.0)
36
+ activerecord-jdbc-adapter (~> 50.0)
37
+ jdbc-postgres (>= 9.4, < 43)
38
+ activesupport (4.2.10)
39
+ i18n (~> 0.7)
40
+ minitest (~> 5.1)
41
+ thread_safe (~> 0.3, >= 0.3.4)
42
+ tzinfo (~> 1.1)
43
+ addressable (2.4.0)
44
+ arel (6.0.4)
45
+ builder (3.2.3)
46
+ concurrent-ruby (1.0.5)
47
+ concurrent-ruby (1.0.5-java)
48
+ crass (1.0.3)
49
+ descendants_tracker (0.0.4)
50
+ thread_safe (~> 0.3, >= 0.3.1)
51
+ diff-lcs (1.3)
52
+ erubis (2.7.0)
53
+ factory_bot (4.8.2)
33
54
  activesupport (>= 3.0.0)
34
- faraday (0.8.8)
35
- multipart-post (~> 1.2.0)
36
- git (1.2.6)
37
- github_api (0.10.1)
38
- addressable
39
- faraday (~> 0.8.1)
40
- hashie (>= 1.2)
41
- multi_json (~> 1.4)
42
- nokogiri (~> 1.5.2)
43
- oauth2
44
- hashie (2.0.5)
45
- highline (1.6.20)
46
- httpauth (0.2.0)
47
- i18n (0.6.5)
48
- jdbc-postgres (9.2.1004)
49
- jeweler (1.8.8)
55
+ faraday (0.9.2)
56
+ multipart-post (>= 1.2, < 3)
57
+ git (1.3.0)
58
+ github_api (0.16.0)
59
+ addressable (~> 2.4.0)
60
+ descendants_tracker (~> 0.0.4)
61
+ faraday (~> 0.8, < 0.10)
62
+ hashie (>= 3.4)
63
+ mime-types (>= 1.16, < 3.0)
64
+ oauth2 (~> 1.0)
65
+ globalid (0.4.1)
66
+ activesupport (>= 4.2.0)
67
+ hashie (3.5.6)
68
+ highline (1.7.10)
69
+ i18n (0.9.1)
70
+ concurrent-ruby (~> 1.0)
71
+ jar-dependencies (0.3.11)
72
+ jdbc-postgres (42.1.4)
73
+ jeweler (2.3.7)
50
74
  builder
51
- bundler (~> 1.0)
75
+ bundler (>= 1)
52
76
  git (>= 1.2.5)
53
- github_api (= 0.10.1)
77
+ github_api (~> 0.16.0)
54
78
  highline (>= 1.6.15)
55
- nokogiri (= 1.5.10)
79
+ nokogiri (>= 1.5.10)
80
+ psych (~> 2.2)
56
81
  rake
57
82
  rdoc
58
- json (1.8.1)
59
- json (1.8.1-java)
60
- jwt (0.1.8)
61
- multi_json (>= 1.5)
62
- minitest (4.7.5)
63
- multi_json (1.8.2)
64
- multi_xml (0.5.5)
65
- multipart-post (1.2.0)
66
- nokogiri (1.5.10)
67
- nokogiri (1.5.10-java)
68
- oauth2 (0.9.2)
69
- faraday (~> 0.8)
70
- httpauth (~> 0.2)
71
- jwt (~> 0.1.4)
72
- multi_json (~> 1.0)
83
+ semver2
84
+ jwt (1.5.6)
85
+ loofah (2.1.1)
86
+ crass (~> 1.0.2)
87
+ nokogiri (>= 1.5.9)
88
+ mail (2.7.0)
89
+ mini_mime (>= 0.1.1)
90
+ mime-types (2.99.3)
91
+ mini_mime (1.0.0)
92
+ mini_portile2 (2.3.0)
93
+ minitest (5.10.3)
94
+ multi_json (1.12.2)
95
+ multi_xml (0.6.0)
96
+ multipart-post (2.0.0)
97
+ nokogiri (1.8.1)
98
+ mini_portile2 (~> 2.3.0)
99
+ nokogiri (1.8.1-java)
100
+ oauth2 (1.4.0)
101
+ faraday (>= 0.8, < 0.13)
102
+ jwt (~> 1.0)
103
+ multi_json (~> 1.3)
73
104
  multi_xml (~> 0.5)
74
- rack (~> 1.2)
75
- pg (0.17.0)
76
- rack (1.5.2)
77
- rake (10.1.0)
78
- rdoc (4.0.1)
79
- json (~> 1.4)
80
- rspec (2.14.1)
81
- rspec-core (~> 2.14.0)
82
- rspec-expectations (~> 2.14.0)
83
- rspec-mocks (~> 2.14.0)
84
- rspec-core (2.14.7)
85
- rspec-expectations (2.14.4)
86
- diff-lcs (>= 1.1.3, < 2.0)
87
- rspec-mocks (2.14.4)
88
- thread_safe (0.1.3)
89
- atomic
90
- thread_safe (0.1.3-java)
91
- atomic
92
- tzinfo (0.3.38)
93
- yard (0.8.7.3)
105
+ rack (>= 1.2, < 3)
106
+ pg (0.21.0)
107
+ psych (2.2.4)
108
+ psych (2.2.4-java)
109
+ jar-dependencies (>= 0.1.7)
110
+ rack (1.6.8)
111
+ rack-test (0.6.3)
112
+ rack (>= 1.0)
113
+ rails (4.2.10)
114
+ actionmailer (= 4.2.10)
115
+ actionpack (= 4.2.10)
116
+ actionview (= 4.2.10)
117
+ activejob (= 4.2.10)
118
+ activemodel (= 4.2.10)
119
+ activerecord (= 4.2.10)
120
+ activesupport (= 4.2.10)
121
+ bundler (>= 1.3.0, < 2.0)
122
+ railties (= 4.2.10)
123
+ sprockets-rails
124
+ rails-deprecated_sanitizer (1.0.3)
125
+ activesupport (>= 4.2.0.alpha)
126
+ rails-dom-testing (1.0.8)
127
+ activesupport (>= 4.2.0.beta, < 5.0)
128
+ nokogiri (~> 1.6)
129
+ rails-deprecated_sanitizer (>= 1.0.1)
130
+ rails-html-sanitizer (1.0.3)
131
+ loofah (~> 2.0)
132
+ railties (4.2.10)
133
+ actionpack (= 4.2.10)
134
+ activesupport (= 4.2.10)
135
+ rake (>= 0.8.7)
136
+ thor (>= 0.18.1, < 2.0)
137
+ rake (12.3.0)
138
+ rdoc (6.0.0)
139
+ redcarpet (3.4.0)
140
+ rspec (3.7.0)
141
+ rspec-core (~> 3.7.0)
142
+ rspec-expectations (~> 3.7.0)
143
+ rspec-mocks (~> 3.7.0)
144
+ rspec-core (3.7.0)
145
+ rspec-support (~> 3.7.0)
146
+ rspec-expectations (3.7.0)
147
+ diff-lcs (>= 1.2.0, < 2.0)
148
+ rspec-support (~> 3.7.0)
149
+ rspec-mocks (3.7.0)
150
+ diff-lcs (>= 1.2.0, < 2.0)
151
+ rspec-support (~> 3.7.0)
152
+ rspec-support (3.7.0)
153
+ semver2 (3.4.2)
154
+ sprockets (3.7.1)
155
+ concurrent-ruby (~> 1.0)
156
+ rack (> 1, < 3)
157
+ sprockets-rails (3.2.1)
158
+ actionpack (>= 4.0)
159
+ activesupport (>= 4.0)
160
+ sprockets (>= 3.0.0)
161
+ thor (0.20.0)
162
+ thread_safe (0.3.6)
163
+ thread_safe (0.3.6-java)
164
+ tzinfo (1.2.4)
165
+ thread_safe (~> 0.1)
166
+ yard (0.9.12)
94
167
 
95
168
  PLATFORMS
96
169
  java
97
170
  ruby
98
171
 
99
172
  DEPENDENCIES
100
- RedCloth
101
- activerecord (>= 4.0)
102
173
  activerecord-jdbcpostgresql-adapter
103
- activesupport (>= 4.0)
104
- factory_girl
174
+ factory_bot
105
175
  jeweler
106
176
  pg
177
+ rails (~> 4)
178
+ redcarpet
107
179
  rspec
108
180
  yard
181
+
182
+ BUNDLED WITH
183
+ 1.16.0
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ > ⚠️ **DEPRECATED:** `enum_type` is no longer maintained. Modern Rails has
2
+ > native ActiveRecord enum support (`enum`) that covers most use cases; for
3
+ > PostgreSQL native ENUM types, consider alternatives like the
4
+ > `activerecord-postgres_enum` gem family. The final release is v2.2.1.
5
+
6
+ enum_type
7
+ =========
8
+
9
+ **Enumerated Types in ActiveRecord**
10
+
11
+ | | |
12
+ |:------------|:--------------------------------|
13
+ | **Author** | Tim Morgan |
14
+ | **Version** | 2.1.2 (Nov 10, 2013) |
15
+ | **License** | Released under the MIT license. |
16
+
17
+ About
18
+ -----
19
+
20
+ `enum_type` allows you to effectively use the PostgreSQL `ENUM` data type in
21
+ your ActiveRecord models. It's a really simple gem that just adds a convenience
22
+ method to take care of the usual "witch chant" that accompanies building an
23
+ enumerated type in Rails.
24
+
25
+ Installation
26
+ ------------
27
+
28
+ **Important Note:** This gem requires Ruby 1.9+. Ruby 1.8 is not supported, and
29
+ will never be.
30
+
31
+ First, add the `enum_type` gem to your `Gemfile`:
32
+
33
+ ```` ruby
34
+ gem 'enum_type'
35
+ ````
36
+
37
+ Then, extend your model with the `EnumType` module:
38
+
39
+ ```` ruby
40
+ class MyModel < ActiveRecord::Base
41
+ extend EnumType
42
+ end
43
+ ````
44
+
45
+ Usage
46
+ -----
47
+
48
+ In your model, call the `enum_type` method, providing one or more enumerated
49
+ fields, and any additional options:
50
+
51
+ ```` ruby
52
+ class MyModel < ActiveRecord::Base
53
+ extend EnumType
54
+ enum_type :status, %w( active pending admin superadmin banned )
55
+ end
56
+ ````
57
+
58
+ See the {EnumType#enum_type} method documentation for more information.
data/Rakefile CHANGED
@@ -11,12 +11,12 @@ require 'rake'
11
11
 
12
12
  require 'jeweler'
13
13
  Jeweler::Tasks.new do |gem|
14
- gem.name = "enum_type"
15
- gem.summary = %Q{PostgreSQL enumerated types in ActiveRecord}
16
- gem.description = %Q{Allows ActiveRecord to better use PostgreSQL's ENUM types.}
17
- gem.email = "git@timothymorgan.info"
18
- gem.homepage = "http://github.com/riscfuture/enum_type"
19
- gem.authors = [ "Tim Morgan" ]
14
+ gem.name = "enum_type"
15
+ gem.summary = %Q{PostgreSQL enumerated types in ActiveRecord}
16
+ gem.description = %Q{Allows ActiveRecord to better use PostgreSQL's ENUM types.}
17
+ gem.email = 'git@timothymorgan.info'
18
+ gem.homepage = 'http://github.com/riscfuture/enum_type'
19
+ gem.authors = ["Tim Morgan"]
20
20
  gem.required_ruby_version = '>= 1.9'
21
21
  gem.add_dependency "activerecord", ">= 0"
22
22
  end
@@ -26,14 +26,23 @@ require 'rspec/core/rake_task'
26
26
  RSpec::Core::RakeTask.new
27
27
 
28
28
  require 'yard'
29
+
30
+ # bring sexy back (sexy == tables)
31
+ module YARD::Templates::Helpers::HtmlHelper
32
+ def html_markup_markdown(text)
33
+ markup_class(:markdown).new(text, :gh_blockcode, :fenced_code, :autolink, :tables, :no_intraemphasis).to_html
34
+ end
35
+ end
36
+
29
37
  YARD::Rake::YardocTask.new('doc') do |doc|
30
- doc.options << "-m" << "textile"
31
- doc.options << "--protected"
32
- doc.options << "-r" << "README.textile"
33
- doc.options << "-o" << "doc"
34
- doc.options << "--title" << "enum_type Documentation"
35
-
36
- doc.files = [ 'lib/**/*', 'README.textile' ]
38
+ doc.options << '-m' << 'markdown'
39
+ doc.options << '-M' << 'redcarpet'
40
+ doc.options << '--protected' << '--no-private'
41
+ doc.options << '-r' << 'README.md'
42
+ doc.options << '-o' << 'doc'
43
+ doc.options << '--title' << 'enum_type Documentation'
44
+
45
+ doc.files = %w(lib/**/* README.md)
37
46
  end
38
47
 
39
48
  task(default: :spec)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.2.1
data/enum_type.gemspec CHANGED
@@ -2,20 +2,21 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: enum_type 2.1.2 ruby lib
5
+ # stub: enum_type 2.2.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "enum_type"
9
- s.version = "2.1.2"
9
+ s.version = "2.2.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
12
13
  s.authors = ["Tim Morgan"]
13
- s.date = "2013-11-11"
14
+ s.date = "2013-12-26"
14
15
  s.description = "Allows ActiveRecord to better use PostgreSQL's ENUM types."
15
16
  s.email = "git@timothymorgan.info"
16
17
  s.extra_rdoc_files = [
17
18
  "LICENSE",
18
- "README.textile"
19
+ "README.md"
19
20
  ]
20
21
  s.files = [
21
22
  ".document",
@@ -25,7 +26,7 @@ Gem::Specification.new do |s|
25
26
  "Gemfile",
26
27
  "Gemfile.lock",
27
28
  "LICENSE",
28
- "README.textile",
29
+ "README.md",
29
30
  "Rakefile",
30
31
  "VERSION",
31
32
  "enum_type.gemspec",
@@ -36,10 +37,18 @@ Gem::Specification.new do |s|
36
37
  "spec/spec_helper.rb"
37
38
  ]
38
39
  s.homepage = "http://github.com/riscfuture/enum_type"
39
- s.require_paths = ["lib"]
40
40
  s.required_ruby_version = Gem::Requirement.new(">= 1.9")
41
- s.rubygems_version = "2.1.10"
42
- s.summary = "PostgreSQL enumerated types in ActiveRecord"
41
+ s.rubygems_version = "2.2.0"
42
+ s.summary = "[DEPRECATED] PostgreSQL enumerated types in ActiveRecord"
43
+ s.post_install_message = <<~MSG
44
+
45
+ ⚠️ DEPRECATED: enum_type is no longer maintained.
46
+
47
+ No longer maintained. Modern Rails has native ActiveRecord enum support (`enum`) that covers most use cases; for PostgreSQL native ENUM types, consider alternatives like the `activerecord-postgres_enum` gem family.
48
+
49
+ This is the final release. No further updates are planned.
50
+
51
+ MSG
43
52
 
44
53
  if s.respond_to? :specification_version then
45
54
  s.specification_version = 4
@@ -47,37 +56,34 @@ Gem::Specification.new do |s|
47
56
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
57
  s.add_runtime_dependency(%q<activerecord>, [">= 4.0"])
49
58
  s.add_runtime_dependency(%q<activesupport>, [">= 4.0"])
50
- s.add_development_dependency(%q<jeweler>, [">= 0"])
51
- s.add_development_dependency(%q<yard>, [">= 0"])
52
- s.add_development_dependency(%q<RedCloth>, [">= 0"])
53
- s.add_development_dependency(%q<rspec>, [">= 0"])
54
- s.add_development_dependency(%q<factory_girl>, [">= 0"])
55
- s.add_development_dependency(%q<pg>, [">= 0"])
56
- s.add_development_dependency(%q<activerecord-jdbcpostgresql-adapter>, [">= 0"])
57
- s.add_runtime_dependency(%q<activerecord>, [">= 0"])
59
+ s.add_development_dependency(%q<jeweler>)
60
+ s.add_development_dependency(%q<yard>)
61
+ s.add_development_dependency(%q<redcarpet>)
62
+ s.add_development_dependency(%q<rspec>)
63
+ s.add_development_dependency(%q<factory_girl>)
64
+ s.add_development_dependency(%q<pg>)
65
+ s.add_development_dependency(%q<activerecord-jdbcpostgresql-adapter>)
58
66
  else
59
67
  s.add_dependency(%q<activerecord>, [">= 4.0"])
60
68
  s.add_dependency(%q<activesupport>, [">= 4.0"])
61
- s.add_dependency(%q<jeweler>, [">= 0"])
62
- s.add_dependency(%q<yard>, [">= 0"])
63
- s.add_dependency(%q<RedCloth>, [">= 0"])
64
- s.add_dependency(%q<rspec>, [">= 0"])
65
- s.add_dependency(%q<factory_girl>, [">= 0"])
66
- s.add_dependency(%q<pg>, [">= 0"])
67
- s.add_dependency(%q<activerecord-jdbcpostgresql-adapter>, [">= 0"])
68
- s.add_dependency(%q<activerecord>, [">= 0"])
69
+ s.add_dependency(%q<jeweler>)
70
+ s.add_dependency(%q<yard>)
71
+ s.add_dependency(%q<redcarpet>)
72
+ s.add_dependency(%q<rspec>)
73
+ s.add_dependency(%q<factory_girl>)
74
+ s.add_dependency(%q<pg>)
75
+ s.add_dependency(%q<activerecord-jdbcpostgresql-adapter>)
69
76
  end
70
77
  else
71
78
  s.add_dependency(%q<activerecord>, [">= 4.0"])
72
79
  s.add_dependency(%q<activesupport>, [">= 4.0"])
73
- s.add_dependency(%q<jeweler>, [">= 0"])
74
- s.add_dependency(%q<yard>, [">= 0"])
75
- s.add_dependency(%q<RedCloth>, [">= 0"])
76
- s.add_dependency(%q<rspec>, [">= 0"])
77
- s.add_dependency(%q<factory_girl>, [">= 0"])
78
- s.add_dependency(%q<pg>, [">= 0"])
79
- s.add_dependency(%q<activerecord-jdbcpostgresql-adapter>, [">= 0"])
80
- s.add_dependency(%q<activerecord>, [">= 0"])
80
+ s.add_dependency(%q<jeweler>)
81
+ s.add_dependency(%q<yard>)
82
+ s.add_dependency(%q<redcarpet>)
83
+ s.add_dependency(%q<rspec>)
84
+ s.add_dependency(%q<factory_girl>)
85
+ s.add_dependency(%q<pg>)
86
+ s.add_dependency(%q<activerecord-jdbcpostgresql-adapter>)
81
87
  end
82
88
  end
83
89
 
@@ -1,8 +1,9 @@
1
1
  require 'active_support/core_ext/module/aliasing'
2
2
  require 'active_record/connection_adapters/postgresql_adapter'
3
3
 
4
- # Patch the PostgreSQL adapter to recognize defaults on ENUM columns.
4
+ # Patch the PostgreSQL adapter to recognize defaults on `ENUM` columns.
5
5
 
6
+ # @private
6
7
  class ActiveRecord::ConnectionAdapters::PostgreSQLColumn
7
8
 
8
9
  def initialize(name, default, oid_type, sql_type = nil, null = true)
@@ -36,6 +37,7 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLColumn
36
37
  end
37
38
  end if ActiveRecord::ConnectionAdapters::PostgreSQLColumn.methods.include?(:extract_value_from_default)
38
39
 
40
+ # @private
39
41
  class ActiveRecord::ConnectionAdapters::JdbcColumn
40
42
  def initialize(config, name, default, *args)
41
43
  call_discovered_column_callbacks(config)
data/lib/enum_type.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'enum_type/extensions'
2
2
 
3
- # Adds the @enum_type@ method to a model.
3
+ # Adds the `enum_type` method to a model.
4
4
  #
5
5
  # @example Basic usage
6
6
  # class MyModel < ActiveRecord::Base
@@ -17,16 +17,19 @@ module EnumType
17
17
  # @overload enum_type(field, ..., options={})
18
18
  # @param [Symbol] field An enumerated field.
19
19
  # @param [Hash] options A hash of options.
20
- # @option options [true, false] :allow_nil (false) If @true@, a nil value
21
- # is allowed.
20
+ # @option options [true, false] :allow_nil (false) If `true`, a `nil` value
21
+ # is allowed.
22
22
  # @option options [Array<String>] :values If given, restricts valid values
23
- # to those in the given array.
23
+ # to those in the given array.
24
+ # @option options [String] :register_type If `true`, registers the column's
25
+ # type with the PostgreSQL adapter, to suppress "unknown OID" warnings.
24
26
  #
25
27
  # @example Enumerated field with restricted types
26
28
  # enum_type :color, values: %w( red orange yellow green blue purple )
27
29
 
28
30
  def enum_type(*fields)
29
31
  options = fields.extract_options!
32
+
30
33
  fields.each do |field|
31
34
  define_method field do
32
35
  value = read_attribute(field)
@@ -39,6 +42,19 @@ module EnumType
39
42
 
40
43
  validates_presence_of(field) unless options[:allow_nil]
41
44
  validates_inclusion_of(field, in: options[:values].map(&:to_sym), allow_nil: options[:allow_nil]) if options[:values]
45
+
46
+ if options[:register_type]
47
+ #ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID.register_type field.to_s,
48
+ # ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Identity.new
49
+ begin
50
+ result = connection.select_one("SELECT atttypid FROM pg_catalog.pg_attribute WHERE attrelid = #{connection.quote table_name}::regclass AND attname = #{connection.quote field.to_s}")
51
+ type_oid = Integer(result['atttypid'])
52
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::TYPE_MAP[type_oid] =
53
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Identity.new
54
+ rescue => err
55
+ Rails.logger.warn "Couldn't register type #{field}: #{err}"
56
+ end
57
+ end
42
58
  end
43
59
  end
44
60
  end
@@ -4,7 +4,7 @@ module SpecSupport
4
4
  class EnumTypeTester
5
5
  include ActiveModel::Validations
6
6
  extend EnumType
7
-
7
+
8
8
  def self.set_field(field)
9
9
  @field = field
10
10
  reset_callbacks :validate
@@ -12,7 +12,9 @@ module SpecSupport
12
12
  enum_type @field
13
13
  end
14
14
 
15
- def self.field() @field end
15
+ def self.field()
16
+ @field
17
+ end
16
18
 
17
19
  def read_attribute(_)
18
20
  instance_variable_get :"@#{self.class.field}"
@@ -37,72 +39,88 @@ describe EnumType do
37
39
  context "[getter]" do
38
40
  it "should return a symbol" do
39
41
  Model.connection.execute "INSERT INTO models (state) VALUES ('completed')"
40
- Model.last.state.should eql(:completed)
42
+ expect(Model.last.state).to eql(:completed)
41
43
  end
42
-
44
+
43
45
  it "should return nil if the value is nil" do
44
46
  Model.connection.execute "INSERT INTO models (state) VALUES (NULL)"
45
- Model.last.state.should be_nil
47
+ expect(Model.last.state).to be_nil
46
48
  end
47
49
  end
48
50
 
49
51
  context "[setter]" do
50
52
  it "should typecast the value to a string" do
51
- m = Model.new
53
+ m = Model.new
52
54
  m.state = :failed
53
- m.state.should eql(:failed)
55
+ expect(m.state).to eql(:failed)
54
56
  m.save!
55
- m.reload.state.should eql(:failed)
56
- m.state_before_type_cast.should eql('failed')
57
+ expect(m.reload.state).to eql(:failed)
58
+ expect(m.state_before_type_cast).to eql('failed')
57
59
  end
58
-
60
+
59
61
  it "should leave nil as nil" do
60
- m = Model.new
62
+ m = Model.new
61
63
  m.state = nil
62
- m.state.should eql(nil)
64
+ expect(m.state).to eql(nil)
63
65
  m.save!
64
- m.reload.state.should be_nil
66
+ expect(m.reload.state).to be_nil
65
67
  end
66
68
  end
67
69
 
68
70
  context "[validations]" do
69
71
  before :each do
70
- @field = FactoryGirl.generate(:enum_field)
72
+ @field = FactoryBot.generate(:enum_field)
71
73
  SpecSupport::EnumTypeTester.set_field(@field)
72
74
  @model = SpecSupport::EnumTypeTester.new
73
75
  end
74
-
76
+
75
77
  it "should validate inclusion if :values option is given" do
76
- SpecSupport::EnumTypeTester.enum_type @field, values: [ :a, :b ]
78
+ SpecSupport::EnumTypeTester.enum_type @field, values: [:a, :b]
77
79
  @model.send :"#{@field}=", :a
78
- @model.get.should eql('a')
79
- @model.should be_valid
80
+ expect(@model.get).to eql('a')
81
+ expect(@model).to be_valid
80
82
  @model.send :"#{@field}=", :c
81
- @model.should_not be_valid
83
+ expect(@model).not_to be_valid
82
84
  end
83
85
 
84
86
  it "should not validate presence if :allow_nil is true" do
85
87
  pending "Doesn't work"
86
88
  SpecSupport::EnumTypeTester.enum_type @field, allow_nil: true
87
89
  @model.send :"#{@field}=", nil
88
- @model.should be_valid
90
+ expect(@model).to be_valid
89
91
  end
90
-
92
+
91
93
  it "should validate presence if :allow_nil is not given" do
92
94
  SpecSupport::EnumTypeTester.enum_type @field
93
95
  @model.send :"#{@field}=", nil
94
- @model.should_not be_valid
96
+ expect(@model).not_to be_valid
95
97
  end
96
-
98
+
97
99
  it "should validate presence if :allow_nil is false" do
98
100
  SpecSupport::EnumTypeTester.enum_type @field, allow_nil: false
99
101
  @model.send :"#{@field}=", nil
100
- @model.should_not be_valid
102
+ expect(@model).not_to be_valid
103
+ end
104
+ end
105
+
106
+ context '[:register_type option]' do
107
+ before(:each) { @field = FactoryBot.generate(:enum_field) }
108
+
109
+ it "should register each new PostgreSQL type with ActiveRecord when set" do
110
+ expect(Model.connection).
111
+ to receive(:select_one).once.
112
+ with(/SELECT atttypid FROM pg_catalog.pg_attribute WHERE attrelid = 'models'::regclass AND attname = '#{@field}'/).
113
+ and_return('atttypid' => '12345')
114
+ Model.enum_type @field, register_type: true
115
+ if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID.const_defined?(:TYPE_MAP)
116
+ expect(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::TYPE_MAP[12345]).
117
+ to be_kind_of(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Identity)
118
+ end
101
119
  end
102
120
  end
103
-
121
+
104
122
  it "should determine the correct column default" do
105
- Model.columns.detect { |c| c.name == 'state' }.default.should eql('pending')
123
+ expect(Model.columns.detect { |c| c.name == 'state' }.default).to eql('pending')
106
124
  end
107
125
  end
108
126
  end
data/spec/factories.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'factory_girl'
2
- FactoryGirl.define do
2
+ FactoryBot.define do
3
3
  sequence(:enum_field) { |i| :"field#{i}" }
4
4
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,8 @@
1
- Bundler.require :default, :test
1
+ require 'bundler'
2
+ Bundler.require :default, :development
3
+
4
+ require 'rails/all'
5
+ Rails.logger = ActiveSupport::Logger.new(STDOUT)
2
6
 
3
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
metadata CHANGED
@@ -1,153 +1,138 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enum_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2013-11-11 00:00:00.000000000 Z
10
+ date: 2013-12-26 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - '>='
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '4.0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - '>='
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '4.0'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: activesupport
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - '>='
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
32
  version: '4.0'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - '>='
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '4.0'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: jeweler
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - '>='
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - '>='
51
+ - - ">="
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: yard
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - '>='
58
+ - - ">="
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
- - - '>='
65
+ - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
68
  - !ruby/object:Gem::Dependency
70
- name: RedCloth
69
+ name: redcarpet
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - '>='
72
+ - - ">="
74
73
  - !ruby/object:Gem::Version
75
74
  version: '0'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - '>='
79
+ - - ">="
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: rspec
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
- - - '>='
86
+ - - ">="
88
87
  - !ruby/object:Gem::Version
89
88
  version: '0'
90
89
  type: :development
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
- - - '>='
93
+ - - ">="
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  - !ruby/object:Gem::Dependency
98
97
  name: factory_girl
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
- - - '>='
100
+ - - ">="
102
101
  - !ruby/object:Gem::Version
103
102
  version: '0'
104
103
  type: :development
105
104
  prerelease: false
106
105
  version_requirements: !ruby/object:Gem::Requirement
107
106
  requirements:
108
- - - '>='
107
+ - - ">="
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  - !ruby/object:Gem::Dependency
112
111
  name: pg
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
- - - '>='
114
+ - - ">="
116
115
  - !ruby/object:Gem::Version
117
116
  version: '0'
118
117
  type: :development
119
118
  prerelease: false
120
119
  version_requirements: !ruby/object:Gem::Requirement
121
120
  requirements:
122
- - - '>='
121
+ - - ">="
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
125
124
  - !ruby/object:Gem::Dependency
126
125
  name: activerecord-jdbcpostgresql-adapter
127
126
  requirement: !ruby/object:Gem::Requirement
128
127
  requirements:
129
- - - '>='
128
+ - - ">="
130
129
  - !ruby/object:Gem::Version
131
130
  version: '0'
132
131
  type: :development
133
132
  prerelease: false
134
133
  version_requirements: !ruby/object:Gem::Requirement
135
134
  requirements:
136
- - - '>='
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: activerecord
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - '>='
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - '>='
135
+ - - ">="
151
136
  - !ruby/object:Gem::Version
152
137
  version: '0'
153
138
  description: Allows ActiveRecord to better use PostgreSQL's ENUM types.
@@ -156,16 +141,16 @@ executables: []
156
141
  extensions: []
157
142
  extra_rdoc_files:
158
143
  - LICENSE
159
- - README.textile
144
+ - README.md
160
145
  files:
161
- - .document
162
- - .rspec
163
- - .ruby-gemset
164
- - .ruby-version
146
+ - ".document"
147
+ - ".rspec"
148
+ - ".ruby-gemset"
149
+ - ".ruby-version"
165
150
  - Gemfile
166
151
  - Gemfile.lock
167
152
  - LICENSE
168
- - README.textile
153
+ - README.md
169
154
  - Rakefile
170
155
  - VERSION
171
156
  - enum_type.gemspec
@@ -177,24 +162,30 @@ files:
177
162
  homepage: http://github.com/riscfuture/enum_type
178
163
  licenses: []
179
164
  metadata: {}
180
- post_install_message:
165
+ post_install_message: |2+
166
+
167
+ ⚠️ DEPRECATED: enum_type is no longer maintained.
168
+
169
+ No longer maintained. Modern Rails has native ActiveRecord enum support (`enum`) that covers most use cases; for PostgreSQL native ENUM types, consider alternatives like the `activerecord-postgres_enum` gem family.
170
+
171
+ This is the final release. No further updates are planned.
172
+
181
173
  rdoc_options: []
182
174
  require_paths:
183
175
  - lib
184
176
  required_ruby_version: !ruby/object:Gem::Requirement
185
177
  requirements:
186
- - - '>='
178
+ - - ">="
187
179
  - !ruby/object:Gem::Version
188
180
  version: '1.9'
189
181
  required_rubygems_version: !ruby/object:Gem::Requirement
190
182
  requirements:
191
- - - '>='
183
+ - - ">="
192
184
  - !ruby/object:Gem::Version
193
185
  version: '0'
194
186
  requirements: []
195
- rubyforge_project:
196
- rubygems_version: 2.1.10
197
- signing_key:
187
+ rubygems_version: 4.0.11
198
188
  specification_version: 4
199
- summary: PostgreSQL enumerated types in ActiveRecord
189
+ summary: "[DEPRECATED] PostgreSQL enumerated types in ActiveRecord"
200
190
  test_files: []
191
+ ...
data/README.textile DELETED
@@ -1,45 +0,0 @@
1
- h1. enum_type -- Enumerated Types in ActiveRecord
2
-
3
- | *Author* | Tim Morgan |
4
- | *Version* | 2.1.2 (Nov 10, 2013) |
5
- | *License* | Released under the MIT license. |
6
-
7
- h2. About
8
-
9
- @enum_type@ allows you to effectively use the PostgreSQL @ENUM@ data type in
10
- your ActiveRecord models. It's a really simple gem that just adds a convenience
11
- method to take care of the usual "witch chant" that accompanies building an
12
- enumerated type in Rails.
13
-
14
- h2. Installation
15
-
16
- *Important Note:* This gem requires Ruby 1.9. Ruby 1.8 is not supported, and
17
- will never be.
18
-
19
- First, add the @enum_type@ gem to your @Gemfile@:
20
-
21
- <pre><code>
22
- gem 'enum_type'
23
- </code></pre>
24
-
25
- Then, extend your model with the @EnumType@ module:
26
-
27
- <pre><code>
28
- class MyModel < ActiveRecord::Base
29
- extend EnumType
30
- end
31
- </code></pre>
32
-
33
- h2. Usage
34
-
35
- In your model, call the @enum_type@ method, providing one or more enumerated
36
- fields, and any additional options:
37
-
38
- <pre><code>
39
- class MyModel < ActiveRecord::Base
40
- extend EnumType
41
- enum_type :status, %w( active pending admin superadmin banned )
42
- end
43
- </code></pre>
44
-
45
- See the {EnumType#enum_type} method documentation for more information.