schema_plus 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -2
- data/lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb +10 -0
- data/lib/schema_plus/active_record/connection_adapters/index_definition.rb +2 -2
- data/lib/schema_plus/version.rb +1 -1
- data/runspecs +1 -1
- data/schema_plus.gemspec +3 -0
- data/spec/connections/mysql/connection.rb +1 -1
- data/spec/connections/mysql2/connection.rb +1 -1
- metadata +77 -50
- data/spec/support/extensions/active_model.rb +0 -13
data/README.rdoc
CHANGED
@@ -11,9 +11,11 @@ For added rails DRYness see also the gems
|
|
11
11
|
== Compatibility
|
12
12
|
|
13
13
|
SchemaPlus supports all combinations of:
|
14
|
-
* rails 3.0 or 3.1
|
14
|
+
* rails 2.3, 3.0, or 3.1
|
15
15
|
* MRI ruby 1.8.7 or 1.9.2
|
16
|
-
* PostgreSQL, MySQL (using mysql or mysql2 gem), or
|
16
|
+
* PostgreSQL, MySQL (using mysql or mysql2 gem), or SQLite3 (using sqlite3 3.7.7 which has foreign key support)
|
17
|
+
|
18
|
+
Support for rails 2.3 will likely be dropped starting in version 0.2.x.
|
17
19
|
|
18
20
|
== Installation
|
19
21
|
|
@@ -95,6 +95,16 @@ module SchemaPlus
|
|
95
95
|
false
|
96
96
|
end
|
97
97
|
|
98
|
+
# This is define in rails 3.x, but not in rails2.x
|
99
|
+
unless defined? ::ActiveRecord::ConnectionAdapters::SchemaStatements::index_name_exists?
|
100
|
+
# File activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 403
|
101
|
+
def index_name_exists?(table_name, index_name, default)
|
102
|
+
return default unless respond_to?(:indexes)
|
103
|
+
index_name = index_name.to_s
|
104
|
+
indexes(table_name).detect { |i| i.name == index_name }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
98
108
|
end
|
99
109
|
end
|
100
110
|
end
|
@@ -19,8 +19,8 @@ module SchemaPlus
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize_with_schema_plus(*args) #:nodoc:
|
22
|
-
# same args as add_index(table_name, column_names, options
|
23
|
-
if args.length ==
|
22
|
+
# same args as add_index(table_name, column_names, options)
|
23
|
+
if args.length == 3 and Hash === args.last
|
24
24
|
table_name, column_names, options = args + [{}]
|
25
25
|
initialize_without_schema_plus(table_name, options[:name], options[:unique], column_names, options[:lengths])
|
26
26
|
@conditions = options[:conditions]
|
data/lib/schema_plus/version.rb
CHANGED
data/runspecs
CHANGED
data/schema_plus.gemspec
CHANGED
@@ -24,6 +24,9 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency("valuable")
|
25
25
|
|
26
26
|
case ENV['SCHEMA_PLUS_RAILS_VERSION']
|
27
|
+
when '2.3'
|
28
|
+
s.add_development_dependency("rails", "~> 2.3")
|
29
|
+
s.add_development_dependency("mysql2", "~> 0.2.6")
|
27
30
|
when '3.0'
|
28
31
|
s.add_development_dependency("rails", "~> 3.0")
|
29
32
|
s.add_development_dependency("mysql2", "~> 0.2.6")
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.1
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Ronen Barzel
|
@@ -15,18 +11,17 @@ autorequire:
|
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
13
|
|
18
|
-
date: 2011-07-26 00:00:00
|
14
|
+
date: 2011-07-26 00:00:00 -07:00
|
19
15
|
default_executable:
|
20
16
|
dependencies:
|
21
17
|
- !ruby/object:Gem::Dependency
|
22
18
|
name: rails
|
23
19
|
prerelease: false
|
24
20
|
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
25
22
|
requirements:
|
26
23
|
- - ">="
|
27
24
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
25
|
version: "0"
|
31
26
|
type: :runtime
|
32
27
|
version_requirements: *id001
|
@@ -34,112 +29,123 @@ dependencies:
|
|
34
29
|
name: valuable
|
35
30
|
prerelease: false
|
36
31
|
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
37
33
|
requirements:
|
38
34
|
- - ">="
|
39
35
|
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 0
|
42
36
|
version: "0"
|
43
37
|
type: :runtime
|
44
38
|
version_requirements: *id002
|
45
39
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
40
|
+
name: rails
|
47
41
|
prerelease: false
|
48
42
|
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
49
44
|
requirements:
|
50
|
-
- -
|
45
|
+
- - ~>
|
51
46
|
- !ruby/object:Gem::Version
|
52
|
-
|
53
|
-
- 0
|
54
|
-
version: "0"
|
47
|
+
version: "2.3"
|
55
48
|
type: :development
|
56
49
|
version_requirements: *id003
|
57
50
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
51
|
+
name: mysql2
|
59
52
|
prerelease: false
|
60
53
|
requirement: &id004 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
61
55
|
requirements:
|
62
56
|
- - ~>
|
63
57
|
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
- 0
|
66
|
-
- 8
|
67
|
-
- 7
|
68
|
-
version: 0.8.7
|
58
|
+
version: 0.2.6
|
69
59
|
type: :development
|
70
60
|
version_requirements: *id004
|
71
61
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
62
|
+
name: rake
|
73
63
|
prerelease: false
|
74
64
|
requirement: &id005 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
75
66
|
requirements:
|
76
|
-
- -
|
67
|
+
- - ~>
|
77
68
|
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
- 0
|
80
|
-
version: "0"
|
69
|
+
version: 0.8.7
|
81
70
|
type: :development
|
82
71
|
version_requirements: *id005
|
83
72
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
73
|
+
name: rspec
|
85
74
|
prerelease: false
|
86
75
|
requirement: &id006 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
87
77
|
requirements:
|
88
78
|
- - ">="
|
89
79
|
- !ruby/object:Gem::Version
|
90
|
-
segments:
|
91
|
-
- 0
|
92
80
|
version: "0"
|
93
81
|
type: :development
|
94
82
|
version_requirements: *id006
|
95
83
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
84
|
+
name: pg
|
97
85
|
prerelease: false
|
98
86
|
requirement: &id007 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
99
88
|
requirements:
|
100
89
|
- - ">="
|
101
90
|
- !ruby/object:Gem::Version
|
102
|
-
segments:
|
103
|
-
- 0
|
104
91
|
version: "0"
|
105
92
|
type: :development
|
106
93
|
version_requirements: *id007
|
107
94
|
- !ruby/object:Gem::Dependency
|
108
|
-
name:
|
95
|
+
name: mysql
|
109
96
|
prerelease: false
|
110
97
|
requirement: &id008 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
111
99
|
requirements:
|
112
100
|
- - ">="
|
113
101
|
- !ruby/object:Gem::Version
|
114
|
-
segments:
|
115
|
-
- 0
|
116
102
|
version: "0"
|
117
103
|
type: :development
|
118
104
|
version_requirements: *id008
|
119
105
|
- !ruby/object:Gem::Dependency
|
120
|
-
name:
|
106
|
+
name: sqlite3
|
121
107
|
prerelease: false
|
122
108
|
requirement: &id009 !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
123
110
|
requirements:
|
124
111
|
- - ">="
|
125
112
|
- !ruby/object:Gem::Version
|
126
|
-
segments:
|
127
|
-
- 0
|
128
113
|
version: "0"
|
129
114
|
type: :development
|
130
115
|
version_requirements: *id009
|
131
116
|
- !ruby/object:Gem::Dependency
|
132
|
-
name: simplecov
|
117
|
+
name: simplecov
|
133
118
|
prerelease: false
|
134
119
|
requirement: &id010 !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
135
121
|
requirements:
|
136
122
|
- - ">="
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
segments:
|
139
|
-
- 0
|
140
124
|
version: "0"
|
141
125
|
type: :development
|
142
126
|
version_requirements: *id010
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: simplecov-gem-adapter
|
129
|
+
prerelease: false
|
130
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
type: :development
|
137
|
+
version_requirements: *id011
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: ruby-debug19
|
140
|
+
prerelease: false
|
141
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: "0"
|
147
|
+
type: :development
|
148
|
+
version_requirements: *id012
|
143
149
|
description: "SchemaPlus is an ActiveRecord extension that provides enhanced capabilities for schema definition and querying, including: enhanced and more DRY index capabilities, support and automation for foreign key constraints, and support for views."
|
144
150
|
email:
|
145
151
|
- ronen@barzel.org
|
@@ -194,7 +200,6 @@ files:
|
|
194
200
|
- spec/schema_dumper_spec.rb
|
195
201
|
- spec/schema_spec.rb
|
196
202
|
- spec/spec_helper.rb
|
197
|
-
- spec/support/extensions/active_model.rb
|
198
203
|
- spec/support/helpers.rb
|
199
204
|
- spec/support/matchers/automatic_foreign_key_matchers.rb
|
200
205
|
- spec/support/matchers/have_index.rb
|
@@ -211,25 +216,47 @@ rdoc_options: []
|
|
211
216
|
require_paths:
|
212
217
|
- lib
|
213
218
|
required_ruby_version: !ruby/object:Gem::Requirement
|
219
|
+
none: false
|
214
220
|
requirements:
|
215
221
|
- - ">="
|
216
222
|
- !ruby/object:Gem::Version
|
217
|
-
segments:
|
218
|
-
- 0
|
219
223
|
version: "0"
|
220
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
221
226
|
requirements:
|
222
227
|
- - ">="
|
223
228
|
- !ruby/object:Gem::Version
|
224
|
-
segments:
|
225
|
-
- 0
|
226
229
|
version: "0"
|
227
230
|
requirements: []
|
228
231
|
|
229
232
|
rubyforge_project: schema_plus
|
230
|
-
rubygems_version: 1.
|
233
|
+
rubygems_version: 1.6.2
|
231
234
|
signing_key:
|
232
235
|
specification_version: 3
|
233
236
|
summary: Enhances ActiveRecord schema mechanism, including more DRY index creation and support for foreign key constraints and views.
|
234
|
-
test_files:
|
235
|
-
|
237
|
+
test_files:
|
238
|
+
- spec/column_spec.rb
|
239
|
+
- spec/connections/mysql/connection.rb
|
240
|
+
- spec/connections/mysql2/connection.rb
|
241
|
+
- spec/connections/postgresql/connection.rb
|
242
|
+
- spec/connections/sqlite3/connection.rb
|
243
|
+
- spec/foreign_key_definition_spec.rb
|
244
|
+
- spec/foreign_key_spec.rb
|
245
|
+
- spec/index_definition_spec.rb
|
246
|
+
- spec/index_spec.rb
|
247
|
+
- spec/migration_spec.rb
|
248
|
+
- spec/models/comment.rb
|
249
|
+
- spec/models/post.rb
|
250
|
+
- spec/models/user.rb
|
251
|
+
- spec/references_spec.rb
|
252
|
+
- spec/schema/auto_schema.rb
|
253
|
+
- spec/schema/core_schema.rb
|
254
|
+
- spec/schema_dumper_spec.rb
|
255
|
+
- spec/schema_spec.rb
|
256
|
+
- spec/spec_helper.rb
|
257
|
+
- spec/support/helpers.rb
|
258
|
+
- spec/support/matchers/automatic_foreign_key_matchers.rb
|
259
|
+
- spec/support/matchers/have_index.rb
|
260
|
+
- spec/support/matchers/reference.rb
|
261
|
+
- spec/support/reference.rb
|
262
|
+
- spec/views_spec.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# ported from rspec-rails
|
2
|
-
# There is no reason to install whole gem as we
|
3
|
-
# need only that tiny helper
|
4
|
-
module ::ActiveModel::Validations
|
5
|
-
|
6
|
-
def error_on(attribute)
|
7
|
-
self.valid?
|
8
|
-
[self.errors[attribute]].flatten.compact
|
9
|
-
end
|
10
|
-
|
11
|
-
alias :errors_on :error_on
|
12
|
-
|
13
|
-
end
|