enum_type 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -2
- data/Gemfile.lock +45 -29
- data/README.textile +1 -1
- data/VERSION +1 -1
- data/enum_type.gemspec +13 -10
- data/lib/enum_type/extensions.rb +20 -3
- data/spec/spec_helper.rb +2 -1
- metadata +144 -90
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,46 +1,62 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
RedCloth (4.2.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
activerecord (3.
|
10
|
-
activemodel (= 3.
|
11
|
-
activesupport (= 3.
|
12
|
-
arel (~>
|
13
|
-
tzinfo (~> 0.3.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
RedCloth (4.2.9)
|
5
|
+
RedCloth (4.2.9-java)
|
6
|
+
activemodel (3.2.3)
|
7
|
+
activesupport (= 3.2.3)
|
8
|
+
builder (~> 3.0.0)
|
9
|
+
activerecord (3.2.3)
|
10
|
+
activemodel (= 3.2.3)
|
11
|
+
activesupport (= 3.2.3)
|
12
|
+
arel (~> 3.0.2)
|
13
|
+
tzinfo (~> 0.3.29)
|
14
|
+
activerecord-jdbc-adapter (1.2.2)
|
15
|
+
activerecord-jdbcpostgresql-adapter (1.2.2)
|
16
|
+
activerecord-jdbc-adapter (~> 1.2.2)
|
17
|
+
jdbc-postgres (>= 9.0, < 9.2)
|
18
|
+
activesupport (3.2.3)
|
19
|
+
i18n (~> 0.6)
|
20
|
+
multi_json (~> 1.0)
|
21
|
+
arel (3.0.2)
|
22
|
+
builder (3.0.0)
|
23
|
+
diff-lcs (1.1.3)
|
24
|
+
factory_girl (3.3.0)
|
25
|
+
activesupport (>= 3.0.0)
|
19
26
|
git (1.2.5)
|
20
|
-
i18n (0.
|
21
|
-
|
27
|
+
i18n (0.6.0)
|
28
|
+
jdbc-postgres (9.1.901)
|
29
|
+
jeweler (1.8.3)
|
22
30
|
bundler (~> 1.0)
|
23
31
|
git (>= 1.2.5)
|
24
32
|
rake
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
rdoc
|
34
|
+
json (1.7.3)
|
35
|
+
json (1.7.3-java)
|
36
|
+
multi_json (1.3.5)
|
37
|
+
pg (0.13.2)
|
38
|
+
rake (0.9.2.2)
|
39
|
+
rdoc (3.12)
|
40
|
+
json (~> 1.4)
|
41
|
+
rspec (2.10.0)
|
42
|
+
rspec-core (~> 2.10.0)
|
43
|
+
rspec-expectations (~> 2.10.0)
|
44
|
+
rspec-mocks (~> 2.10.0)
|
45
|
+
rspec-core (2.10.0)
|
46
|
+
rspec-expectations (2.10.0)
|
47
|
+
diff-lcs (~> 1.1.3)
|
48
|
+
rspec-mocks (2.10.1)
|
49
|
+
tzinfo (0.3.33)
|
50
|
+
yard (0.8.1)
|
37
51
|
|
38
52
|
PLATFORMS
|
53
|
+
java
|
39
54
|
ruby
|
40
55
|
|
41
56
|
DEPENDENCIES
|
42
57
|
RedCloth
|
43
58
|
activerecord (>= 3.0)
|
59
|
+
activerecord-jdbcpostgresql-adapter
|
44
60
|
activesupport (>= 3.0)
|
45
61
|
factory_girl
|
46
62
|
jeweler
|
data/README.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.0
|
data/enum_type.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "2.
|
7
|
+
s.name = "enum_type"
|
8
|
+
s.version = "2.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Tim Morgan"]
|
12
|
+
s.date = "2012-05-14"
|
13
|
+
s.description = "Allows ActiveRecord to better use PostgreSQL's ENUM types."
|
14
|
+
s.email = "git@timothymorgan.info"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
17
|
"README.textile"
|
@@ -32,11 +32,11 @@ Gem::Specification.new do |s|
|
|
32
32
|
"spec/factories.rb",
|
33
33
|
"spec/spec_helper.rb"
|
34
34
|
]
|
35
|
-
s.homepage =
|
36
|
-
s.require_paths = [
|
35
|
+
s.homepage = "http://github.com/riscfuture/enum_type"
|
36
|
+
s.require_paths = ["lib"]
|
37
37
|
s.required_ruby_version = Gem::Requirement.new(">= 1.9")
|
38
|
-
s.rubygems_version =
|
39
|
-
s.summary =
|
38
|
+
s.rubygems_version = "1.8.24"
|
39
|
+
s.summary = "PostgreSQL enumerated types in ActiveRecord"
|
40
40
|
|
41
41
|
if s.respond_to? :specification_version then
|
42
42
|
s.specification_version = 3
|
@@ -50,6 +50,7 @@ Gem::Specification.new do |s|
|
|
50
50
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
51
|
s.add_development_dependency(%q<factory_girl>, [">= 0"])
|
52
52
|
s.add_development_dependency(%q<pg>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<activerecord-jdbcpostgresql-adapter>, [">= 0"])
|
53
54
|
s.add_runtime_dependency(%q<activerecord>, [">= 0"])
|
54
55
|
else
|
55
56
|
s.add_dependency(%q<activerecord>, [">= 3.0"])
|
@@ -60,6 +61,7 @@ Gem::Specification.new do |s|
|
|
60
61
|
s.add_dependency(%q<rspec>, [">= 0"])
|
61
62
|
s.add_dependency(%q<factory_girl>, [">= 0"])
|
62
63
|
s.add_dependency(%q<pg>, [">= 0"])
|
64
|
+
s.add_dependency(%q<activerecord-jdbcpostgresql-adapter>, [">= 0"])
|
63
65
|
s.add_dependency(%q<activerecord>, [">= 0"])
|
64
66
|
end
|
65
67
|
else
|
@@ -71,6 +73,7 @@ Gem::Specification.new do |s|
|
|
71
73
|
s.add_dependency(%q<rspec>, [">= 0"])
|
72
74
|
s.add_dependency(%q<factory_girl>, [">= 0"])
|
73
75
|
s.add_dependency(%q<pg>, [">= 0"])
|
76
|
+
s.add_dependency(%q<activerecord-jdbcpostgresql-adapter>, [">= 0"])
|
74
77
|
s.add_dependency(%q<activerecord>, [">= 0"])
|
75
78
|
end
|
76
79
|
end
|
data/lib/enum_type/extensions.rb
CHANGED
@@ -7,7 +7,7 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLColumn
|
|
7
7
|
def initialize(name, default, sql_type = nil, null = true)
|
8
8
|
super(name, self.class.extract_value_from_default(default, sql_type), sql_type, null)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def self.extract_value_from_default_with_enum(default, type)
|
12
12
|
case default
|
13
13
|
when /\A'(.*)'::(?:#{Regexp.escape type})\z/
|
@@ -16,8 +16,25 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLColumn
|
|
16
16
|
extract_value_from_default_without_enum default
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
class << self
|
21
21
|
alias_method_chain :extract_value_from_default, :enum
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end if ActiveRecord::ConnectionAdapters::PostgreSQLColumn.methods.include?(:extract_value_from_default)
|
24
|
+
|
25
|
+
class ActiveRecord::ConnectionAdapters::JdbcColumn
|
26
|
+
def initialize(config, name, default, *args)
|
27
|
+
call_discovered_column_callbacks(config)
|
28
|
+
super(name,enum_default_value(default, args.first),*args)
|
29
|
+
init_column(name, default, *args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def enum_default_value(default, type)
|
33
|
+
case default
|
34
|
+
when /\A'(.*)'::(?:#{Regexp.escape type})\z/
|
35
|
+
$1
|
36
|
+
else
|
37
|
+
default_value default
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end if defined?(ActiveRecord::ConnectionAdapters::JdbcColumn)
|
data/spec/spec_helper.rb
CHANGED
@@ -7,7 +7,7 @@ require 'factories'
|
|
7
7
|
require 'enum_type'
|
8
8
|
|
9
9
|
ActiveRecord::Base.establish_connection(
|
10
|
-
adapter: 'postgresql',
|
10
|
+
adapter: (defined?(JRuby) ? 'jdbcpostgresql' : 'postgresql'),
|
11
11
|
database: 'enum_type_test',
|
12
12
|
username: 'enum_type_tester'
|
13
13
|
)
|
@@ -23,5 +23,6 @@ RSpec.configure do |config|
|
|
23
23
|
Model.connection.execute "DROP TYPE IF EXISTS state_type"
|
24
24
|
Model.connection.execute "CREATE TYPE state_type AS ENUM ('pending', 'processing', 'completed', 'failed')"
|
25
25
|
Model.connection.execute "CREATE TABLE models (id SERIAL PRIMARY KEY, state state_type DEFAULT 'pending')"
|
26
|
+
Model.connection.reconnect!
|
26
27
|
end
|
27
28
|
end
|
metadata
CHANGED
@@ -1,126 +1,184 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: enum_type
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.0
|
4
5
|
prerelease:
|
5
|
-
version: 2.0.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Tim Morgan
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: activerecord
|
17
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
27
31
|
name: activesupport
|
28
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
29
33
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
38
47
|
name: jeweler
|
39
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
40
49
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
45
54
|
type: :development
|
46
55
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
49
63
|
name: yard
|
50
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
51
65
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
56
70
|
type: :development
|
57
71
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
60
79
|
name: RedCloth
|
61
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
62
81
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
67
86
|
type: :development
|
68
87
|
prerelease: false
|
69
|
-
version_requirements:
|
70
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
71
95
|
name: rspec
|
72
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
73
97
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
78
102
|
type: :development
|
79
103
|
prerelease: false
|
80
|
-
version_requirements:
|
81
|
-
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
82
111
|
name: factory_girl
|
83
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
84
113
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version:
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
89
118
|
type: :development
|
90
119
|
prerelease: false
|
91
|
-
version_requirements:
|
92
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
93
127
|
name: pg
|
94
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
95
129
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version:
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
100
134
|
type: :development
|
101
135
|
prerelease: false
|
102
|
-
version_requirements:
|
103
|
-
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: activerecord-jdbcpostgresql-adapter
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
104
159
|
name: activerecord
|
105
|
-
requirement:
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
106
161
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version:
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
111
166
|
type: :runtime
|
112
167
|
prerelease: false
|
113
|
-
version_requirements:
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
114
174
|
description: Allows ActiveRecord to better use PostgreSQL's ENUM types.
|
115
175
|
email: git@timothymorgan.info
|
116
176
|
executables: []
|
117
|
-
|
118
177
|
extensions: []
|
119
|
-
|
120
|
-
extra_rdoc_files:
|
178
|
+
extra_rdoc_files:
|
121
179
|
- LICENSE
|
122
180
|
- README.textile
|
123
|
-
files:
|
181
|
+
files:
|
124
182
|
- .document
|
125
183
|
- .rspec
|
126
184
|
- Gemfile
|
@@ -137,30 +195,26 @@ files:
|
|
137
195
|
- spec/spec_helper.rb
|
138
196
|
homepage: http://github.com/riscfuture/enum_type
|
139
197
|
licenses: []
|
140
|
-
|
141
198
|
post_install_message:
|
142
199
|
rdoc_options: []
|
143
|
-
|
144
|
-
require_paths:
|
200
|
+
require_paths:
|
145
201
|
- lib
|
146
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
203
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version:
|
152
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ! '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '1.9'
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
209
|
none: false
|
154
|
-
requirements:
|
155
|
-
- -
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version:
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
158
214
|
requirements: []
|
159
|
-
|
160
215
|
rubyforge_project:
|
161
|
-
rubygems_version: 1.8.
|
216
|
+
rubygems_version: 1.8.24
|
162
217
|
signing_key:
|
163
218
|
specification_version: 3
|
164
219
|
summary: PostgreSQL enumerated types in ActiveRecord
|
165
220
|
test_files: []
|
166
|
-
|