activerecord_enum 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/README.markdown +10 -2
- data/Rakefile +1 -0
- data/activerecord_enum.gemspec +1 -1
- data/lib/activerecord_enum/version.rb +1 -1
- data/lib/connection_adapters/sqlite3.rb +1 -1
- data/spec/Gemfile.rails_3_0 +1 -1
- data/spec/Gemfile.rails_3_1 +1 -1
- data/spec/Gemfile.rails_3_2 +1 -1
- data/spec/Gemfile.rails_4_0 +4 -0
- data/spec/enum_spec.rb +3 -3
- data/spec/schema/enum_new.rb +0 -1
- data/spec/schema/enum_old.rb +0 -1
- data/spec/schema/set_new.rb +0 -1
- data/spec/schema/set_old.rb +0 -1
- data/spec/set_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- metadata +100 -111
data/.travis.yml
CHANGED
data/README.markdown
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Provides ActiveRecord support for the nonstandard `ENUM` and `SET` data types.
|
4
4
|
|
5
|
-
[![Build Status](
|
5
|
+
[![Build Status](https://travis-ci.org/iangreenleaf/activerecord_enum.png?branch=master)](http://travis-ci.org/iangreenleaf/activerecord_enum)
|
6
6
|
|
7
7
|
## Running the tests ##
|
8
8
|
|
@@ -22,7 +22,13 @@ To run the tests for just one adapter:
|
|
22
22
|
|
23
23
|
### Y U NO WORK?! ###
|
24
24
|
|
25
|
-
|
25
|
+
It currently works with:
|
26
|
+
|
27
|
+
* Rails 3.0, 3.1, 3.2, 4.0.
|
28
|
+
* The `mysql2` and `sqlite` adapters.
|
29
|
+
* Ruby 1.9.3, 2.0.0. It probably also works with Ruby 1.8, but that is unsupported.
|
30
|
+
|
31
|
+
If you'd like to support other adapters, pull requests are welcome!
|
26
32
|
|
27
33
|
### Why doesn't it validate anything? ###
|
28
34
|
|
@@ -41,3 +47,5 @@ For SET columns, you may be interested in [iangreenleaf/active_set](https://gith
|
|
41
47
|
This isn't a plugin everyone should use. There are a number of plugins to simulate enum behavior backed by standard data types. Personally, I like [nofxx/symbolize](https://github.com/nofxx/symbolize).
|
42
48
|
|
43
49
|
However, sometimes we can't or won't avoid working with these data types. When that happens, I got you covered.
|
50
|
+
|
51
|
+
## [Contributors](https://github.com/iangreenleaf/activerecord_enum/graphs/contributors) ##
|
data/Rakefile
CHANGED
data/activerecord_enum.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.rubyforge_project = "activerecord_enum"
|
16
16
|
|
17
|
-
s.add_dependency "activerecord", "
|
17
|
+
s.add_dependency "activerecord", ">= 3.0"
|
18
18
|
s.add_development_dependency "rake"
|
19
19
|
s.add_development_dependency "bundler"
|
20
20
|
s.add_development_dependency "mysql2", "~> 0.3.11"
|
@@ -2,7 +2,7 @@ require 'active_record/connection_adapters/sqlite3_adapter'
|
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
module ConnectionAdapters
|
5
|
-
class SQLite3Adapter < SQLiteAdapter
|
5
|
+
class SQLite3Adapter < (defined?(SQLiteAdapter) ? SQLiteAdapter : AbstractAdapter)
|
6
6
|
def type_to_sql_with_enum type, limit=nil, *args
|
7
7
|
if type.to_s == "enum" || type.to_s == "set"
|
8
8
|
type, limit = :string, nil
|
data/spec/Gemfile.rails_3_0
CHANGED
data/spec/Gemfile.rails_3_1
CHANGED
data/spec/Gemfile.rails_3_2
CHANGED
data/spec/enum_spec.rb
CHANGED
@@ -7,15 +7,15 @@ describe "ENUM datatype" do
|
|
7
7
|
subject { dumped_schema }
|
8
8
|
|
9
9
|
it "dumps native format" do
|
10
|
-
subject.should match %r{t\.enum\s+"color",\s
|
10
|
+
subject.should match %r{t\.enum\s+"color",\s+(:limit =>|limit:) \["blue", "red", "yellow"\]}
|
11
11
|
end
|
12
12
|
|
13
13
|
it "dumps default option" do
|
14
|
-
subject.should match %r{t\.enum\s+"color"
|
14
|
+
subject.should match %r{t\.enum\s+"color",.+(:default =>|default:) "red"}
|
15
15
|
end
|
16
16
|
|
17
17
|
it "dumps null option" do
|
18
|
-
subject.should match %r{t\.enum\s+"color"
|
18
|
+
subject.should match %r{t\.enum\s+"color",.+(:null =>|null:) false$}
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/spec/schema/enum_new.rb
CHANGED
data/spec/schema/enum_old.rb
CHANGED
data/spec/schema/set_new.rb
CHANGED
data/spec/schema/set_old.rb
CHANGED
data/spec/set_spec.rb
CHANGED
@@ -7,15 +7,15 @@ describe "SET datatype" do
|
|
7
7
|
subject { dumped_schema }
|
8
8
|
|
9
9
|
it "dumps native format" do
|
10
|
-
subject.should match %r{t\.set\s+"gadgets",\s
|
10
|
+
subject.should match %r{t\.set\s+"gadgets",\s+(:limit =>|limit:) \["propeller", "tail gun", "gps"\]}
|
11
11
|
end
|
12
12
|
|
13
13
|
it "dumps default option" do
|
14
|
-
subject.should match %r{t\.set\s+"gadgets"
|
14
|
+
subject.should match %r{t\.set\s+"gadgets",.+(:default =>|default:) \["propeller", "gps"\]}
|
15
15
|
end
|
16
16
|
|
17
17
|
it "dumps null option" do
|
18
|
-
subject.should match %r{t\.set\s+"gadgets"
|
18
|
+
subject.should match %r{t\.set\s+"gadgets",.+(:null =>|null:) false$}
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,123 +1,119 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_enum
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ian Young
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
-
none: false
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
hash: 7
|
27
|
-
segments:
|
28
|
-
- 3
|
29
|
-
- 0
|
30
|
-
version: "3.0"
|
31
|
-
version_requirements: *id001
|
12
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
32
15
|
name: activerecord
|
33
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
34
22
|
type: :runtime
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
25
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
|
-
version_requirements: *id002
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
46
31
|
name: rake
|
47
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
48
38
|
type: :development
|
49
|
-
|
50
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
41
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
version_requirements: *id003
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
60
47
|
name: bundler
|
61
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
62
54
|
type: :development
|
63
|
-
|
64
|
-
|
55
|
+
prerelease: false
|
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
|
63
|
+
name: mysql2
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
|
-
requirements:
|
66
|
+
requirements:
|
67
67
|
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
hash: 5
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
- 3
|
73
|
-
- 11
|
68
|
+
- !ruby/object:Gem::Version
|
74
69
|
version: 0.3.11
|
75
|
-
version_requirements: *id004
|
76
|
-
name: mysql2
|
77
|
-
prerelease: false
|
78
70
|
type: :development
|
79
|
-
|
80
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
73
|
none: false
|
82
|
-
requirements:
|
74
|
+
requirements:
|
83
75
|
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
|
87
|
-
- 1
|
88
|
-
- 3
|
89
|
-
- 4
|
90
|
-
version: 1.3.4
|
91
|
-
version_requirements: *id005
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.3.11
|
78
|
+
- !ruby/object:Gem::Dependency
|
92
79
|
name: sqlite3
|
93
|
-
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.4
|
94
86
|
type: :development
|
95
|
-
|
96
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
89
|
none: false
|
98
|
-
requirements:
|
90
|
+
requirements:
|
99
91
|
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
103
|
-
- 2
|
104
|
-
- 9
|
105
|
-
- 0
|
106
|
-
version: 2.9.0
|
107
|
-
version_requirements: *id006
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.4
|
94
|
+
- !ruby/object:Gem::Dependency
|
108
95
|
name: rspec
|
109
|
-
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.9.0
|
110
102
|
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.9.0
|
111
110
|
description: Adds the ENUM data type natively to ActiveRecord.
|
112
|
-
email:
|
111
|
+
email:
|
113
112
|
- ian.greenleaf+github@gmail.com
|
114
113
|
executables: []
|
115
|
-
|
116
114
|
extensions: []
|
117
|
-
|
118
115
|
extra_rdoc_files: []
|
119
|
-
|
120
|
-
files:
|
116
|
+
files:
|
121
117
|
- .gitignore
|
122
118
|
- .travis.yml
|
123
119
|
- Gemfile
|
@@ -133,6 +129,7 @@ files:
|
|
133
129
|
- spec/Gemfile.rails_3_0
|
134
130
|
- spec/Gemfile.rails_3_1
|
135
131
|
- spec/Gemfile.rails_3_2
|
132
|
+
- spec/Gemfile.rails_4_0
|
136
133
|
- spec/all_rails
|
137
134
|
- spec/database.yml.tmpl
|
138
135
|
- spec/enum_spec.rb
|
@@ -142,43 +139,35 @@ files:
|
|
142
139
|
- spec/schema/set_old.rb
|
143
140
|
- spec/set_spec.rb
|
144
141
|
- spec/spec_helper.rb
|
145
|
-
homepage:
|
142
|
+
homepage: ''
|
146
143
|
licenses: []
|
147
|
-
|
148
144
|
post_install_message:
|
149
145
|
rdoc_options: []
|
150
|
-
|
151
|
-
require_paths:
|
146
|
+
require_paths:
|
152
147
|
- lib
|
153
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
149
|
none: false
|
155
|
-
requirements:
|
156
|
-
- -
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
|
159
|
-
|
160
|
-
- 0
|
161
|
-
version: "0"
|
162
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
155
|
none: false
|
164
|
-
requirements:
|
165
|
-
- -
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
|
168
|
-
segments:
|
169
|
-
- 0
|
170
|
-
version: "0"
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
171
160
|
requirements: []
|
172
|
-
|
173
161
|
rubyforge_project: activerecord_enum
|
174
|
-
rubygems_version: 1.8.
|
162
|
+
rubygems_version: 1.8.23
|
175
163
|
signing_key:
|
176
164
|
specification_version: 3
|
177
165
|
summary: Enum data types for ActiveRecord
|
178
|
-
test_files:
|
166
|
+
test_files:
|
179
167
|
- spec/Gemfile.rails_3_0
|
180
168
|
- spec/Gemfile.rails_3_1
|
181
169
|
- spec/Gemfile.rails_3_2
|
170
|
+
- spec/Gemfile.rails_4_0
|
182
171
|
- spec/all_rails
|
183
172
|
- spec/database.yml.tmpl
|
184
173
|
- spec/enum_spec.rb
|