legacy_data 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -23,8 +23,9 @@ class ModelsFromTablesGenerator < Rails::Generator::Base
23
23
  :assigns => analyzed_table.to_hash
24
24
  end
25
25
  end
26
- # rescue => e
27
- # puts e.backtrace
26
+ rescue => e
27
+ # for debugging...
28
+ puts e.backtrace
28
29
  end
29
30
 
30
31
  protected
data/legacy_data.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{legacy_data}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alex Rothenberg"]
12
- s.date = %q{2009-10-08}
12
+ s.date = %q{2009-10-12}
13
13
  s.description = %q{Create ActiveRecord models from an existing database}
14
14
  s.email = %q{alex@alexrothenberg.com}
15
15
  s.extra_rdoc_files = [
@@ -83,10 +83,11 @@ module LegacyData
83
83
 
84
84
  def primary_key
85
85
  if connection.respond_to?(:pk_and_sequence_for)
86
- pk = connection.pk_and_sequence_for(table_name).first
86
+ pk, seq = connection.pk_and_sequence_for(table_name)
87
87
  elsif connection.respond_to?(:primary_key)
88
88
  pk = connection.primary_key(table_name)
89
89
  end
90
+ pk
90
91
  end
91
92
 
92
93
  def relations
data/lib/legacy_data.rb CHANGED
@@ -1,4 +1,12 @@
1
1
  require 'legacy_data/table_definition'
2
2
  require 'legacy_data/schema'
3
3
  require 'legacy_data/table_class_name_mapper'
4
- require 'active_record/connection_adapters/oracle_enhanced_adapter'
4
+
5
+
6
+ module ActiveRecord
7
+ Base.class_eval do
8
+ if ['OracleEnhanced'].include? connection.adapter_name
9
+ require "#{File.dirname(__FILE__)}/active_record/connection_adapters/#{connection.adapter_name.underscore}_adapter"
10
+ end
11
+ end
12
+ end
@@ -1,13 +1,3 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- ActiveRecord::Base.establish_connection({:adapter=>'sqlite3', :database=> ":memory:"})
4
-
5
- ActiveRecord::Base.connection.create_table :posts do |t|
6
- t.string :title
7
- t.text :body
8
- end
9
- ActiveRecord::Base.connection.create_table :comments do |t|
10
- t.integer :post_id
11
- t.text :body
12
- end
13
3
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,19 @@
1
1
  require 'rubygems'
2
2
  require 'activerecord'
3
- require 'active_record/connection_adapters/oracle_enhanced_adapter'
3
+ # require 'active_record/connection_adapters/oracle_enhanced_adapter'
4
+
5
+ ## TODO parameterize this ....
6
+ ActiveRecord::Base.establish_connection({:adapter=>'sqlite3', :database=> ":memory:"})
7
+
8
+ ActiveRecord::Base.connection.create_table :posts do |t|
9
+ t.string :title
10
+ t.text :body
11
+ end
12
+ ActiveRecord::Base.connection.create_table :comments do |t|
13
+ t.integer :post_id
14
+ t.text :body
15
+ end
16
+
4
17
 
5
18
  # $LOAD_PATH.unshift(File.dirname(__FILE__))
6
19
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legacy_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rothenberg
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-08 00:00:00 -04:00
12
+ date: 2009-10-12 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency