acts_as_geocodable 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG DELETED
@@ -1,18 +0,0 @@
1
- 2.0.0 - 2010-10-01
2
- * Rewritten for Rails 3
3
- * New Rails 3/ARel finder syntax
4
- * Double Rainbows
5
-
6
- 0.2.1 - 2008-8-8
7
- * Results are now WillPaginate compatible
8
-
9
- 0.2.0 - 2007-10-27
10
- * Added validates_as_geocodable (Mark Van Holstyn)
11
- * Allow address mapping to be a single field (Mark Van Holstyn)
12
-
13
- 0.1.0
14
- * Added remote_location to get a users location based on their remote_ip
15
- * renamed :city to :locality in address mapping to be consistent with Graticule 0.2
16
- create a migration with:
17
- rename_column :geocodes, :city, :locality
18
- * replace #full_address with #to_location
@@ -1,129 +0,0 @@
1
- h1. acts_as_geocodable
2
-
3
- acts_as_geocodable helps you build geo-aware applications. It automatically geocodes your models when they are saved, giving you the ability to search by location and calculate distances between records.
4
-
5
- *Beginning with version 2, we require Rails 3. Use one of the 1.0.x tags to work with Rails 2.3.*
6
-
7
- We've adopted the ARel style syntax for finding records.
8
-
9
- h2. Usage
10
-
11
- <pre><code>event = Event.create :street => "777 NE Martin Luther King, Jr. Blvd.",
12
- :locality => "Portland", :region => "Oregon", :postal_code => 97232
13
-
14
- event.geocode.latitude #=> 45.529100000000
15
- event.geocode.longitude #=> -122.644200000000
16
-
17
- event.distance_to "49423" #=> 1807.66560483205
18
-
19
- Event.origin("97232", :within => 50)
20
-
21
- Event.origin("Portland, OR").nearest</code></pre>
22
-
23
- h2. Installation
24
-
25
- Install as a gem
26
-
27
- <pre><code>gem install acts_as_geocodable</code></pre>
28
-
29
- or add it to your Gemfile
30
-
31
- <pre><code>gem 'acts_as_geocodable'</code></pre>
32
-
33
- "Graticule":http://github.com/collectiveidea/graticule is used for all the heavy lifting and will be installed too.
34
-
35
- h2. Upgrading
36
-
37
- Before October 2008, precision wasn't included in the @Geocode@ model. Make sure you add a string precision column to your geocode table if you're upgrading from an older version, and update Graticule.
38
-
39
- Also, if you're upgrading from a previous version of this plugin, note that @:city@ has been renamed to @:locality@ to be consistent with Graticule 0.2. Create a migration that has:
40
-
41
- <pre><code>rename_column :geocodes, :city, :locality</code></pre>
42
-
43
- Also remember to change your mapping in your geocodable classes to use the @:locality@ key instead of @:city@:
44
-
45
- <pre><code>class Event < ActiveRecord::Base
46
- acts_as_geocodable :address => {:street => :address1, :locality => :city,
47
- :region => :state, :postal_code => :zip}
48
- end</code></pre>
49
-
50
- h2. Configuration
51
-
52
- Create the required tables
53
-
54
- <pre><code>rails generate acts_as_geocodable
55
- rake db:migrate</code></pre>
56
-
57
- Set the default geocoder in your environment.rb file.
58
-
59
- <pre><code>Geocode.geocoder = Graticule.service(:yahoo).new 'your_api_key'</code></pre>
60
-
61
- Then, in each model you want to make geocodable, add @acts_as_geocodable@.
62
-
63
- <pre><code>class Event < ActiveRecord::Base
64
- acts_as_geocodable
65
- end</code></pre>
66
-
67
- The only requirement is that your model must have address fields. By default, acts_as_geocodable looks for attributes called +street+, +locality+, +region+, +postal_code+, and +country+. To change these, you can provide a mapping in the @:address@ option:
68
-
69
- <pre><code>class Event < ActiveRecord::Base
70
- acts_as_geocodable :address => {:street => :address1, :locality => :city, :region => :state, :postal_code => :zip}
71
- end</code></pre>
72
-
73
- If that doesn't meet your needs, simply override the default @to_location@ method in your model, and return a @Graticule::Location@ with those attributes set.
74
-
75
- acts_as_geocodable can also update your address fields with the data returned from the geocoding service:
76
-
77
- <pre><code>class Event < ActiveRecord::Base
78
- acts_as_geocodable :normalize_address => true
79
- end</code></pre>
80
-
81
- h2. IP-based Geocoding
82
-
83
- acts_as_geocodable adds a @remote_location@ method in your controllers that uses http://hostip.info to guess remote users location based on their IP address.
84
-
85
- <pre><code>def index
86
- @nearest = Store.origin(remote_location).nearest if remote_location
87
- @stores = Store.all
88
- end</code></pre>
89
-
90
- Keep in mind that IP-based geocoding is not always accurate, and often will not return any results.
91
-
92
- h2. Contributing
93
-
94
- In the spirit of "free software":http://www.fsf.org/licensing/essays/free-sw.html, **everyone** is encouraged to help improve this project.
95
-
96
- Here are some ways *you* can contribute:
97
-
98
- * using alpha, beta, and prerelease versions
99
- * reporting bugs
100
- * suggesting new features
101
- * writing or editing documentation
102
- * writing specifications
103
- * writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
104
- * refactoring code
105
- * closing "issues":https://github.com/collectiveidea/acts_as_geocodable/issues/
106
- * reviewing patches
107
-
108
- h2. Submitting an Issue
109
-
110
- We use the "GitHub issue tracker":https://github.com/collectiveidea/acts_as_geocodable/issues/ to track bugs
111
- and features. Before submitting a bug report or feature request, check to make sure it hasn't already
112
- been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
113
- bug report, please include a "Gist":https://gist.github.com/ that includes a stack trace and any
114
- details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
115
- operating system. Ideally, a bug report should include a pull request with failing specs.
116
-
117
- h2. Submitting a Pull Request
118
-
119
- 1. Fork the project.
120
- 2. Create a topic branch.
121
- 3. Implement your feature or bug fix.
122
- 4. Add specs for your feature or bug fix.
123
- 5. Run @bundle exec rake@. If your changes are not 100% covered and passing, go back to step 4.
124
- 6. Commit and push your changes.
125
- 7. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
126
-
127
- h3. To Do
128
-
129
- * configurable formulas