has_many_polymorphs 2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/CHANGELOG +86 -0
  2. data/LICENSE +184 -0
  3. data/Manifest +173 -0
  4. data/README +205 -0
  5. data/Rakefile +28 -0
  6. data/TODO +2 -0
  7. data/examples/hmph.rb +69 -0
  8. data/generators/tagging/tagging_generator.rb +97 -0
  9. data/generators/tagging/templates/migration.rb +28 -0
  10. data/generators/tagging/templates/tag.rb +39 -0
  11. data/generators/tagging/templates/tag_test.rb +15 -0
  12. data/generators/tagging/templates/tagging.rb +16 -0
  13. data/generators/tagging/templates/tagging_extensions.rb +203 -0
  14. data/generators/tagging/templates/tagging_test.rb +85 -0
  15. data/generators/tagging/templates/taggings.yml +23 -0
  16. data/generators/tagging/templates/tags.yml +7 -0
  17. data/has_many_polymorphs.gemspec +36 -0
  18. data/init.rb +2 -0
  19. data/lib/has_many_polymorphs/association.rb +160 -0
  20. data/lib/has_many_polymorphs/autoload.rb +69 -0
  21. data/lib/has_many_polymorphs/base.rb +60 -0
  22. data/lib/has_many_polymorphs/class_methods.rb +600 -0
  23. data/lib/has_many_polymorphs/configuration.rb +19 -0
  24. data/lib/has_many_polymorphs/debugging_tools.rb +103 -0
  25. data/lib/has_many_polymorphs/rake_task_redefine_task.rb +35 -0
  26. data/lib/has_many_polymorphs/reflection.rb +58 -0
  27. data/lib/has_many_polymorphs/support_methods.rb +88 -0
  28. data/lib/has_many_polymorphs.rb +27 -0
  29. data/test/fixtures/bow_wows.yml +10 -0
  30. data/test/fixtures/cats.yml +18 -0
  31. data/test/fixtures/eaters_foodstuffs.yml +0 -0
  32. data/test/fixtures/fish.yml +12 -0
  33. data/test/fixtures/frogs.yml +5 -0
  34. data/test/fixtures/keep_your_enemies_close.yml +0 -0
  35. data/test/fixtures/little_whale_pupils.yml +0 -0
  36. data/test/fixtures/people.yml +7 -0
  37. data/test/fixtures/petfoods.yml +11 -0
  38. data/test/fixtures/whales.yml +5 -0
  39. data/test/fixtures/wild_boars.yml +10 -0
  40. data/test/generator/tagging_generator_test.rb +42 -0
  41. data/test/integration/app/README +182 -0
  42. data/test/integration/app/Rakefile +19 -0
  43. data/test/integration/app/app/controllers/application.rb +7 -0
  44. data/test/integration/app/app/controllers/bones_controller.rb +5 -0
  45. data/test/integration/app/app/helpers/addresses_helper.rb +2 -0
  46. data/test/integration/app/app/helpers/application_helper.rb +3 -0
  47. data/test/integration/app/app/helpers/bones_helper.rb +2 -0
  48. data/test/integration/app/app/helpers/sellers_helper.rb +28 -0
  49. data/test/integration/app/app/helpers/states_helper.rb +2 -0
  50. data/test/integration/app/app/helpers/users_helper.rb +2 -0
  51. data/test/integration/app/app/models/bone.rb +2 -0
  52. data/test/integration/app/app/models/double_sti_parent.rb +2 -0
  53. data/test/integration/app/app/models/double_sti_parent_relationship.rb +2 -0
  54. data/test/integration/app/app/models/organic_substance.rb +2 -0
  55. data/test/integration/app/app/models/single_sti_parent.rb +4 -0
  56. data/test/integration/app/app/models/single_sti_parent_relationship.rb +4 -0
  57. data/test/integration/app/app/models/stick.rb +2 -0
  58. data/test/integration/app/app/models/stone.rb +2 -0
  59. data/test/integration/app/app/views/addresses/edit.html.erb +12 -0
  60. data/test/integration/app/app/views/addresses/index.html.erb +18 -0
  61. data/test/integration/app/app/views/addresses/new.html.erb +11 -0
  62. data/test/integration/app/app/views/addresses/show.html.erb +3 -0
  63. data/test/integration/app/app/views/bones/index.rhtml +5 -0
  64. data/test/integration/app/app/views/layouts/addresses.html.erb +17 -0
  65. data/test/integration/app/app/views/layouts/sellers.html.erb +17 -0
  66. data/test/integration/app/app/views/layouts/states.html.erb +17 -0
  67. data/test/integration/app/app/views/layouts/users.html.erb +17 -0
  68. data/test/integration/app/app/views/sellers/edit.html.erb +12 -0
  69. data/test/integration/app/app/views/sellers/index.html.erb +20 -0
  70. data/test/integration/app/app/views/sellers/new.html.erb +11 -0
  71. data/test/integration/app/app/views/sellers/show.html.erb +3 -0
  72. data/test/integration/app/app/views/states/edit.html.erb +12 -0
  73. data/test/integration/app/app/views/states/index.html.erb +19 -0
  74. data/test/integration/app/app/views/states/new.html.erb +11 -0
  75. data/test/integration/app/app/views/states/show.html.erb +3 -0
  76. data/test/integration/app/app/views/users/edit.html.erb +12 -0
  77. data/test/integration/app/app/views/users/index.html.erb +22 -0
  78. data/test/integration/app/app/views/users/new.html.erb +11 -0
  79. data/test/integration/app/app/views/users/show.html.erb +3 -0
  80. data/test/integration/app/config/boot.rb +110 -0
  81. data/test/integration/app/config/database.yml +17 -0
  82. data/test/integration/app/config/environment.rb +19 -0
  83. data/test/integration/app/config/environment.rb.canonical +19 -0
  84. data/test/integration/app/config/environments/development.rb +9 -0
  85. data/test/integration/app/config/environments/production.rb +18 -0
  86. data/test/integration/app/config/environments/test.rb +19 -0
  87. data/test/integration/app/config/locomotive.yml +6 -0
  88. data/test/integration/app/config/routes.rb +33 -0
  89. data/test/integration/app/config/ultrasphinx/default.base +56 -0
  90. data/test/integration/app/config/ultrasphinx/development.conf.canonical +155 -0
  91. data/test/integration/app/db/migrate/001_create_sticks.rb +11 -0
  92. data/test/integration/app/db/migrate/002_create_stones.rb +11 -0
  93. data/test/integration/app/db/migrate/003_create_organic_substances.rb +11 -0
  94. data/test/integration/app/db/migrate/004_create_bones.rb +8 -0
  95. data/test/integration/app/db/migrate/005_create_single_sti_parents.rb +11 -0
  96. data/test/integration/app/db/migrate/006_create_double_sti_parents.rb +11 -0
  97. data/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb +13 -0
  98. data/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb +14 -0
  99. data/test/integration/app/db/migrate/009_create_library_model.rb +11 -0
  100. data/test/integration/app/doc/README_FOR_APP +2 -0
  101. data/test/integration/app/generators/commenting_generator_test.rb +83 -0
  102. data/test/integration/app/lib/library_model.rb +2 -0
  103. data/test/integration/app/public/404.html +30 -0
  104. data/test/integration/app/public/500.html +30 -0
  105. data/test/integration/app/public/dispatch.cgi +10 -0
  106. data/test/integration/app/public/dispatch.fcgi +24 -0
  107. data/test/integration/app/public/dispatch.rb +10 -0
  108. data/test/integration/app/public/favicon.ico +0 -0
  109. data/test/integration/app/public/images/rails.png +0 -0
  110. data/test/integration/app/public/index.html +277 -0
  111. data/test/integration/app/public/javascripts/application.js +2 -0
  112. data/test/integration/app/public/javascripts/controls.js +833 -0
  113. data/test/integration/app/public/javascripts/dragdrop.js +942 -0
  114. data/test/integration/app/public/javascripts/effects.js +1088 -0
  115. data/test/integration/app/public/javascripts/prototype.js +2515 -0
  116. data/test/integration/app/public/robots.txt +1 -0
  117. data/test/integration/app/public/stylesheets/scaffold.css +74 -0
  118. data/test/integration/app/script/about +3 -0
  119. data/test/integration/app/script/breakpointer +3 -0
  120. data/test/integration/app/script/console +3 -0
  121. data/test/integration/app/script/destroy +3 -0
  122. data/test/integration/app/script/generate +3 -0
  123. data/test/integration/app/script/performance/benchmarker +3 -0
  124. data/test/integration/app/script/performance/profiler +3 -0
  125. data/test/integration/app/script/plugin +3 -0
  126. data/test/integration/app/script/process/inspector +3 -0
  127. data/test/integration/app/script/process/reaper +3 -0
  128. data/test/integration/app/script/process/spawner +3 -0
  129. data/test/integration/app/script/runner +3 -0
  130. data/test/integration/app/script/server +3 -0
  131. data/test/integration/app/test/fixtures/double_sti_parent_relationships.yml +7 -0
  132. data/test/integration/app/test/fixtures/double_sti_parents.yml +7 -0
  133. data/test/integration/app/test/fixtures/organic_substances.yml +5 -0
  134. data/test/integration/app/test/fixtures/single_sti_parent_relationships.yml +7 -0
  135. data/test/integration/app/test/fixtures/single_sti_parents.yml +7 -0
  136. data/test/integration/app/test/fixtures/sticks.yml +7 -0
  137. data/test/integration/app/test/fixtures/stones.yml +7 -0
  138. data/test/integration/app/test/functional/addresses_controller_test.rb +57 -0
  139. data/test/integration/app/test/functional/bones_controller_test.rb +8 -0
  140. data/test/integration/app/test/functional/sellers_controller_test.rb +57 -0
  141. data/test/integration/app/test/functional/states_controller_test.rb +57 -0
  142. data/test/integration/app/test/functional/users_controller_test.rb +57 -0
  143. data/test/integration/app/test/test_helper.rb +8 -0
  144. data/test/integration/app/test/unit/bone_test.rb +8 -0
  145. data/test/integration/app/test/unit/double_sti_parent_relationship_test.rb +8 -0
  146. data/test/integration/app/test/unit/double_sti_parent_test.rb +8 -0
  147. data/test/integration/app/test/unit/organic_substance_test.rb +8 -0
  148. data/test/integration/app/test/unit/single_sti_parent_relationship_test.rb +8 -0
  149. data/test/integration/app/test/unit/single_sti_parent_test.rb +8 -0
  150. data/test/integration/app/test/unit/stick_test.rb +8 -0
  151. data/test/integration/app/test/unit/stone_test.rb +8 -0
  152. data/test/integration/server_test.rb +43 -0
  153. data/test/models/aquatic/fish.rb +5 -0
  154. data/test/models/aquatic/pupils_whale.rb +7 -0
  155. data/test/models/aquatic/whale.rb +15 -0
  156. data/test/models/beautiful_fight_relationship.rb +26 -0
  157. data/test/models/canine.rb +9 -0
  158. data/test/models/cat.rb +5 -0
  159. data/test/models/dog.rb +18 -0
  160. data/test/models/eaters_foodstuff.rb +8 -0
  161. data/test/models/frog.rb +4 -0
  162. data/test/models/kitten.rb +3 -0
  163. data/test/models/parentship.rb +4 -0
  164. data/test/models/person.rb +9 -0
  165. data/test/models/petfood.rb +39 -0
  166. data/test/models/tabby.rb +2 -0
  167. data/test/models/wild_boar.rb +3 -0
  168. data/test/modules/extension_module.rb +9 -0
  169. data/test/modules/other_extension_module.rb +9 -0
  170. data/test/patches/symlinked_plugins_1.2.6.diff +46 -0
  171. data/test/schema.rb +87 -0
  172. data/test/setup.rb +14 -0
  173. data/test/test_helper.rb +52 -0
  174. data/test/unit/has_many_polymorphs_test.rb +713 -0
  175. data.tar.gz.sig +1 -0
  176. metadata +279 -0
  177. metadata.gz.sig +0 -0
@@ -0,0 +1,56 @@
1
+ #
2
+ # Sphinx/Ultrasphinx user-configurable options.
3
+ #
4
+ # Copy this file to RAILS_ROOT/config/ultrasphinx.
5
+ # You can use individual namespaces if you want (e.g. "development.base").
6
+ #
7
+
8
+ indexer
9
+ {
10
+ # Indexer running options
11
+ mem_limit = 256M
12
+ }
13
+
14
+ searchd
15
+ {
16
+ # Daemon options
17
+ # What interface the search daemon should listen on and where to store its logs
18
+ address = 0.0.0.0
19
+ port = 3313
20
+ log = /tmp/sphinx/searchd.log
21
+ query_log = /tmp/sphinx/query.log
22
+ read_timeout = 5
23
+ max_children = 300
24
+ pid_file = /tmp/sphinx/searchd.pid
25
+ max_matches = 100000
26
+ }
27
+
28
+ client
29
+ {
30
+ # Client options
31
+ dictionary_name = ts
32
+ # How your application connects to the search daemon (not necessarily the same as above)
33
+ server_host = localhost
34
+ server_port = 3313
35
+ }
36
+
37
+ source
38
+ {
39
+ # Individual SQL source options
40
+ sql_range_step = 20000
41
+ strip_html = 0
42
+ index_html_attrs =
43
+ sql_query_post =
44
+ }
45
+
46
+ index
47
+ {
48
+ # Index building options
49
+ path = /tmp/sphinx/
50
+ docinfo = extern # just leave this alone
51
+ morphology = stem_en
52
+ stopwords = # /path/to/stopwords.txt
53
+ min_word_len = 1
54
+ charset_type = utf-8 # or sbcs (Single Byte Character Set)
55
+ charset_table = 0..9, A..Z->a..z, -, _, ., &, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F,U+C5->U+E5, U+E5, U+C4->U+E4, U+E4, U+D6->U+F6, U+F6, U+16B, U+0c1->a, U+0c4->a, U+0c9->e, U+0cd->i, U+0d3->o, U+0d4->o, U+0da->u, U+0dd->y, U+0e1->a, U+0e4->a, U+0e9->e, U+0ed->i, U+0f3->o, U+0f4->o, U+0fa->u, U+0fd->y, U+104->U+105, U+105, U+106->U+107, U+10c->c, U+10d->c, U+10e->d, U+10f->d, U+116->U+117, U+117, U+118->U+119, U+11a->e, U+11b->e, U+12E->U+12F, U+12F, U+139->l, U+13a->l, U+13d->l, U+13e->l, U+141->U+142, U+142, U+143->U+144, U+144,U+147->n, U+148->n, U+154->r, U+155->r, U+158->r, U+159->r, U+15A->U+15B, U+15B, U+160->s, U+160->U+161, U+161->s, U+164->t, U+165->t, U+16A->U+16B, U+16B, U+16e->u, U+16f->u, U+172->U+173, U+173, U+179->U+17A, U+17A, U+17B->U+17C, U+17C, U+17d->z, U+17e->z,
56
+ }
@@ -0,0 +1,155 @@
1
+
2
+ # Auto-generated at Wed Oct 03 03:57:12 -0400 2007.
3
+ # Hand modifications will be overwritten.
4
+ # /Users/eweaver/Desktop/projects/chow/vendor/plugins/ultrasphinx/test/integration/app/config/ultrasphinx/default.base
5
+ indexer {
6
+ mem_limit = 256M
7
+ }
8
+ searchd {
9
+ read_timeout = 5
10
+ max_children = 300
11
+ log = /tmp/sphinx/searchd.log
12
+ port = 3313
13
+ max_matches = 100000
14
+ query_log = /tmp/sphinx/query.log
15
+ pid_file = /tmp/sphinx/searchd.pid
16
+ address = 0.0.0.0
17
+ }
18
+
19
+ # Source configuration
20
+
21
+ source geo__states
22
+ {
23
+ strip_html = 0
24
+ sql_range_step = 20000
25
+ index_html_attrs =
26
+ sql_query_post =
27
+
28
+ type = mysql
29
+ sql_query_pre = SET SESSION group_concat_max_len = 65535
30
+ sql_query_pre = SET NAMES utf8
31
+
32
+ sql_db = app_development
33
+ sql_host = localhost
34
+ sql_pass =
35
+ sql_user = root
36
+ sql_query_range = SELECT MIN(id), MAX(id) FROM states
37
+ sql_query = SELECT (states.id * 4 + 0) AS id, CAST(GROUP_CONCAT(addresses.name SEPARATOR ' ') AS CHAR) AS address_name, 0 AS capitalization, 'Geo::State' AS class, 0 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, '' AS content, UNIX_TIMESTAMP('1970-01-01 00:00:00') AS created_at, 0 AS deleted, '' AS email, '__empty_searchable__' AS empty_searchable, '' AS login, '' AS name, '' AS state, 0 AS user_id FROM states LEFT OUTER JOIN addresses ON states.id = addresses.state_id WHERE states.id >= $start AND states.id <= $end GROUP BY id
38
+
39
+ sql_group_column = capitalization
40
+ sql_group_column = class_id
41
+ sql_group_column = company_name_facet
42
+ sql_date_column = created_at
43
+ sql_group_column = deleted
44
+ sql_group_column = user_id
45
+ sql_query_info = SELECT * FROM states WHERE states.id = (($id - 0) / 4)
46
+ }
47
+
48
+
49
+ # Source configuration
50
+
51
+ source sellers
52
+ {
53
+ strip_html = 0
54
+ sql_range_step = 20000
55
+ index_html_attrs =
56
+ sql_query_post =
57
+
58
+ type = mysql
59
+ sql_query_pre = SET SESSION group_concat_max_len = 65535
60
+ sql_query_pre = SET NAMES utf8
61
+
62
+ sql_db = app_development
63
+ sql_host = localhost
64
+ sql_pass =
65
+ sql_user = root
66
+ sql_query_range = SELECT MIN(id), MAX(id) FROM sellers
67
+ sql_query = SELECT (sellers.id * 4 + 1) AS id, '' AS address_name, sellers.capitalization AS capitalization, 'Seller' AS class, 1 AS class_id, '' AS company, sellers.company_name AS company_name, CRC32(sellers.company_name) AS company_name_facet, '' AS content, UNIX_TIMESTAMP(sellers.created_at) AS created_at, 0 AS deleted, '' AS email, '__empty_searchable__' AS empty_searchable, '' AS login, '' AS name, '' AS state, sellers.user_id AS user_id FROM sellers WHERE sellers.id >= $start AND sellers.id <= $end GROUP BY id
68
+
69
+ sql_group_column = capitalization
70
+ sql_group_column = class_id
71
+ sql_group_column = company_name_facet
72
+ sql_date_column = created_at
73
+ sql_group_column = deleted
74
+ sql_group_column = user_id
75
+ sql_query_info = SELECT * FROM sellers WHERE sellers.id = (($id - 1) / 4)
76
+ }
77
+
78
+
79
+ # Source configuration
80
+
81
+ source geo__addresses
82
+ {
83
+ strip_html = 0
84
+ sql_range_step = 20000
85
+ index_html_attrs =
86
+ sql_query_post =
87
+
88
+ type = mysql
89
+ sql_query_pre = SET SESSION group_concat_max_len = 65535
90
+ sql_query_pre = SET NAMES utf8
91
+
92
+ sql_db = app_development
93
+ sql_host = localhost
94
+ sql_pass =
95
+ sql_user = root
96
+ sql_query_range = SELECT MIN(id), MAX(id) FROM addresses
97
+ sql_query = SELECT (addresses.id * 4 + 2) AS id, '' AS address_name, 0 AS capitalization, 'Geo::Address' AS class, 2 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, CONCAT_WS(' ', addresses.line_1, addresses.line_2, addresses.city, addresses.province_region, addresses.zip_postal_code) AS content, UNIX_TIMESTAMP('1970-01-01 00:00:00') AS created_at, 0 AS deleted, '' AS email, '__empty_searchable__' AS empty_searchable, '' AS login, addresses.name AS name, states.name AS state, 0 AS user_id FROM addresses LEFT OUTER JOIN states ON states.id = addresses.state_id WHERE addresses.id >= $start AND addresses.id <= $end GROUP BY id
98
+
99
+ sql_group_column = capitalization
100
+ sql_group_column = class_id
101
+ sql_group_column = company_name_facet
102
+ sql_date_column = created_at
103
+ sql_group_column = deleted
104
+ sql_group_column = user_id
105
+ sql_query_info = SELECT * FROM addresses WHERE addresses.id = (($id - 2) / 4)
106
+ }
107
+
108
+
109
+ # Source configuration
110
+
111
+ source users
112
+ {
113
+ strip_html = 0
114
+ sql_range_step = 20000
115
+ index_html_attrs =
116
+ sql_query_post =
117
+
118
+ type = mysql
119
+ sql_query_pre = SET SESSION group_concat_max_len = 65535
120
+ sql_query_pre = SET NAMES utf8
121
+
122
+ sql_db = app_development
123
+ sql_host = localhost
124
+ sql_pass =
125
+ sql_user = root
126
+ sql_query_range = SELECT MIN(id), MAX(id) FROM users
127
+ sql_query = SELECT (users.id * 4 + 3) AS id, '' AS address_name, 0 AS capitalization, 'User' AS class, 3 AS class_id, sellers.company_name AS company, '' AS company_name, 0 AS company_name_facet, '' AS content, UNIX_TIMESTAMP('1970-01-01 00:00:00') AS created_at, users.deleted AS deleted, users.email AS email, '__empty_searchable__' AS empty_searchable, users.login AS login, '' AS name, '' AS state, 0 AS user_id FROM users LEFT OUTER JOIN sellers ON users.id = sellers.user_id WHERE users.id >= $start AND users.id <= $end AND (deleted = 0) GROUP BY id
128
+
129
+ sql_group_column = capitalization
130
+ sql_group_column = class_id
131
+ sql_group_column = company_name_facet
132
+ sql_date_column = created_at
133
+ sql_group_column = deleted
134
+ sql_group_column = user_id
135
+ sql_query_info = SELECT * FROM users WHERE users.id = (($id - 3) / 4)
136
+ }
137
+
138
+
139
+ # Index configuration
140
+
141
+ index complete
142
+ {
143
+ source = geo__addresses
144
+ source = geo__states
145
+ source = sellers
146
+ source = users
147
+ charset_type = utf-8
148
+ charset_table = 0..9, A..Z->a..z, -, _, ., &, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F,U+C5->U+E5, U+E5, U+C4->U+E4, U+E4, U+D6->U+F6, U+F6, U+16B, U+0c1->a, U+0c4->a, U+0c9->e, U+0cd->i, U+0d3->o, U+0d4->o, U+0da->u, U+0dd->y, U+0e1->a, U+0e4->a, U+0e9->e, U+0ed->i, U+0f3->o, U+0f4->o, U+0fa->u, U+0fd->y, U+104->U+105, U+105, U+106->U+107, U+10c->c, U+10d->c, U+10e->d, U+10f->d, U+116->U+117, U+117, U+118->U+119, U+11a->e, U+11b->e, U+12E->U+12F, U+12F, U+139->l, U+13a->l, U+13d->l, U+13e->l, U+141->U+142, U+142, U+143->U+144, U+144,U+147->n, U+148->n, U+154->r, U+155->r, U+158->r, U+159->r, U+15A->U+15B, U+15B, U+160->s, U+160->U+161, U+161->s, U+164->t, U+165->t, U+16A->U+16B, U+16B, U+16e->u, U+16f->u, U+172->U+173, U+173, U+179->U+17A, U+17A, U+17B->U+17C, U+17C, U+17d->z, U+17e->z,
149
+ min_word_len = 1
150
+ stopwords =
151
+ path = /tmp/sphinx//sphinx_index_complete
152
+ docinfo = extern
153
+ morphology = stem_en
154
+ }
155
+
@@ -0,0 +1,11 @@
1
+ class CreateSticks < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :sticks do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :sticks
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateStones < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :stones do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :stones
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateOrganicSubstances < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :organic_substances do |t|
4
+ t.column :type, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :organic_substances
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ class CreateBones < ActiveRecord::Migration
2
+ def self.up
3
+ # Using STI
4
+ end
5
+
6
+ def self.down
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ class CreateSingleStiParents < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :single_sti_parents do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :single_sti_parents
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateDoubleStiParents < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :double_sti_parents do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :double_sti_parents
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ class CreateSingleStiParentRelationships < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :single_sti_parent_relationships do |t|
4
+ t.column :the_bone_type, :string, :null => false
5
+ t.column :the_bone_id, :integer, :null => false
6
+ t.column :single_sti_parent_id, :integer, :null => false
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :single_sti_parent_relationships
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ class CreateDoubleStiParentRelationships < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :double_sti_parent_relationships do |t|
4
+ t.column :the_bone_type, :string, :null => false
5
+ t.column :the_bone_id, :integer, :null => false
6
+ t.column :parent_type, :string, :null => false
7
+ t.column :parent_id, :integer, :null => false
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :double_sti_parent_relationships
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ class CreateLibraryModel < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :library_models do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :library_models
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ Use this README file to introduce your application and point to useful places in the API for learning more.
2
+ Run "rake appdoc" to generate API documentation for your models and controllers.
@@ -0,0 +1,83 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'fileutils'
3
+
4
+ class CommentingGeneratorTest < ActiveSupport::TestCase
5
+
6
+ def test_ensure_comments_dont_exist
7
+ # make sure the comments are already defined
8
+ assert_equal false, Object.send(:const_defined?, :Comment)
9
+ assert_equal false, Object.send(:const_defined?, :Commenting)
10
+ end
11
+
12
+ def test_ensure_files_exist_after_generator_runs
13
+ run_generator
14
+
15
+ # make sure the files are there
16
+ for generated_file in generated_files do
17
+ assert File.exists?(File.expand_path(generated_file))
18
+ end
19
+ end
20
+
21
+ def test_classes_exist_with_associations
22
+ run_generator
23
+ assert_nothing_raised { Commenting }
24
+ assert_nothing_raised { Comment }
25
+ citation = Citation.find(:first)
26
+ assert !citation.nil?
27
+ assert citation.respond_to?(:comments)
28
+ user = User.find(:first)
29
+ assert !user.nil?
30
+ assert user.respond_to?(:comments)
31
+ end
32
+
33
+ def teardown
34
+ Object.send(:remove_const, :Comment) if Object.send(:const_defined?, :Comment)
35
+ Object.send(:remove_const, :Commenting) if Object.send(:const_defined?, :Commenting)
36
+ remove_all_generated_files
37
+ remove_require_for_commenting_extensions
38
+ end
39
+
40
+ def generated_files
41
+ generated_files = [File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'comment.rb')]
42
+ generated_files << File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'commenting.rb')
43
+ generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'unit', 'commenting_test.rb')
44
+ generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'unit', 'comment_test.rb')
45
+ generated_files << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'commenting_extensions.rb')
46
+ generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'fixtures', 'comments.yml')
47
+ generated_files << File.join(File.dirname(__FILE__), '..', '..', 'test', 'fixtures', 'commentings.yml')
48
+ end
49
+
50
+ def remove_all_generated_files
51
+ for generated_file in generated_files do
52
+ if File.exists?(generated_file)
53
+ assert FileUtils.rm(generated_file)
54
+ end
55
+ end
56
+ end
57
+
58
+ def run_migrate
59
+ `rake db:migrate RAILS_ENV=test`
60
+ end
61
+
62
+ def run_generator
63
+ command = File.join(File.dirname(__FILE__), '..', '..', 'script', 'generate')
64
+ `#{command} commenting Citation User`
65
+ run_migrate
66
+ end
67
+
68
+ def remove_require_for_commenting_extensions
69
+ environment = File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment.rb')
70
+ new_environment = ''
71
+ if File.exists?(environment)
72
+ if (open(environment) { |file| file.grep(/Rails/).any? })
73
+ IO.readlines(environment).each do |line|
74
+ new_environment += line unless line.match(/commenting_extensions/i)
75
+ end
76
+ File.open(environment, "w+") do |f|
77
+ f.pos = 0
78
+ f.print new_environment
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,2 @@
1
+ class LibraryModel < ActiveRecord::Base
2
+ end
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
+ <title>The page you were looking for doesn't exist (404)</title>
9
+ <style type="text/css">
10
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
+ div.dialog {
12
+ width: 25em;
13
+ padding: 0 4em;
14
+ margin: 4em auto 0 auto;
15
+ border: 1px solid #ccc;
16
+ border-right-color: #999;
17
+ border-bottom-color: #999;
18
+ }
19
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ <!-- This file lives in public/404.html -->
25
+ <div class="dialog">
26
+ <h1>The page you were looking for doesn't exist.</h1>
27
+ <p>You may have mistyped the address or the page may have moved.</p>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
+ <title>We're sorry, but something went wrong</title>
9
+ <style type="text/css">
10
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
+ div.dialog {
12
+ width: 25em;
13
+ padding: 0 4em;
14
+ margin: 4em auto 0 auto;
15
+ border: 1px solid #ccc;
16
+ border-right-color: #999;
17
+ border-bottom-color: #999;
18
+ }
19
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ <!-- This file lives in public/500.html -->
25
+ <div class="dialog">
26
+ <h1>We're sorry, but something went wrong.</h1>
27
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,10 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
+
5
+ # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
+ # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
+ require "dispatcher"
8
+
9
+ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
+ Dispatcher.dispatch
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # You may specify the path to the FastCGI crash log (a log of unhandled
4
+ # exceptions which forced the FastCGI instance to exit, great for debugging)
5
+ # and the number of requests to process before running garbage collection.
6
+ #
7
+ # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
8
+ # and the GC period is nil (turned off). A reasonable number of requests
9
+ # could range from 10-100 depending on the memory footprint of your app.
10
+ #
11
+ # Example:
12
+ # # Default log path, normal GC behavior.
13
+ # RailsFCGIHandler.process!
14
+ #
15
+ # # Default log path, 50 requests between GC.
16
+ # RailsFCGIHandler.process! nil, 50
17
+ #
18
+ # # Custom log path, normal GC behavior.
19
+ # RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
20
+ #
21
+ require File.dirname(__FILE__) + "/../config/environment"
22
+ require 'fcgi_handler'
23
+
24
+ RailsFCGIHandler.process!
@@ -0,0 +1,10 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
+
5
+ # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
+ # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
+ require "dispatcher"
8
+
9
+ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
+ Dispatcher.dispatch
File without changes