mongoid-geospatial 5.0.0 → 7.0.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.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +8 -0
  3. data/.travis.yml +26 -20
  4. data/CHANGELOG.md +23 -0
  5. data/CONTRIBUTING.md +118 -0
  6. data/Gemfile +8 -16
  7. data/Guardfile +2 -2
  8. data/MIT-LICENSE +2 -2
  9. data/README.md +202 -212
  10. data/RELEASING.md +62 -0
  11. data/Rakefile +4 -1
  12. data/lib/mongoid/geospatial/config/point.rb +19 -0
  13. data/lib/mongoid/geospatial/config.rb +29 -0
  14. data/lib/mongoid/geospatial/fields/circle.rb +3 -3
  15. data/lib/mongoid/geospatial/fields/point.rb +29 -10
  16. data/lib/mongoid/geospatial/geometry_field.rb +6 -4
  17. data/lib/mongoid/geospatial/helpers/sphere.rb +1 -1
  18. data/lib/mongoid/geospatial/version.rb +1 -1
  19. data/lib/mongoid/geospatial/wrappers/georuby.rb +1 -0
  20. data/lib/mongoid/geospatial.rb +107 -30
  21. data/mongoid-geospatial.gemspec +3 -4
  22. data/{bench → spec}/bench +1 -1
  23. data/spec/models/bar.rb +1 -0
  24. data/spec/models/event.rb +1 -1
  25. data/spec/models/farm.rb +1 -1
  26. data/spec/models/person.rb +2 -9
  27. data/spec/models/river.rb +7 -7
  28. data/spec/mongoid/geospatial/config_spec.rb +22 -0
  29. data/spec/mongoid/geospatial/fields/line_string_spec.rb +3 -4
  30. data/spec/mongoid/geospatial/fields/point_spec.rb +50 -4
  31. data/spec/mongoid/geospatial/fields/polygon_spec.rb +3 -3
  32. data/spec/mongoid/geospatial/geospatial_spec.rb +80 -8
  33. data/spec/mongoid/geospatial/helpers/core_spec.rb +6 -3
  34. data/spec/mongoid/geospatial/helpers/spatial_spec.rb +3 -3
  35. data/spec/mongoid/geospatial/helpers/sphere_spec.rb +6 -6
  36. data/spec/mongoid.yml +298 -0
  37. data/spec/spec_helper.rb +9 -19
  38. data/spec/support/authentication.rb +0 -1
  39. metadata +18 -12
data/README.md CHANGED
@@ -1,244 +1,227 @@
1
- Mongoid Geospatial
2
- ==================
3
-
1
+ # Mongoid Geospatial
4
2
 
5
3
  A Mongoid Extension that simplifies the use of MongoDB spatial features.
6
4
 
7
- * Version 5.x -> Mongoid 5
8
- * Version 4.x -> Mongoid 4
9
-
10
- ** Gem name has changed: 'mongoid-geospatial' (notice the hyphen) **
11
- Please change the underscore to a hyphen.
12
- That will require it correctly within bundler:
13
- `require 'mongoid/geospatial'`
14
-
15
5
  [![Gem Version](https://badge.fury.io/rb/mongoid-geospatial.svg)](http://badge.fury.io/rb/mongoid-geospatial)
16
- [![Code Climate](https://codeclimate.com/github/nofxx/mongoid-geospatial.svg)](https://codeclimate.com/github/nofxx/mongoid-geospatial)
17
- [![Coverage Status](https://coveralls.io/repos/nofxx/mongoid-geospatial/badge.svg?branch=master)](https://coveralls.io/r/nofxx/mongoid-geospatial?branch=master)
18
- [![Dependency Status](https://gemnasium.com/nofxx/mongoid-geospatial.svg)](https://gemnasium.com/nofxx/mongoid-geospatial)
19
- [![Build Status](https://travis-ci.org/nofxx/mongoid-geospatial.svg?branch=master)](https://travis-ci.org/nofxx/mongoid-geospatial)
6
+ [![Code Climate](https://codeclimate.com/github/mongoid/mongoid-geospatial.svg)](https://codeclimate.com/github/mongoid/mongoid-geospatial)
7
+ [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid-geospatial/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid-geospatial?branch=master)
8
+ [![Build Status](https://travis-ci.org/mongoid/mongoid-geospatial.svg?branch=master)](https://travis-ci.org/mongoid/mongoid-geospatial)
20
9
 
10
+ ## Quick Start
21
11
 
22
- Quick Start
23
- -----------
24
-
25
- This gem focus on (making helpers for) MongoDB's spatial features.
26
- But you may also use an external Geometric/Spatial gem alongside.
27
-
28
- # Gemfile
29
- gem 'mongoid-geospatial'
12
+ This gem focuses on (making helpers for) MongoDB's spatial features using Mongoid 5, 6 and 7.
30
13
 
14
+ ```ruby
15
+ # Gemfile
16
+ gem 'mongoid-geospatial'
17
+ ```
31
18
 
32
19
  A `Place` to illustrate `Point`, `Line` and `Polygon`
33
20
 
34
- class Place
35
- include Mongoid::Document
21
+ ```ruby
22
+ class Place
23
+ include Mongoid::Document
36
24
 
37
- # Include the module
38
- include Mongoid::Geospatial
25
+ # Include the module
26
+ include Mongoid::Geospatial
39
27
 
40
- # Just like mongoid,
41
- field :name, type: String
28
+ # Just like mongoid,
29
+ field :name, type: String
42
30
 
43
- # define your field, but choose a geometry type:
44
- field :location, type: Point
45
- field :route, type: Linestring
46
- field :area, type: Polygon
47
-
48
- # To query on your points, don't forget to index:
49
- # You may use a method:
50
- sphere_index :location # 2d
51
- # or
52
- spatial_index :location # 2dsphere
53
-
54
- # Or use a helper directly on the `field`:
55
- field :location, type: Point, spatial: true # 2d
56
- # or
57
- field :location, type: Point, sphere: true # 2dsphere
58
- end
31
+ # define your field, but choose a geometry type:
32
+ field :location, type: Point
33
+ field :route, type: LineString
34
+ field :area, type: Polygon
59
35
 
36
+ # To query on your points, don't forget to index:
37
+ # You may use a method:
38
+ sphere_index :location # 2dsphere
39
+ # or
40
+ spatial_index :location # 2d
60
41
 
42
+ # Or use a helper directly on the `field`:
43
+ field :location, type: Point, spatial: true # 2d
44
+ # or
45
+ field :location, type: Point, sphere: true # 2dsphere
46
+ end
47
+ ```
61
48
 
62
49
  Generate indexes on MongoDB via rake:
63
50
 
64
-
65
- rake db:mongoid:create_indexes
66
-
51
+ ```
52
+ rake db:mongoid:create_indexes
53
+ ```
67
54
 
68
55
  Or programatically:
69
56
 
57
+ ```ruby
58
+ Place.create_indexes
59
+ ```
70
60
 
71
- Place.create_indexes
72
-
61
+ ## Points
73
62
 
63
+ This gem defines a specific `Point` class under the Mongoid::Geospatial namespace. Make sure to use `type: ::Mongoid::Geospatial::Point` to avoid name errors or collisions with other `Point` classes you might already have defined `NameError`s.
74
64
 
75
- Points
76
- ------
65
+ Currently, MongoDB supports query operations on 2D points only, so that's what this lib does. All geometries apart from points are just arrays in the database. Here's is how you can input a point as:
77
66
 
78
- Currently, MongoDB supports query operations on 2D points only, so that's
79
- what this lib does. All geometries apart from points are just arrays
80
- in the database. Here's is how you can input a point as:
67
+ - longitude latitude array in that order - [long,lat] ([x, y])
68
+ - an unordered hash with latitude key(:lat, :latitude) and a longitude key(:lon, :long, :lng, :longitude)
69
+ - an ordered hash with longitude as the first item and latitude as the second item; this hash does not have include the latitude and longitude keys
70
+ - anything with the a method #to_xy or #to_lng_lat that converts itself to [long, lat] array
81
71
 
82
- * longitude latitude array in that order - [long,lat] ([x, y])
83
- * an unordered hash with latitude key(:lat, :latitude) and a longitude key(:lon, :long, :lng, :longitude)
84
- * an ordered hash with longitude as the first item and latitude as the second item
85
- This hash does not have include the latitude and longitude keys
86
- \*only works in ruby 1.9 and up because hashes below ruby 1.9 because they are not ordered
87
- * anything with the a method #to_xy or #to_lng_lat that converts itself to [long, lat] array
72
+ _Note: the convention of having longitude as the first coordinate may vary for other libraries. For instance, Google Maps often refer to "LatLng". Make sure you keep those differences in mind. See below for how to configure this library for LatLng._
88
73
 
89
74
  We store data in the DB as a [x, y] array then reformat when it is returned to you
90
75
 
91
-
92
- cafe = Place.create(
93
- name: 'Café Rider',
94
- location: {:lat => 44.106667, :lng => -73.935833},
95
- # or
96
- location: {latitude: 40.703056, longitude: -74.026667}
97
- #...
76
+ ```ruby
77
+ cafe = Place.create(
78
+ name: 'Café Rider',
79
+ location: {:lat => 44.106667, :lng => -73.935833},
80
+ # or
81
+ location: {latitude: 40.703056, longitude: -74.026667}
82
+ #...
83
+ ```
98
84
 
99
85
  Now to access this spatial information we can do this
100
86
 
101
- cafe.location # => [-74.026667, 40.703056]
87
+ ```ruby
88
+ cafe.location # => [-74.026667, 40.703056]
89
+ ```
102
90
 
103
91
  If you need a hash
104
92
 
105
- cafe.location.to_hsh # => { x: -74.026667, y: 40.703056 }
93
+ ```ruby
94
+ cafe.location.to_hsh # => { x: -74.026667, y: 40.703056 }
95
+ ```
106
96
 
107
97
  If you are using GeoRuby or RGeo
108
98
 
109
- cafe.location.to_geo # => GeoRuby::Point
110
-
111
- cafe.location.to_rgeo # => RGeo::Point
99
+ ```ruby
100
+ cafe.location.to_geo # => GeoRuby::Point
112
101
 
102
+ cafe.location.to_rgeo # => RGeo::Point
103
+ ```
113
104
 
114
105
  Conventions:
115
106
 
116
107
  This lib uses #x and #y everywhere.
117
108
  It's shorter than lat or lng or another variation that also confuses.
118
- A point is a 2D mathematical notation, longitude/latitude is when you
119
- use that notation to map an sphere. In other words:
120
- All longitudes are 'xs' where not all 'xs' are longitudes.
109
+ A point is a 2D mathematical notation, longitude/latitude is when you use that notation to map an sphere. In other words: all longitudes are 'xs' where not all 'xs' are longitudes.
121
110
 
122
- Distance and other geometrical calculations are delegated to the external
123
- library of your choice. More info about using RGeo or GeoRuby below.
124
- Some built in helpers for mongoid queries:
111
+ Distance and other geometrical calculations are delegated to the external library of your choice. More info about using RGeo or GeoRuby below. Some built in helpers for mongoid queries:
125
112
 
126
- # Returns middle point + radius
127
- # Useful to search #within_circle
128
- cafe.location.radius(5) # [[-74.., 40..], 5]
129
- cafe.location.radius_sphere(5) # [[-74.., 40..], 0.00048..]
130
-
131
- # Returns hash if needed
132
- cafe.location.to_hsh # {:x => -74.., :y => 40..}
133
- cafe.location.to_hsh(:lon, :lat) # {:lon => -74.., :lat => 40..}
113
+ ```ruby
114
+ # Returns middle point + radius
115
+ # Useful to search #within_circle
116
+ cafe.location.radius(5) # [[-74.., 40..], 5]
117
+ cafe.location.radius_sphere(5) # [[-74.., 40..], 0.00048..]
134
118
 
119
+ # Returns hash if needed
120
+ cafe.location.to_hsh # {:x => -74.., :y => 40..}
121
+ cafe.location.to_hsh(:lon, :lat) # {:lon => -74.., :lat => 40..}
122
+ ```
135
123
 
136
124
  And for polygons and lines:
137
125
 
138
- house.area.bbox # Returns polygon bounding_box (envelope)
139
- house.area.center # Returns calculate middle point
140
-
141
-
142
-
143
-
126
+ ```ruby
127
+ house.area.bbox # Returns polygon bounding_box (envelope)
128
+ house.area.center # Returns calculate middle point
129
+ ```
144
130
 
145
- Model Setup
146
- -----------
131
+ ## Model Setup
147
132
 
148
133
  You can create Point, Line, Circle, Box and Polygon on your models:
149
134
 
135
+ ```ruby
136
+ class CrazyGeom
137
+ include Mongoid::Document
138
+ include Mongoid::Geospatial
150
139
 
151
- class CrazyGeom
152
- include Mongoid::Document
153
- include Mongoid::Geospatial
154
-
155
- field :location, type: Point, spatial: true, delegate: true
156
-
157
- field :route, type: Line
158
- field :area, type: Polygon
140
+ field :location, type: Point, spatial: true, delegate: true
159
141
 
160
- field :square, type: Box
161
- field :around, type: Circle
142
+ field :route, type: Line
143
+ field :area, type: Polygon
162
144
 
163
- # default mongodb options
164
- spatial_index :location, {bit: 24, min: -180, max: 180}
145
+ field :square, type: Box
146
+ field :around, type: Circle
165
147
 
166
- # query by location
167
- spatial_scope :location
168
- end
148
+ # default mongodb options
149
+ spatial_index :location, {bit: 24, min: -180, max: 180}
169
150
 
151
+ # query by location
152
+ spatial_scope :location
153
+ end
154
+ ```
170
155
 
171
- Helpers
172
- -------
156
+ ## Helpers
173
157
 
174
158
  You can use `spatial: true` to add a '2d' index automatically,
175
159
  No need for `spatial_index :location`:
176
160
 
161
+ ```ruby
162
+ field :location, type: Point, spatial: true
163
+ ```
177
164
 
178
- field :location, type: Point, spatial: true
179
-
180
-
181
- And you can use `sphere: true` to add a '2dsphere' index automatically,
182
- No need for `spatial_sphere :location`:
183
-
184
-
185
- field :location, type: Point, sphere: true
165
+ And you can use `sphere: true` to add a '2dsphere' index automatically, no need for `spatial_sphere :location`:
186
166
 
167
+ ```ruby
168
+ field :location, type: Point, sphere: true
169
+ ```
187
170
 
188
171
  You can delegate some point methods to the instance itself:
189
172
 
190
-
191
- field :location, type: Point, delegate: true
192
-
173
+ ```ruby
174
+ field :location, type: Point, delegate: true
175
+ ```
193
176
 
194
177
  Now instead of `instance.location.x` you may call `instance.x`.
195
178
 
196
-
197
- Nearby
198
- ------
179
+ ## Nearby
199
180
 
200
181
  You can add a `spatial_scope` on your models. So you can query:
201
182
 
202
- Bar.nearby(my.location)
183
+ ```ruby
184
+ Bar.nearby(my.location)
185
+ ```
203
186
 
204
187
  instead of
205
188
 
206
- Bar.near(location: my.location)
189
+ ```ruby
190
+ Bar.near(location: my.location)
191
+ ```
207
192
 
208
193
  Good when you're drunk. Just add to your model:
209
194
 
210
- spatial_scope :<field>
211
-
212
-
195
+ ```ruby
196
+ spatial_scope :<field>
197
+ ```
213
198
 
214
- Geometry
215
- --------
199
+ ## Geometry
216
200
 
217
201
  You can also store Circle, Box, Line (LineString) and Polygons.
218
202
  Some helper methods are available to them:
219
203
 
204
+ ```ruby
205
+ # Returns a geometry bounding box
206
+ # Useful to query #within_geometry
207
+ polygon.bbox
208
+ polygon.bounding_box
220
209
 
221
- # Returns a geometry bounding box
222
- # Useful to query #within_geometry
223
- polygon.bbox
224
- polygon.bounding_box
225
-
226
- # Returns a geometry calculated middle point
227
- # Useful to query for #near
228
- polygon.center
229
-
230
- # Returns middle point + radius
231
- # Useful to search #within_circle
232
- polygon.radius(5) # [[1.0, 1.0], 5]
233
- polygon.radius_sphere(5) # [[1.0, 1.0], 0.00048..]
210
+ # Returns a geometry calculated middle point
211
+ # Useful to query for #near
212
+ polygon.center
234
213
 
214
+ # Returns middle point + radius
215
+ # Useful to search #within_circle
216
+ polygon.radius(5) # [[1.0, 1.0], 5]
217
+ polygon.radius_sphere(5) # [[1.0, 1.0], 0.00048..]
218
+ ```
235
219
 
236
- Query
237
- -----
220
+ ## Query
238
221
 
239
- Before you read about this gem have sure you read this:
222
+ Before you proceed, make sure you have read this:
240
223
 
241
- http://mongoid.org/en/origin/docs/selection.html#standard
224
+ http://mongoid.github.io/old/en/origin/docs/selection.html#standard
242
225
 
243
226
  All MongoDB queries are handled by Mongoid/Origin.
244
227
 
@@ -246,80 +229,75 @@ http://www.rubydoc.info/github/mongoid/origin/Origin/Selectable
246
229
 
247
230
  You can use Geometry instance directly on any query:
248
231
 
249
- * near
250
-
232
+ - near
251
233
 
252
- ```
234
+ ```ruby
253
235
  Bar.near(location: person.house)
254
236
  Bar.where(:location.near => person.house)
255
237
  ```
256
238
 
257
- * near_sphere
239
+ - near_sphere
258
240
 
259
- ```
241
+ ```ruby
260
242
  Bar.near_sphere(location: person.house)
261
243
  Bar.where(:location.near_sphere => person.house)
262
244
  ```
263
245
 
264
- * within_polygon
246
+ - within_polygon
265
247
 
266
- ```
248
+ ```ruby
267
249
  Bar.within_polygon(location: [[[x,y],...[x,y]]])
268
250
  # or with a bbox
269
251
  Bar.within_polygon(location: street.bbox)
270
252
  ```
271
253
 
254
+ - intersects_line
255
+ - intersects_point
256
+ - intersects_polygon
272
257
 
273
- * intersects_line
274
- * intersects_point
275
- * intersects_polygon
276
-
277
-
278
-
279
- External Libraries
280
- ------------------
258
+ ## External Libraries
281
259
 
282
260
  We currently support GeoRuby and RGeo.
283
261
  If you require one of those, a #to_geo and #to_rgeo, respectivelly,
284
262
  method(s) will be available to all spatial fields, returning the
285
263
  external library corresponding object.
286
264
 
287
-
288
265
  ### Use RGeo?
266
+
289
267
  https://github.com/dazuma/rgeo
290
268
 
291
269
  RGeo is a Ruby wrapper for Proj/GEOS.
292
270
  It's perfect when you need to work with complex calculations and projections.
293
271
  It'll require more stuff installed to compile/work.
294
272
 
295
-
296
273
  ### Use GeoRuby?
274
+
297
275
  https://github.com/nofxx/georuby
298
276
 
299
277
  GeoRuby is a pure Ruby Geometry Library.
300
278
  It's perfect if you want simple calculations and/or keep your stack in pure ruby.
301
279
  Albeit not full featured in maths it has a handful of methods and good import/export helpers.
302
280
 
303
-
304
281
  ### Example
305
282
 
306
- class Person
307
- include Mongoid::Document
308
- include Mongoid::Geospatial
283
+ ```ruby
284
+ class Person
285
+ include Mongoid::Document
286
+ include Mongoid::Geospatial
309
287
 
310
- field :location, type: Point
311
- end
288
+ field :location, type: Point
289
+ end
312
290
 
313
- me = Person.new(location: [8, 8])
291
+ me = Person.new(location: [8, 8])
314
292
 
315
- # Example with GeoRuby
316
- point.class # Mongoid::Geospatial::Point
317
- point.to_geo.class # GeoRuby::SimpleFeatures::Point
318
-
319
- # Example with RGeo
320
- point.class # Mongoid::Geospatial::Point
321
- point.to_rgeo.class # RGeo::Geographic::SphericalPointImpl
293
+ # Example with GeoRuby
294
+ point.class # Mongoid::Geospatial::Point
295
+ point.to_geo.class # GeoRuby::SimpleFeatures::Point
322
296
 
297
+ # Example with RGeo
298
+ point.class # Mongoid::Geospatial::Point
299
+ point.to_rgeo.class # RGeo::Geographic::SphericalPointImpl
300
+ ```
323
301
 
324
302
  ## Configure
325
303
 
@@ -327,70 +305,82 @@ Assemble it as you need (use a initializer file):
327
305
 
328
306
  With RGeo
329
307
 
330
- Mongoid::Geospatial.with_rgeo!
331
- # Optional
332
- # Mongoid::Geospatial.factory = RGeo::Geographic.spherical_factory
333
-
308
+ ```ruby
309
+ Mongoid::Geospatial.with_rgeo!
310
+ # Optional
311
+ # Mongoid::Geospatial.factory = RGeo::Geographic.spherical_factory
312
+ ```
334
313
 
335
314
  With GeoRuby
336
315
 
337
- Mongoid::Geospatial.with_georuby!
338
-
339
-
340
- Defaults (change if you know what you're doing)
316
+ ```ruby
317
+ Mongoid::Geospatial.with_georuby!
318
+ ```
341
319
 
342
- Mongoid::Geospatial.lng_symbol = :x
343
- Mongoid::Geospatial.lat_symbol = :y
344
- Mongoid::Geospatial.earth_radius = EARTH_RADIUS
320
+ By default the convention of this library is LngLat, configure it for LatLng as follows.
345
321
 
322
+ ```ruby
323
+ Mongoid::Geospatial.configure do |config|
324
+ config.point.x = Mongoid::Geospatial.lat_symbols
325
+ config.point.y = Mongoid::Geospatial.lng_symbols
326
+ end
327
+ ```
346
328
 
329
+ You will need to manually migrate any existing `Point` data if you change configuration in an existing system.
347
330
 
348
- This Fork
349
- ---------
331
+ ## This Fork
350
332
 
351
333
  This fork is not backwards compatible with 'mongoid_spacial'.
352
334
  This fork delegates calculations to external libs.
353
335
 
354
336
  Change in your models:
355
337
 
356
- include Mongoid::Spacial::Document
338
+ ```ruby
339
+ include Mongoid::Spacial::Document
340
+ ```
357
341
 
358
342
  to
359
343
 
360
- include Mongoid::Geospatial
361
-
344
+ ```ruby
345
+ include Mongoid::Geospatial
346
+ ```
362
347
 
363
348
  And for the fields:
364
349
 
365
-
366
- field :source, type: Array, spacial: true
350
+ ```ruby
351
+ field :source, type: Array, spacial: true
352
+ ```
367
353
 
368
354
  to
369
355
 
370
- field :source, type: Point, spatial: true # or sphere: true
371
-
356
+ ```ruby
357
+ field :source, type: Point, spatial: true # or sphere: true
358
+ ```
372
359
 
373
360
  Beware the 't' and 'c' issue. It's spaTial.
374
361
 
375
-
376
-
377
- Troubleshooting
378
- ---------------
362
+ ## Troubleshooting
379
363
 
380
364
  **Mongo::OperationFailure: can't find special index: 2d**
381
365
 
382
366
  Indexes need to be created. Execute command:
383
367
 
384
- rake db:mongoid:create_indexes
368
+ ```
369
+ rake db:mongoid:create_indexes
370
+ ```
385
371
 
386
372
  Programatically
387
373
 
388
- Model.create_indexes
374
+ ```
375
+ Model.create_indexes
376
+ ```
377
+
378
+ ## Contributing
379
+
380
+ See [CONTRIBUTING](CONTRIBUTING.md).
389
381
 
382
+ ## License
390
383
 
391
- Contributing
392
- ------------
384
+ Copyright (c) 2009-2017 Mongoid Geospatial Authors
393
385
 
394
- * Have mongod running
395
- * Install dev gems with `bundle install`
396
- * Run `rake spec`, `spec spec` or `guard`
386
+ MIT License, see [MIT-LICENSE](MIT-LICENSE).
data/RELEASING.md ADDED
@@ -0,0 +1,62 @@
1
+ Releasing Mongoid::Geospatial
2
+ =============================
3
+
4
+ There're no particular rules about when to release mongoid-geospatial. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
5
+
6
+ ### Release
7
+
8
+ Run tests, check that all tests succeed locally.
9
+
10
+ ```
11
+ bundle install
12
+ bundle exec rake
13
+ ```
14
+
15
+ Check that the last build succeeded in [Travis CI](https://travis-ci.org/mongoid/mongoid-geospatial) for all supported platforms.
16
+
17
+ Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
18
+
19
+ ```
20
+ ### 0.4.0 (2014-01-27)
21
+ ```
22
+
23
+ Remove the line with "Your contribution here.", since there will be no more contributions to this release.
24
+
25
+ Commit your changes.
26
+
27
+ ```
28
+ git add CHANGELOG.md lib/mongoid/geospatial/version.rb
29
+ git commit -m "Preparing for release, 0.4.0."
30
+ git push origin master
31
+ ```
32
+
33
+ Release.
34
+
35
+ ```
36
+ $ rake release
37
+
38
+ mongoid-geospatial 0.4.0 built to pkg/mongoid-geospatial-0.4.0.gem.
39
+ Tagged v0.4.0.
40
+ Pushed git commits and tags.
41
+ Pushed mongoid-geospatial 0.4.0 to rubygems.org.
42
+ ```
43
+
44
+ ### Prepare for the Next Version
45
+
46
+ Add the next release to [CHANGELOG.md](CHANGELOG.md).
47
+
48
+ ```
49
+ ### 0.4.1 (Next)
50
+
51
+ * Your contribution here.
52
+ ```
53
+
54
+ Increment the minor version, modify [lib/mongoid/geospatial/version.rb](lib/mongoid/geospatial/version.rb).
55
+
56
+ Commit your changes.
57
+
58
+ ```
59
+ git add CHANGELOG.md lib/mongoid/geospatial/version.rb
60
+ git commit -m "Preparing for next developer iteration, 0.4.1."
61
+ git push origin master
62
+ ```
data/Rakefile CHANGED
@@ -12,6 +12,9 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
12
12
  spec.rcov = true
13
13
  end
14
14
 
15
- task default: :spec
15
+ require 'rubocop/rake_task'
16
+ RuboCop::RakeTask.new(:rubocop)
17
+
18
+ task default: %i[rubocop spec]
16
19
 
17
20
  require 'yard'
@@ -0,0 +1,19 @@
1
+ module Mongoid
2
+ module Geospatial
3
+ module Config
4
+ module Point
5
+ extend self
6
+
7
+ attr_accessor :x
8
+ attr_accessor :y
9
+
10
+ def reset!
11
+ self.x = Mongoid::Geospatial.lng_symbols
12
+ self.y = Mongoid::Geospatial.lat_symbols
13
+ end
14
+
15
+ reset!
16
+ end
17
+ end
18
+ end
19
+ end