mongoid-geospatial 5.0.0 → 5.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.
- checksums.yaml +5 -5
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +93 -0
- data/.travis.yml +26 -20
- data/CHANGELOG.md +19 -0
- data/CONTRIBUTING.md +118 -0
- data/Dangerfile +1 -0
- data/Gemfile +26 -14
- data/Guardfile +2 -2
- data/MIT-LICENSE +2 -2
- data/README.md +186 -181
- data/RELEASING.md +62 -0
- data/Rakefile +4 -1
- data/bench/bench +1 -1
- data/lib/mongoid/geospatial.rb +6 -4
- data/lib/mongoid/geospatial/config.rb +29 -0
- data/lib/mongoid/geospatial/config/point.rb +19 -0
- data/lib/mongoid/geospatial/fields/circle.rb +3 -3
- data/lib/mongoid/geospatial/fields/point.rb +16 -9
- data/lib/mongoid/geospatial/geometry_field.rb +6 -4
- data/lib/mongoid/geospatial/version.rb +1 -1
- data/lib/mongoid/geospatial/wrappers/georuby.rb +1 -0
- data/mongoid-geospatial.gemspec +3 -4
- data/spec/models/event.rb +1 -1
- data/spec/models/farm.rb +1 -1
- data/spec/models/person.rb +2 -4
- data/spec/mongoid/geospatial/config_spec.rb +22 -0
- data/spec/mongoid/geospatial/fields/point_spec.rb +21 -2
- data/spec/mongoid/geospatial/geospatial_spec.rb +1 -1
- data/spec/mongoid/geospatial/helpers/core_spec.rb +6 -3
- data/spec/mongoid/geospatial/helpers/spatial_spec.rb +3 -4
- data/spec/mongoid/geospatial/helpers/sphere_spec.rb +4 -6
- data/spec/spec_helper.rb +2 -7
- data/spec/support/authentication.rb +0 -1
- metadata +16 -7
@@ -5,15 +5,17 @@ module Mongoid
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.from_hash(hsh)
|
8
|
-
|
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
|
-
|
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
|
-
|
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,9 @@ 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
|
16
|
-
|
17
|
-
|
18
|
-
'v' => 1)
|
15
|
+
.to include('key' => { 'location' => '2d' },
|
16
|
+
'name' => 'location_2d',
|
17
|
+
'ns' => 'mongoid_geo_test.bars')
|
19
18
|
end
|
20
19
|
|
21
20
|
it 'should set spatial fields' do
|
@@ -12,11 +12,9 @@ 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
|
16
|
-
|
17
|
-
|
18
|
-
'ns' => 'mongoid_geo_test.alarms',
|
19
|
-
'v' => 1)
|
15
|
+
.to include('key' => { 'spot' => '2dsphere' },
|
16
|
+
'name' => 'spot_2dsphere',
|
17
|
+
'ns' => 'mongoid_geo_test.alarms')
|
20
18
|
end
|
21
19
|
|
22
20
|
it 'should set spatial fields' do
|
@@ -24,7 +22,7 @@ describe Mongoid::Fields do
|
|
24
22
|
end
|
25
23
|
|
26
24
|
it 'should work fine indexed' do
|
27
|
-
far
|
25
|
+
far = Alarm.create!(name: 'Far', spot: [7, 7])
|
28
26
|
expect(far.spot).to be_instance_of(Mongoid::Geospatial::Point)
|
29
27
|
end
|
30
28
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,18 +8,12 @@ $LOAD_PATH.unshift(MODELS)
|
|
8
8
|
$LOAD_PATH.unshift(SUPPORT)
|
9
9
|
|
10
10
|
if ENV['CI']
|
11
|
-
# require "simplecov"
|
12
11
|
require 'coveralls'
|
13
12
|
Coveralls.wear!
|
14
|
-
# SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
15
|
-
# SimpleCov.start do
|
16
|
-
# add_filter "spec"
|
17
|
-
# end
|
18
13
|
end
|
19
14
|
|
20
|
-
require 'pry'
|
21
15
|
require 'rspec'
|
22
|
-
require 'mongoid'
|
16
|
+
# require 'mongoid'
|
23
17
|
# require "mocha"
|
24
18
|
require 'mongoid/geospatial'
|
25
19
|
|
@@ -42,6 +36,7 @@ RSpec.configure do |config|
|
|
42
36
|
|
43
37
|
config.before(:each) do
|
44
38
|
Mongoid.purge!
|
39
|
+
Mongoid::Geospatial::Config.reset!
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
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: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ong
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 4.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 4.0.0
|
28
28
|
description: Mongoid Extension that simplifies MongoDB casting and operations on spatial
|
29
29
|
Ruby objects.
|
30
30
|
email:
|
@@ -37,14 +37,22 @@ files:
|
|
37
37
|
- ".gitignore"
|
38
38
|
- ".hound.yml"
|
39
39
|
- ".rspec"
|
40
|
+
- ".rubocop.yml"
|
41
|
+
- ".rubocop_todo.yml"
|
40
42
|
- ".travis.yml"
|
43
|
+
- CHANGELOG.md
|
44
|
+
- CONTRIBUTING.md
|
45
|
+
- Dangerfile
|
41
46
|
- Gemfile
|
42
47
|
- Guardfile
|
43
48
|
- MIT-LICENSE
|
44
49
|
- README.md
|
50
|
+
- RELEASING.md
|
45
51
|
- Rakefile
|
46
52
|
- bench/bench
|
47
53
|
- lib/mongoid/geospatial.rb
|
54
|
+
- lib/mongoid/geospatial/config.rb
|
55
|
+
- lib/mongoid/geospatial/config/point.rb
|
48
56
|
- lib/mongoid/geospatial/ext/rgeo_spherical_point_impl.rb
|
49
57
|
- lib/mongoid/geospatial/fields/box.rb
|
50
58
|
- lib/mongoid/geospatial/fields/circle.rb
|
@@ -69,6 +77,7 @@ files:
|
|
69
77
|
- spec/models/phone.rb
|
70
78
|
- spec/models/place.rb
|
71
79
|
- spec/models/river.rb
|
80
|
+
- spec/mongoid/geospatial/config_spec.rb
|
72
81
|
- spec/mongoid/geospatial/fields/box_spec.rb
|
73
82
|
- spec/mongoid/geospatial/fields/circle_spec.rb
|
74
83
|
- spec/mongoid/geospatial/fields/line_string_spec.rb
|
@@ -85,7 +94,7 @@ files:
|
|
85
94
|
- spec/support/authentication.rb
|
86
95
|
- spec/support/mongod.conf
|
87
96
|
- spec/support/mongoid.yml
|
88
|
-
homepage: https://github.com/
|
97
|
+
homepage: https://github.com/mongoid/mongoid-geospatial
|
89
98
|
licenses:
|
90
99
|
- MIT
|
91
100
|
metadata: {}
|
@@ -105,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
114
|
version: '0'
|
106
115
|
requirements: []
|
107
116
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.7.6
|
109
118
|
signing_key:
|
110
119
|
specification_version: 4
|
111
120
|
summary: Mongoid Extension that simplifies MongoDB Geospatial Operations.
|
@@ -120,6 +129,7 @@ test_files:
|
|
120
129
|
- spec/models/phone.rb
|
121
130
|
- spec/models/place.rb
|
122
131
|
- spec/models/river.rb
|
132
|
+
- spec/mongoid/geospatial/config_spec.rb
|
123
133
|
- spec/mongoid/geospatial/fields/box_spec.rb
|
124
134
|
- spec/mongoid/geospatial/fields/circle_spec.rb
|
125
135
|
- spec/mongoid/geospatial/fields/line_string_spec.rb
|
@@ -136,4 +146,3 @@ test_files:
|
|
136
146
|
- spec/support/authentication.rb
|
137
147
|
- spec/support/mongod.conf
|
138
148
|
- spec/support/mongoid.yml
|
139
|
-
has_rdoc:
|