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
@@ -29,25 +29,97 @@ describe Mongoid::Geospatial do
29
29
  before do
30
30
  Bar.create_indexes
31
31
  end
32
+ after do
33
+ Bar.collection.indexes.drop_all
34
+ end
32
35
 
33
- let!(:jfk) do
34
- Bar.create(name: 'jfk', location: [-73.77694444, 40.63861111])
36
+ let!(:moes) do
37
+ Bar.create!(name: "Moe's", location: [-73.77694444, 40.63861111])
35
38
  end
36
39
 
37
- let!(:lax) do
38
- Bar.create(name: 'lax', location: [-118.40, 33.94])
40
+ let!(:rose) do
41
+ Bar.create!(name: 'Rosa', location: [-118.40, 33.94])
42
+ end
43
+
44
+ let!(:jane) do
45
+ Bar.create!(name: "Jane's", location: [1, 1])
46
+ end
47
+
48
+ let!(:foo) do
49
+ Bar.create!(name: "Foo", location: [3, 3])
50
+ end
51
+
52
+ it 'should work specifing center and different location foo' do
53
+ expect(Bar.nearby(foo.location)).to be_a Mongoid::Criteria
54
+ expect(Bar.nearby(foo.location).selector).to eq({"location" => {"$near" => [3.0, 3.0]}})
55
+ end
56
+
57
+ it 'should work specifing center and different location moes' do
58
+ expect(Bar.nearby(moes.location).limit(2)).to eq([moes, rose])
59
+ end
60
+
61
+ it 'should work finding first' do
62
+ expect(Bar.nearby(moes.location).first).to eq(moes)
63
+ end
64
+
65
+ it 'really should work find first nearby' do
66
+ expect(Bar.count).to eq(4)
67
+ expect(Bar.nearby([1, 1]).to_a).to eq([jane, foo, moes, rose])
68
+ expect(Bar.nearby([2, 2]).to_a.first).to eq(jane)
69
+ # THIS WILL FAIL MONGOID ISSUE
70
+ # expect(Bar.nearby(rose.location).first).to eq(rose)
71
+ end
72
+
73
+ it 'should work specifing first' do
74
+ bars = Bar.nearby(rose.location).to_a
75
+ expect(bars.first).to eq(rose)
39
76
  end
40
77
 
41
- it 'should work specifing center and different location' do
42
- expect(Bar.nearby(lax.location)).to eq([lax, jfk])
78
+ it 'should work specifing first' do
79
+ expect(Bar.nearby(rose.location).to_a.first).to eq(rose)
43
80
  end
81
+
82
+ it 'should work specifing first' do
83
+ expect(Bar.nearby(rose.location).to_a.first).to eq(rose)
84
+ end
85
+
86
+ it 'should work specifing first' do
87
+ expect(Bar.nearby(rose.location).first).to eq(rose)
88
+ end
89
+
90
+ it 'returns the documents sorted closest to furthest' do
91
+ expect(Bar.closest_to_location(rose.location).to_a)
92
+ .to eq([rose, moes, jane, foo])
93
+ end
94
+
95
+ it 'returns the documents sorted closest to furthest' do
96
+ expect(Bar.closest_to_location(rose.location).limit(2))
97
+ .to eq([rose, moes])
98
+ end
99
+
100
+ it 'returns the documents sorted closest to furthest' do
101
+ expect(Bar.closest_to_location(rose.location).first).to eq(rose)
102
+ end
103
+
104
+ it 'returns the documents sorted closest to furthest' do
105
+ expect(Bar.closest_to_location(rose.location).to_a)
106
+ .to eq([rose, moes, jane, foo])
107
+ end
108
+
109
+ it 'should work specifing center and different location foo' do
110
+ expect(Bar.closest_to_location(foo.location)).to be_a Mongoid::Criteria
111
+ expect(Bar.closest_to_location(foo.location).selector).to eq({"location" => {"$near" => [3.0, 3.0]}})
112
+ end
113
+
44
114
  end
45
115
 
46
116
  context '#nearby 2dsphere' do
47
117
  before do
48
118
  Alarm.create_indexes
49
119
  end
50
-
120
+ after do
121
+ Alarm.collection.indexes.drop_all
122
+ end
51
123
  let!(:jfk) do
52
124
  Alarm.create(name: 'jfk', spot: [-73.77694444, 40.63861111])
53
125
  end
@@ -72,7 +144,7 @@ describe Mongoid::Geospatial do
72
144
  before do
73
145
  Alarm.create_indexes
74
146
  50.times do
75
- Alarm.create(spot: [rand(10) + 1, rand(10) + 1])
147
+ Alarm.create(spot: [rand(1..10), rand(1..10)])
76
148
  end
77
149
  end
78
150
 
@@ -5,15 +5,17 @@ module Mongoid
5
5
  end
6
6
 
7
7
  def self.from_hash(hsh)
8
- fail 'Hash must have at least 2 items' if hsh.size < 2
8
+ raise 'Hash must have at least 2 items' if hsh.size < 2
9
+
9
10
  [from_hash_x(hsh), from_hash_y(hsh)]
10
11
  end
11
12
 
12
13
  def self.from_hash_y(hsh)
13
14
  v = (Mongoid::Geospatial.lat_symbols & hsh.keys).first
14
15
  return hsh[v].to_f if !v.nil? && hsh[v]
16
+
15
17
  if Mongoid::Geospatial.lng_symbols.index(hsh.keys[1])
16
- fail "Hash cannot contain #{Mongoid::Geospatial.lng_symbols.inspect} "\
18
+ raise "Hash cannot contain #{Mongoid::Geospatial.lng_symbols.inspect} "\
17
19
  "as second arg without #{Mongoid::Geospatial.lat_symbols.inspect}"
18
20
  end
19
21
  hsh.values[1].to_f
@@ -22,8 +24,9 @@ module Mongoid
22
24
  def self.from_hash_x(hsh)
23
25
  v = (Mongoid::Geospatial.lng_symbols & hsh.keys).first
24
26
  return hsh[v].to_f if !v.nil? && hsh[v]
27
+
25
28
  if Mongoid::Geospatial.lat_symbols.index(keys[0])
26
- fail "Hash cannot contain #{Mongoid::Geospatial.lat_symbols.inspect} "\
29
+ raise "Hash cannot contain #{Mongoid::Geospatial.lat_symbols.inspect} "\
27
30
  "as first arg without #{Mongoid::Geospatial.lng_symbols.inspect}"
28
31
  end
29
32
  values[0].to_f
@@ -12,10 +12,10 @@ describe Mongoid::Fields do
12
12
 
13
13
  it 'should create correct indexes' do
14
14
  expect(Bar.collection.indexes.get(location: '2d'))
15
- .to eq('key' => { 'location' => '2d' },
15
+ .to eq('background' => false,
16
+ 'key' => { 'location' => '2d' },
16
17
  'name' => 'location_2d',
17
- 'ns' => 'mongoid_geo_test.bars',
18
- 'v' => 1)
18
+ 'v' => 2)
19
19
  end
20
20
 
21
21
  it 'should set spatial fields' do
@@ -12,11 +12,11 @@ describe Mongoid::Fields do
12
12
 
13
13
  it 'should create correct indexes' do
14
14
  expect(Alarm.collection.indexes.get(spot: '2dsphere'))
15
- .to eq('2dsphereIndexVersion' => 2,
16
- 'key' => { 'spot' => '2dsphere' },
17
- 'name' => 'spot_2dsphere',
18
- 'ns' => 'mongoid_geo_test.alarms',
19
- 'v' => 1)
15
+ .to include('2dsphereIndexVersion' => 3,
16
+ 'background' => false,
17
+ 'key' => { 'spot' => '2dsphere' },
18
+ 'name' => 'spot_2dsphere',
19
+ 'v' => 2)
20
20
  end
21
21
 
22
22
  it 'should set spatial fields' do
@@ -24,7 +24,7 @@ describe Mongoid::Fields do
24
24
  end
25
25
 
26
26
  it 'should work fine indexed' do
27
- far = Alarm.create!(name: 'Far', spot: [7, 7])
27
+ far = Alarm.create!(name: 'Far', spot: [7, 7])
28
28
  expect(far.spot).to be_instance_of(Mongoid::Geospatial::Point)
29
29
  end
30
30
  end
data/spec/mongoid.yml ADDED
@@ -0,0 +1,298 @@
1
+ development:
2
+ # Configure available database clients. (required)
3
+ clients:
4
+ # Defines the default client. (required)
5
+ default:
6
+ # Mongoid can connect to a URI accepted by the driver:
7
+ # uri: mongodb://user:password@mongodb.domain.com:27017/queroir_development
8
+
9
+ # Otherwise define the parameters separately.
10
+ # This defines the name of the default database that Mongoid can connect to.
11
+ # (required).
12
+ database: mongoid_geospatial_dev
13
+ # Provides the hosts the default client can connect to. Must be an array
14
+ # of host:port pairs. (required)
15
+ hosts:
16
+ - localhost:28017
17
+ options:
18
+ # Note that all options listed below are Ruby driver client options (the mongo gem).
19
+ # Please refer to the driver documentation of the version of the mongo gem you are using
20
+ # for the most up-to-date list of options.
21
+
22
+ # Change the default write concern. (default = { w: 1 })
23
+ # write:
24
+ # w: 1
25
+
26
+ # Change the default read preference. Valid options for mode are: :secondary,
27
+ # :secondary_preferred, :primary, :primary_preferred, :nearest
28
+ # (default: primary)
29
+ # read:
30
+ # mode: :secondary_preferred
31
+ # tag_sets:
32
+ # - use: web
33
+
34
+ # The name of the user for authentication.
35
+ # user: 'user'
36
+
37
+ # The password of the user for authentication.
38
+ # password: 'password'
39
+
40
+ # The user's database roles.
41
+ # roles:
42
+ # - 'dbOwner'
43
+
44
+ # Change the default authentication mechanism. Valid options include:
45
+ # :scram, :scram256, :mongodb_cr, :mongodb_x509, :gssapi, :aws, :plain.
46
+ # MongoDB Server defaults to :scram, which will use "SCRAM-SHA-256" if available,
47
+ # otherwise fallback to "SCRAM-SHA-1" (:scram256 will always use "SCRAM-SHA-256".)
48
+ # This setting is handled by the MongoDB Ruby Driver. Please refer to:
49
+ # https://mongodb.com/docs/ruby-driver/current/reference/authentication/
50
+ # auth_mech: :scram
51
+
52
+ # The database or source to authenticate the user against.
53
+ # (default: the database specified above or admin)
54
+ # auth_source: admin
55
+
56
+ # Force the driver cluster to behave in a certain manner instead of auto-discovering.
57
+ # Can be one of: :direct, :replica_set, :sharded. Set to :direct
58
+ # when connecting to hidden members of a replica set.
59
+ # connect: :direct
60
+
61
+ # Changes the default time in seconds the server monitors refresh their status
62
+ # via hello commands. (default: 10)
63
+ # heartbeat_frequency: 10
64
+
65
+ # The time in seconds for selecting servers for a near read preference. (default: 0.015)
66
+ # local_threshold: 0.015
67
+
68
+ # The timeout in seconds for selecting a server for an operation. (default: 30)
69
+ # server_selection_timeout: 30
70
+
71
+ # The maximum number of connections in the connection pool. (default: 5)
72
+ # max_pool_size: 5
73
+
74
+ # The minimum number of connections in the connection pool. (default: 1)
75
+ # min_pool_size: 1
76
+
77
+ # The time to wait, in seconds, in the connection pool for a connection
78
+ # to be checked in before timing out. (default: 5)
79
+ # wait_queue_timeout: 5
80
+
81
+ # The time to wait to establish a connection before timing out, in seconds.
82
+ # (default: 10)
83
+ # connect_timeout: 10
84
+
85
+ # How long to wait for a response for each operation sent to the
86
+ # server. This timeout should be set to a value larger than the
87
+ # processing time for the longest operation that will be executed
88
+ # by the application. Note that this is a client-side timeout;
89
+ # the server may continue executing an operation after the client
90
+ # aborts it with the SocketTimeout exception.
91
+ # (default: nil, meaning no timeout)
92
+ # socket_timeout: 5
93
+
94
+ # The name of the replica set to connect to. Servers provided as seeds that do
95
+ # not belong to this replica set will be ignored.
96
+ # replica_set: name
97
+
98
+ # Compressors to use for wire protocol compression. (default is to not use compression)
99
+ # "zstd" requires zstd-ruby gem. "snappy" requires snappy gem.
100
+ # Refer to: https://www.mongodb.com/docs/ruby-driver/current/reference/create-client/#compression
101
+ # compressors: ["zstd", "snappy", "zlib"]
102
+
103
+ # Whether to connect to the servers via ssl. (default: false)
104
+ # ssl: true
105
+
106
+ # The certificate file used to identify the connection against MongoDB.
107
+ # ssl_cert: /path/to/my.cert
108
+
109
+ # The private keyfile used to identify the connection against MongoDB.
110
+ # Note that even if the key is stored in the same file as the certificate,
111
+ # both need to be explicitly specified.
112
+ # ssl_key: /path/to/my.key
113
+
114
+ # A passphrase for the private key.
115
+ # ssl_key_pass_phrase: password
116
+
117
+ # Whether to do peer certification validation. (default: true)
118
+ # ssl_verify: true
119
+
120
+ # The file containing concatenated certificate authority certificates
121
+ # used to validate certs passed from the other end of the connection.
122
+ # ssl_ca_cert: /path/to/ca.cert
123
+
124
+ # Whether to truncate long log lines. (default: true)
125
+ # truncate_logs: true
126
+
127
+ # Configure Mongoid-specific options. (optional)
128
+ options:
129
+ # Allow BSON::Decimal128 to be parsed and returned directly in
130
+ # field values. When BSON 5 is present and the this option is set to false
131
+ # (the default), BSON::Decimal128 values in the database will be returned
132
+ # as BigDecimal.
133
+ #
134
+ # @note this option only has effect when BSON 5+ is present. Otherwise,
135
+ # the setting is ignored.
136
+ # allow_bson5_decimal128: false
137
+
138
+ # When this flag is false, named scopes cannot unset a default scope.
139
+ # This is the traditional (and default) behavior in Mongoid 9 and earlier.
140
+ #
141
+ # Setting this flag to true will allow named scopes to unset the default
142
+ # scope. This will be the default in Mongoid 10.
143
+ #
144
+ # See https://jira.mongodb.org/browse/MONGOID-5785 for more details.
145
+ # allow_scopes_to_unset_default_scope: false
146
+
147
+ # Application name that is printed to the MongoDB logs upon establishing
148
+ # a connection. Note that the name cannot exceed 128 bytes in length.
149
+ # It is also used as the database name if the database name is not
150
+ # explicitly defined.
151
+ app_name: mongoid_geospatial
152
+
153
+ # When this flag is false, callbacks for embedded documents will not be
154
+ # called. This is the default in 9.0.
155
+ #
156
+ # Setting this flag to true restores the pre-9.0 behavior, where callbacks
157
+ # for embedded documents are called. This may lead to stack overflow errors
158
+ # if there are more than cicrca 1000 embedded documents in the root
159
+ # document's dependencies graph.
160
+ # See https://jira.mongodb.org/browse/MONGOID-5658 for more details.
161
+ # around_callbacks_for_embeds: false
162
+
163
+ # Sets the async_query_executor for the application. By default the thread pool executor
164
+ # is set to `:immediate. Options are:
165
+ #
166
+ # - :immediate - Initializes a single +Concurrent::ImmediateExecutor+
167
+ # - :global_thread_pool - Initializes a single +Concurrent::ThreadPoolExecutor+
168
+ # that uses the +async_query_concurrency+ for the +max_threads+ value.
169
+ # async_query_executor: :immediate
170
+
171
+ # Mark belongs_to associations as required by default, so that saving a
172
+ # model with a missing belongs_to association will trigger a validation
173
+ # error.
174
+ # belongs_to_required_by_default: true
175
+
176
+ # Set the global discriminator key.
177
+ # discriminator_key: "_type"
178
+
179
+ # Raise an exception when a field is redefined.
180
+ # duplicate_fields_exception: false
181
+
182
+ # Defines how many asynchronous queries can be executed concurrently.
183
+ # This option should be set only if `async_query_executor` is set
184
+ # to `:global_thread_pool`.
185
+ # global_executor_concurrency: nil
186
+
187
+ # When this flag is true, any attempt to change the _id of a persisted
188
+ # document will raise an exception (`Errors::ImmutableAttribute`).
189
+ # This is the default in 9.0. Setting this flag to false restores the
190
+ # pre-9.0 behavior, where changing the _id of a persisted
191
+ # document might be ignored, or it might work, depending on the situation.
192
+ # immutable_ids: true
193
+
194
+ # Include the root model name in json serialization.
195
+ # include_root_in_json: false
196
+
197
+ # # Include the _type field in serialization.
198
+ # include_type_for_serialization: false
199
+
200
+ # Whether to join nested persistence contexts for atomic operations
201
+ # to parent contexts by default.
202
+ # join_contexts: false
203
+
204
+ # When this flag is false (the default as of Mongoid 9.0), a document that
205
+ # is created or loaded will remember the storage options that were active
206
+ # when it was loaded, and will use those same options by default when
207
+ # saving or reloading itself.
208
+ #
209
+ # When this flag is true you'll get pre-9.0 behavior, where a document will
210
+ # not remember the storage options from when it was loaded/created, and
211
+ # subsequent updates will need to explicitly set up those options each time.
212
+ #
213
+ # For example:
214
+ #
215
+ # record = Model.with(collection: 'other_collection') { Model.first }
216
+ #
217
+ # This will try to load the first document from 'other_collection' and
218
+ # instantiate it as a Model instance. Pre-9.0, the record object would
219
+ # not remember that it came from 'other_collection', and attempts to
220
+ # update it or reload it would fail unless you first remembered to
221
+ # explicitly specify the collection every time.
222
+ #
223
+ # As of Mongoid 9.0, the record will remember that it came from
224
+ # 'other_collection', and updates and reloads will automatically default
225
+ # to that collection, for that record object.
226
+ # legacy_persistence_context_behavior: false
227
+
228
+ # When this flag is false, a document will become read-only only once the
229
+ # #readonly! method is called, and an error will be raised on attempting
230
+ # to save or update such documents, instead of just on delete. When this
231
+ # flag is true, a document is only read-only if it has been projected
232
+ # using #only or #without, and read-only documents will not be
233
+ # deletable/destroyable, but they will be savable/updatable.
234
+ # When this feature flag is turned on, the read-only state will be reset on
235
+ # reload, but when it is turned off, it won't be.
236
+ # legacy_readonly: false
237
+
238
+ # The log level.
239
+ #
240
+ # It must be set prior to referencing clients or Mongo.logger,
241
+ # changes to this option are not be propagated to any clients and
242
+ # loggers that already exist.
243
+ #
244
+ # Additionally, only when the clients are configured via the
245
+ # configuration file is the log level given by this option honored.
246
+ # log_level: :info
247
+
248
+ # Store BigDecimals as Decimal128s instead of strings in the db.
249
+ # map_big_decimal_to_decimal128: true
250
+
251
+ # Preload all models in development, needed when models use inheritance.
252
+ # preload_models: false
253
+
254
+ # When this flag is true, callbacks for every embedded document will be
255
+ # called only once, even if the embedded document is embedded in multiple
256
+ # documents in the root document's dependencies graph.
257
+ # This is the default in 9.0. Setting this flag to false restores the
258
+ # pre-9.0 behavior, where callbacks are called for every occurrence of an
259
+ # embedded document. The pre-9.0 behavior leads to a problem that for multi
260
+ # level nested documents callbacks are called multiple times.
261
+ # See https://jira.mongodb.org/browse/MONGOID-5542
262
+ # prevent_multiple_calls_of_embedded_callbacks: true
263
+
264
+ # Raise an error when performing a #find and the document is not found.
265
+ # raise_not_found_error: true
266
+
267
+ # Raise an error when defining a scope with the same name as an
268
+ # existing method.
269
+ # scope_overwrite_exception: false
270
+
271
+ # Return stored times as UTC.
272
+ use_utc: true
273
+
274
+ # Configure Driver-specific options. (optional)
275
+ driver_options:
276
+ # When this flag is off, an aggregation done on a view will be executed over
277
+ # the documents included in that view, instead of all documents in the
278
+ # collection. When this flag is on, the view fiter is ignored.
279
+ # broken_view_aggregate: true
280
+
281
+ # When this flag is set to false, the view options will be correctly
282
+ # propagated to readable methods.
283
+ # broken_view_options: true
284
+
285
+ # When this flag is set to true, the update and replace methods will
286
+ # validate the paramters and raise an error if they are invalid.
287
+ # validate_update_replace: false
288
+
289
+ test:
290
+ clients:
291
+ default:
292
+ database: mongoid_geospatial_test
293
+ hosts:
294
+ - localhost:28017
295
+ options:
296
+ read:
297
+ mode: :primary
298
+ max_pool_size: 1
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- # require 'pry'
2
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
3
 
@@ -8,26 +7,21 @@ $LOAD_PATH.unshift(MODELS)
8
7
  $LOAD_PATH.unshift(SUPPORT)
9
8
 
10
9
  if ENV['CI']
11
- # require "simplecov"
12
10
  require 'coveralls'
13
11
  Coveralls.wear!
14
- # SimpleCov.formatter = Coveralls::SimpleCov::Formatter
15
- # SimpleCov.start do
16
- # add_filter "spec"
17
- # end
18
12
  end
19
13
 
20
- require 'pry'
21
14
  require 'rspec'
22
- require 'mongoid'
23
- # require "mocha"
24
15
  require 'mongoid/geospatial'
25
16
 
26
- LOGGER = Logger.new($stdout)
17
+ Mongoid.load!(File.expand_path('../mongoid.yml', __FILE__), :test)
27
18
 
28
- Mongoid.configure do |config|
29
- config.connect_to('mongoid_geo_test')
19
+ if ENV['DEBUG'] == 'true'
20
+ Mongo::Logger.logger.level = Logger::DEBUG
21
+ else
22
+ Mongo::Logger.logger.level = Logger::INFO
30
23
  end
24
+ # Mongo::Logger.logger.level = Logger::DEBUG
31
25
 
32
26
  # Autoload every model for the test suite that sits in spec/app/models.
33
27
  Dir[File.join(MODELS, '*.rb')].sort.each do |file|
@@ -35,18 +29,14 @@ Dir[File.join(MODELS, '*.rb')].sort.each do |file|
35
29
  autoload name.camelize.to_sym, name
36
30
  end
37
31
 
38
- Dir[File.join(SUPPORT, '*.rb')].each { |file| require File.basename(file) }
32
+ # Require all support files.
33
+ Dir[File.join(SUPPORT, '*.rb')].sort.each { |file| require file }
39
34
 
40
35
  RSpec.configure do |config|
41
- # config.mock_with(:mocha)
42
-
43
36
  config.before(:each) do
44
37
  Mongoid.purge!
38
+ Mongoid::Geospatial::Config.reset!
45
39
  end
46
40
  end
47
41
 
48
- Mongo::Logger.logger.level = Logger::INFO if Mongoid::VERSION >= '5'
49
-
50
- # Mongoid.load!(File.expand_path('../support/mongoid.yml', __FILE__), :test)
51
-
52
42
  puts "Running with Mongoid v#{Mongoid::VERSION}"
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  module Support #:nodoc:
3
2
  # module Authentication
4
3
  # extend self
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-geospatial
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ong
8
8
  - Marcos Piccinini
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mongoid
@@ -17,14 +16,14 @@ dependencies:
17
16
  requirements:
18
17
  - - ">="
19
18
  - !ruby/object:Gem::Version
20
- version: 5.0.0.beta
19
+ version: 4.0.0
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - ">="
26
25
  - !ruby/object:Gem::Version
27
- version: 5.0.0.beta
26
+ version: 4.0.0
28
27
  description: Mongoid Extension that simplifies MongoDB casting and operations on spatial
29
28
  Ruby objects.
30
29
  email:
@@ -37,14 +36,19 @@ files:
37
36
  - ".gitignore"
38
37
  - ".hound.yml"
39
38
  - ".rspec"
39
+ - ".rubocop.yml"
40
40
  - ".travis.yml"
41
+ - CHANGELOG.md
42
+ - CONTRIBUTING.md
41
43
  - Gemfile
42
44
  - Guardfile
43
45
  - MIT-LICENSE
44
46
  - README.md
47
+ - RELEASING.md
45
48
  - Rakefile
46
- - bench/bench
47
49
  - lib/mongoid/geospatial.rb
50
+ - lib/mongoid/geospatial/config.rb
51
+ - lib/mongoid/geospatial/config/point.rb
48
52
  - lib/mongoid/geospatial/ext/rgeo_spherical_point_impl.rb
49
53
  - lib/mongoid/geospatial/fields/box.rb
50
54
  - lib/mongoid/geospatial/fields/circle.rb
@@ -59,6 +63,7 @@ files:
59
63
  - lib/mongoid/geospatial/wrappers/georuby.rb
60
64
  - lib/mongoid/geospatial/wrappers/rgeo.rb
61
65
  - mongoid-geospatial.gemspec
66
+ - spec/bench
62
67
  - spec/models/address.rb
63
68
  - spec/models/alarm.rb
64
69
  - spec/models/bar.rb
@@ -69,6 +74,8 @@ files:
69
74
  - spec/models/phone.rb
70
75
  - spec/models/place.rb
71
76
  - spec/models/river.rb
77
+ - spec/mongoid.yml
78
+ - spec/mongoid/geospatial/config_spec.rb
72
79
  - spec/mongoid/geospatial/fields/box_spec.rb
73
80
  - spec/mongoid/geospatial/fields/circle_spec.rb
74
81
  - spec/mongoid/geospatial/fields/line_string_spec.rb
@@ -85,11 +92,10 @@ files:
85
92
  - spec/support/authentication.rb
86
93
  - spec/support/mongod.conf
87
94
  - spec/support/mongoid.yml
88
- homepage: https://github.com/nofxx/mongoid-geospatial
95
+ homepage: https://github.com/mongoid/mongoid-geospatial
89
96
  licenses:
90
97
  - MIT
91
98
  metadata: {}
92
- post_install_message:
93
99
  rdoc_options: []
94
100
  require_paths:
95
101
  - lib
@@ -104,12 +110,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
110
  - !ruby/object:Gem::Version
105
111
  version: '0'
106
112
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.4.8
109
- signing_key:
113
+ rubygems_version: 3.6.7
110
114
  specification_version: 4
111
115
  summary: Mongoid Extension that simplifies MongoDB Geospatial Operations.
112
116
  test_files:
117
+ - spec/bench
113
118
  - spec/models/address.rb
114
119
  - spec/models/alarm.rb
115
120
  - spec/models/bar.rb
@@ -120,6 +125,8 @@ test_files:
120
125
  - spec/models/phone.rb
121
126
  - spec/models/place.rb
122
127
  - spec/models/river.rb
128
+ - spec/mongoid.yml
129
+ - spec/mongoid/geospatial/config_spec.rb
123
130
  - spec/mongoid/geospatial/fields/box_spec.rb
124
131
  - spec/mongoid/geospatial/fields/circle_spec.rb
125
132
  - spec/mongoid/geospatial/fields/line_string_spec.rb
@@ -136,4 +143,3 @@ test_files:
136
143
  - spec/support/authentication.rb
137
144
  - spec/support/mongod.conf
138
145
  - spec/support/mongoid.yml
139
- has_rdoc: