mongoid-geospatial 7.0.0 → 7.2.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +109 -33
  3. data/lib/mongoid/geospatial/config/point.rb +5 -2
  4. data/lib/mongoid/geospatial/config.rb +2 -0
  5. data/lib/mongoid/geospatial/ext/rgeo_spherical_point_impl.rb +2 -0
  6. data/lib/mongoid/geospatial/fields/box.rb +2 -0
  7. data/lib/mongoid/geospatial/fields/circle.rb +2 -2
  8. data/lib/mongoid/geospatial/fields/line_string.rb +2 -0
  9. data/lib/mongoid/geospatial/fields/point.rb +59 -50
  10. data/lib/mongoid/geospatial/fields/polygon.rb +2 -0
  11. data/lib/mongoid/geospatial/geometry_field.rb +4 -2
  12. data/lib/mongoid/geospatial/helpers/delegate.rb +2 -0
  13. data/lib/mongoid/geospatial/helpers/geom.rb +22 -0
  14. data/lib/mongoid/geospatial/helpers/spatial.rb +2 -0
  15. data/lib/mongoid/geospatial/helpers/sphere.rb +2 -0
  16. data/lib/mongoid/geospatial/keys.rb +20 -0
  17. data/lib/mongoid/geospatial/version.rb +3 -1
  18. data/lib/mongoid/geospatial/wrappers/georuby.rb +2 -0
  19. data/lib/mongoid/geospatial/wrappers/rgeo.rb +2 -0
  20. data/lib/mongoid/geospatial.rb +196 -16
  21. metadata +7 -75
  22. data/.coveralls.yml +0 -1
  23. data/.gitignore +0 -49
  24. data/.hound.yml +0 -2
  25. data/.rspec +0 -3
  26. data/.rubocop.yml +0 -8
  27. data/.travis.yml +0 -33
  28. data/CHANGELOG.md +0 -23
  29. data/CONTRIBUTING.md +0 -118
  30. data/Gemfile +0 -17
  31. data/Guardfile +0 -16
  32. data/RELEASING.md +0 -62
  33. data/Rakefile +0 -20
  34. data/mongoid-geospatial.gemspec +0 -18
  35. data/spec/bench +0 -64
  36. data/spec/models/address.rb +0 -69
  37. data/spec/models/alarm.rb +0 -12
  38. data/spec/models/bar.rb +0 -14
  39. data/spec/models/bus.rb +0 -12
  40. data/spec/models/event.rb +0 -18
  41. data/spec/models/farm.rb +0 -13
  42. data/spec/models/person.rb +0 -91
  43. data/spec/models/phone.rb +0 -8
  44. data/spec/models/place.rb +0 -13
  45. data/spec/models/river.rb +0 -22
  46. data/spec/mongoid/geospatial/config_spec.rb +0 -22
  47. data/spec/mongoid/geospatial/fields/box_spec.rb +0 -8
  48. data/spec/mongoid/geospatial/fields/circle_spec.rb +0 -8
  49. data/spec/mongoid/geospatial/fields/line_string_spec.rb +0 -78
  50. data/spec/mongoid/geospatial/fields/point_spec.rb +0 -296
  51. data/spec/mongoid/geospatial/fields/polygon_spec.rb +0 -87
  52. data/spec/mongoid/geospatial/geospatial_spec.rb +0 -222
  53. data/spec/mongoid/geospatial/helpers/core_spec.rb +0 -35
  54. data/spec/mongoid/geospatial/helpers/delegate_spec.rb +0 -67
  55. data/spec/mongoid/geospatial/helpers/spatial_spec.rb +0 -40
  56. data/spec/mongoid/geospatial/helpers/sphere_spec.rb +0 -31
  57. data/spec/mongoid/geospatial/wrappers/georuby_spec.rb +0 -63
  58. data/spec/mongoid/geospatial/wrappers/rgeo_spec.rb +0 -115
  59. data/spec/mongoid.yml +0 -298
  60. data/spec/spec_helper.rb +0 -42
  61. data/spec/support/authentication.rb +0 -28
  62. data/spec/support/mongod.conf +0 -3
  63. data/spec/support/mongoid.yml +0 -19
@@ -1,8 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mongoid'
2
4
  require 'active_support/concern' # Explicitly require for `extend ActiveSupport::Concern`
3
5
  require 'mongoid/geospatial/helpers/spatial'
4
6
  require 'mongoid/geospatial/helpers/sphere'
5
7
  require 'mongoid/geospatial/helpers/delegate'
8
+ require 'mongoid/geospatial/helpers/geom'
9
+ require 'mongoid/geospatial/keys'
6
10
 
7
11
  module Mongoid
8
12
  #
@@ -67,6 +71,27 @@ module Mongoid
67
71
  require 'mongoid/geospatial/wrappers/georuby'
68
72
  end
69
73
 
74
+ #
75
+ # A [lng, lat] pair, or nothing. `Point.mongoize` is lenient — it reads
76
+ # "nowhere" as [0.0] — and a half pair is a query Mongo cannot answer.
77
+ #
78
+ def self.mongoize_point!(geom)
79
+ coords = Point.mongoize(geom)
80
+ unless coords.is_a?(Array) && coords.size == 2 && coords.all?(Numeric)
81
+ raise ArgumentError, "Invalid coordinates: #{geom.inspect}"
82
+ end
83
+
84
+ coords
85
+ end
86
+
87
+ #
88
+ # Selector for `$nearSphere` with a km cap. Metres on the wire.
89
+ #
90
+ def self.near_query(geom, km) # rubocop:disable Naming/MethodParameterName
91
+ { '$geometry' => { 'type' => 'Point', 'coordinates' => mongoize_point!(geom) },
92
+ '$maxDistance' => km * 1_000 }
93
+ end
94
+
70
95
  # Methods applied to Document's class
71
96
  module ClassMethods
72
97
  #
@@ -90,6 +115,46 @@ module Mongoid
90
115
  spatial_fields_indexed << name
91
116
  index({ name => '2dsphere' }, options)
92
117
  end
118
+ alias sphere_index spherical_index
119
+
120
+ #
121
+ # A Point on a 2dsphere index. Default name is `geom`.
122
+ #
123
+ def geom(name = :geom)
124
+ field name, type: Point, sphere: true
125
+ end
126
+
127
+ #
128
+ # # Queries
129
+ #
130
+ # MongoDB provides the following geospatial query operators.
131
+ #
132
+ # $geoIntersects
133
+ # Selects geometries that intersect with a GeoJSON geometry.
134
+ # The 2dsphere index supports $geoIntersects.
135
+ #
136
+ # $geoWithin
137
+ # Selects geometries within a bounding GeoJSON geometry.
138
+ # The 2dsphere and 2d indexes support $geoWithin.
139
+ #
140
+ # $near
141
+ # Returns geospatial objects in proximity to a point.
142
+ # Requires a geospatial index. The 2dsphere and 2d indexes support $near.
143
+ #
144
+ # $nearSphere
145
+ # Returns geospatial objects in proximity to a point on a sphere.
146
+ # Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere.
147
+ #
148
+ # # Aggregation
149
+ #
150
+ # MongoDB provides the following geospatial aggregation pipeline stage:
151
+ #
152
+ # $geoNear
153
+ # Returns an ordered stream of documents based on the proximity to a geospatial point.
154
+ # Incorporates the functionality of $match, $sort, and $limit for geospatial data.
155
+ # The output documents include an additional distance field and can include a location identifier field.
156
+ # $geoNear requires a geospatial index.
157
+ #
93
158
 
94
159
  #
95
160
  # Defines a class method to find the closest document to a given point
@@ -129,7 +194,7 @@ module Mongoid
129
194
  merged_options[:spherical]
130
195
  else
131
196
  # self.fields uses string keys for field names
132
- field_def = self.fields[field_name.to_s]
197
+ field_def = fields[field_name.to_s]
133
198
  field_def && field_def.options[:sphere]
134
199
  end
135
200
  query_operator = is_spherical ? :near_sphere : :near
@@ -143,15 +208,15 @@ module Mongoid
143
208
  {
144
209
  # Using $geometry for clarity when $maxDistance is used,
145
210
  # which is standard for $near/$nearSphere operators.
146
- "$geometry" => { type: "Point", coordinates: mongoized_coords },
147
- "$maxDistance" => merged_options[:max_distance].to_f
211
+ '$geometry' => { type: 'Point', coordinates: mongoized_coords },
212
+ '$maxDistance' => merged_options[:max_distance].to_f
148
213
  }
149
214
  else
150
215
  mongoized_coords # Simple array [lng, lat] for the operator
151
216
  end
152
217
 
153
218
  # Start with a base criteria, applying an optional filter query
154
- current_criteria = merged_options[:query] ? self.where(merged_options[:query]) : self.all
219
+ current_criteria = merged_options[:query] ? where(merged_options[:query]) : all
155
220
 
156
221
  # Apply the geospatial query. $near and $nearSphere queries return sorted results.
157
222
  current_criteria.where(field_name_sym.send(query_operator) => geo_query_value)
@@ -167,33 +232,148 @@ module Mongoid
167
232
  #
168
233
  # @param coordinates [Array, Mongoid::Geospatial::Point] The coordinates (e.g., [lon, lat])
169
234
  # or a Point object to find documents near to.
170
- # @param _options [Hash] Optional hash for future extensions (currently unused).
235
+ # @param km [Numeric, nil] Optional cap in kilometres (`$maxDistance` in metres).
171
236
  #
172
237
  # @return [Mongoid::Criteria] A criteria object for the query.
173
238
  #
174
239
  # Example:
175
240
  # Bar.nearby([10, 20])
176
- # Alarm.nearby(my_point_object)
241
+ # Alarm.nearby(my_point_object, km: 30)
177
242
  #
178
- def nearby(coordinates, _options = {})
179
- if self.spatial_fields.empty?
180
- raise "No spatial fields defined for #{self.name} to use with .nearby. " \
243
+ def nearby(coordinates, km: nil, **_opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Naming/MethodParameterName
244
+ if spatial_fields.empty?
245
+ raise "No spatial fields defined for #{name} to use with .nearby. " \
181
246
  "Mark a field with 'spatial: true' or 'sphere: true'."
182
247
  end
183
248
 
184
- field_name_sym = self.spatial_fields.first.to_sym
185
- field_definition = self.fields[field_name_sym.to_s]
249
+ field_name_sym = spatial_fields.first.to_sym
250
+ field_definition = fields[field_name_sym.to_s]
186
251
 
187
- unless field_definition
188
- raise "Could not find field definition for spatial field: #{field_name_sym}"
252
+ raise "Could not find field definition for spatial field: #{field_name_sym}" unless field_definition
253
+
254
+ if km
255
+ # GeoJSON `$maxDistance` is metres. `$near` on a 2d index is radians.
256
+ query = Mongoid::Geospatial.near_query(coordinates, km)
257
+ criteria.where(field_name_sym.near_sphere => query)
258
+ else
259
+ query_operator = field_definition.options[:sphere] ? :near_sphere : :near
260
+ criteria.where(field_name_sym.send(query_operator) => coordinates)
189
261
  end
262
+ end
190
263
 
191
- query_operator = field_definition.options[:sphere] ? :near_sphere : :near
264
+ #
265
+ # Documents within +km+ of +geom+, nearest first.
266
+ # `$nearSphere` + `$maxDistance` in metres.
267
+ #
268
+ def within(geom, km) # rubocop:disable Naming/MethodParameterName
269
+ nearby(geom, km: km)
270
+ end
271
+
272
+ # Performs a $geoNear aggregation pipeline stage to find documents near a point,
273
+ # returning them sorted by distance and including the distance.
274
+ #
275
+ # This method is a wrapper around the MongoDB `$geoNear` aggregation stage,
276
+ # which allows for more complex queries and options than the simple `near` or `near_sphere` methods.
277
+ #
278
+ # * But it's not chainable like a standard Mongoid query *
279
+ #
280
+ # @param field_name [String, Symbol] The name of the geospatial field to query.
281
+ # This field must be indexed with a geospatial index (2d or 2dsphere).
282
+ # @param coordinates [Array, Hash, Mongoid::Geospatial::Point] The point to search near.
283
+ # Examples: `[lng, lat]`, `{ type: 'Point', coordinates: [lng, lat] }`, a `Mongoid::Geospatial::Point` object.
284
+ # @param options [Hash] Options for the $geoNear stage.
285
+ # Key options include:
286
+ # - `:spherical` [Boolean] If true, calculates distances using spherical geometry. Defaults to `false`.
287
+ # - `:distanceField` [String] Name of the output field that will contain the distance. Defaults to `'distance'`.
288
+ # - `:maxDistance` [Numeric] The maximum distance from the center point that documents can be.
289
+ # For spherical queries, specify distance in meters. For 2d queries, in the same units as coordinates.
290
+ # - `:minDistance` [Numeric] The minimum distance. (MongoDB 2.6+)
291
+ # - `:query` [Hash] Limits the results to the documents that match the query.
292
+ # - `:limit` [Integer] The maximum number of documents to return (applied as a separate `$limit` pipeline stage).
293
+ # - `:distanceMultiplier` [Numeric] A factor to multiply all distances returned by the query.
294
+ # - `:includeLocs` [String] Specifies the name of the output field that identifies the location used to calculate the distance.
295
+ # This is useful when the queried field contains multiple locations (e.g., an array of points) or complex GeoJSON
296
+ # geometries (e.g., a Polygon), as it shows which specific point was used for the distance calculation.
297
+ # Example: `includeLocs: 'matchedPoint'` would add a `matchedPoint` field to each output document.
298
+ #
299
+ # @return [Array<Mongoid::Document>] An array of instantiated Mongoid documents.
300
+ # Each document will include its original fields plus any fields added by the `$geoNear` stage,
301
+ # such as the field specified by `:distanceField` (e.g., `document.distance`) and `:includeLocs`.
302
+ # These additional fields are accessible as dynamic attributes on the model instances.
303
+ #
304
+ # @raise [ArgumentError] If coordinates cannot be mongoized.
305
+ #
306
+ # Example:
307
+ # # Find places near [10, 20], using spherical calculations, up to 5km away
308
+ # Place.geo_near(:location, [10, 20],
309
+ # spherical: true,
310
+ # maxDistance: 5000, # 5 kilometers in meters
311
+ # distanceField: 'dist.calculated',
312
+ # query: { category: 'restaurant' },
313
+ # limit: 10)
314
+ #
315
+ # # Iterate over results
316
+ # Place.geo_near(:location, [10, 20], spherical: true).each do |place|
317
+ # puts "#{place.name} is #{place.distance} meters away." # Assumes distanceField is 'distance'
318
+ # end
319
+ #
320
+ def geo_near(field_name, coordinates, options = {})
321
+ mongoized_coords = Mongoid::Geospatial.mongoize_point!(coordinates)
322
+
323
+ # User-provided options. Work with a copy.
324
+ user_options = options.dup
325
+ limit_value = user_options.delete(:limit) # Handled by a separate pipeline stage
326
+
327
+ # `km:` is metres on the wire, and metres only holds for a GeoJSON
328
+ # `near` on a sphere. A legacy pair would read `maxDistance` in radians.
329
+ if (km = user_options.delete(:km))
330
+ user_options[:maxDistance] = km.to_f * 1_000
331
+ user_options[:spherical] = true
332
+ mongoized_coords = { 'type' => 'Point', 'coordinates' => mongoized_coords }
333
+ end
334
+
335
+ # Core $geoNear parameters derived from method arguments, these are not overrideable by user_options.
336
+ geo_near_core_params = {
337
+ key: field_name.to_s,
338
+ near: mongoized_coords
339
+ }
340
+
341
+ # Defaultable $geoNear parameters. User options will override these.
342
+ geo_near_defaultable_params = {
343
+ distanceField: 'distance',
344
+ spherical: false # Default to planar (2d) calculations
345
+ }
192
346
 
193
- criteria.where(field_name_sym.send(query_operator) => coordinates)
347
+ # Merge user options over defaults, then ensure core parameters are set.
348
+ geo_near_stage_options = geo_near_defaultable_params.merge(user_options).merge(geo_near_core_params)
349
+
350
+ # $geoNear wants a strict boolean, and honours the caller's choice.
351
+ geo_near_stage_options[:spherical] = geo_near_stage_options[:spherical] ? true : false
352
+
353
+ # Note on performance:
354
+ # $geoNear is an aggregation pipeline stage. For simple proximity queries,
355
+ # it might exhibit slightly higher "real" time (wall-clock time) in benchmarks
356
+ # compared to direct query operators like $near or $nearSphere. This is often
357
+ # due to the inherent overhead of the aggregation framework versus a direct query.
358
+ # However, $geoNear offers more capabilities, such as returning the distance
359
+ # (distanceField), distanceMultiplier, includeLocs, and integrating with other
360
+ # aggregation stages, which are not available with $near/$nearSphere.
361
+ pipeline = [{ '$geoNear' => geo_near_stage_options }]
362
+
363
+ # Add $limit stage if limit_value was provided
364
+ pipeline << { '$limit' => limit_value.to_i } if limit_value
365
+
366
+ # Execute the aggregation pipeline
367
+ collection.aggregate(pipeline)
368
+
369
+ # Don't instantiate results here.
370
+ # aggregated_results = collection.aggregate(pipeline)
371
+ # Map the raw Hash results from aggregation to Mongoid model instances.
372
+ # Mongoid's #instantiate method correctly handles creating model objects
373
+ # and assigning attributes, including dynamic ones like the distanceField.
374
+ # aggregated_results.map { |attrs| instantiate(attrs) }
194
375
  end
195
376
  end
196
377
  end
197
378
  end
198
-
199
379
  require 'mongoid/geospatial/config'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-geospatial
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ong
@@ -32,20 +32,8 @@ executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - ".coveralls.yml"
36
- - ".gitignore"
37
- - ".hound.yml"
38
- - ".rspec"
39
- - ".rubocop.yml"
40
- - ".travis.yml"
41
- - CHANGELOG.md
42
- - CONTRIBUTING.md
43
- - Gemfile
44
- - Guardfile
45
35
  - MIT-LICENSE
46
36
  - README.md
47
- - RELEASING.md
48
- - Rakefile
49
37
  - lib/mongoid/geospatial.rb
50
38
  - lib/mongoid/geospatial/config.rb
51
39
  - lib/mongoid/geospatial/config/point.rb
@@ -57,45 +45,18 @@ files:
57
45
  - lib/mongoid/geospatial/fields/polygon.rb
58
46
  - lib/mongoid/geospatial/geometry_field.rb
59
47
  - lib/mongoid/geospatial/helpers/delegate.rb
48
+ - lib/mongoid/geospatial/helpers/geom.rb
60
49
  - lib/mongoid/geospatial/helpers/spatial.rb
61
50
  - lib/mongoid/geospatial/helpers/sphere.rb
51
+ - lib/mongoid/geospatial/keys.rb
62
52
  - lib/mongoid/geospatial/version.rb
63
53
  - lib/mongoid/geospatial/wrappers/georuby.rb
64
54
  - lib/mongoid/geospatial/wrappers/rgeo.rb
65
- - mongoid-geospatial.gemspec
66
- - spec/bench
67
- - spec/models/address.rb
68
- - spec/models/alarm.rb
69
- - spec/models/bar.rb
70
- - spec/models/bus.rb
71
- - spec/models/event.rb
72
- - spec/models/farm.rb
73
- - spec/models/person.rb
74
- - spec/models/phone.rb
75
- - spec/models/place.rb
76
- - spec/models/river.rb
77
- - spec/mongoid.yml
78
- - spec/mongoid/geospatial/config_spec.rb
79
- - spec/mongoid/geospatial/fields/box_spec.rb
80
- - spec/mongoid/geospatial/fields/circle_spec.rb
81
- - spec/mongoid/geospatial/fields/line_string_spec.rb
82
- - spec/mongoid/geospatial/fields/point_spec.rb
83
- - spec/mongoid/geospatial/fields/polygon_spec.rb
84
- - spec/mongoid/geospatial/geospatial_spec.rb
85
- - spec/mongoid/geospatial/helpers/core_spec.rb
86
- - spec/mongoid/geospatial/helpers/delegate_spec.rb
87
- - spec/mongoid/geospatial/helpers/spatial_spec.rb
88
- - spec/mongoid/geospatial/helpers/sphere_spec.rb
89
- - spec/mongoid/geospatial/wrappers/georuby_spec.rb
90
- - spec/mongoid/geospatial/wrappers/rgeo_spec.rb
91
- - spec/spec_helper.rb
92
- - spec/support/authentication.rb
93
- - spec/support/mongod.conf
94
- - spec/support/mongoid.yml
95
55
  homepage: https://github.com/mongoid/mongoid-geospatial
96
56
  licenses:
97
57
  - MIT
98
- metadata: {}
58
+ metadata:
59
+ rubygems_mfa_required: 'true'
99
60
  rdoc_options: []
100
61
  require_paths:
101
62
  - lib
@@ -103,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
64
  requirements:
104
65
  - - ">="
105
66
  - !ruby/object:Gem::Version
106
- version: '0'
67
+ version: 3.1.0
107
68
  required_rubygems_version: !ruby/object:Gem::Requirement
108
69
  requirements:
109
70
  - - ">="
@@ -113,33 +74,4 @@ requirements: []
113
74
  rubygems_version: 3.6.7
114
75
  specification_version: 4
115
76
  summary: Mongoid Extension that simplifies MongoDB Geospatial Operations.
116
- test_files:
117
- - spec/bench
118
- - spec/models/address.rb
119
- - spec/models/alarm.rb
120
- - spec/models/bar.rb
121
- - spec/models/bus.rb
122
- - spec/models/event.rb
123
- - spec/models/farm.rb
124
- - spec/models/person.rb
125
- - spec/models/phone.rb
126
- - spec/models/place.rb
127
- - spec/models/river.rb
128
- - spec/mongoid.yml
129
- - spec/mongoid/geospatial/config_spec.rb
130
- - spec/mongoid/geospatial/fields/box_spec.rb
131
- - spec/mongoid/geospatial/fields/circle_spec.rb
132
- - spec/mongoid/geospatial/fields/line_string_spec.rb
133
- - spec/mongoid/geospatial/fields/point_spec.rb
134
- - spec/mongoid/geospatial/fields/polygon_spec.rb
135
- - spec/mongoid/geospatial/geospatial_spec.rb
136
- - spec/mongoid/geospatial/helpers/core_spec.rb
137
- - spec/mongoid/geospatial/helpers/delegate_spec.rb
138
- - spec/mongoid/geospatial/helpers/spatial_spec.rb
139
- - spec/mongoid/geospatial/helpers/sphere_spec.rb
140
- - spec/mongoid/geospatial/wrappers/georuby_spec.rb
141
- - spec/mongoid/geospatial/wrappers/rgeo_spec.rb
142
- - spec/spec_helper.rb
143
- - spec/support/authentication.rb
144
- - spec/support/mongod.conf
145
- - spec/support/mongoid.yml
77
+ test_files: []
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/.gitignore DELETED
@@ -1,49 +0,0 @@
1
- Gemfile.lock
2
- # rcov generated
3
- coverage
4
-
5
- # rdoc generated
6
- rdoc
7
-
8
- # yard generated
9
- doc
10
- .yardoc
11
-
12
- # bundler
13
- .bundle
14
-
15
- # jeweler generated
16
- pkg
17
-
18
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
- #
20
- # * Create a file at ~/.gitignore
21
- # * Include files you want ignored
22
- # * Run: git config --global core.excludesfile ~/.gitignore
23
- #
24
- # After doing this, these files will be ignored in all your git projects,
25
- # saving you from having to 'pollute' every project you touch with them
26
- #
27
- # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
- #
29
- # For MacOS:
30
- #
31
- .DS_Store
32
-
33
- # For TextMate
34
- #*.tmproj
35
- #tmtags
36
-
37
- # For emacs:
38
- #*~
39
- #\#*
40
- #.\#*
41
-
42
- # For vim:
43
- *.swp
44
-
45
- # For redcar:
46
- #.redcar
47
-
48
- # For rubinius:
49
- #*.rbc
data/.hound.yml DELETED
@@ -1,2 +0,0 @@
1
- ruby:
2
- enabled: true
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --tty
2
- --color
3
- --format documentation
data/.rubocop.yml DELETED
@@ -1,8 +0,0 @@
1
- # Omakase Ruby styling for Rails
2
- inherit_gem: { rubocop-rails-omakase: rubocop.yml }
3
-
4
- # Overwrite or add rules to create your own house style
5
- #
6
- # # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
7
- # Layout/SpaceInsideArrayLiteralBrackets:
8
- # Enabled: false
data/.travis.yml DELETED
@@ -1,33 +0,0 @@
1
- sudo: false
2
-
3
- language: ruby
4
-
5
- cache: bundler
6
-
7
- services: mongodb
8
-
9
- rvm:
10
- - 2.5.3
11
-
12
- before_install:
13
- - gem update bundler
14
-
15
- before_script:
16
- - bundle exec danger
17
-
18
- addons:
19
- apt:
20
- sources:
21
- - mongodb-3.2-precise
22
- packages:
23
- - mongodb-org-server
24
-
25
- env:
26
- - MONGOID_VERSION=5
27
- - MONGOID_VERSION=6
28
- - MONGOID_VERSION=7
29
- - MONGOID_VERSION=HEAD
30
-
31
- matrix:
32
- allow_failures:
33
- - env: MONGOID_VERSION=HEAD
data/CHANGELOG.md DELETED
@@ -1,23 +0,0 @@
1
- ## 5.1.1 (Next)
2
-
3
- * Your contribution here.
4
-
5
- ## 5.1.0 (2018/11/09)
6
-
7
- * [#61](https://github.com/mongoid/mongoid-geospatial/pull/64): Add global configuration for switching between LngLat and LatLng - [@dblock](https://github.com/dblock).
8
- * [#59](https://github.com/mongoid/mongoid-geospatial/pull/59), [#65](https://github.com/mongoid/mongoid-geospatial/pull/65): Test against Mongoid 5, 6 and 7 - [@dblock](https://github.com/dblock).
9
- * [#52](https://github.com/mongoid/mongoid-geospatial/pull/52), [#70](https://github.com/mongoid/mongoid-geospatial/pull/70): Added Danger and Rubocop, PR and code linters - [@dblock](https://github.com/dblock).
10
-
11
- ## 5.0.0 (2015/07/23)
12
-
13
- * Mongoid 5 support - [@nofxx](https://github.com/nofxx).
14
-
15
- ## 4.0.1 (2015/03/04)
16
-
17
- ## 4.0.0 (2015/01/11)
18
-
19
- * Mongoid 4 support - [@nofxx](https://github.com/nofxx).
20
-
21
- ## 3.9.0 (2014/12/22)
22
-
23
- * Initial public release - [@nofxx](https://github.com/nofxx).
data/CONTRIBUTING.md DELETED
@@ -1,118 +0,0 @@
1
- Contributing to Mongoid::Geospatial
2
- ===================================
3
-
4
- Mongoid::Geospatial is work of [many of contributors](https://github.com/mongoid/mongoid-geospatial/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/mongoid/mongoid-geospatial/pulls), [propose features, ask questions and discuss issues](https://github.com/mongoid/mongoid-geospatial/issues).
5
-
6
- #### Fork the Project
7
-
8
- Fork the [project on Github](https://github.com/mongoid/mongoid-geospatial) and check out your copy.
9
-
10
- ```
11
- git clone https://github.com/contributor/mongoid-geospatial.git
12
- cd mongoid-geospatial
13
- git remote add upstream https://github.com/mongoid/mongoid-geospatial.git
14
- ```
15
-
16
- #### Create a Topic Branch
17
-
18
- Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
19
-
20
- ```
21
- git checkout master
22
- git pull upstream master
23
- git checkout -b my-feature-branch
24
- ```
25
-
26
- #### Bundle Install and Test
27
-
28
- Ensure that you can build the project and run tests.
29
-
30
- ```
31
- bundle install
32
- bundle exec rake
33
- ```
34
-
35
- #### Write Tests
36
-
37
- Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/mongoid-geospatial](spec/mongoid-geospatial).
38
-
39
- We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
40
-
41
- #### Write Code
42
-
43
- Implement your feature or bug fix.
44
-
45
- Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
46
-
47
- Make sure that `bundle exec rake` completes without errors.
48
-
49
- #### Write Documentation
50
-
51
- Document any external behavior in the [README](README.md).
52
-
53
- #### Update Changelog
54
-
55
- Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
56
-
57
- #### Commit Changes
58
-
59
- Make sure git knows your name and email address:
60
-
61
- ```
62
- git config --global user.name "Your Name"
63
- git config --global user.email "contributor@example.com"
64
- ```
65
-
66
- Writing good commit logs is important. A commit log should describe what changed and why.
67
-
68
- ```
69
- git add ...
70
- git commit
71
- ```
72
-
73
- #### Push
74
-
75
- ```
76
- git push origin my-feature-branch
77
- ```
78
-
79
- #### Make a Pull Request
80
-
81
- Go to https://github.com/contributor/mongoid-geospatial and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
82
-
83
- #### Rebase
84
-
85
- If you've been working on a change for a while, rebase with upstream/master.
86
-
87
- ```
88
- git fetch upstream
89
- git rebase upstream/master
90
- git push origin my-feature-branch -f
91
- ```
92
-
93
- #### Update CHANGELOG Again
94
-
95
- Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
96
-
97
- ```
98
- * [#123](https://github.com/mongoid/mongoid-geospatial/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
99
- ```
100
-
101
- Amend your previous commit and force push the changes.
102
-
103
- ```
104
- git commit --amend
105
- git push origin my-feature-branch -f
106
- ```
107
-
108
- #### Check on Your Pull Request
109
-
110
- Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
111
-
112
- #### Be Patient
113
-
114
- It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
115
-
116
- #### Thank You
117
-
118
- Please do know that we really appreciate and value your time and work. We love you, really.
data/Gemfile DELETED
@@ -1,17 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'mongoid'
4
-
5
- gemspec
6
-
7
- group :development, :test do
8
- gem 'fuubar'
9
- gem 'rake'
10
- gem 'guard'
11
- gem 'guard-rspec'
12
- gem 'rubocop'
13
- end
14
-
15
- group :test do
16
- gem 'coveralls', require: false if ENV['CI']
17
- end
data/Guardfile DELETED
@@ -1,16 +0,0 @@
1
- #
2
- # Mongoid Geospatial Guardfile
3
- #
4
- ignore(/\/.#.+/)
5
-
6
- # notification :off
7
-
8
- guard :rubocop, all_on_start: false, keep_failed: false, notification: false, cli: ['--format', 'emacs'] do
9
- watch(/^lib\/(.+)\.rb$/)
10
- end
11
-
12
- guard :rspec, cmd: 'bundle exec rspec', notification: true do
13
- watch(/^spec\/.+_spec\.rb$/)
14
- watch(/^lib\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
15
- watch('spec/spec_helper.rb') { 'spec' }
16
- end