activerecord_enum 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -4,11 +4,21 @@ Provides ActiveRecord support for the nonstandard `ENUM` and `SET` data types.
4
4
 
5
5
  [![Build Status](http://travis-ci.org/iangreenleaf/activerecord_enum.png)](http://travis-ci.org/iangreenleaf/activerecord_enum)
6
6
 
7
+ ## Running the tests ##
8
+
9
+ To run the tests for all supported database adapters:
10
+
11
+ rake spec:all
12
+
13
+ To run the tests for just one adapter:
14
+
15
+ DB=mysql rake spec
16
+
7
17
  ## Hypothetically asked questions ##
8
18
 
9
19
  ### Y U NO WORK?! ###
10
20
 
11
- Sorry, it currently only works with Rails 3.0.x and the mysql2 and sqlite adapters. I plan to support 3.1.x and other standard adapters at some point.
21
+ Sorry, it currently only works with Rails 3.x and the mysql2 and sqlite adapters. I plan to support other standard adapters at some point.
12
22
 
13
23
  ### Why doesn't it validate anything? ###
14
24
 
@@ -14,12 +14,12 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "activerecord_enum"
16
16
 
17
- s.add_dependency "activerecord", "~> 3.0.9"
17
+ s.add_dependency "activerecord", "~> 3.2.3"
18
18
  s.add_development_dependency "rake"
19
19
  s.add_development_dependency "bundler"
20
- s.add_development_dependency "mysql2", "~> 0.2.0"
20
+ s.add_development_dependency "mysql2", "~> 0.3.11"
21
21
  s.add_development_dependency "sqlite3", "~>1.3.4"
22
- s.add_development_dependency "rspec", "~> 2.6.0"
22
+ s.add_development_dependency "rspec", "~> 2.9.0"
23
23
 
24
24
  s.files = `git ls-files`.split("\n")
25
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -1,3 +1,3 @@
1
1
  module ActiverecordEnum
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -6,7 +6,9 @@ require 'active_record/connection_adapters/abstract/schema_definitions.rb'
6
6
 
7
7
  module ActiveRecord
8
8
  module ConnectionAdapters
9
- class Mysql2Adapter < AbstractAdapter
9
+ existing_class = defined?( Mysql2Adapter ) ? Mysql2Adapter : AbstractMysqlAdapter
10
+
11
+ existing_class.class_eval do
10
12
  def native_database_types_with_enum
11
13
  native_database_types_without_enum.merge( :enum => { :name => "enum" }, :set => { :name => "set" } )
12
14
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'rspec'
2
2
  require 'activerecord_enum'
3
3
 
4
+ def db
5
+ ENV["DB"] || "mysql"
6
+ end
7
+
4
8
  def load_schema filename
5
9
  # silence verbose schema loading
6
10
  original_stdout = $stdout
@@ -21,7 +25,7 @@ def dumped_schema
21
25
  end
22
26
 
23
27
  def column_props table, column
24
- case ENV["DB"]
28
+ case db
25
29
  when "mysql"
26
30
  result = ActiveRecord::Base.connection.select_one "SHOW FIELDS FROM #{table} WHERE Field='#{column}'"
27
31
  { :type => result["Type"], :default => result["Default"], :null => ( result["Null"] == "YES" ) }
@@ -34,7 +38,6 @@ end
34
38
 
35
39
  db_config = YAML::load(IO.read("spec/database.yml"))
36
40
  ActiveRecord::Base.configurations = db_config
37
- db = ENV["DB"] || "mysql"
38
41
  ActiveRecord::Base.establish_connection db
39
42
  RSpec.configure do |c|
40
43
  c.filter_run_excluding :db_support => ! db_config[db]["supports_enums"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_enum
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ian Young
@@ -15,27 +15,25 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-03 00:00:00 Z
18
+ date: 2012-04-05 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: activerecord
22
- prerelease: false
23
21
  requirement: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
26
24
  - - ~>
27
25
  - !ruby/object:Gem::Version
28
- hash: 21
26
+ hash: 9
29
27
  segments:
30
28
  - 3
31
- - 0
32
- - 9
33
- version: 3.0.9
34
- type: :runtime
29
+ - 2
30
+ - 3
31
+ version: 3.2.3
35
32
  version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rake
33
+ name: activerecord
38
34
  prerelease: false
35
+ type: :runtime
36
+ - !ruby/object:Gem::Dependency
39
37
  requirement: &id002 !ruby/object:Gem::Requirement
40
38
  none: false
41
39
  requirements:
@@ -45,11 +43,11 @@ dependencies:
45
43
  segments:
46
44
  - 0
47
45
  version: "0"
48
- type: :development
49
46
  version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: bundler
47
+ name: rake
52
48
  prerelease: false
49
+ type: :development
50
+ - !ruby/object:Gem::Dependency
53
51
  requirement: &id003 !ruby/object:Gem::Requirement
54
52
  none: false
55
53
  requirements:
@@ -59,27 +57,27 @@ dependencies:
59
57
  segments:
60
58
  - 0
61
59
  version: "0"
62
- type: :development
63
60
  version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: mysql2
61
+ name: bundler
66
62
  prerelease: false
63
+ type: :development
64
+ - !ruby/object:Gem::Dependency
67
65
  requirement: &id004 !ruby/object:Gem::Requirement
68
66
  none: false
69
67
  requirements:
70
68
  - - ~>
71
69
  - !ruby/object:Gem::Version
72
- hash: 23
70
+ hash: 5
73
71
  segments:
74
72
  - 0
75
- - 2
76
- - 0
77
- version: 0.2.0
78
- type: :development
73
+ - 3
74
+ - 11
75
+ version: 0.3.11
79
76
  version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: sqlite3
77
+ name: mysql2
82
78
  prerelease: false
79
+ type: :development
80
+ - !ruby/object:Gem::Dependency
83
81
  requirement: &id005 !ruby/object:Gem::Requirement
84
82
  none: false
85
83
  requirements:
@@ -91,24 +89,26 @@ dependencies:
91
89
  - 3
92
90
  - 4
93
91
  version: 1.3.4
94
- type: :development
95
92
  version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- name: rspec
93
+ name: sqlite3
98
94
  prerelease: false
95
+ type: :development
96
+ - !ruby/object:Gem::Dependency
99
97
  requirement: &id006 !ruby/object:Gem::Requirement
100
98
  none: false
101
99
  requirements:
102
100
  - - ~>
103
101
  - !ruby/object:Gem::Version
104
- hash: 23
102
+ hash: 43
105
103
  segments:
106
104
  - 2
107
- - 6
105
+ - 9
108
106
  - 0
109
- version: 2.6.0
110
- type: :development
107
+ version: 2.9.0
111
108
  version_requirements: *id006
109
+ name: rspec
110
+ prerelease: false
111
+ type: :development
112
112
  description: Adds the ENUM data type natively to ActiveRecord.
113
113
  email:
114
114
  - ian.greenleaf+github@gmail.com
@@ -166,9 +166,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  requirements: []
167
167
 
168
168
  rubyforge_project: activerecord_enum
169
- rubygems_version: 1.7.2
169
+ rubygems_version: 1.8.11
170
170
  signing_key:
171
171
  specification_version: 3
172
172
  summary: Enum data types for ActiveRecord
173
- test_files: []
174
-
173
+ test_files:
174
+ - spec/database.yml.tmpl
175
+ - spec/enum_spec.rb
176
+ - spec/schema/enum_new.rb
177
+ - spec/schema/enum_old.rb
178
+ - spec/schema/set_new.rb
179
+ - spec/schema/set_old.rb
180
+ - spec/set_spec.rb
181
+ - spec/spec_helper.rb