Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Rubocop

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- run: bundle exec rubocop
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

services:
mongo:
image: mongo:7
ports: ["27017:27017"]

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true

- name: Run tests
run: bundle exec rspec
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
inherit_from: .rubocop_todo.yml

AllCops:
NewCops: enable
TargetRubyVersion: 3.1

plugins:
- rubocop-rake
# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
Expand Down
58 changes: 58 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2026-02-04 21:23:09 UTC using RuboCop version 1.84.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Gemspec/DuplicatedAssignment:
Exclude:
- 'mongoid-geospatial.gemspec'

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 26

# Offense count: 25
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 259

# Offense count: 4
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 25

# Offense count: 3
Style/ClassVars:
Exclude:
- 'lib/mongoid/geospatial.rb'

# Offense count: 3
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/mongoid/geospatial/config.rb'
- 'lib/mongoid/geospatial/config/point.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, Autocorrect.
# SupportedStyles: module_function, extend_self, forbidden
Style/ModuleFunction:
Exclude:
- 'lib/mongoid/geospatial/config.rb'
- 'lib/mongoid/geospatial/config/point.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Max: 135
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ group :development, :test do
gem 'reline'
gem 'rgeo'
gem 'rubocop'
gem 'rubocop-rake'
gem 'yard'
end

group :test do
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
A Mongoid Extension that simplifies the use of MongoDB spatial features.

[![Gem Version](https://badge.fury.io/rb/mongoid-geospatial.svg)](http://badge.fury.io/rb/mongoid-geospatial)
[![Test](https://github.com/mongoid/mongoid-geospatial/actions/workflows/test.yml/badge.svg)](https://github.com/mongoid/mongoid-geospatial/actions/workflows/test.yml)
[![Code Climate](https://codeclimate.com/github/mongoid/mongoid-geospatial.svg)](https://codeclimate.com/github/mongoid/mongoid-geospatial)
[![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid-geospatial/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid-geospatial?branch=master)
[![Build Status](https://travis-ci.org/mongoid/mongoid-geospatial.svg?branch=master)](https://travis-ci.org/mongoid/mongoid-geospatial)

## Quick Start

Expand Down
3 changes: 3 additions & 0 deletions spec/benchmark/geolibs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ Mongoid.load!(File.expand_path('mongoid.yml', __dir__), :test)

class NoGeo
include Mongoid::Document

field :name
end

class Rider
include Mongoid::Document
include Mongoid::Geospatial

field :name
end

class Cafe
include Mongoid::Document
include Mongoid::Geospatial

field :name
field :spot, type: Point
end
Expand Down
2 changes: 2 additions & 0 deletions spec/benchmark/geonear
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Mongoid.load!(File.expand_path('../mongoid.yml', __dir__), :test)
class Cafe
include Mongoid::Document
include Mongoid::Geospatial

field :name
field :geom, type: Point, spatial: true
spatial_index :geom
Expand All @@ -20,6 +21,7 @@ end
class Cafe2d
include Mongoid::Document
include Mongoid::Geospatial

field :name
field :geom, type: Point, sphere: true
spherical_index :geom
Expand Down
1 change: 1 addition & 0 deletions spec/models/phone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Sample spec class
class Phone
include Mongoid::Document

field :number

embeds_one :country_code
Expand Down