mongoid_spacial 0.2.16 → 0.2.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ mongoid_spacial
@@ -0,0 +1 @@
1
+ ruby-1.9.3
data/Gemfile CHANGED
@@ -1,4 +1,10 @@
1
- source 'http://rubygems.org'
2
-
1
+ source 'https://rubygems.org'
3
2
  # Specify your gem's dependencies in mongoid_spacial.gemspec
4
3
  gemspec
4
+
5
+ gem "rake"
6
+ gem "yard"
7
+
8
+ group :test do
9
+ gem "rspec", "~> 2.11"
10
+ end
data/README.md CHANGED
@@ -34,6 +34,13 @@ class River
34
34
  end
35
35
  ```
36
36
 
37
+ Generate indexes on MongoDB:
38
+
39
+ ```
40
+ rake db:mongoid:create_indexes
41
+ ```
42
+
43
+
37
44
  Before we manipulate the data mongoid_spacial handles is what we call points.
38
45
 
39
46
  Points can be:
@@ -65,7 +72,7 @@ hudson.source #=> {:lng => -73.935833, :lat => 44.106667}
65
72
  hudson.mouth #=> [-74.026667, 40.703056] # notice how this returned as a lng,lat array because return_array was true
66
73
  # notice how the order of lng and lat were switched. it will always come out like this when using spacial.
67
74
  # Also adds a handy distance function
68
- hudson.distance_from(:source, [-74,40], :mi)
75
+ hudson.distance_from(:source, [-74,40], {:unit=>:mi})
69
76
 
70
77
  ```
71
78
  Mongoid Geo has extended all built in spacial symbol extentions
@@ -143,6 +150,14 @@ rivers = rivers.per(25).page(1)
143
150
  rivers.reset! # resets the object to it is original state right after query.
144
151
  ```
145
152
 
153
+ Troubleshooting
154
+ -------------
155
+
156
+ **Mongo::OperationFailure: can't find special index: 2d**
157
+
158
+ Indexes need to be created. Execute command: <code>rake db:mongoid:create_indexes</code>
159
+
160
+
146
161
  Thanks
147
162
  -----------
148
163
  * Thanks to Kristian Mandrup for creating the base of the gem and a few of the tests
@@ -16,15 +16,13 @@ module Mongoid
16
16
  # @param [Hash] options options for spacial_index
17
17
  def spacial_index name, *options
18
18
  self.spacial_fields_indexed << name
19
- index [[ name, Mongo::GEO2D ]], *options
19
+ index [[ name, ::Mongo::GEO2D ]], *options
20
20
  end
21
21
  end
22
22
 
23
- module InstanceMethods #:nodoc:
24
- def distance_from(key,p2, opts = {})
25
- p1 = self.send(key)
26
- Mongoid::Spacial.distance(p1, p2, opts)
27
- end
23
+ def distance_from(key,p2, opts = {})
24
+ p1 = self.send(key)
25
+ Mongoid::Spacial.distance(p1, p2, opts)
28
26
  end
29
27
  end
30
28
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Spacial
3
- VERSION = "0.2.16"
3
+ VERSION = "0.2.17"
4
4
  end
5
5
  end
@@ -2,8 +2,8 @@
2
2
  require File.expand_path('../lib/mongoid_spacial/spacial/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Ryan Ong"]
6
- gem.email = ["ryanong@gmail.com"]
5
+ gem.authors = ["Ryan Ong", "Arthur Neves"]
6
+ gem.email = ["ryanong@gmail.com", "arthurnn@gmail.com"]
7
7
  gem.description = %q{mongoid_spacial simplifies spacial calculations. Adds integration into mongoid so pagination and other function continue to work. It adds symbol extentions to simplify query creation.}
8
8
  gem.summary = %q{A Mongoid Extention that simplifies and adds support for MongoDB Geo Spacial Calculations.}
9
9
  gem.homepage = "https://github.com/ryanong/mongoid_spacial"
@@ -15,13 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Mongoid::Spacial::VERSION
17
17
 
18
- gem.add_dependency("mongoid", ['>= 2.3.0'])
18
+ gem.add_dependency("mongoid", ['>= 2.1.0', '< 3.0.0'])
19
19
  gem.add_dependency('activesupport', ["~> 3.0"])
20
- gem.add_development_dependency('yard', ["~>0.6.0"])
21
- gem.add_development_dependency('rspec', ['~>2.3'])
22
- gem.add_development_dependency('rcov', ['>= 0'])
23
- gem.add_development_dependency('mocha', ['>= 0'])
24
- gem.add_development_dependency('will_paginate', ['>= 0'])
25
- gem.add_development_dependency('kaminari', ['>= 0'])
26
20
 
27
21
  end
@@ -91,7 +91,7 @@ describe Mongoid::Contexts::Mongo do
91
91
  end
92
92
  end
93
93
  context ":paginator :array" do
94
- [nil,1,2].each do |page|
94
+ [nil,1,2].each do |page|
95
95
  it "page=#{page} should have 25" do
96
96
  Bar.geo_near([1,1], :page => page).size.should == 25
97
97
  end
@@ -100,26 +100,27 @@ describe Mongoid::Contexts::Mongo do
100
100
  it "page=3 should have 0" do
101
101
  Bar.geo_near([1,1], :page => 20).size.should == 0
102
102
  end
103
-
103
+
104
104
  it "per_page=5" do
105
105
  Bar.geo_near([1,1], :page => 1, :per_page => 5).size.should == 5
106
106
  end
107
107
  end
108
108
 
109
- context ":paginator :kaminari" do
109
+ context ":paginator :kaminari" do
110
110
  let(:near) {Bar.geo_near([1,1], :page => 1)}
111
111
  it "should have current_page" do
112
112
  near.current_page.should == 1
113
113
  end
114
114
 
115
115
  it "should have num_pages" do
116
+ pending
116
117
  near.num_pages.should == 2
117
118
  end
118
119
 
119
120
  it "should have limit_value" do
120
121
  near.limit_value.should == 25
121
122
  end
122
- end
123
+ end
123
124
  end
124
125
 
125
126
  end
@@ -6,9 +6,8 @@ SUPPORT = File.join(File.dirname(__FILE__), "support")
6
6
  $LOAD_PATH.unshift(MODELS)
7
7
  $LOAD_PATH.unshift(SUPPORT)
8
8
 
9
- require "mongoid"
10
- require "mocha"
11
9
  require "rspec"
10
+ require "mongoid"
12
11
  require "mongoid_spacial"
13
12
 
14
13
  LOGGER = Logger.new($stdout)
@@ -28,7 +27,6 @@ Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file)
28
27
  Dir[ File.join(SUPPORT, "*.rb") ].each { |file| require File.basename(file) }
29
28
 
30
29
  RSpec.configure do |config|
31
- config.mock_with(:mocha)
32
30
 
33
31
  config.after(:suite) { Mongoid.purge! }
34
32
 
metadata CHANGED
@@ -1,109 +1,61 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_spacial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Ong
9
+ - Arthur Neves
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2011-10-05 00:00:00.000000000Z
13
+ date: 2013-05-08 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: mongoid
16
- requirement: &2160448560 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ! '>='
20
21
  - !ruby/object:Gem::Version
21
- version: 2.3.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *2160448560
25
- - !ruby/object:Gem::Dependency
26
- name: activesupport
27
- requirement: &2160448020 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
22
+ version: 2.1.0
23
+ - - <
31
24
  - !ruby/object:Gem::Version
32
- version: '3.0'
25
+ version: 3.0.0
33
26
  type: :runtime
34
27
  prerelease: false
35
- version_requirements: *2160448020
36
- - !ruby/object:Gem::Dependency
37
- name: yard
38
- requirement: &2160447500 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 0.6.0
44
- type: :development
45
- prerelease: false
46
- version_requirements: *2160447500
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
- requirement: &2160446960 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '2.3'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *2160446960
58
- - !ruby/object:Gem::Dependency
59
- name: rcov
60
- requirement: &2160446480 !ruby/object:Gem::Requirement
28
+ version_requirements: !ruby/object:Gem::Requirement
61
29
  none: false
62
30
  requirements:
63
31
  - - ! '>='
64
32
  - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: *2160446480
69
- - !ruby/object:Gem::Dependency
70
- name: mocha
71
- requirement: &2160445940 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ! '>='
33
+ version: 2.1.0
34
+ - - <
75
35
  - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *2160445940
36
+ version: 3.0.0
80
37
  - !ruby/object:Gem::Dependency
81
- name: will_paginate
82
- requirement: &2160445420 !ruby/object:Gem::Requirement
38
+ name: activesupport
39
+ requirement: !ruby/object:Gem::Requirement
83
40
  none: false
84
41
  requirements:
85
- - - ! '>='
42
+ - - ~>
86
43
  - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
44
+ version: '3.0'
45
+ type: :runtime
89
46
  prerelease: false
90
- version_requirements: *2160445420
91
- - !ruby/object:Gem::Dependency
92
- name: kaminari
93
- requirement: &2160444860 !ruby/object:Gem::Requirement
47
+ version_requirements: !ruby/object:Gem::Requirement
94
48
  none: false
95
49
  requirements:
96
- - - ! '>='
50
+ - - ~>
97
51
  - !ruby/object:Gem::Version
98
- version: '0'
99
- type: :development
100
- prerelease: false
101
- version_requirements: *2160444860
52
+ version: '3.0'
102
53
  description: mongoid_spacial simplifies spacial calculations. Adds integration into
103
54
  mongoid so pagination and other function continue to work. It adds symbol extentions
104
55
  to simplify query creation.
105
56
  email:
106
57
  - ryanong@gmail.com
58
+ - arthurnn@gmail.com
107
59
  executables: []
108
60
  extensions: []
109
61
  extra_rdoc_files: []
@@ -111,6 +63,8 @@ files:
111
63
  - .document
112
64
  - .gitignore
113
65
  - .rspec
66
+ - .ruby-gemset
67
+ - .ruby-version
114
68
  - Gemfile
115
69
  - LICENSE.txt
116
70
  - README.md
@@ -229,15 +183,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
183
  - - ! '>='
230
184
  - !ruby/object:Gem::Version
231
185
  version: '0'
186
+ segments:
187
+ - 0
188
+ hash: -2483791480544653354
232
189
  required_rubygems_version: !ruby/object:Gem::Requirement
233
190
  none: false
234
191
  requirements:
235
192
  - - ! '>='
236
193
  - !ruby/object:Gem::Version
237
194
  version: '0'
195
+ segments:
196
+ - 0
197
+ hash: -2483791480544653354
238
198
  requirements: []
239
199
  rubyforge_project:
240
- rubygems_version: 1.8.6
200
+ rubygems_version: 1.8.25
241
201
  signing_key:
242
202
  specification_version: 3
243
203
  summary: A Mongoid Extention that simplifies and adds support for MongoDB Geo Spacial