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 CHANGED
@@ -1,6 +1,7 @@
1
1
  .bundle
2
2
  Gemfile.lock
3
3
  *.sw?
4
+ *~
4
5
  .DS_Store
5
6
  coverage
6
7
  rdoc
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
- * If you are using Rails 2.3 you must use v 0.1.12 of this gem "gem install legacy_data --version 0.1.12"
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.0
1
+ 0.2.1
@@ -8,6 +8,7 @@ def create_blog_tables
8
8
  connection.create_table :posts do |t|
9
9
  t.string :title
10
10
  t.text :body
11
+ t.boolean :published, :null=>false
11
12
  end
12
13
  connection.create_table :comments do |t|
13
14
  t.integer :post_id
@@ -2,6 +2,7 @@ Factory.define :comment do |comment|
2
2
  end
3
3
 
4
4
  Factory.define :post do |post|
5
+ post.published false
5
6
  end
6
7
 
7
8
  Factory.define :tag do |tag|
@@ -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
 
@@ -5,6 +5,7 @@ Factory.define :post_tag do |post_tag|
5
5
  end
6
6
 
7
7
  Factory.define :post do |post|
8
+ post.published false
8
9
  end
9
10
 
10
11
  Factory.define :tag do |tag|
@@ -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
 
@@ -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 [[],[]] unless connection.respond_to? :constraints
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
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-02 00:00:00 -05:00
18
+ date: 2010-12-06 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency