jorahood-ar-extensions 0.9.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/ChangeLog +145 -0
  2. data/README +167 -0
  3. data/Rakefile +79 -0
  4. data/config/database.yml +7 -0
  5. data/config/database.yml.template +7 -0
  6. data/config/mysql.schema +72 -0
  7. data/config/postgresql.schema +39 -0
  8. data/db/migrate/generic_schema.rb +96 -0
  9. data/db/migrate/mysql_schema.rb +31 -0
  10. data/db/migrate/oracle_schema.rb +5 -0
  11. data/db/migrate/version.rb +4 -0
  12. data/init.rb +31 -0
  13. data/lib/ar-extensions/create_and_update.rb +509 -0
  14. data/lib/ar-extensions/csv.rb +309 -0
  15. data/lib/ar-extensions/delete.rb +143 -0
  16. data/lib/ar-extensions/extensions.rb +506 -0
  17. data/lib/ar-extensions/finder_options.rb +275 -0
  18. data/lib/ar-extensions/finders.rb +94 -0
  19. data/lib/ar-extensions/foreign_keys.rb +70 -0
  20. data/lib/ar-extensions/fulltext.rb +62 -0
  21. data/lib/ar-extensions/import.rb +352 -0
  22. data/lib/ar-extensions/insert_select.rb +178 -0
  23. data/lib/ar-extensions/synchronize.rb +30 -0
  24. data/lib/ar-extensions/temporary_table.rb +124 -0
  25. data/lib/ar-extensions/union.rb +204 -0
  26. data/lib/ar-extensions/version.rb +9 -0
  27. data/tests/connections/native_mysql/connection.rb +16 -0
  28. data/tests/connections/native_oracle/connection.rb +16 -0
  29. data/tests/connections/native_postgresql/connection.rb +19 -0
  30. data/tests/connections/native_sqlite/connection.rb +14 -0
  31. data/tests/connections/native_sqlite3/connection.rb +14 -0
  32. data/tests/fixtures/addresses.yml +25 -0
  33. data/tests/fixtures/books.yml +46 -0
  34. data/tests/fixtures/developers.yml +20 -0
  35. data/tests/fixtures/unit/active_record_base_finders/addresses.yml +25 -0
  36. data/tests/fixtures/unit/active_record_base_finders/books.yml +64 -0
  37. data/tests/fixtures/unit/active_record_base_finders/developers.yml +20 -0
  38. data/tests/fixtures/unit/synchronize/books.yml +16 -0
  39. data/tests/fixtures/unit/to_csv_headers/addresses.yml +8 -0
  40. data/tests/fixtures/unit/to_csv_headers/developers.yml +6 -0
  41. data/tests/fixtures/unit/to_csv_with_common_options/addresses.yml +40 -0
  42. data/tests/fixtures/unit/to_csv_with_common_options/developers.yml +13 -0
  43. data/tests/fixtures/unit/to_csv_with_common_options/languages.yml +29 -0
  44. data/tests/fixtures/unit/to_csv_with_common_options/teams.yml +3 -0
  45. data/tests/fixtures/unit/to_csv_with_default_options/developers.yml +7 -0
  46. data/tests/models/address.rb +4 -0
  47. data/tests/models/animal.rb +2 -0
  48. data/tests/models/book.rb +3 -0
  49. data/tests/models/cart_item.rb +4 -0
  50. data/tests/models/developer.rb +8 -0
  51. data/tests/models/group.rb +3 -0
  52. data/tests/models/language.rb +5 -0
  53. data/tests/models/mysql/book.rb +3 -0
  54. data/tests/models/mysql/test_innodb.rb +3 -0
  55. data/tests/models/mysql/test_memory.rb +3 -0
  56. data/tests/models/mysql/test_myisam.rb +3 -0
  57. data/tests/models/project.rb +2 -0
  58. data/tests/models/shopping_cart.rb +4 -0
  59. data/tests/models/team.rb +4 -0
  60. data/tests/models/topic.rb +13 -0
  61. data/tests/mysql/test_create_and_update.rb +290 -0
  62. data/tests/mysql/test_delete.rb +142 -0
  63. data/tests/mysql/test_finder_options.rb +121 -0
  64. data/tests/mysql/test_finders.rb +29 -0
  65. data/tests/mysql/test_import.rb +354 -0
  66. data/tests/mysql/test_insert_select.rb +173 -0
  67. data/tests/mysql/test_mysql_adapter.rb +45 -0
  68. data/tests/mysql/test_union.rb +81 -0
  69. data/tests/oracle/test_adapter.rb +14 -0
  70. data/tests/postgresql/test_adapter.rb +14 -0
  71. metadata +147 -0
@@ -0,0 +1,25 @@
1
+ first_developers_address:
2
+ id: 1
3
+ developer_id: 1
4
+ address: 1111 SomeWhere Rd.
5
+ city: Someville
6
+ state: MI
7
+ zip: 49548
8
+
9
+ second_developers_address:
10
+ id: 2
11
+ developer_id: 2
12
+ address: 2222 SomeWhere Rd.
13
+ city: Someville
14
+ state: MI
15
+ zip: 49548
16
+
17
+ second_developers_beachhouse_address:
18
+ id: 3
19
+ developer_id: 2
20
+ address: 2223 North Shore Dr.
21
+ city: Charlevoix
22
+ state: MI
23
+ zip: 49720
24
+
25
+
@@ -0,0 +1,46 @@
1
+ first:
2
+ id: 1
3
+ title: "The Voyage of Jerle Shannara: Antrax"
4
+ publisher: Del Rey
5
+ author_name: Terry Brooks
6
+ second:
7
+ id: 2
8
+ title: "The Voyage of Jerle Shannara: Ilse Witch"
9
+ publisher: Del Rey
10
+ author_name: Terry Brooks
11
+ for_sale: false
12
+ third:
13
+ id: 3
14
+ title: "The Voyage of Jerle Shannara: Jarka Ruus"
15
+ publisher: Del Rey
16
+ author_name: Terry Brooks
17
+ fourth:
18
+ id: 4
19
+ title: "The Voyage of Jerle Shannara: Morgwar"
20
+ publisher: Del Rey
21
+ author_name: Terry Brooks
22
+ fifth:
23
+ id: 5
24
+ title: "Circle At Center"
25
+ publisher: "ACE Fantasy"
26
+ author_name: Douglas Niles
27
+ sixth:
28
+ id: 6
29
+ title: WISDOM for the way
30
+ publisher: Hallmark Books
31
+ author_name: Charles R. Swindoll
32
+ seventh:
33
+ id: 7
34
+ title: High Tech Startup
35
+ publisher: Free Press
36
+ author_name: John L. Neshem
37
+ eighth:
38
+ id: 8
39
+ title: The Two Swords
40
+ publisher: Forgotten Realms
41
+ author_name: R.A. Salvatore
42
+ ninth:
43
+ id: 9
44
+ title: Come Thirsty
45
+ publisher: W Publishing Group
46
+ author_name: Max Lucado
@@ -0,0 +1,20 @@
1
+ first_developer:
2
+ id: 1
3
+ name: Zach Dennis
4
+ salary: 1
5
+ created_at:
6
+ updated_at:
7
+
8
+ second_developer:
9
+ id: 2
10
+ name: John Doe
11
+ salary: 2
12
+ created_at:
13
+ updated_at:
14
+
15
+ null_developer:
16
+ id: 3
17
+ name: NULL
18
+ salary: 3
19
+ created_at:
20
+ updated_at:
@@ -0,0 +1,25 @@
1
+ first_developers_address:
2
+ id: 1
3
+ developer_id: 1
4
+ address: 1111 SomeWhere Rd.
5
+ city: Someville
6
+ state: MI
7
+ zip: 49548
8
+
9
+ second_developers_address:
10
+ id: 2
11
+ developer_id: 2
12
+ address: 2222 SomeWhere Rd.
13
+ city: Someville
14
+ state: MI
15
+ zip: 49548
16
+
17
+ second_developers_beachhouse_address:
18
+ id: 3
19
+ developer_id: 2
20
+ address: 2223 North Shore Dr.
21
+ city: Charlevoix
22
+ state: MI
23
+ zip: 49720
24
+
25
+
@@ -0,0 +1,64 @@
1
+ first:
2
+ id: 1
3
+ title: "The Voyage of Jerle Shannara: Antrax"
4
+ publisher: Del Rey
5
+ author_name: Terry Brooks
6
+ created_at: 2007-03-12 21:38:04
7
+ created_on: 2007-03-12 21:38:04
8
+ second:
9
+ id: 2
10
+ title: "The Voyage of Jerle Shannara: Ilse Witch"
11
+ publisher: Del Rey
12
+ author_name: Terry Brooks
13
+ created_at: 2007-01-10 21:20:00
14
+ created_on: 2007-01-10 21:20:00
15
+ for_sale: false
16
+ third:
17
+ id: 3
18
+ title: "The Voyage of Jerle Shannara: Jarka Ruus"
19
+ publisher: Del Rey
20
+ author_name: Terry Brooks
21
+ created_at: 2006-03-12 21:38:04
22
+ created_on: 2006-03-12 21:38:04
23
+ fourth:
24
+ id: 4
25
+ title: "The Voyage of Jerle Shannara: Morgwar"
26
+ publisher: Del Rey
27
+ author_name: Terry Brooks
28
+ created_at: 2005-03-12 21:38:04
29
+ created_on: 2005-03-12 21:38:04
30
+ fifth:
31
+ id: 5
32
+ title: "Circle At Center"
33
+ publisher: "ACE Fantasy"
34
+ author_name: Douglas Niles
35
+ created_at: 2004-03-12 21:38:04
36
+ created_on: 2004-03-12 21:38:04
37
+ sixth:
38
+ id: 6
39
+ title: WISDOM for the way
40
+ publisher: Hallmark Books
41
+ author_name: Charles R. Swindoll
42
+ created_at: 2004-01-12 21:38:04
43
+ created_on: 2004-01-12 21:38:04
44
+ seventh:
45
+ id: 7
46
+ title: High Tech Startup
47
+ publisher: Free Press
48
+ author_name: John L. Neshem
49
+ created_at: 2003-01-12 21:38:04
50
+ created_on: 2003-12-12 21:38:04
51
+ eighth:
52
+ id: 8
53
+ title: The Two Swords
54
+ publisher: Forgotten Realms
55
+ author_name: R.A. Salvatore
56
+ created_at: 2002-01-12 21:38:04
57
+ created_on: 2002-03-12 21:38:04
58
+ ninth:
59
+ id: 9
60
+ title: Come Thirsty
61
+ publisher: W Publishing Group
62
+ author_name: Max Lucado
63
+ created_at: 2001-01-12 21:38:04
64
+ created_on: 2001-01-12 21:38:04
@@ -0,0 +1,20 @@
1
+ first_developer:
2
+ id: 1
3
+ name: Zach Dennis
4
+ salary: 1
5
+ created_at:
6
+ updated_at:
7
+
8
+ second_developer:
9
+ id: 2
10
+ name: John Doe
11
+ salary: 2
12
+ created_at:
13
+ updated_at:
14
+
15
+ null_developer:
16
+ id: 3
17
+ name: NULL
18
+ salary: 3
19
+ created_at:
20
+ updated_at:
@@ -0,0 +1,16 @@
1
+ first:
2
+ id: 1
3
+ title: "Book1"
4
+ publisher: Publisher1
5
+ author_name: Oscar The Grouch
6
+ second:
7
+ id: 2
8
+ title: "Book2"
9
+ publisher: Publisher
10
+ author_name: Big Bird
11
+ third:
12
+ id: 3
13
+ title: "Book3"
14
+ publisher: Publisher
15
+ author_name: Elmo
16
+
@@ -0,0 +1,8 @@
1
+ first_developers_address:
2
+ id: 1
3
+ developer_id: 1
4
+ address: 1111 SomeWhere Rd.
5
+ city: Someville
6
+ state: MI
7
+ zip: 49548
8
+
@@ -0,0 +1,6 @@
1
+ first_developer:
2
+ id: 1
3
+ name: Zach Dennis
4
+ salary: 1
5
+ created_at:
6
+ updated_at:
@@ -0,0 +1,40 @@
1
+ first_developers_address:
2
+ id: 1
3
+ developer_id: 1
4
+ address: 1111 SomeWhere Rd.
5
+ city: Someville
6
+ state: MI
7
+ zip: 49548
8
+
9
+ first_developer_second_address:
10
+ id: 2
11
+ developer_id: 1
12
+ address: 2222 SomeWhere Rd.
13
+ city: Someville
14
+ state: MI
15
+ zip: 49548
16
+
17
+ second_developers_address:
18
+ id: 3
19
+ developer_id: 2
20
+ address: 1111 SomeWhere Rd.
21
+ city: Someville
22
+ state: MI
23
+ zip: 49548
24
+
25
+ second_developer_second_address:
26
+ id: 4
27
+ developer_id: 2
28
+ address: 2222 SomeWhere Rd.
29
+ city: Someville
30
+ state: MI
31
+ zip: 49548
32
+
33
+ second_developer_third_address:
34
+ id: 5
35
+ developer_id: 2
36
+ address: 3333 SomeWhere Rd.
37
+ city: Someville
38
+ state: MI
39
+ zip: 49548
40
+
@@ -0,0 +1,13 @@
1
+ first_developer:
2
+ id: 1
3
+ name: Zach Dennis
4
+ salary: 1
5
+ team_id: 1
6
+ created_at:
7
+ updated_at:
8
+ second_developer:
9
+ id: 2
10
+ name: Mark Van Holstyn
11
+ salary: 10
12
+ created_at:
13
+ updated_at:
@@ -0,0 +1,29 @@
1
+ ruby:
2
+ id: 1
3
+ name: Ruby
4
+ developer_id: 1
5
+
6
+ perl:
7
+ id: 2
8
+ name: Perl
9
+ developer_id: 1
10
+
11
+ java:
12
+ id: 3
13
+ name: Java
14
+ developer_id: 2
15
+
16
+ php:
17
+ id: 4
18
+ name: PHP
19
+ developer_id: 2
20
+
21
+ xml:
22
+ id: 5
23
+ name: XML
24
+ developer_id: 2
25
+
26
+ python:
27
+ id: 6
28
+ name: Python
29
+ developer_id: 2
@@ -0,0 +1,3 @@
1
+ Team:
2
+ id: 1
3
+ name: TeamOne
@@ -0,0 +1,7 @@
1
+ first_developer:
2
+ id: 1
3
+ name: Zach Dennis
4
+ salary: 1
5
+ team_id: 1
6
+ created_at:
7
+ updated_at:
@@ -0,0 +1,4 @@
1
+ class Address < ActiveRecord::Base
2
+ include ActiveRecord::Extensions::FindToCSV
3
+ belongs_to :developer
4
+ end
@@ -0,0 +1,2 @@
1
+ class Animal < ActiveRecord::Base
2
+ end
@@ -0,0 +1,3 @@
1
+ class Book < ActiveRecord::Base
2
+ belongs_to :topic
3
+ end
@@ -0,0 +1,4 @@
1
+ class CartItem < ActiveRecord::Base
2
+ belongs_to :book
3
+ belongs_to :shopping_cart
4
+ end
@@ -0,0 +1,8 @@
1
+ class Developer < ActiveRecord::Base
2
+ include ActiveRecord::Extensions::FindToCSV
3
+
4
+ has_many :addresses
5
+ has_many :languages
6
+ belongs_to :team
7
+ end
8
+
@@ -0,0 +1,3 @@
1
+ class Group < ActiveRecord::Base
2
+ self.table_name = 'group'
3
+ end
@@ -0,0 +1,5 @@
1
+ class Language < ActiveRecord::Base
2
+ include ActiveRecord::Extensions::FindToCSV
3
+
4
+ belongs_to :developer
5
+ end
@@ -0,0 +1,3 @@
1
+ class Book < ActiveRecord::Base
2
+ fulltext :title, :fields=>%W( title publisher author_name )
3
+ end
@@ -0,0 +1,3 @@
1
+ class TestInnoDb < ActiveRecord::Base
2
+ set_table_name 'test_innodb'
3
+ end
@@ -0,0 +1,3 @@
1
+ class TestMemory < ActiveRecord::Base
2
+ set_table_name 'test_memory'
3
+ end
@@ -0,0 +1,3 @@
1
+ class TestMyISAM < ActiveRecord::Base
2
+ set_table_name 'test_myisam'
3
+ end
@@ -0,0 +1,2 @@
1
+ class Project < ActiveRecord::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ShoppingCart < ActiveRecord::Base
2
+ has_many :cart_items
3
+ has_many :books, :through => :cart_items
4
+ end
@@ -0,0 +1,4 @@
1
+ class Team < ActiveRecord::Base
2
+ include ActiveRecord::Extensions::FindToCSV
3
+ has_many :developers
4
+ end
@@ -0,0 +1,13 @@
1
+ class Topic < ActiveRecord::Base
2
+ validates_presence_of :author_name
3
+ has_many :books
4
+
5
+ composed_of :description, :mapping => [ %w(title title), %w(author_name author_name)], :allow_nil => true, :class_name => "TopicDescription"
6
+ end
7
+
8
+ class TopicDescription
9
+ attr_reader :title, :author_name
10
+ def initialize(title, author_name)
11
+ @title, @author_name = title, author_name
12
+ end
13
+ end