mongoid_geospatial 2.8.2 → 2.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +19 -0
- data/Gemfile +14 -6
- data/Guardfile +1 -16
- data/{LICENSE → MIT-LICENSE} +0 -0
- data/README.md +14 -20
- data/lib/mongoid_geospatial.rb +1 -0
- data/lib/mongoid_geospatial/geospatial.rb +21 -0
- data/lib/mongoid_geospatial/helpers/delegate.rb +6 -5
- data/lib/mongoid_geospatial/helpers/spatial.rb +8 -14
- data/lib/mongoid_geospatial/helpers/sphere.rb +18 -0
- data/lib/mongoid_geospatial/version.rb +1 -1
- data/mongoid_geospatial.gemspec +3 -7
- data/spec/models/alarm.rb +2 -1
- data/spec/models/event.rb +5 -8
- data/spec/models/person.rb +15 -15
- data/spec/mongoid_geospatial/geospatial_spec.rb +48 -17
- data/spec/mongoid_geospatial/helpers/delegate_spec.rb +12 -3
- data/spec/mongoid_geospatial/helpers/spatial_spec.rb +1 -0
- data/spec/mongoid_geospatial/helpers/sphere_spec.rb +26 -0
- data/spec/spec_helper.rb +11 -1
- metadata +26 -81
- data/.document +0 -5
- data/.rspec +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff35a5a79d20c1dd655b49bb626bdce8b8c2e6b4
|
4
|
+
data.tar.gz: 0d4041b8ec06429c6db10a9ecd9da1d28a5afa7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb1cd1a60cd4641a184a94c5a3336d306e61dd0202fb9b7b270a49d13e7367a5dde932545b2b449c78b7ed9b3b40528cbdf2c002903c62a86f911d9052715be
|
7
|
+
data.tar.gz: dd5fb4f2a67516d97e444d679b3c454e8cc55a09a5edaba462cdd34ff32dc94eda20f2db6f810cbfbc75e7352f2ed955c74ea1f2464a2a95d2149abc69a240ca
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
language: ruby
|
2
|
+
bundler_args: --without development
|
3
|
+
rvm:
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
- ruby-head
|
7
|
+
- rbx-19mode
|
8
|
+
- jruby
|
9
|
+
- jruby-head
|
10
|
+
jdk:
|
11
|
+
- oraclejdk7
|
12
|
+
- openjdk7
|
13
|
+
env: JRUBY_OPTS="--server -Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -J-Xms512m -J-Xmx1024m"
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: ruby-head
|
17
|
+
- rvm: jruby-head
|
18
|
+
services:
|
19
|
+
- mongodb
|
data/Gemfile
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
gemspec # Specify gem's dependencies in mongoid_geospatial.gemspec
|
3
3
|
|
4
|
-
gem '
|
4
|
+
gem 'rake'
|
5
5
|
|
6
6
|
group :development do
|
7
|
-
gem 'rgeo'
|
8
|
-
gem 'georuby'
|
9
|
-
gem 'dbf'
|
10
|
-
gem 'rspec'
|
11
|
-
gem 'guard-rspec'
|
12
7
|
gem 'pry'
|
8
|
+
gem "yard"
|
13
9
|
# gem 'fuubar'
|
14
10
|
end
|
15
11
|
|
16
12
|
group :test do
|
17
13
|
gem 'dbf'
|
14
|
+
gem 'rspec'
|
18
15
|
gem 'nokogiri'
|
16
|
+
gem 'rgeo'
|
17
|
+
gem 'georuby'
|
18
|
+
|
19
|
+
if ENV["CI"]
|
20
|
+
gem "coveralls", require: false
|
21
|
+
gem "yard"
|
22
|
+
else
|
23
|
+
gem "guard"
|
24
|
+
gem "guard-rspec"
|
25
|
+
gem "rb-fsevent"
|
26
|
+
end
|
19
27
|
end
|
data/Guardfile
CHANGED
@@ -2,23 +2,8 @@
|
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
require 'guard'
|
4
4
|
|
5
|
-
guard 'rspec'
|
5
|
+
guard 'rspec' do
|
6
6
|
watch(%r{^spec/.+_spec\.rb$})
|
7
7
|
watch(%r{^lib/(.+)\.rb$}) { "spec" } # { |m| "spec spec/lib/#{m[1]}_spec.rb" }
|
8
8
|
watch('spec/spec_helper.rb') { "spec" }
|
9
|
-
|
10
|
-
# Rails example
|
11
|
-
# watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
12
|
-
# watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
13
|
-
# watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
14
|
-
# watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
15
|
-
# watch('config/routes.rb') { "spec/routing" }
|
16
|
-
# watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
17
|
-
|
18
|
-
# Capybara request specs
|
19
|
-
# watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
20
|
-
|
21
|
-
# Turnip features and steps
|
22
|
-
# watch(%r{^spec/acceptance/(.+)\.feature$})
|
23
|
-
# watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
24
9
|
end
|
data/{LICENSE → MIT-LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -6,12 +6,13 @@ A Mongoid Extension that simplifies the use of MongoDB spatial features.
|
|
6
6
|
** On beta again **
|
7
7
|
|
8
8
|
Removing some trash, improving and adding support for RGeo and GeoRuby.
|
9
|
-
Version
|
9
|
+
Version 3+ is going to be beta testing, when it's ready I'll release v4,
|
10
10
|
So the major version stays the same as mongoid.
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
[![Gem Version](https://badge.fury.io/rb/mongoid_geospatial.png)](http://badge.fury.io/rb/mongoid_geospatial)
|
13
|
+
[![Code Climate](https://codeclimate.com/github/nofxx/mongoid_geospatial.png)](https://codeclimate.com/github/nofxx/mongoid_geospatial)
|
14
|
+
[![Coverage Status](https://coveralls.io/repos/nofxx/mongoid_geospatial/badge.png)](https://coveralls.io/r/nofxx/mongoid_geospatial)
|
15
|
+
[![Build Status](https://travis-ci.org/nofxx/mongoid_geospatial.png?branch=master)](https://travis-ci.org/nofxx/mongoid_geospatial)
|
15
16
|
|
16
17
|
|
17
18
|
Quick Start
|
@@ -49,7 +50,7 @@ For geo points, an extra macro `geo_field` is available
|
|
49
50
|
class Place
|
50
51
|
include Mongoid::Document
|
51
52
|
include Mongoid::Geospatial
|
52
|
-
|
53
|
+
|
53
54
|
# field :location, type: Point, spatial: true
|
54
55
|
geo_field :location
|
55
56
|
end
|
@@ -109,7 +110,14 @@ If you are using GeoRuby or RGeo
|
|
109
110
|
|
110
111
|
hudson.mouth.to_geo # => NiceGeolib::Point
|
111
112
|
|
112
|
-
Conventions:
|
113
|
+
Conventions:
|
114
|
+
|
115
|
+
This lib uses #x and #y everywhere.
|
116
|
+
It's shorter than lat or lng or another variation that also confuses.
|
117
|
+
A point is a 2D mathematical notation, longitude/latitude is when you use that notation to map an sphere.
|
118
|
+
|
119
|
+
In other words, all longitudes are 'xs' where not all 'xs' are longitudes.
|
120
|
+
In the eyes of a moralist it's not even a valid position point, it does not have #z or #m.
|
113
121
|
|
114
122
|
Distance and other geometrical calculations are delegated to the external
|
115
123
|
library you choosed. More info about using RGeo or GeoRuby below.
|
@@ -492,12 +500,6 @@ Using mongoid_geospatial (or mongoid for that matter) without rails?
|
|
492
500
|
You need a way to create indexes easily, check out the gem above.
|
493
501
|
|
494
502
|
|
495
|
-
Thanks
|
496
|
-
------
|
497
|
-
|
498
|
-
* Thanks to Kristian Mandrup for creating the base of the gem and a few of the tests
|
499
|
-
* Thanks to CarZen LLC. for letting me release the code we are using
|
500
|
-
|
501
503
|
|
502
504
|
Contributing
|
503
505
|
------------
|
@@ -509,11 +511,3 @@ Contributing
|
|
509
511
|
* Commit and push until you are happy with your contribution
|
510
512
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
511
513
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
512
|
-
|
513
|
-
|
514
|
-
Copyright
|
515
|
-
-----------
|
516
|
-
|
517
|
-
WTFPL
|
518
|
-
|
519
|
-
http://en.wikipedia.org/wiki/WTFPL
|
data/lib/mongoid_geospatial.rb
CHANGED
@@ -5,6 +5,7 @@ require 'mongoid_geospatial/geospatial'
|
|
5
5
|
require 'mongoid_geospatial/extensions/core_ext'
|
6
6
|
require 'mongoid_geospatial/extensions/rgeo_spherical_point_impl'
|
7
7
|
require 'mongoid_geospatial/helpers/spatial'
|
8
|
+
require 'mongoid_geospatial/helpers/sphere'
|
8
9
|
require 'mongoid_geospatial/helpers/delegate'
|
9
10
|
|
10
11
|
require 'mongoid_geospatial/fields/geometry_field'
|
@@ -54,6 +54,11 @@ module Mongoid
|
|
54
54
|
index({name => '2d'}, options)
|
55
55
|
end
|
56
56
|
|
57
|
+
def sphere_index name, options = {}
|
58
|
+
self.spatial_fields_indexed << name
|
59
|
+
index({name => '2dsphere'}, options)
|
60
|
+
end
|
61
|
+
|
57
62
|
def spatial_scope field, opts = {}
|
58
63
|
self.singleton_class.class_eval do
|
59
64
|
# define_method(:close) do |args|
|
@@ -67,3 +72,19 @@ module Mongoid
|
|
67
72
|
|
68
73
|
end
|
69
74
|
end
|
75
|
+
|
76
|
+
# model.instance_eval do # wont work
|
77
|
+
# # define_method "near_#{field.name}" do |*args|
|
78
|
+
# # self.where(field.name => args)
|
79
|
+
# # end
|
80
|
+
# end
|
81
|
+
|
82
|
+
# define_method "near_#{field.name}" do |*args|
|
83
|
+
# queryable.where(field.near_sphere => args)
|
84
|
+
# end
|
85
|
+
|
86
|
+
# model.class_eval do
|
87
|
+
# define_method "close_to" do |*args|
|
88
|
+
# queriable.where(field.name.near_sphere => *args)
|
89
|
+
# end
|
90
|
+
# end
|
@@ -1,9 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Mongoid fields extension
|
3
|
+
#
|
4
|
+
# field :foo, :delegate => {opts
|
5
|
+
#
|
1
6
|
Mongoid::Fields.option :delegate do |model, field, options|
|
2
7
|
options = {} unless options.kind_of?(Hash)
|
3
8
|
x_meth = options[:x] || :x
|
4
9
|
y_meth = options[:y] || :y
|
5
10
|
|
6
11
|
model.instance_eval do
|
12
|
+
|
7
13
|
define_method x_meth do self[field.name][0]; end
|
8
14
|
define_method y_meth do self[field.name][1]; end
|
9
15
|
|
@@ -15,10 +21,5 @@ Mongoid::Fields.option :delegate do |model, field, options|
|
|
15
21
|
self[field.name][1] = arg
|
16
22
|
end
|
17
23
|
|
18
|
-
# model.class_eval do
|
19
|
-
# define_method "close_to" do |*args|
|
20
|
-
# queriable.where(field.name.near_sphere => *args)
|
21
|
-
# end
|
22
|
-
# end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,24 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
# # self.where(field.name => args)
|
9
|
-
# # end
|
10
|
-
# end
|
1
|
+
#
|
2
|
+
# Mongoid fields extension
|
3
|
+
#
|
4
|
+
# field :foo, :spatial => true
|
5
|
+
#
|
6
|
+
Mongoid::Fields.option :spatial do |model, field, options|
|
7
|
+
# options = {} unless options.kind_of?(Hash)
|
11
8
|
|
12
9
|
model.class_eval do
|
10
|
+
|
13
11
|
self.spatial_fields << field.name.to_sym
|
14
12
|
self.spatial_fields_indexed << field.name.to_sym
|
15
13
|
|
16
14
|
# Create 2D index
|
17
15
|
spatial_index field.name
|
18
16
|
|
19
|
-
# define_method "near_#{field.name}" do |*args|
|
20
|
-
# queryable.where(field.near_sphere => args)
|
21
|
-
# end
|
22
17
|
end
|
23
|
-
|
24
18
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Mongoid fields extension
|
3
|
+
#
|
4
|
+
# field :foo, :sphere => true
|
5
|
+
#
|
6
|
+
Mongoid::Fields.option :sphere do |model, field, options|
|
7
|
+
# options = {} unless options.kind_of?(Hash)
|
8
|
+
|
9
|
+
model.class_eval do
|
10
|
+
|
11
|
+
self.spatial_fields << field.name.to_sym
|
12
|
+
self.spatial_fields_indexed << field.name.to_sym
|
13
|
+
|
14
|
+
# Create 2Dsphere index
|
15
|
+
sphere_index field.name
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/mongoid_geospatial.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/mongoid_geospatial/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Ryan Ong", "Marcos Piccinini"]
|
6
6
|
gem.email = ["use@git.hub.com"]
|
7
|
-
gem.description = "Mongoid Extension that simplifies
|
8
|
-
gem.summary = "Mongoid Extension that simplifies
|
7
|
+
gem.description = "Mongoid Extension that simplifies MongoDB operations and autocast for spatial Ruby objects."
|
8
|
+
gem.summary = "Mongoid Extension that simplifies MongoDB Geospatial Operations."
|
9
9
|
gem.homepage = "https://github.com/nofxx/mongoid_geospatial"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -17,10 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.license = "MIT"
|
18
18
|
|
19
19
|
gem.add_dependency('mongoid', ['>= 3.0.0'])
|
20
|
+
gem.add_dependency('activemodel', [">= 3.2"])
|
20
21
|
gem.add_dependency('activesupport', [">= 3.2"])
|
21
|
-
gem.add_development_dependency('yard', [">= 0.6.0"])
|
22
|
-
gem.add_development_dependency('rspec', ['>= 2.11'])
|
23
|
-
gem.add_development_dependency('kaminari', ['>= 0'])
|
24
|
-
gem.add_development_dependency('will_paginate', ['>= 0'])
|
25
|
-
gem.add_development_dependency("rake")
|
26
22
|
end
|
data/spec/models/alarm.rb
CHANGED
data/spec/models/event.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
class Event
|
2
2
|
include Mongoid::Document
|
3
|
+
include Mongoid::Geospatial
|
3
4
|
|
4
|
-
field :
|
5
|
-
field :date, :
|
6
|
-
|
7
|
-
|
8
|
-
:class_name => 'Person',
|
9
|
-
:inverse_of => :administrated_events,
|
10
|
-
:dependent => :nullify
|
11
|
-
belongs_to :owner
|
5
|
+
field :name
|
6
|
+
field :date, type: Date
|
7
|
+
|
8
|
+
field :location, type: Point, :delegate => true, :default => [7,7]
|
12
9
|
|
13
10
|
def self.each_day(start_date, end_date)
|
14
11
|
groups = only(:date).asc(:date).where(:date.gte => start_date, :date.lte => end_date).group
|
data/spec/models/person.rb
CHANGED
@@ -10,26 +10,26 @@ class Person
|
|
10
10
|
class_attribute :somebody_elses_important_class_options
|
11
11
|
self.somebody_elses_important_class_options = { :keep_me_around => true }
|
12
12
|
|
13
|
+
field :ssn
|
13
14
|
field :title
|
14
|
-
field :terms,
|
15
|
-
field :pets,
|
16
|
-
field :age,
|
17
|
-
field :dob,
|
15
|
+
field :terms, type: Boolean
|
16
|
+
field :pets, type: Boolean, :default => false
|
17
|
+
field :age, type: Integer, :default => 100
|
18
|
+
field :dob, type: Date
|
19
|
+
field :lunch_time, type: Time
|
20
|
+
field :aliases, type: Array
|
21
|
+
field :map, type: Hash
|
22
|
+
field :score, type: Integer
|
23
|
+
field :owner_id, type: Integer
|
24
|
+
field :reading, type: Object
|
25
|
+
field :bson_id, type: bson_object_id_class
|
18
26
|
field :employer_id
|
19
|
-
field :lunch_time, :type => Time
|
20
|
-
field :aliases, :type => Array
|
21
|
-
field :map, :type => Hash
|
22
|
-
field :score, :type => Integer
|
23
|
-
field :blood_alcohol_content, :type => Float, :default => lambda{ 0.0 }
|
24
|
-
field :last_drink_taken_at, :type => Date, :default => lambda { 1.day.ago.in_time_zone("Alaska") }
|
25
|
-
field :ssn
|
26
|
-
field :owner_id, :type => Integer
|
27
27
|
field :security_code
|
28
|
-
field :
|
29
|
-
field :
|
28
|
+
field :blood_alcohol_content, type: Float, :default => lambda{ 0.0 }
|
29
|
+
field :last_drink_taken_at, type: Date, :default => lambda { 1.day.ago.in_time_zone("Alaska") }
|
30
30
|
|
31
31
|
# Geo
|
32
|
-
field :location, :
|
32
|
+
field :location, type: Point
|
33
33
|
|
34
34
|
index age: 1
|
35
35
|
index addresses: 1
|
@@ -16,26 +16,57 @@ describe Mongoid::Geospatial do
|
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
# TODO: Model helpers
|
21
|
-
# describe "#geo_near" do
|
19
|
+
context "Creating indexes" do
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
it "should create a 2d index" do
|
22
|
+
Bar.create_indexes
|
23
|
+
Bar.index_options.keys.should include({:location => '2d'})
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
it "should create a 2dsphere index" do
|
27
|
+
Alarm.create_indexes
|
28
|
+
Alarm.index_options.keys.should include({:spot => '2dsphere'})
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
# Bar.create(:name => 'lax', :location => [-118.40, 33.94])
|
33
|
-
# end
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
context "#nearby 2d" do
|
34
|
+
|
35
|
+
before do
|
36
|
+
Bar.create_indexes
|
37
|
+
end
|
38
|
+
|
39
|
+
let!(:jfk) do
|
40
|
+
Bar.create(:name => 'jfk', :location => [-73.77694444, 40.63861111 ])
|
41
|
+
end
|
42
|
+
|
43
|
+
let!(:lax) do
|
44
|
+
Bar.create(:name => 'lax', :location => [-118.40, 33.94])
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should work with specifying specific center and different location attribute on collction" do
|
48
|
+
Bar.nearby(lax.location).should == [lax, jfk]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
context "#nearby 2dsphere" do
|
54
|
+
|
55
|
+
before do
|
56
|
+
Alarm.create_indexes
|
57
|
+
end
|
58
|
+
|
59
|
+
let!(:jfk) do
|
60
|
+
Alarm.create(:name => 'jfk', :spot => [-73.77694444, 40.63861111 ])
|
61
|
+
end
|
62
|
+
|
63
|
+
let!(:lax) do
|
64
|
+
Alarm.create(:name => 'lax', :spot => [-118.40, 33.94])
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should work with specifying specific center and different spot attribute on collction" do
|
68
|
+
Alarm.nearby(lax.spot).should == [lax, jfk]
|
69
|
+
end
|
39
70
|
|
40
71
|
# context ':maxDistance' do
|
41
72
|
# it "should get 1 item" do
|
@@ -107,6 +138,6 @@ describe Mongoid::Geospatial do
|
|
107
138
|
# it "per_page=5" do
|
108
139
|
# Bar.geo_near([1,1], :page => 1, :per_page => 5).size.should == 5
|
109
140
|
# end
|
110
|
-
|
141
|
+
end
|
111
142
|
|
112
143
|
end
|
@@ -3,6 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Mongoid::Fields do
|
4
4
|
|
5
5
|
context "delegate" do
|
6
|
+
|
6
7
|
before do
|
7
8
|
Bus.create_indexes
|
8
9
|
end
|
@@ -31,15 +32,23 @@ describe Mongoid::Fields do
|
|
31
32
|
|
32
33
|
end
|
33
34
|
|
34
|
-
it "should set instance
|
35
|
+
it "should set instance methods x= and y=" do
|
35
36
|
bus = Bus.create!(name: "B", location: [7,7])
|
36
37
|
bus.x = 9; bus.y = 9
|
37
38
|
bus.location.to_a.should eq([9,9])
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
+
it "should work fine with default values" do
|
42
|
+
event = Event.create!(name: "Bvent")
|
43
|
+
event.x = 9; event.y = 9
|
44
|
+
event.location.to_a.should eq([9,9])
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not work fine with nils" do
|
48
|
+
bus = Bus.create!(name: "B", location: nil)
|
49
|
+
-> { bus.x = 9; bus.y = 9 }.should raise_error(NoMethodError)
|
50
|
+
end
|
41
51
|
|
42
|
-
context "geom" do
|
43
52
|
end
|
44
53
|
|
45
54
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Mongoid::Fields do
|
4
|
+
|
5
|
+
context "spatial" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
Alarm.create_indexes
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should created indexes" do
|
12
|
+
Alarm.index_options.keys.should include({:spot => '2dsphere'})
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set spatial fields" do
|
16
|
+
Alarm.spatial_fields.should eql([:spot])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should work fine indexed" do
|
20
|
+
far = Alarm.create!(name: "Far", spot: [7,7])
|
21
|
+
far.spot.should be_instance_of(Mongoid::Geospatial::Point)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'pry'
|
1
|
+
# require 'pry'
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
4
|
|
@@ -7,6 +7,16 @@ SUPPORT = File.join(File.dirname(__FILE__), "support")
|
|
7
7
|
$LOAD_PATH.unshift(MODELS)
|
8
8
|
$LOAD_PATH.unshift(SUPPORT)
|
9
9
|
|
10
|
+
if ENV["CI"]
|
11
|
+
#require "simplecov"
|
12
|
+
require "coveralls"
|
13
|
+
Coveralls.wear!
|
14
|
+
#SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
15
|
+
#SimpleCov.start do
|
16
|
+
# add_filter "spec"
|
17
|
+
#end
|
18
|
+
end
|
19
|
+
|
10
20
|
require "mongoid"
|
11
21
|
# require "mocha"
|
12
22
|
require "rspec"
|
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: 2.8.
|
4
|
+
version: 2.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ong
|
@@ -9,121 +9,64 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 3.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
27
|
version: 3.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: activemodel
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '3.2'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '3.2'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - '>='
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 0.6.0
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - '>='
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 0.6.0
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: rspec
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '2.11'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '2.11'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: kaminari
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - '>='
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - '>='
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: will_paginate
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - '>='
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - '>='
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: rake
|
43
|
+
name: activesupport
|
100
44
|
requirement: !ruby/object:Gem::Requirement
|
101
45
|
requirements:
|
102
|
-
- -
|
46
|
+
- - ">="
|
103
47
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
105
|
-
type: :
|
48
|
+
version: '3.2'
|
49
|
+
type: :runtime
|
106
50
|
prerelease: false
|
107
51
|
version_requirements: !ruby/object:Gem::Requirement
|
108
52
|
requirements:
|
109
|
-
- -
|
53
|
+
- - ">="
|
110
54
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
112
|
-
description: Mongoid Extension that simplifies
|
113
|
-
|
114
|
-
to simplify query creation.
|
55
|
+
version: '3.2'
|
56
|
+
description: Mongoid Extension that simplifies MongoDB operations and autocast for
|
57
|
+
spatial Ruby objects.
|
115
58
|
email:
|
116
59
|
- use@git.hub.com
|
117
60
|
executables: []
|
118
61
|
extensions: []
|
119
62
|
extra_rdoc_files: []
|
120
63
|
files:
|
121
|
-
- .
|
122
|
-
- .gitignore
|
123
|
-
- .
|
64
|
+
- ".coveralls.yml"
|
65
|
+
- ".gitignore"
|
66
|
+
- ".travis.yml"
|
124
67
|
- Gemfile
|
125
68
|
- Guardfile
|
126
|
-
- LICENSE
|
69
|
+
- MIT-LICENSE
|
127
70
|
- README.md
|
128
71
|
- Rakefile
|
129
72
|
- lib/mongoid_geospatial.rb
|
@@ -138,6 +81,7 @@ files:
|
|
138
81
|
- lib/mongoid_geospatial/geospatial.rb
|
139
82
|
- lib/mongoid_geospatial/helpers/delegate.rb
|
140
83
|
- lib/mongoid_geospatial/helpers/spatial.rb
|
84
|
+
- lib/mongoid_geospatial/helpers/sphere.rb
|
141
85
|
- lib/mongoid_geospatial/version.rb
|
142
86
|
- lib/mongoid_geospatial/wrappers/georuby.rb
|
143
87
|
- lib/mongoid_geospatial/wrappers/rgeo.rb
|
@@ -161,6 +105,7 @@ files:
|
|
161
105
|
- spec/mongoid_geospatial/geospatial_spec.rb
|
162
106
|
- spec/mongoid_geospatial/helpers/delegate_spec.rb
|
163
107
|
- spec/mongoid_geospatial/helpers/spatial_spec.rb
|
108
|
+
- spec/mongoid_geospatial/helpers/sphere_spec.rb
|
164
109
|
- spec/mongoid_geospatial/wrappers/georuby_spec.rb
|
165
110
|
- spec/mongoid_geospatial/wrappers/rgeo_spec.rb
|
166
111
|
- spec/spec_helper.rb
|
@@ -177,21 +122,20 @@ require_paths:
|
|
177
122
|
- lib
|
178
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
179
124
|
requirements:
|
180
|
-
- -
|
125
|
+
- - ">="
|
181
126
|
- !ruby/object:Gem::Version
|
182
127
|
version: '0'
|
183
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
129
|
requirements:
|
185
|
-
- -
|
130
|
+
- - ">="
|
186
131
|
- !ruby/object:Gem::Version
|
187
132
|
version: '0'
|
188
133
|
requirements: []
|
189
134
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.0.
|
135
|
+
rubygems_version: 2.0.7
|
191
136
|
signing_key:
|
192
137
|
specification_version: 4
|
193
|
-
summary: Mongoid Extension that simplifies
|
194
|
-
Calculations.
|
138
|
+
summary: Mongoid Extension that simplifies MongoDB Geospatial Operations.
|
195
139
|
test_files:
|
196
140
|
- spec/models/address.rb
|
197
141
|
- spec/models/alarm.rb
|
@@ -212,6 +156,7 @@ test_files:
|
|
212
156
|
- spec/mongoid_geospatial/geospatial_spec.rb
|
213
157
|
- spec/mongoid_geospatial/helpers/delegate_spec.rb
|
214
158
|
- spec/mongoid_geospatial/helpers/spatial_spec.rb
|
159
|
+
- spec/mongoid_geospatial/helpers/sphere_spec.rb
|
215
160
|
- spec/mongoid_geospatial/wrappers/georuby_spec.rb
|
216
161
|
- spec/mongoid_geospatial/wrappers/rgeo_spec.rb
|
217
162
|
- spec/spec_helper.rb
|
data/.document
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|