foreigner-matcher 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 040a77aa46e11c55687026338766c6172f5124d3
4
- data.tar.gz: 1c4e54f5a6109bb11b15d10c62616db3452b5d34
3
+ metadata.gz: 6a34b92119950726090515e7a0f22487189c750a
4
+ data.tar.gz: 2905df2a90aaca7702e7a298934d818742ad8a70
5
5
  SHA512:
6
- metadata.gz: a9076d22605fbc18bd71cab26665b3d71e21e452938f6d460957b8be5ea1476781a43fa0ba0112e52ed4d9dd33eca5b29c1e3148602d503d5c950f7b36d8a555
7
- data.tar.gz: 47d8ff0f6a0c7de9de8cc43f500c236ca96a4a7e7c27d24dc68d041d1ec3c26cd22771de3de65a2c66ffdbf5f30e1e2e8db9c8cd3c6a2c4cd8b5a266ebee4f2f
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.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.1)
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.2)
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2012 Cameron Dykes
1
+ Copyright (c) 2011-2013 Cameron Dykes
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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 user_types comments searches special_user_records table_without_foreign_keys users ).each do |test_table|
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
@@ -28,13 +28,17 @@ module ForeignerMatcher # :nodoc:
28
28
  private
29
29
 
30
30
  def foreign_key_definition
31
- defaults = { :primary_key => "id", :column => "#{@parent.singularize}_id" }
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
@@ -1,5 +1,5 @@
1
1
  module Foreigner
2
2
  module Matcher
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  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', :name => 'special_user_records_special_user_id_fk', :dependent => :delete) }
27
- it { should have_foreign_key_for(:users, :column => 'special_user_id', :name => 'special_user_records_special_user_id_fk', :dependent => :delete) }
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.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-05-04 00:00:00.000000000 Z
11
+ date: 2013-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreigner