foreigner-matcher 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/LICENSE.txt +1 -1
- data/Rakefile +3 -1
- data/lib/foreigner-matcher.rb +5 -1
- data/lib/foreigner-matcher/version.rb +1 -1
- data/spec/test_models/special_user_record_spec.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a34b92119950726090515e7a0f22487189c750a
|
4
|
+
data.tar.gz: 2905df2a90aaca7702e7a298934d818742ad8a70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea9af498c35b1f54ac30fe6a9dae55d7849ce8ce95b368d130142d6fddafc4dc2d804330627106c9958a88e48ab668a3517516c8f581be7e9fbe14050203fbd5
|
7
|
+
data.tar.gz: be95eb3eb8e86baec258c9690b85a401f723bf9425becf42ed6ddf5be944c50de97f6e53e7c44f223392c1b31ce1ae71213a59502297d443f87cf60498a73953
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
foreigner-matcher (0.2.
|
4
|
+
foreigner-matcher (0.2.3)
|
5
5
|
foreigner (>= 1.0.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -39,7 +39,7 @@ GEM
|
|
39
39
|
builder (3.0.4)
|
40
40
|
diff-lcs (1.2.3)
|
41
41
|
erubis (2.7.0)
|
42
|
-
foreigner (1.4.
|
42
|
+
foreigner (1.4.2)
|
43
43
|
activerecord (>= 3.0.0)
|
44
44
|
hike (1.2.2)
|
45
45
|
i18n (0.6.1)
|
@@ -51,7 +51,7 @@ GEM
|
|
51
51
|
metaclass (0.0.1)
|
52
52
|
mocha (0.13.3)
|
53
53
|
metaclass (~> 0.0.1)
|
54
|
-
multi_json (1.7.
|
54
|
+
multi_json (1.7.7)
|
55
55
|
mysql2 (0.3.11)
|
56
56
|
pg (0.15.1)
|
57
57
|
rack (1.4.5)
|
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ namespace :db do
|
|
36
36
|
puts "Connected to #{db_config['database']} via a #{db_config['adapter']} connector"
|
37
37
|
|
38
38
|
puts "\nDropping test tables, if they exist"
|
39
|
-
%w( default_options user_logins
|
39
|
+
%w( default_options user_logins comments searches special_user_records table_without_foreign_keys user_types users ).each do |test_table|
|
40
40
|
print "\tDropping #{test_table}..."
|
41
41
|
conn.execute("drop table if exists #{test_table}")
|
42
42
|
print "done\n"
|
@@ -52,6 +52,7 @@ namespace :db do
|
|
52
52
|
print_table_creation('special_user_records') do
|
53
53
|
conn.create_table(:special_user_records) do |t|
|
54
54
|
t.integer :special_user_id
|
55
|
+
t.integer :special_user_type_id
|
55
56
|
end
|
56
57
|
end
|
57
58
|
[ :default_options, :user_logins, :user_types, :comments, :searches, :table_without_foreign_keys ].each do |user_table|
|
@@ -92,6 +93,7 @@ namespace :db do
|
|
92
93
|
end
|
93
94
|
print_foreign_key_creation('special_user_records') do
|
94
95
|
conn.add_foreign_key(:special_user_records, :users, :column => "special_user_id", :dependent => :delete)
|
96
|
+
conn.add_foreign_key(:special_user_records, :user_types, :column => "special_user_type_id", :name => "special_user_type_fk")
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
data/lib/foreigner-matcher.rb
CHANGED
@@ -28,13 +28,17 @@ module ForeignerMatcher # :nodoc:
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def foreign_key_definition
|
31
|
-
defaults = { :primary_key => "id", :column =>
|
31
|
+
defaults = { :primary_key => "id", :column => foreign_key_definition_column_name }
|
32
32
|
defaults[:name] = "#{@child.class.table_name}_#{defaults[:column]}_fk"
|
33
33
|
defaults[:dependent] = nil if postgresql_db?
|
34
34
|
full_options = defaults.merge(@options)
|
35
35
|
Foreigner::ConnectionAdapters::ForeignKeyDefinition.new(@child.class.table_name, @parent.pluralize, full_options)
|
36
36
|
end
|
37
37
|
|
38
|
+
def foreign_key_definition_column_name
|
39
|
+
@options[:column] || "#{@parent.singularize}_id"
|
40
|
+
end
|
41
|
+
|
38
42
|
def child_foreign_keys
|
39
43
|
@child.class.connection.foreign_keys(@child.class.table_name)
|
40
44
|
end
|
@@ -23,7 +23,9 @@ describe SpecialUserRecord do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'matcher' do
|
26
|
-
it { should have_foreign_key_for(:user, :column => 'special_user_id', :
|
27
|
-
it { should have_foreign_key_for(:users, :column => 'special_user_id', :
|
26
|
+
it { should have_foreign_key_for(:user, :column => 'special_user_id', :dependent => :delete) }
|
27
|
+
it { should have_foreign_key_for(:users, :column => 'special_user_id', :dependent => :delete) }
|
28
|
+
it { should have_foreign_key_for(:user_type, :column => 'special_user_type_id', :name => 'special_user_type_fk') }
|
29
|
+
it { should have_foreign_key_for(:user_types, :column => 'special_user_type_id', :name => 'special_user_type_fk') }
|
28
30
|
end
|
29
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreigner-matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dykes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreigner
|