muck-shares 0.1.8 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (369) hide show
  1. data/.gitignore +2 -1
  2. data/README.rdoc +7 -6
  3. data/Rakefile +5 -13
  4. data/VERSION +1 -1
  5. data/app/controllers/muck/shares_controller.rb +0 -1
  6. data/app/models/country.rb +13 -0
  7. data/app/models/language.rb +15 -0
  8. data/app/models/state.rb +13 -0
  9. data/{locales → config/locales}/ar.yml +2 -2
  10. data/{locales → config/locales}/bg.yml +2 -2
  11. data/{locales → config/locales}/ca.yml +2 -2
  12. data/{locales → config/locales}/cs.yml +2 -2
  13. data/{locales → config/locales}/da.yml +2 -2
  14. data/{locales → config/locales}/de.yml +2 -2
  15. data/{locales → config/locales}/el.yml +2 -2
  16. data/{locales → config/locales}/en.yml +2 -2
  17. data/{locales → config/locales}/es.yml +2 -2
  18. data/{locales → config/locales}/et.yml +2 -2
  19. data/{locales → config/locales}/fa.yml +2 -2
  20. data/{locales → config/locales}/fi.yml +2 -2
  21. data/{locales → config/locales}/fr.yml +2 -2
  22. data/{locales → config/locales}/gl.yml +2 -2
  23. data/{locales → config/locales}/hi.yml +2 -2
  24. data/{locales → config/locales}/hr.yml +2 -2
  25. data/{locales → config/locales}/hu.yml +2 -2
  26. data/{locales → config/locales}/id.yml +2 -2
  27. data/{locales → config/locales}/it.yml +2 -2
  28. data/{locales → config/locales}/iw.yml +2 -2
  29. data/{locales → config/locales}/ja.yml +2 -2
  30. data/{locales → config/locales}/ko.yml +2 -2
  31. data/{locales → config/locales}/lt.yml +2 -2
  32. data/{locales → config/locales}/lv.yml +2 -2
  33. data/{locales → config/locales}/mt.yml +2 -2
  34. data/{locales → config/locales}/nl.yml +2 -2
  35. data/{locales → config/locales}/no.yml +2 -2
  36. data/{locales → config/locales}/pl.yml +2 -2
  37. data/{locales → config/locales}/pt-PT.yml +2 -2
  38. data/{locales → config/locales}/ro.yml +2 -2
  39. data/{locales → config/locales}/ru.yml +2 -2
  40. data/{locales → config/locales}/sk.yml +2 -2
  41. data/{locales → config/locales}/sl.yml +2 -2
  42. data/{locales → config/locales}/sq.yml +2 -2
  43. data/{locales → config/locales}/sr.yml +2 -2
  44. data/{locales → config/locales}/sv.yml +2 -2
  45. data/config/locales/th.yml +22 -0
  46. data/{locales → config/locales}/tl.yml +2 -2
  47. data/{locales → config/locales}/tr.yml +2 -2
  48. data/{locales → config/locales}/uk.yml +2 -2
  49. data/{locales → config/locales}/vi.yml +2 -2
  50. data/{locales → config/locales}/zh-CN.yml +2 -2
  51. data/{locales → config/locales}/zh-TW.yml +3 -3
  52. data/{locales → config/locales}/zh.yml +2 -2
  53. data/config/routes.rb +9 -0
  54. data/lib/muck_shares.rb +3 -4
  55. data/lib/muck_shares/engine.rb +18 -0
  56. data/lib/muck_shares/models/share.rb +37 -0
  57. data/lib/muck_shares/models/sharer.rb +11 -0
  58. data/lib/tasks/tasks.rb +12 -0
  59. data/test/rails_test/.gitignore +8 -0
  60. data/test/rails_test/.rake_tasks +103 -0
  61. data/test/rails_test/Gemfile +45 -0
  62. data/test/rails_test/Rakefile +10 -0
  63. data/test/{rails_root → rails_test}/app/controllers/application_controller.rb +1 -1
  64. data/test/{rails_root → rails_test}/app/controllers/default_controller.rb +0 -0
  65. data/test/{rails_root → rails_test}/app/helpers/application_helper.rb +0 -0
  66. data/test/{rails_root → rails_test}/app/models/.keep +0 -0
  67. data/test/{rails_root → rails_test}/app/models/activity.rb +0 -0
  68. data/test/{rails_root → rails_test}/app/models/comment.rb +1 -1
  69. data/test/rails_test/app/models/profile.rb +3 -0
  70. data/test/{rails_root → rails_test}/app/models/share.rb +0 -0
  71. data/test/{rails_root → rails_test}/app/models/user.rb +5 -4
  72. data/test/{rails_root → rails_test}/app/models/user_session.rb +0 -0
  73. data/test/{rails_root → rails_test}/app/views/default/index.html.erb +0 -0
  74. data/test/{rails_root → rails_test}/app/views/layouts/default.html.erb +0 -0
  75. data/test/rails_test/config.ru +4 -0
  76. data/test/rails_test/config/application.rb +42 -0
  77. data/test/rails_test/config/boot.rb +13 -0
  78. data/test/rails_test/config/database.yml +16 -0
  79. data/test/rails_test/config/environment.rb +5 -0
  80. data/test/rails_test/config/environments/development.rb +26 -0
  81. data/test/rails_test/config/environments/production.rb +49 -0
  82. data/test/rails_test/config/environments/test.rb +35 -0
  83. data/test/rails_test/config/initializers/backtrace_silencers.rb +7 -0
  84. data/test/rails_test/config/initializers/geokit_config.rb +63 -0
  85. data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
  86. data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
  87. data/test/rails_test/config/initializers/muck.rb +60 -0
  88. data/test/rails_test/config/initializers/secret_token.rb +7 -0
  89. data/test/rails_test/config/initializers/session_store.rb +8 -0
  90. data/test/rails_test/config/routes.rb +4 -0
  91. data/test/{rails_root → rails_test}/features/shares.feature +0 -0
  92. data/test/{rails_root → rails_test}/features/step_definitions/common_steps.rb +0 -0
  93. data/test/{rails_root → rails_test}/features/step_definitions/share_steps.rb +0 -0
  94. data/test/rails_test/features/step_definitions/web_steps.rb +219 -0
  95. data/test/rails_test/features/support/custom_env.rb +19 -0
  96. data/test/rails_test/features/support/env.rb +58 -0
  97. data/test/rails_test/features/support/paths.rb +33 -0
  98. data/test/rails_test/lib/tasks/cucumber.rake +53 -0
  99. data/test/rails_test/spec/controllers/shares_controller_spec.rb +113 -0
  100. data/test/rails_test/spec/models/share_spec.rb +55 -0
  101. data/test/rails_test/spec/models/user_spec.rb +25 -0
  102. data/test/rails_test/spec/spec_helper.rb +29 -0
  103. data/test/rails_test/vendor/plugins/geokit-rails/.gitignore +2 -0
  104. data/test/rails_test/vendor/plugins/geokit-rails/CHANGELOG.rdoc +46 -0
  105. data/test/rails_test/vendor/plugins/geokit-rails/MIT-LICENSE +20 -0
  106. data/test/rails_test/vendor/plugins/geokit-rails/README.markdown +561 -0
  107. data/test/rails_test/vendor/plugins/geokit-rails/Rakefile +18 -0
  108. data/test/rails_test/vendor/plugins/geokit-rails/about.yml +9 -0
  109. data/test/rails_test/vendor/plugins/geokit-rails/assets/api_keys_template +61 -0
  110. data/test/rails_test/vendor/plugins/geokit-rails/init.rb +1 -0
  111. data/test/rails_test/vendor/plugins/geokit-rails/install.rb +14 -0
  112. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails.rb +26 -0
  113. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb +456 -0
  114. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/abstract.rb +31 -0
  115. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/mysql.rb +22 -0
  116. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/postgresql.rb +22 -0
  117. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/sqlserver.rb +43 -0
  118. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/defaults.rb +22 -0
  119. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/geocoder_control.rb +16 -0
  120. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/ip_geocode_lookup.rb +46 -0
  121. data/test/rails_test/vendor/plugins/geokit-rails/test/acts_as_mappable_test.rb +474 -0
  122. data/test/rails_test/vendor/plugins/geokit-rails/test/boot.rb +25 -0
  123. data/test/rails_test/vendor/plugins/geokit-rails/test/database.yml +20 -0
  124. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/companies.yml +7 -0
  125. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/custom_locations.yml +54 -0
  126. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/locations.yml +54 -0
  127. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_addresses.yml +17 -0
  128. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_families.yml +2 -0
  129. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_houses.yml +9 -0
  130. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_organizations.yml +5 -0
  131. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_people.yml +5 -0
  132. data/test/{rails_root/db/.keep → rails_test/vendor/plugins/geokit-rails/test/fixtures/stores.yml} +0 -0
  133. data/test/rails_test/vendor/plugins/geokit-rails/test/ip_geocode_lookup_test.rb +77 -0
  134. data/test/rails_test/vendor/plugins/geokit-rails/test/models/company.rb +3 -0
  135. data/test/rails_test/vendor/plugins/geokit-rails/test/models/custom_location.rb +12 -0
  136. data/test/rails_test/vendor/plugins/geokit-rails/test/models/location.rb +4 -0
  137. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_address.rb +4 -0
  138. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_family.rb +3 -0
  139. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_house.rb +3 -0
  140. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_organization.rb +4 -0
  141. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_person.rb +4 -0
  142. data/test/rails_test/vendor/plugins/geokit-rails/test/models/store.rb +3 -0
  143. data/test/rails_test/vendor/plugins/geokit-rails/test/schema.rb +60 -0
  144. data/test/rails_test/vendor/plugins/geokit-rails/test/tasks.rake +31 -0
  145. data/test/rails_test/vendor/plugins/geokit-rails/test/test_helper.rb +23 -0
  146. metadata +246 -352
  147. data/config/muck_shares_routes.rb +0 -8
  148. data/install.rb +0 -1
  149. data/lib/active_record/acts/muck_share.rb +0 -59
  150. data/lib/active_record/acts/muck_sharer.rb +0 -28
  151. data/lib/muck_shares/initialize_routes.rb +0 -8
  152. data/lib/muck_shares/tasks.rb +0 -28
  153. data/locales/th.yml +0 -22
  154. data/muck-shares.gemspec +0 -401
  155. data/rails/init.rb +0 -4
  156. data/test/rails_root/Rakefile +0 -17
  157. data/test/rails_root/app/models/profile.rb +0 -3
  158. data/test/rails_root/config/amazon_s3.yml +0 -14
  159. data/test/rails_root/config/boot.rb +0 -109
  160. data/test/rails_root/config/database.yml +0 -23
  161. data/test/rails_root/config/environment.rb +0 -33
  162. data/test/rails_root/config/environments/cucumber.rb +0 -38
  163. data/test/rails_root/config/environments/development.rb +0 -19
  164. data/test/rails_root/config/environments/production.rb +0 -1
  165. data/test/rails_root/config/environments/test.rb +0 -28
  166. data/test/rails_root/config/initializers/requires.rb +0 -13
  167. data/test/rails_root/config/initializers/session_store.rb +0 -8
  168. data/test/rails_root/config/routes.rb +0 -3
  169. data/test/rails_root/db/migrate/20090320174818_create_muck_permissions_and_roles.rb +0 -16
  170. data/test/rails_root/db/migrate/20090402033319_add_muck_activities.rb +0 -36
  171. data/test/rails_root/db/migrate/20090402234137_create_languages.rb +0 -18
  172. data/test/rails_root/db/migrate/20090426041056_create_countries.rb +0 -15
  173. data/test/rails_root/db/migrate/20090426041103_create_states.rb +0 -18
  174. data/test/rails_root/db/migrate/20090512013727_create_profiles.rb +0 -21
  175. data/test/rails_root/db/migrate/20090602041838_create_users.rb +0 -39
  176. data/test/rails_root/db/migrate/20090608073052_create_friends.rb +0 -16
  177. data/test/rails_root/db/migrate/20090613173314_create_comments.rb +0 -24
  178. data/test/rails_root/db/migrate/20090704220055_create_slugs.rb +0 -18
  179. data/test/rails_root/db/migrate/20090704220120_acts_as_taggable_on_migration.rb +0 -29
  180. data/test/rails_root/db/migrate/20090730154102_allow_null_user.rb +0 -9
  181. data/test/rails_root/db/migrate/20090803185323_create_shares.rb +0 -16
  182. data/test/rails_root/db/migrate/20090804184247_add_comment_count_to_shares.rb +0 -9
  183. data/test/rails_root/db/migrate/20090804231857_add_shares_uri_index.rb +0 -9
  184. data/test/rails_root/features/step_definitions/webrat_steps.rb +0 -128
  185. data/test/rails_root/features/support/env.rb +0 -49
  186. data/test/rails_root/features/support/paths.rb +0 -33
  187. data/test/rails_root/lib/tasks/cucumber.rake +0 -20
  188. data/test/rails_root/public/.htaccess +0 -40
  189. data/test/rails_root/public/404.html +0 -30
  190. data/test/rails_root/public/422.html +0 -30
  191. data/test/rails_root/public/500.html +0 -30
  192. data/test/rails_root/public/dispatch.rb +0 -10
  193. data/test/rails_root/public/favicon.ico +0 -0
  194. data/test/rails_root/public/images/arrow_left.gif +0 -0
  195. data/test/rails_root/public/images/arrow_right.gif +0 -0
  196. data/test/rails_root/public/images/fancybox/fancy_closebox.png +0 -0
  197. data/test/rails_root/public/images/fancybox/fancy_left.png +0 -0
  198. data/test/rails_root/public/images/fancybox/fancy_progress.png +0 -0
  199. data/test/rails_root/public/images/fancybox/fancy_right.png +0 -0
  200. data/test/rails_root/public/images/fancybox/fancy_shadow_e.png +0 -0
  201. data/test/rails_root/public/images/fancybox/fancy_shadow_n.png +0 -0
  202. data/test/rails_root/public/images/fancybox/fancy_shadow_ne.png +0 -0
  203. data/test/rails_root/public/images/fancybox/fancy_shadow_nw.png +0 -0
  204. data/test/rails_root/public/images/fancybox/fancy_shadow_s.png +0 -0
  205. data/test/rails_root/public/images/fancybox/fancy_shadow_se.png +0 -0
  206. data/test/rails_root/public/images/fancybox/fancy_shadow_sw.png +0 -0
  207. data/test/rails_root/public/images/fancybox/fancy_shadow_w.png +0 -0
  208. data/test/rails_root/public/images/fancybox/fancy_title_left.png +0 -0
  209. data/test/rails_root/public/images/fancybox/fancy_title_main.png +0 -0
  210. data/test/rails_root/public/images/fancybox/fancy_title_right.png +0 -0
  211. data/test/rails_root/public/images/icons/accept.png +0 -0
  212. data/test/rails_root/public/images/icons/add.png +0 -0
  213. data/test/rails_root/public/images/icons/delete.png +0 -0
  214. data/test/rails_root/public/images/icons/vote.png +0 -0
  215. data/test/rails_root/public/images/loading.gif +0 -0
  216. data/test/rails_root/public/images/nothing.png +0 -0
  217. data/test/rails_root/public/images/profile_default.jpg +0 -0
  218. data/test/rails_root/public/images/rails.png +0 -0
  219. data/test/rails_root/public/images/spinner.gif +0 -0
  220. data/test/rails_root/public/images/sprites.png +0 -0
  221. data/test/rails_root/public/javascripts/application.js +0 -2
  222. data/test/rails_root/public/javascripts/builder.js +0 -136
  223. data/test/rails_root/public/javascripts/controls.js +0 -963
  224. data/test/rails_root/public/javascripts/dragdrop.js +0 -972
  225. data/test/rails_root/public/javascripts/effects.js +0 -1120
  226. data/test/rails_root/public/javascripts/fancyzoom.min.js +0 -1
  227. data/test/rails_root/public/javascripts/jquery/jquery-ui.js +0 -273
  228. data/test/rails_root/public/javascripts/jquery/jquery.easing.js +0 -1
  229. data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +0 -9
  230. data/test/rails_root/public/javascripts/jquery/jquery.form.js +0 -637
  231. data/test/rails_root/public/javascripts/jquery/jquery.jgrowl.js +0 -2
  232. data/test/rails_root/public/javascripts/jquery/jquery.js +0 -19
  233. data/test/rails_root/public/javascripts/jquery/jquery.tips.js +0 -69
  234. data/test/rails_root/public/javascripts/muck.js +0 -80
  235. data/test/rails_root/public/javascripts/muck_activities.js +0 -108
  236. data/test/rails_root/public/javascripts/prototype.js +0 -4225
  237. data/test/rails_root/public/javascripts/scriptaculous.js +0 -58
  238. data/test/rails_root/public/javascripts/slider.js +0 -277
  239. data/test/rails_root/public/javascripts/sound.js +0 -60
  240. data/test/rails_root/public/robots.txt +0 -1
  241. data/test/rails_root/public/stylesheets/.keep +0 -0
  242. data/test/rails_root/public/stylesheets/admin.css +0 -12
  243. data/test/rails_root/public/stylesheets/blueprint/ie.css +0 -26
  244. data/test/rails_root/public/stylesheets/blueprint/liquid_screen.css +0 -203
  245. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
  246. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
  247. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
  248. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/readme.txt +0 -32
  249. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/screen.css +0 -97
  250. data/test/rails_root/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +0 -14
  251. data/test/rails_root/public/stylesheets/blueprint/plugins/fancy-type/screen.css +0 -71
  252. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
  253. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
  254. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
  255. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
  256. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
  257. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  258. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
  259. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
  260. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/readme.txt +0 -18
  261. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/screen.css +0 -40
  262. data/test/rails_root/public/stylesheets/blueprint/plugins/liquid/liquid.css +0 -134
  263. data/test/rails_root/public/stylesheets/blueprint/plugins/liquid/src/liquid.css +0 -197
  264. data/test/rails_root/public/stylesheets/blueprint/plugins/rtl/readme.txt +0 -10
  265. data/test/rails_root/public/stylesheets/blueprint/plugins/rtl/screen.css +0 -109
  266. data/test/rails_root/public/stylesheets/blueprint/print.css +0 -30
  267. data/test/rails_root/public/stylesheets/blueprint/screen.css +0 -251
  268. data/test/rails_root/public/stylesheets/blueprint/sprite.css +0 -1
  269. data/test/rails_root/public/stylesheets/blueprint/src/forms.css +0 -49
  270. data/test/rails_root/public/stylesheets/blueprint/src/grid.css +0 -213
  271. data/test/rails_root/public/stylesheets/blueprint/src/grid.png +0 -0
  272. data/test/rails_root/public/stylesheets/blueprint/src/ie.css +0 -59
  273. data/test/rails_root/public/stylesheets/blueprint/src/print.css +0 -85
  274. data/test/rails_root/public/stylesheets/blueprint/src/reset.css +0 -38
  275. data/test/rails_root/public/stylesheets/blueprint/src/typography.css +0 -105
  276. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png +0 -0
  277. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-thick_15_444444_40x40.png +0 -0
  278. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_100_f0f0f0_1x400.png +0 -0
  279. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_50_99c2ff_1x400.png +0 -0
  280. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_55_fbf5d0_1x400.png +0 -0
  281. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_80_e6e6e6_1x400.png +0 -0
  282. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  283. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png +0 -0
  284. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-soft_100_e7eef3_1x100.png +0 -0
  285. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_222222_256x240.png +0 -0
  286. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
  287. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
  288. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
  289. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_888888_256x240.png +0 -0
  290. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_cd0a0a_256x240.png +0 -0
  291. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
  292. data/test/rails_root/public/stylesheets/jquery/cupertino/jquery-ui-1.7.1.custom.css +0 -404
  293. data/test/rails_root/public/stylesheets/jquery/jquery.fancybox.css +0 -44
  294. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  295. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  296. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  297. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  298. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  299. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  300. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  301. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  302. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_217bc0_256x240.png +0 -0
  303. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
  304. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_469bdd_256x240.png +0 -0
  305. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
  306. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
  307. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
  308. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
  309. data/test/rails_root/public/stylesheets/jquery/redmond/jquery-ui-1.7.1.custom.css +0 -404
  310. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  311. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  312. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  313. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  314. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  315. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  316. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  317. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  318. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_222222_256x240.png +0 -0
  319. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  320. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_454545_256x240.png +0 -0
  321. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_888888_256x240.png +0 -0
  322. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  323. data/test/rails_root/public/stylesheets/jquery/smoothness/jquery-ui-1.7.1.custom.css +0 -404
  324. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  325. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  326. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  327. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  328. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  329. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  330. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  331. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  332. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  333. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  334. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  335. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  336. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  337. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  338. data/test/rails_root/public/stylesheets/jquery/ui-lightness/jquery-ui-1.7.1.custom.css +0 -404
  339. data/test/rails_root/public/stylesheets/reset.css +0 -0
  340. data/test/rails_root/public/stylesheets/styles.css +0 -89
  341. data/test/rails_root/public/stylesheets/themes/blue/styles.css +0 -1
  342. data/test/rails_root/public/stylesheets/themes/red/styles.css +0 -1
  343. data/test/rails_root/script/about +0 -3
  344. data/test/rails_root/script/breakpointer +0 -3
  345. data/test/rails_root/script/console +0 -3
  346. data/test/rails_root/script/create_project.rb +0 -52
  347. data/test/rails_root/script/cucumber +0 -8
  348. data/test/rails_root/script/dbconsole +0 -3
  349. data/test/rails_root/script/destroy +0 -3
  350. data/test/rails_root/script/generate +0 -3
  351. data/test/rails_root/script/performance/benchmarker +0 -3
  352. data/test/rails_root/script/performance/profiler +0 -3
  353. data/test/rails_root/script/performance/request +0 -3
  354. data/test/rails_root/script/plugin +0 -3
  355. data/test/rails_root/script/process/inspector +0 -3
  356. data/test/rails_root/script/process/reaper +0 -3
  357. data/test/rails_root/script/process/spawner +0 -3
  358. data/test/rails_root/script/runner +0 -3
  359. data/test/rails_root/script/server +0 -3
  360. data/test/rails_root/test/functional/.keep +0 -0
  361. data/test/rails_root/test/functional/shares_controller_test.rb +0 -119
  362. data/test/rails_root/test/test_helper.rb +0 -11
  363. data/test/rails_root/test/unit/.keep +0 -0
  364. data/test/rails_root/test/unit/share_test.rb +0 -59
  365. data/test/rails_root/test/unit/user_test.rb +0 -26
  366. data/test/rails_root/vendor/plugins/ssl_requirement/README +0 -43
  367. data/test/rails_root/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb +0 -62
  368. data/test/rails_root/vendor/plugins/ssl_requirement/test/ssl_requirement_test.rb +0 -132
  369. data/uninstall.rb +0 -1
@@ -0,0 +1,561 @@
1
+ ## INSTALLATION
2
+
3
+ Geokit consists of a Gem ([geokit-gem](http://github.com/andre/geokit-gem/tree/master)) and a Rails plugin ([geokit-rails](http://github.com/andre/geokit-rails/tree/master)).
4
+
5
+ #### 1. Install the Rails plugin:
6
+
7
+ cd [YOUR_RAILS_APP_ROOT]
8
+ script/plugin install git://github.com/andre/geokit-rails.git
9
+
10
+ #### 2. Add this line to your environment.rb
11
+ (inside the Rails::Initializer.run do |config| block)
12
+
13
+ config.gem "geokit"
14
+
15
+ This informs Rails of the gem dependency.
16
+
17
+ #### 3. Tell Rails to install the gem:
18
+
19
+ rake gems:install
20
+
21
+ And you're good to go! If you're running an older verion of Rails, just install the gem manually: `sudo gem install rails`
22
+
23
+ ## FEATURE SUMMARY
24
+
25
+ Geokit provides key functionality for location-oriented Rails applications:
26
+
27
+ - Distance calculations, for both flat and spherical environments. For example,
28
+ given the location of two points on the earth, you can calculate the miles/KM
29
+ between them.
30
+ - ActiveRecord distance-based finders. For example, you can find all the points
31
+ in your database within a 50-mile radius.
32
+ - IP-based location lookup utilizing hostip.info. Provide an IP address, and get
33
+ city name and latitude/longitude in return
34
+ - A before_filter helper to geocoder the user's location based on IP address,
35
+ and retain the location in a cookie.
36
+ - Geocoding from multiple providers. It provides a fail-over mechanism, in case
37
+ your input fails to geocode in one service. Geocoding is provided buy the Geokit
38
+ gem, which you must have installed
39
+
40
+ The goal of this plugin is to provide the common functionality for location-oriented
41
+ applications (geocoding, location lookup, distance calculation) in an easy-to-use
42
+ package.
43
+
44
+ ## A NOTE ON TERMINOLOGY
45
+
46
+ Throughout the code and API, latitude and longitude are referred to as lat
47
+ and lng. We've found over the long term the abbreviation saves lots of typing time.
48
+
49
+ ## LOCATION QUERIES
50
+
51
+ To get started, just specify an ActiveRecord class as `acts_as_mappale`:
52
+
53
+ class Location < ActiveRecord::Base
54
+ acts_as_mappable
55
+ end
56
+
57
+ There are some defaults you can override:
58
+
59
+ class Location < ActiveRecord::Base
60
+ acts_as_mappable :default_units => :miles,
61
+ :default_formula => :sphere,
62
+ :distance_field_name => :distance,
63
+ :lat_column_name => :lat,
64
+ :lng_column_name => :lng
65
+ end
66
+
67
+
68
+ The optional parameters are :units, :formula, and distance_field_name.
69
+ Values for :units can be :miles, :kms (kilometers), or :nms (nautical miles),
70
+ with :miles as the default. Values for :formula can be :sphere or :flat with
71
+ :sphere as the default. :sphere gives you Haversine calculations, while :flat
72
+ gives the Pythagoreum Theory. These defaults persist through out the plug-in.
73
+
74
+ The plug-in creates a calculated `distance` field on AR instances that have
75
+ been retrieved throw a Geokit location query. By default, these fields are
76
+ known as "distance" but this can be changed through the `:distance_field_name` key.
77
+
78
+ You can also define alternative column names for latitude and longitude using
79
+ the `:lat_column_name` and `:lng_column_name` keys. The defaults are 'lat' and
80
+ 'lng' respectively.
81
+
82
+ Once you've specified acts_as_mappable, a set of distance-based
83
+ finder methods are available:
84
+
85
+ Origin as a two-element array of latititude/longitude:
86
+
87
+ find(:all, :origin => [37.792,-122.393])
88
+
89
+ Origin as a geocodeable string:
90
+
91
+ find(:all, :origin => '100 Spear st, San Francisco, CA')
92
+
93
+ Origin as an object which responds to lat and lng methods,
94
+ or latitude and longitude methods, or whatever methods you have
95
+ specified for `lng_column_name` and `lat_column_name`:
96
+
97
+ find(:all, :origin=>my_store) # my_store.lat and my_store.lng methods exist
98
+
99
+ Often you will need to find within a certain distance. The prefered syntax is:
100
+
101
+ find(:all, :origin => @somewhere, :within => 5)
102
+
103
+ . . . however these syntaxes will also work:
104
+
105
+ find_within(5, :origin => @somewhere)
106
+ find(:all, :origin => @somewhere, :conditions => "distance < 5")
107
+
108
+ Note however that the third form should be avoided. With either of the first two,
109
+ Geokit automatically adds a bounding box to speed up the radial query in the database.
110
+ With the third form, it does not.
111
+
112
+ If you need to combine distance conditions with other conditions, you should do
113
+ so like this:
114
+
115
+ find(:all, :origin => @somewhere, :within => 5, :conditions=>['state=?',state])
116
+
117
+ If :origin is not provided in the finder call, the find method
118
+ works as normal. Further, the key is removed
119
+ from the :options hash prior to invoking the superclass behavior.
120
+
121
+ Other convenience methods work intuitively and are as follows:
122
+
123
+ find_within(distance, :origin => @somewhere)
124
+ find_beyond(distance, :origin => @somewhere)
125
+ find_closest(:origin => @somewhere)
126
+ find_farthest(:origin => @somewhere)
127
+
128
+ where the options respect the defaults, but can be overridden if
129
+ desired.
130
+
131
+ Lastly, if all that is desired is the raw SQL for distance
132
+ calculations, you can use the following:
133
+
134
+ distance_sql(origin, units=default_units, formula=default_formula)
135
+
136
+ Thereafter, you are free to use it in find_by_sql as you wish.
137
+
138
+ There are methods available to enable you to get the count based upon
139
+ the find condition that you have provided. These all work similarly to
140
+ the finders. So for instance:
141
+
142
+ count(:origin, :conditions => "distance < 5")
143
+ count_within(distance, :origin => @somewhere)
144
+ count_beyond(distance, :origin => @somewhere)
145
+
146
+ ## FINDING WITHIN A BOUNDING BOX
147
+
148
+ If you are displaying points on a map, you probably need to query for whatever falls within the rectangular bounds of the map:
149
+
150
+ Store.find :all, :bounds=>[sw_point,ne_point]
151
+
152
+ The input to :bounds can be array with the two points or a Bounds object. However you provide them, the order should always be the southwest corner, northeast corner of the rectangle. Typically, you will be getting the sw_point and ne_point from a map that is displayed on a web page.
153
+
154
+ If you need to calculate the bounding box from a point and radius, you can do that:
155
+
156
+ bounds=Bounds.from_point_and_radius(home,5)
157
+ Store.find :all, :bounds=>bounds
158
+
159
+ ## USING INCLUDES
160
+
161
+ You can use includes along with your distance finders:
162
+
163
+ stores=Store.find :all, :origin=>home, :include=>[:reviews,:cities] :within=>5, :order=>'distance'
164
+
165
+ *However*, ActiveRecord drops the calculated distance column when you use include. So, if you need to
166
+ use the distance column, you'll have to re-calculate it post-query in Ruby:
167
+
168
+ stores.sort_by_distance_from(home)
169
+
170
+ In this case, you may want to just use the bounding box
171
+ condition alone in your SQL (there's no use calculating the distance twice):
172
+
173
+ bounds=Bounds.from_point_and_radius(home,5)
174
+ stores=Store.find :all, :include=>[:reviews,:cities] :bounds=>bounds
175
+ stores.sort_by_distance_from(home)
176
+
177
+ ## USING :through
178
+
179
+ You can also specify a model as mappable "through" another associated model.
180
+ In other words, that associated model is the actual mappable model with
181
+ "lat" and "lng" attributes, but this "through" model can still utilize
182
+ all of the above find methods to search for records.
183
+
184
+ class Location < ActiveRecord::Base
185
+ belongs_to :locatable, :polymorphic => true
186
+ acts_as_mappable
187
+ end
188
+
189
+ class Company < ActiveRecord::Base
190
+ has_one :location, :as => :locatable # also works for belongs_to associations
191
+ acts_as_mappable :through => :location
192
+ end
193
+
194
+ Then you can still call:
195
+
196
+ Company.find_within(distance, :origin => @somewhere)
197
+
198
+ You can also give :through a hash if you location is nested deep. For example, given:
199
+
200
+ class House
201
+ acts_as_mappable
202
+ end
203
+
204
+ class Family
205
+ belongs_to :house
206
+ end
207
+
208
+ class Person
209
+ belongs_to :family
210
+ acts_as_mappable :through => { :family => :house }
211
+ end
212
+
213
+ Remember that the notes above about USING INCLUDES apply to the results from
214
+ this find, since an include is automatically used.
215
+
216
+ ## IP GEOCODING
217
+
218
+ You can obtain the location for an IP at any time using the geocoder
219
+ as in the following example:
220
+
221
+ location = IpGeocoder.geocode('12.215.42.19')
222
+
223
+ where Location is a GeoLoc instance containing the latitude,
224
+ longitude, city, state, and country code. Also, the success
225
+ value is true.
226
+
227
+ If the IP cannot be geocoded, a GeoLoc instance is returned with a
228
+ success value of false.
229
+
230
+ It should be noted that the IP address needs to be visible to the
231
+ Rails application. In other words, you need to ensure that the
232
+ requesting IP address is forwarded by any front-end servers that
233
+ are out in front of the Rails app. Otherwise, the IP will always
234
+ be that of the front-end server.
235
+
236
+ The Multi-Geocoder will also geocode IP addresses and provide
237
+ failover among multiple IP geocoders. Just pass in an IP address for the
238
+ parameter instead of a street address. Eg:
239
+
240
+ location = Geocoders::MultiGeocoder.geocode('12.215.42.19')
241
+
242
+ The MultiGeocoder class requires 2 configuration setting for the provider order.
243
+ Ordering is done through `Geokit::Geocoders::provider_order` and
244
+ `Geokit::Geocoders::ip_provider_order`, found in
245
+ `config/initializers/geokit_config.rb`. If you don't already have a
246
+ `geokit_config.rb` file, the plugin creates one when it is first installed.
247
+
248
+
249
+ ## IP GEOCODING HELPER
250
+
251
+ A class method called geocode_ip_address has been mixed into the
252
+ ActionController::Base. This enables before_filter style lookup of
253
+ the IP address. Since it is a filter, it can accept any of the
254
+ available filter options.
255
+
256
+ Usage is as below:
257
+
258
+ class LocationAwareController < ActionController::Base
259
+ geocode_ip_address
260
+ end
261
+
262
+ A first-time lookup will result in the GeoLoc class being stored
263
+ in the session as `:geo_location` as well as in a cookie called
264
+ `:geo_session`. Subsequent lookups will use the session value if it
265
+ exists or the cookie value if it doesn't exist. The last resort is
266
+ to make a call to the web service. Clients are free to manage the
267
+ cookie as they wish.
268
+
269
+ The intent of this feature is to be able to provide a good guess as
270
+ to a new visitor's location.
271
+
272
+ ## INTEGRATED FIND AND GEOCODING
273
+
274
+ Geocoding has been integrated with the finders enabling you to pass
275
+ a physical address or an IP address. This would look the following:
276
+
277
+ Location.find_farthest(:origin => '217.15.10.9')
278
+ Location.find_farthest(:origin => 'Irving, TX')
279
+
280
+ where the IP or physical address would be geocoded to a location and
281
+ then the resulting latitude and longitude coordinates would be used
282
+ in the find. This is not expected to be common usage, but it can be
283
+ done nevertheless.
284
+
285
+ ## ADDRESS GEOCODING
286
+
287
+ Geocoding is provided by the Geokit gem, which is required for this plugin.
288
+ See the top of this file for instructions on installing the Geokit gem.
289
+
290
+ Geokit can geocode addresses using multiple geocodeing web services.
291
+ Geokit supports services like Google, Yahoo, and Geocoder.us, and more --
292
+ see the Geokit gem API for a complete list.
293
+
294
+ These geocoder services are made available through the following classes:
295
+ GoogleGeocoder, YahooGeocoder, UsGeocoder, CaGeocoder, and GeonamesGeocoder.
296
+ Further, an additional geocoder class called MultiGeocoder incorporates an ordered failover
297
+ sequence to increase the probability of successful geocoding.
298
+
299
+ All classes are called using the following signature:
300
+
301
+ include Geokit::Geocoders
302
+ location = XxxGeocoder.geocode(address)
303
+
304
+ where you replace Xxx Geocoder with the appropriate class. A GeoLoc
305
+ instance is the result of the call. This class has a "success"
306
+ attribute which will be true if a successful geocoding occurred.
307
+ If successful, the lat and lng properties will be populated.
308
+
309
+ Geocoders are named with the convention NameGeocoder. This
310
+ naming convention enables Geocoder to auto-detect its sub-classes
311
+ in order to create methods called `name_geocoder(address)` so that
312
+ all geocoders can be called through the base class. This is done
313
+ purely for convenience; the individual geocoder classes are expected
314
+ to be used independently.
315
+
316
+ The MultiGeocoder class requires the configuration of a provider
317
+ order which dictates what order to use the various geocoders. Ordering
318
+ is done through `Geokit::Geocoders::provider_order`, found in
319
+ `config/initializers/geokit_config.rb`.
320
+
321
+ If you don't already have a `geokit_config.rb` file, the plugin creates one
322
+ when it is first installed.
323
+
324
+ Make sure your failover configuration matches the usage characteristics
325
+ of your application -- for example, if you routinely get bogus input to
326
+ geocode, your code will be much slower if you have to failover among
327
+ multiple geocoders before determining that the input was in fact bogus.
328
+
329
+ The Geocoder.geocode method returns a GeoLoc object. Basic usage:
330
+
331
+ loc=Geocoder.geocode('100 Spear St, San Francisco, CA')
332
+ if loc.success
333
+ puts loc.lat
334
+ puts loc.lng
335
+ puts loc.full_address
336
+ end
337
+
338
+ ## REVERSE GEOCODING
339
+
340
+ Currently, only the Google Geocoder supports reverse geocoding.
341
+ Pass the lat/lng as a string, array or LatLng instance:
342
+
343
+ res=Geokit::Geocoders::GoogleGeocoder.reverse_geocode "37.791821,-122.394679"
344
+ => #<Geokit::GeoLoc:0x558ed0 ...
345
+ res.full_address
346
+ "101-115 Main St, San Francisco, CA 94105, USA"
347
+
348
+ The address will usually appear as a range, as it does in the above example.
349
+
350
+
351
+ ## INTEGRATED FIND WITH ADDRESS GEOCODING
352
+
353
+ Just has you can pass an IP address directly into an ActiveRecord finder
354
+ as the origin, you can also pass a physical address as the origin:
355
+
356
+ Location.find_closest(:origin => '100 Spear st, San Francisco, CA')
357
+
358
+ where the physical address would be geocoded to a location and then the
359
+ resulting latitude and longitude coordinates would be used in the
360
+ find.
361
+
362
+ Note that if the address fails to geocode, the find method will raise an
363
+ ActiveRecord::GeocodeError you must be prepared to catch. Alternatively,
364
+ You can geocoder the address beforehand, and pass the resulting lat/lng
365
+ into the finder if successful.
366
+
367
+ ## Auto Geocoding
368
+
369
+ If your geocoding needs are simple, you can tell your model to automatically
370
+ geocode itself on create:
371
+
372
+ class Store < ActiveRecord::Base
373
+ acts_as_mappable :auto_geocode=>true
374
+ end
375
+
376
+ It takes two optional params:
377
+
378
+ class Store < ActiveRecord::Base
379
+ acts_as_mappable :auto_geocode=>{:field=>:address, :error_message=>'Could not geocode address'}
380
+ end
381
+
382
+ . . . which is equivilent to:
383
+
384
+ class Store << ActiveRecord::Base
385
+ acts_as_mappable
386
+ before_validation_on_create :geocode_address
387
+
388
+ private
389
+ def geocode_address
390
+ geo=Geokit::Geocoders::MultiGeocoder.geocode (address)
391
+ errors.add(:address, "Could not Geocode address") if !geo.success
392
+ self.lat, self.lng = geo.lat,geo.lng if geo.success
393
+ end
394
+ end
395
+
396
+ If you need any more complicated geocoding behavior for your model, you should roll your own
397
+ `before_validate` callback.
398
+
399
+
400
+ ## Distances, headings, endpoints, and midpoints
401
+
402
+ distance=home.distance_from(work, :units=>:miles)
403
+ heading=home.heading_to(work) # result is in degrees, 0 is north
404
+ endpoint=home.endpoint(90,2) # two miles due east
405
+ midpoing=home.midpoint_to(work)
406
+
407
+ ## Cool stuff you can do with bounds
408
+
409
+ bounds=Bounds.new(sw_point,ne_point)
410
+ bounds.contains?(home)
411
+ puts bounds.center
412
+
413
+
414
+ HOW TO . . .
415
+ =================================================================================
416
+
417
+ A few quick examples to get you started ....
418
+
419
+ ## How to install the Geokit Rails plugin
420
+ (See the very top of this file)
421
+
422
+ ## How to find all stores within a 10-mile radius of a given lat/lng
423
+ 1. ensure your stores table has lat and lng columns with numeric or float
424
+ datatypes to store your latitude/longitude
425
+
426
+ 3. use `acts_as_mappable` on your store model:
427
+
428
+ class Store < ActiveRecord::Base
429
+ acts_as_mappable
430
+ ...
431
+ end
432
+
433
+ 3. finders now have extra capabilities:
434
+
435
+ Store.find(:all, :origin =>[32.951613,-96.958444], :within=>10)
436
+
437
+ ## How to geocode an address
438
+
439
+ 1. configure your geocoder key(s) in `config/initializers/geokit_config.rb`
440
+
441
+ 2. also in `geokit_config.rb`, make sure that `Geokit::Geocoders::provider_order` reflects the
442
+ geocoder(s). If you only want to use one geocoder, there should
443
+ be only one symbol in the array. For example:
444
+
445
+ Geokit::Geocoders::provider_order=[:google]
446
+
447
+ 3. Test it out in script/console
448
+
449
+ include Geokit::Geocoders
450
+ res = MultiGeocoder.geocode('100 Spear St, San Francisco, CA')
451
+ puts res.lat
452
+ puts res.lng
453
+ puts res.full_address
454
+ ... etc. The return type is GeoLoc, see the API for
455
+ all the methods you can call on it.
456
+
457
+ ## How to find all stores within 10 miles of a given address
458
+
459
+ 1. as above, ensure your table has the lat/lng columns, and you've
460
+ applied `acts_as_mappable` to the Store model.
461
+
462
+ 2. configure and test out your geocoder, as above
463
+
464
+ 3. pass the address in under the :origin key
465
+
466
+ Store.find(:all, :origin=>'100 Spear st, San Francisco, CA',
467
+ :within=>10)
468
+
469
+ 4. you can also use a zipcode, or anything else that's geocodable:
470
+
471
+ Store.find(:all, :origin=>'94117',
472
+ :conditions=>'distance<10')
473
+
474
+ ## How to sort a query by distance from an origin
475
+
476
+ You now have access to a 'distance' column, and you can use it
477
+ as you would any other column. For example:
478
+ Store.find(:all, :origin=>'94117', :order=>'distance')
479
+
480
+ ## How to elements of an array according to distance from a common point
481
+
482
+ Usually, you can do your sorting in the database as part of your find call.
483
+ If you need to sort things post-query, you can do so:
484
+
485
+ stores=Store.find :all
486
+ stores.sort_by_distance_from(home)
487
+ puts stores.first.distance
488
+
489
+ Obviously, each of the items in the array must have a latitude/longitude so
490
+ they can be sorted by distance.
491
+
492
+ ## Database indexes
493
+
494
+ MySQL can't create indexes on a calculated field such as those Geokit uses to
495
+ calculate distance based on latitude/longitude values for a record. However,
496
+ indexing the lat and lng columns does improve Geokit distance calculation
497
+ performance since the lat and lng columns are used in a straight comparison
498
+ for distance calculation. Assuming a Page model that is incorporating the
499
+ Geokit plugin the migration would be as follows.
500
+
501
+ class AddIndexOPageLatAndLng < ActiveRecord::Migration
502
+
503
+ def self.up
504
+ add_index :pages, [:lat, :lng]
505
+ end
506
+
507
+ def self.down
508
+ remove_index :pages, [:lat, :lng]
509
+ end
510
+ end
511
+
512
+ ## Database Compatability
513
+
514
+ * Geokit works with MySQL (tested with version 5.0.41), PostgreSQL (tested with version 8.2.6) and Microsoft SQL Server (tested with 2000).
515
+ * Geokit does *not* work with SQLite, as it lacks the necessary geometry functions.
516
+ * Geokit is known to *not* work with Postgres versions under 8.1 -- it uses the least() funciton.
517
+
518
+
519
+ ## HIGH-LEVEL NOTES ON WHAT'S WHERE
520
+
521
+ `acts_as_mappable.rb`, as you'd expect, contains the ActsAsMappable
522
+ module which gets mixed into your models to provide the
523
+ location-based finder goodness.
524
+
525
+ `ip_geocode_lookup.rb` contains the before_filter helper method which
526
+ enables auto lookup of the requesting IP address.
527
+
528
+ ### The Geokit gem provides the building blocks of distance-based operations:
529
+
530
+ The Mappable module, which provides basic
531
+ distance calculation methods, i.e., calculating the distance
532
+ between two points.
533
+
534
+ The LatLng class is a simple container for latitude and longitude, but
535
+ it's made more powerful by mixing in the above-mentioned Mappable
536
+ module -- therefore, you can calculate easily the distance between two
537
+ LatLng ojbects with `distance = first.distance_to(other)`
538
+
539
+ GeoLoc represents an address or location which
540
+ has been geocoded. You can get the city, zipcode, street address, etc.
541
+ from a GeoLoc object. GeoLoc extends LatLng, so you also get lat/lng
542
+ AND the Mappable modeule goodness for free.
543
+
544
+ ## GOOGLE GROUP
545
+
546
+ Follow the Google Group for updates and discussion on Geokit: http://groups.google.com/group/geokit
547
+
548
+ ## IMPORTANT POST-INSTALLATION NOTES:
549
+
550
+ *1. The configuration file*: Geokit for Rails uses a configuration file in config/initializers.
551
+ You *must* add your own keys for the various geocoding services if you want to use geocoding.
552
+ If you need to refer to the original template again, see the `assets/api_keys_template` file.
553
+
554
+ *2. The gem dependency*: Geokit for Rails depends on the Geokit gem. Tell Rails about this
555
+ dependency in `config/environment.rb`, within the initializer block:
556
+ config.gem "geokit"
557
+
558
+ *If you're having trouble with dependencies ....*
559
+
560
+ Try installing the gem manually (sudo gem install geokit), then adding a `require 'geokit'` to the top of
561
+ `vendor/plugins/geokit-rails/init.rb` and/or `config/geokit_config.rb`.