legacy_data 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/README.md +3 -1
- data/VERSION +1 -1
- data/examples/blog_migration.rb +1 -0
- data/examples/generated/blog_mysql/factories.rb +1 -0
- data/examples/generated/blog_mysql/post.rb +7 -1
- data/examples/generated/blog_sqlite3/factories.rb +1 -0
- data/examples/generated/blog_sqlite3/post.rb +7 -1
- data/lib/legacy_data/schema.rb +2 -2
- data/spec/legacy_data/schema_spec.rb +1 -1
- metadata +4 -4
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm @legacy_data
|
1
|
+
rvm --create use @legacy_data
|
data/README.md
CHANGED
@@ -5,7 +5,9 @@ encoded in the database? Do you have to understand the entire data model before
|
|
5
5
|
in the `legacy_data` gem can help! This generator looks into your existing database and generates ActiveRecord models based on the
|
6
6
|
information encoded in it.
|
7
7
|
|
8
|
-
|
8
|
+
This gem works with Rails 3
|
9
|
+
|
10
|
+
* If you are using Rails 2.3 you must use v 0.1.12 "gem install legacy_data --v 0.1.12"
|
9
11
|
|
10
12
|
|
11
13
|
## How to use it
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/examples/blog_migration.rb
CHANGED
@@ -4,6 +4,12 @@ class Post < ActiveRecord::Base
|
|
4
4
|
has_and_belongs_to_many :tags, :association_foreign_key => :tag_id, :foreign_key => :post_id, :join_table => :post_tags
|
5
5
|
|
6
6
|
# Constraints
|
7
|
-
|
7
|
+
def self.possible_values_for_published
|
8
|
+
"true, false"
|
9
|
+
end
|
10
|
+
validates_inclusion_of :published,
|
11
|
+
:in => possible_values_for_published,
|
12
|
+
:message => "is not one of (#{possible_values_for_published.join(', ')})"
|
13
|
+
|
8
14
|
end
|
9
15
|
|
@@ -4,6 +4,12 @@ class Post < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
|
6
6
|
# Constraints
|
7
|
-
|
7
|
+
def self.possible_values_for_published
|
8
|
+
"true, false"
|
9
|
+
end
|
10
|
+
validates_inclusion_of :published,
|
11
|
+
:in => possible_values_for_published,
|
12
|
+
:message => "is not one of (#{possible_values_for_published.join(', ')})"
|
13
|
+
|
8
14
|
end
|
9
15
|
|
data/lib/legacy_data/schema.rb
CHANGED
@@ -134,7 +134,7 @@ module LegacyData
|
|
134
134
|
boolean_presence_columns, @constraints[:presence_of] = presence_constraints
|
135
135
|
@constraints[:numericality_of] = numericality_constraints
|
136
136
|
@constraints[:custom], @constraints[:inclusion_of] = custom_constraints
|
137
|
-
|
137
|
+
|
138
138
|
boolean_presence_columns.each {|col| @constraints[:inclusion_of][col] = "true, false" }
|
139
139
|
end
|
140
140
|
@constraints
|
@@ -186,7 +186,7 @@ module LegacyData
|
|
186
186
|
end
|
187
187
|
|
188
188
|
def custom_constraints
|
189
|
-
return [
|
189
|
+
return [{}, {}] unless connection.respond_to? :constraints
|
190
190
|
custom_constraints, inclusion_constraints = {}, {}
|
191
191
|
connection.constraints(table_name).each do |constraint|
|
192
192
|
constraint_sql = constraint.second
|
@@ -203,7 +203,7 @@ describe LegacyData::Schema do
|
|
203
203
|
|
204
204
|
it 'should give no custom constraints when the adapter does not support it' do
|
205
205
|
@connection.should_receive(:respond_to?).with(:constraints).and_return(false)
|
206
|
-
@schema.custom_constraints.should == [
|
206
|
+
@schema.custom_constraints.should == [{},{}]
|
207
207
|
end
|
208
208
|
|
209
209
|
describe 'custom constraints' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legacy_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Rothenberg
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-06 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|