foreign_keys 2.0.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,6 +59,8 @@ Authors
59
59
  **Tanel Suurhans** - tanel.suurhans_at_perfectline.ee
60
60
  **Tarmo Lehtpuu** - tarmo.lehtpuu_at_perfectline.ee
61
61
 
62
+ This gem is based ideas and enhanchements from Dan Walters "foreign_keys" plugin-
63
+
62
64
  License
63
65
  --------------
64
66
  Copyright 2009 by PerfectLine LLC (<http://www.perfectline.co.uk>) and is released under the MIT license.
@@ -1,6 +1,11 @@
1
+ require 'active_record'
2
+ require 'active_record/connection_adapters/abstract_adapter'
3
+ require 'active_record/connection_adapters/mysql_adapter' if defined? Mysql
4
+ require 'active_record/connection_adapters/postgresql_adapter' if defined? PG
5
+
1
6
  require "foreign_keys/connection_adapters/abstract"
2
- require "foreign_keys/connection_adapters/mysql"
3
- require "foreign_keys/connection_adapters/postgresql"
7
+ require "foreign_keys/connection_adapters/mysql" if defined? Mysql
8
+ require "foreign_keys/connection_adapters/postgresql" if defined? PG
4
9
 
5
10
  require "foreign_keys/schema_dumper"
6
11
 
@@ -15,4 +20,4 @@ if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
15
20
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.__send__(:include, Perfectline::ConnectionAdapters::PostgreSQLAdapter)
16
21
  end
17
22
 
18
- ActiveRecord::SchemaDumper.__send__(:include, Perfectline::SchemaDumper)
23
+ ActiveRecord::SchemaDumper.__send__(:include, Perfectline::SchemaDumper)
@@ -19,11 +19,11 @@ module Perfectline
19
19
  def foreign_keys(table_name)
20
20
  sql = execute("SHOW CREATE TABLE #{quote_table_name(table_name)}").fetch_hash["Create Table"]
21
21
 
22
- returning([]) do |fks|
22
+ [].tap do |fks|
23
23
  sql.scan(/CONSTRAINT `(\w+)` FOREIGN KEY \((.*?)\) REFERENCES `(\w+)` \((.*?)\)(?:\s+ON DELETE\s+(.*?))?(?:\s+ON UPDATE\s+(.*?))?[,\)\n]/) do |name, cols, refs, keys, delete, update|
24
24
 
25
- cols = returning([]){ |array| cols.scan(/`(\w+)`/) { |match| array << match.first.to_sym }}
26
- keys = returning([]){ |array| keys.scan(/`(\w+)`/) { |match| array << match.first.to_sym }}
25
+ cols = [].tap { |array| cols.scan(/`(\w+)`/) { |match| array << match.first.to_sym }}
26
+ keys = [].tap { |array| keys.scan(/`(\w+)`/) { |match| array << match.first.to_sym }}
27
27
 
28
28
  fks.push({
29
29
  :name => name,
@@ -37,7 +37,7 @@ module Perfectline
37
37
  t.table_name = '#{table_name}'
38
38
  }
39
39
 
40
- foreign_keys = returning({}) do |foreign_keys|
40
+ foreign_keys = {}.tap do |foreign_keys|
41
41
  select_all(sql).each do |row|
42
42
  if foreign_keys.has_key?(row["name"])
43
43
  foreign_keys[row["name"]][:columns] << row["from_column"]
@@ -72,4 +72,4 @@ module Perfectline
72
72
  end
73
73
  end
74
74
  end
75
- end
75
+ end
metadata CHANGED
@@ -1,30 +1,26 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: foreign_keys
3
- version: !ruby/object:Gem::Version
4
- version: 2.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.3
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Tanel Suurhans
8
9
  - Tarmo Lehtpuu
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
-
13
- date: 2009-11-23 00:00:00 +02:00
14
- default_executable:
13
+ date: 2012-07-12 00:00:00.000000000 Z
15
14
  dependencies: []
16
-
17
15
  description: Foreign key support plugin for Rails, with schema dumper integration
18
- email:
16
+ email:
19
17
  - tanel.suurhans@perfectline.ee
20
18
  - tarmo.lehtpuu@perfectline.ee
21
19
  executables: []
22
-
23
20
  extensions: []
24
-
25
- extra_rdoc_files:
21
+ extra_rdoc_files:
26
22
  - README.markdown
27
- files:
23
+ files:
28
24
  - README.markdown
29
25
  - init.rb
30
26
  - lib/foreign_keys.rb
@@ -32,33 +28,28 @@ files:
32
28
  - lib/foreign_keys/connection_adapters/mysql.rb
33
29
  - lib/foreign_keys/connection_adapters/postgresql.rb
34
30
  - lib/foreign_keys/schema_dumper.rb
35
- has_rdoc: true
36
31
  homepage: http://github.com/perfectline/foreign_keys/tree/master
37
32
  licenses: []
38
-
39
33
  post_install_message:
40
- rdoc_options:
41
- - --charset=UTF-8
42
- require_paths:
34
+ rdoc_options: []
35
+ require_paths:
43
36
  - lib
44
- required_ruby_version: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: "0"
49
- version:
50
- required_rubygems_version: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: "0"
55
- version:
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
56
49
  requirements: []
57
-
58
50
  rubyforge_project:
59
- rubygems_version: 1.3.5
51
+ rubygems_version: 1.8.24
60
52
  signing_key:
61
53
  specification_version: 3
62
54
  summary: Foreign key support for Rails
63
55
  test_files: []
64
-