Permalink
Browse files

Merge pull request #14 from kristianmandrup/master

Added geo_field macro and some extra README instructions
  • Loading branch information...
2 parents 579607d + 2724015 commit 4965a54af1723649372042ad7e5f05bc6820f6fa @nofxx nofxx committed Mar 2, 2013
Showing with 36 additions and 7 deletions.
  1. +6 −1 Gemfile
  2. +21 −1 README.md
  3. +3 −0 lib/mongoid_geospatial/geospatial.rb
  4. +4 −3 mongoid_geospatial.gemspec
  5. +2 −2 spec/models/bar.rb
View
@@ -1,7 +1,7 @@
source 'http://rubygems.org'
gemspec # Specify gem's dependencies in mongoid_geospatial.gemspec
-gem 'mongoid', '~> 3.0'
+gem 'mongoid', '>= 3.0'
group :development do
gem 'rgeo'
@@ -12,3 +12,8 @@ group :development do
gem 'pry'
# gem 'fuubar'
end
+
+group :test do
+ gem 'dbf'
+ gem 'nokogiri'
+end
View
@@ -14,7 +14,6 @@ There are no plans to support MongoDB < 2.0
There are no plans to support Mongoid <= 2.0
-
Quick Start
-----------
@@ -44,12 +43,33 @@ You can also use an external Geometric/Spatial alongside.
end
+For geo points, an extra macro `geo_field` is available
+
+
+ class Place
+ include Mongoid::Document
+ include Mongoid::Geospatial
+
+ # field :location, type: Point, spatial: true
+ geo_field :location
+ end
+
+
Generate indexes on MongoDB:
rake db:mongoid:create_indexes
+Index programatically via https://github.com/kristianmandrup/mongoid_indexing gem
+
+
+ Mongoid::Indexing.create_indexes
+
+
+This is fx useful when running specs or when working with spatials on a gem or engine.
+
+
Points
------
@@ -41,6 +41,9 @@ def self.use_georuby
end
module ClassMethods #:nodoc:
+ def geo_field name, options = {}
+ field name, {type: Mongoid::Geospatial::Point, spatial: true}.merge(options)
+ end
# create spatial index for given field
# @param [String,Symbol] name
@@ -16,9 +16,10 @@ Gem::Specification.new do |gem|
gem.version = Mongoid::Geospatial::VERSION
gem.add_dependency('mongoid', ['>= 3.0.0'])
- gem.add_dependency('activesupport', ["~> 3.2"])
- gem.add_development_dependency('yard', ["~>0.6.0"])
- gem.add_development_dependency('rspec', ['~>2.11'])
+ gem.add_dependency('activesupport', [">= 3.2"])
+
+ gem.add_development_dependency('yard', [">=0.6.0"])
+ gem.add_development_dependency('rspec', ['>=2.11'])
gem.add_development_dependency('mocha', ['>= 0'])
gem.add_development_dependency('will_paginate', ['>= 0'])
gem.add_development_dependency('kaminari', ['>= 0'])
View
@@ -3,10 +3,10 @@ class Bar
include Mongoid::Geospatial
field :name, :type => String
- field :location, :type => Point, :spatial => true
+
+ geo_field :location
has_one :rating, :as => :ratable
spatial_scope :location
-
end

0 comments on commit 4965a54

Please sign in to comment.