on_the_map 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 0.1.1
2
+
3
+ - Fixed geolocatable_spec
4
+ - Delegate #geolocatable? to #address
5
+
6
+ ## 0.1.0
7
+
8
+ First release
data/README.md CHANGED
@@ -11,42 +11,67 @@ Contains various useful concern modules for:
11
11
  * geo spatial indexing of position
12
12
  * geo spatial searching on position
13
13
 
14
- * Adressable
14
+ The code examples below use the concerned gem to include the concern modules into a class.
15
+ You can use a simple `include OnTheMap::XXXX` in its place or some other concern related API of your choice.
15
16
 
16
17
  ### Adressable
17
18
 
18
- * embeds an address on the model
19
- * adds delegate methods to all embedded address fields
19
+ * embeds an `address` on the model
20
+ * adds delegate methods to all embedded address fields (setters/getters)
20
21
  * adds `full_address` method that returns full adress from concatenation of all fields
21
22
 
23
+ Address fields: `city, state, state_code, province, province_code, postal_code, country, country_code`
24
+
25
+ ```ruby
26
+ class MyModel
27
+ include Mongoid::Document
28
+
29
+ include_concern :addressable, from: :on_the_map
30
+ end
31
+ ```
32
+
22
33
  ### GeoLocatable
23
34
 
24
35
  * includes `addressable` and `positionable` concerns
25
- * performs geocoding after an address is created or updated
26
- * adds `latitude` and `longitude` methods to model
36
+ * performs geocoding to calculate new position after an address is created or updated
37
+ * adds `latitude` and `longitude` to model
38
+
39
+ ```ruby
40
+ class MyModel
41
+ include Mongoid::Document
42
+
43
+ include_concerns :geo_locatable, from: 'OnTheMap'
44
+ end
45
+ ```
27
46
 
28
47
  ### Mappable
29
48
 
30
49
  * include `Gmaps4rails::ActsAsGmappable`
31
- * adds field `normalized_address` to store address calculated and returned by Google Maps geo-coding
32
- * adds method `gmaps4rails_address` which returns main adress for use in geo-coding
50
+ * adds field `normalized_address` to store full address calculated and returned by Google Maps geo-coding
51
+ * adds method `gmaps4rails_address` which returns adress used in gmaps geo-coding (if enabled)
52
+ * includes `geo_locatable` and `positionable` concerns.
53
+
54
+ ```ruby
55
+ class MyModel
56
+ include Mongoid::Document
57
+
58
+ include_concerns :mappable, from: 'OnTheMap'
59
+ end
60
+ ```
33
61
 
34
62
  ### Positionable
35
63
 
36
- * includes `Mongoid::Geospatial` into the model to make GeoSpatial helpers available directly on the model
64
+ * includes `Mongoid::Geospatial` into the model to make GeoSpatial methods available
37
65
  * Adds geo_field `position` (macro from Mongoid GeoSpatial)
38
66
  * adds spatial indexing for position field
39
-
40
67
  * positon field is indexed and used in geo-searches (fx find points near a point)
41
68
 
42
- ## Usage
43
-
44
69
  ```ruby
45
- include_concerns :addressable, from: :on_the_map
46
- include_concerns :mappable, from: :on_the_map
47
- include_concerns :positionable, from: :on_the_map
70
+ class MyModel
71
+ include Mongoid::Document
48
72
 
49
- include_concerns :geo_locatable, from: :on_the_map
73
+ include_concerns :positionable, from: 'OnTheMap'
74
+ end
50
75
  ```
51
76
 
52
77
  See the specs for examples on how to use these concerns.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/address.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Address
2
2
  # include BasicDocument
3
3
  include Mongoid::Document
4
- include Mongoid::Dirty
4
+ # include Mongoid::Dirty
5
5
 
6
6
  after_update :perform_geocoding
7
7
 
@@ -30,7 +30,7 @@ module OnTheMap
30
30
  end
31
31
  end
32
32
 
33
- delegate :region, to: :address
33
+ delegate :region, :geolocatable?, to: :address
34
34
  end
35
35
 
36
36
  def perform_geocoding? name
@@ -30,9 +30,10 @@ module OnTheMap
30
30
 
31
31
  obj.geocoded = true
32
32
 
33
- if obj.respond_to? :gmaps
34
- obj.gmaps = true
35
- end
33
+ # apparently not needed! (according to author of gmaps4rails)
34
+ # if obj.respond_to? :gmaps
35
+ # obj.gmaps = true
36
+ # end
36
37
 
37
38
  obj.send(:geocoding_done!)
38
39
  end
data/on_the_map.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "on_the_map"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2013-03-04"
12
+ s.date = "2013-03-11"
13
13
  s.description = "Makes it easy to add functionality to models related to geocoding, addressing and placing them as pins on a map"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
+ "Changelog.md",
22
23
  "Gemfile",
23
24
  "Gemfile.lock",
24
25
  "LICENSE.txt",
@@ -18,7 +18,7 @@ describe OnTheMap::Addressable do
18
18
  subject { address }
19
19
 
20
20
  context 'blank/empty address' do
21
- let(:address) { MyGeoCodableAddress.create street: '', city: '' }
21
+ let(:address) { MyGeoCodedAddress.create street: '', city: '' }
22
22
 
23
23
  it 'should have a blank full address' do
24
24
  expect(subject.address.full).to be_blank
@@ -77,8 +77,9 @@ describe OnTheMap::Mappable do
77
77
  # leave geocoding to geocoder!
78
78
  its(:gmaps_geocode?) { should be_false }
79
79
 
80
- # geocoder sets gmaps when position has been calculated
81
- its(:gmaps) { should be_true }
80
+ # geocoder sets gmaps when position has been calculated?
81
+ # Note: not done anymore
82
+ its(:gmaps) { should be_false }
82
83
  end
83
84
  end
84
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: on_the_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-04 00:00:00.000000000 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -166,6 +166,7 @@ extra_rdoc_files:
166
166
  files:
167
167
  - .document
168
168
  - .rspec
169
+ - Changelog.md
169
170
  - Gemfile
170
171
  - Gemfile.lock
171
172
  - LICENSE.txt
@@ -203,7 +204,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
204
  version: '0'
204
205
  segments:
205
206
  - 0
206
- hash: 4362256846175368484
207
+ hash: -3810047604221837472
207
208
  required_rubygems_version: !ruby/object:Gem::Requirement
208
209
  none: false
209
210
  requirements: