repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/business.rb | spec/models/business.rb | class Business
include Mongoid::Document
set_database :secondary
field :name
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/namespacing.rb | spec/models/namespacing.rb | module Medical
class Patient
include Mongoid::Document
field :name
embeds_many :prescriptions, :class_name => "Medical::Prescription"
end
class Prescription
include Mongoid::Document
field :name
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/page.rb | spec/models/page.rb | class Page
include Mongoid::Document
embedded_in :quiz
embeds_many :page_questions
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/pet.rb | spec/models/pet.rb | class Pet
include Mongoid::Document
field :name
field :weight, :type => Float, :default => 0.0
embeds_many :vet_visits
embedded_in :pet_owner
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/pet_owner.rb | spec/models/pet_owner.rb | class PetOwner
include Mongoid::Document
field :title
embeds_one :pet
embeds_one :address, :as => :addressable
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/description.rb | spec/models/description.rb | class Description
include Mongoid::Document
field :details
referenced_in :user
referenced_in :updater, :class_name => 'User'
validates :user, :associated => true
validates :details, :presence => true
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/division.rb | spec/models/division.rb | class Division
include Mongoid::Document
field :name, :type => String
embedded_in :league
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/birthday.rb | spec/models/birthday.rb | class Birthday
include Mongoid::Document
field :title
field :date, :type => Date
embedded_in :owner, :inverse_of => :birthdays
def self.each_day(start_date, end_date)
groups = only(:date).asc(:date).where(:date.gte => start_date, :date.lte => end_date).group
groups.each do |date, group|
yield(d... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/league.rb | spec/models/league.rb | class League
include Mongoid::Document
embeds_many :divisions
accepts_nested_attributes_for :divisions, :allow_destroy => true
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/owner.rb | spec/models/owner.rb | class Owner
include Mongoid::Document
field :name
references_many :events
embeds_many :birthdays
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/animal.rb | spec/models/animal.rb | class Animal
include Mongoid::Document
field :name
field :tags, :type => Array
key :name
embedded_in :person
embedded_in :circus
validates_format_of :name, :without => /\$\$\$/
accepts_nested_attributes_for :person
def tag_list
tags.join(", ")
end
def tag_list=(_tag_list)
self.tags = ... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/category.rb | spec/models/category.rb | class RootCategory
include Mongoid::Document
embeds_many :categories
end
class Category
include Mongoid::Document
embedded_in :root_category
embedded_in :category
embeds_many :categories
field :name
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/parents.rb | spec/models/parents.rb | class ParentDoc
include Mongoid::Document
embeds_many :child_docs
field :statistic
field :children_order, :type => Array, :default => [] # hold all the children's id
end
class ChildDoc
include Mongoid::Document
embedded_in :parent_doc
attr_writer :position
after_save :update_position
def posit... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/callbacks.rb | spec/models/callbacks.rb | class Artist
include Mongoid::Document
field :name
embeds_many :songs
embeds_many :labels
before_create :before_create_stub
after_create :create_songs
before_save :before_save_stub
before_destroy :before_destroy_stub
protected
def before_create_stub
true
end
def before_save_stub
true
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/patient.rb | spec/models/patient.rb | class Email
include Mongoid::Document
field :address
validates_uniqueness_of :address
embedded_in :patient
end
class Patient
include Mongoid::Document
field :title
store_in :inpatient
embeds_many :addresses, :as => :addressable
embeds_one :email
validates_presence_of :title, :on => :create
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/player.rb | spec/models/player.rb | class Player
include Mongoid::Document
field :active, :type => Boolean
field :frags, :type => Integer
field :deaths, :type => Integer
field :status
named_scope :active, criteria.where(:active => true) do
def extension
"extension"
end
end
named_scope :inactive, :where => { :active => false... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/vet_visit.rb | spec/models/vet_visit.rb | class VetVisit
include Mongoid::Document
field :date, :type => Date
embedded_in :pet
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/address.rb | spec/models/address.rb | class Address
include Mongoid::Document
attr_accessor :mode
field :address_type
field :number, :type => Integer
field :street
field :city
field :state
field :post_code
field :parent_title
field :services, :type => Array
field :latlng, :type => Array
key :street
embeds_many :locations
embe... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/house.rb | spec/models/house.rb | class House
include Mongoid::Document
field :name, :type => String
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/login.rb | spec/models/login.rb | class Login
include Mongoid::Document
field :username
key :username
validates_uniqueness_of :username
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/location.rb | spec/models/location.rb | class Location
include Mongoid::Document
field :name
embedded_in :address
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/comment.rb | spec/models/comment.rb | class Comment
include Mongoid::Document
include Mongoid::Versioning
include Mongoid::Timestamps
field :title, :type => String
field :text, :type => String
key :text, :type => String
referenced_in :movie
referenced_in :rating
validates :title, :presence => true
validates :movie, :rating, :associated... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/tracking_id_validation_history.rb | spec/models/tracking_id_validation_history.rb | # These models are spcific to test for Github #313.
module MyCompany
module Model
class TrackingId
include Mongoid::Document
include Mongoid::Timestamps
store_in :tracking_ids
embeds_many :validation_history, :class_name => "MyCompany::Model::TrackingIdValidationHistory"
end
end
end
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/name.rb | spec/models/name.rb | class Name
include Mongoid::Document
field :first_name
field :last_name
field :parent_title
key :first_name, :last_name
embeds_many :translations
embedded_in :namable, :polymorphic => true
def set_parent=(set = false)
self.parent_title = namable.title if set
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/override.rb | spec/models/override.rb | class Override
include Mongoid::Document
def self.public_method
end
protected
def self.protected_method
end
private
def self.private_method
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/rating.rb | spec/models/rating.rb | class Rating
include Mongoid::Document
field :value, :type => Integer
referenced_in :ratable, :polymorphic => true
references_many :comments
validates_numericality_of :value, :less_than => 100, :allow_nil => true
validates :ratable, :associated => true
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/favorite.rb | spec/models/favorite.rb | class Favorite
include Mongoid::Document
field :title
validates_uniqueness_of :title, :case_sensitive => false
embedded_in :perp, :inverse_of => :favorites
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/post.rb | spec/models/post.rb | class Post
include Mongoid::Document
include Mongoid::MultiParameterAttributes
include Mongoid::Versioning
include Mongoid::Timestamps
field :title, :type => String
field :content, :type => String
field :rating, :type => Integer
belongs_to :person
belongs_to :author, :foreign_key => :author_id, :cla... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/bar.rb | spec/models/bar.rb | class Bar
include Mongoid::Document
include Mongoid::Spacial::Document
field :name, :type => String
field :location, :type => Array, :spacial => true
references_one :rating, :as => :ratable
spacial_index :location
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/river.rb | spec/models/river.rb | class River
include Mongoid::Document
include Mongoid::Spacial::Document
field :name, type: String
field :length, type: Integer
field :average_discharge, type: Integer
field :source, type: Array, spacial: true
# set return_array to true if you do not want a hash retu... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/video.rb | spec/models/video.rb | class Video
include Mongoid::Document
field :title
embedded_in :person
referenced_in :post
referenced_in :game
default_scope asc(:title)
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/question.rb | spec/models/question.rb | class Question
include Mongoid::Document
field :content
embedded_in :survey
embeds_many :answers
accepts_nested_attributes_for :answers, :reject_if => lambda { |a| a[:content].blank? }, :allow_destroy => true
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/user_account.rb | spec/models/user_account.rb | class UserAccount
include Mongoid::Document
field :username
field :name
field :email
validates_uniqueness_of :username, :message => "is not unique"
validates_uniqueness_of :email, :message => "is not unique", :case_sensitive => false
validates_length_of :name, :minimum => 2, :allow_nil => true
reference... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/acolyte.rb | spec/models/acolyte.rb | class Acolyte
include Mongoid::Document
field :status
field :name
scope :active, where(:status => "active")
default_scope asc(:name)
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/drug.rb | spec/models/drug.rb | class Drug
include Mongoid::Document
field :name, :type => String
referenced_in :person
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/service.rb | spec/models/service.rb | class Service
include Mongoid::Document
field :sid
embedded_in :person
validates_numericality_of :sid
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/role.rb | spec/models/role.rb | class Role
include Mongoid::Document
field :name, :type => String
recursively_embeds_many
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/phone.rb | spec/models/phone.rb | class Phone
include Mongoid::Document
field :number
key :number
embeds_one :country_code
embedded_in :person
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/survey.rb | spec/models/survey.rb | class Survey
include Mongoid::Document
embeds_many :questions
accepts_nested_attributes_for :questions, :reject_if => lambda{ |a| a[:content].blank? }, :allow_destroy => true
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/person.rb | spec/models/person.rb | class Person
include Mongoid::Document
include Mongoid::MultiParameterAttributes
include Mongoid::Timestamps
include Mongoid::Versioning
attr_accessor :mode
class_attribute :somebody_elses_important_class_options
self.somebody_elses_important_class_options = { :keep_me_around => true }
field :title
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/circus.rb | spec/models/circus.rb | class Circus
include Mongoid::Document
field :name
embeds_many :animals
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/alert.rb | spec/models/alert.rb | class Alert
include Mongoid::Document
field :message, :type => String
referenced_in :account
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/wiki_page.rb | spec/models/wiki_page.rb | class WikiPage
include Mongoid::Document
include Mongoid::Versioning
field :title, :type => String
max_versions 5
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/ghost.rb | spec/models/ghost.rb | class Ghost
include Mongoid::Document
field :name, :type => String
referenced_in :movie, :autosave => true
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/fruits.rb | spec/models/fruits.rb | module Fruits
class Apple
include Mongoid::Document
references_many :bananas, :class_name => "Fruits::Banana"
end
class Banana
include Mongoid::Document
referenced_in :apple, :class_name => "Fruits::Apple"
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/models/user.rb | spec/models/user.rb | class User
include Mongoid::Document
field :name
references_one :account, :foreign_key => :creator_id
references_many :posts, :foreign_key => :author_id
references_many :descriptions
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/unit/mongoid/spacial_spec.rb | spec/unit/mongoid/spacial_spec.rb | require "spec_helper"
describe Mongoid::Spacial do
describe '#distance' do
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/unit/mongoid/criterion/within_spacial_spec.rb | spec/unit/mongoid/criterion/within_spacial_spec.rb | require "spec_helper"
describe Mongoid::Criterion::WithinSpacial do
let(:within) do
{
:box => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "box"),
:polygon => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "polygon"),
:center => Mongoid::Criterion::Wit... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/unit/mongoid/criterion/near_spacial_spec.rb | spec/unit/mongoid/criterion/near_spacial_spec.rb | require "spec_helper"
describe Mongoid::Criterion::NearSpacial do
let(:within) do
{
:flat => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "near"),
:sphere => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "nearSphere"),
}
end
NEAR = {
:flat =>
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/unit/mongoid/criterion/complex_spec.rb | spec/unit/mongoid/criterion/complex_spec.rb | require "spec_helper"
describe Mongoid::Criterion::Complex do
let(:complex) { Mongoid::Criterion::Complex.new(:key => :field, :operator => "gt") }
let(:value) { 40 }
context "#to_mongo_query" do
it "should turn value into appropriate query" do
complex.to_mongo_query(value).should == {"$gt" => value}... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/unit/mongoid/criterion/inclusion_spec.rb | spec/unit/mongoid/criterion/inclusion_spec.rb | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false | |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/unit/mongoid/spacial/formulas_spec.rb | spec/unit/mongoid/spacial/formulas_spec.rb | require "spec_helper"
describe Mongoid::Spacial::Formulas do
context "#n_vector" do
it {
bna = [-86.67, 36.12]
lax = [-118.40, 33.94]
dist1 = Mongoid::Spacial::Formulas.n_vector(bna, lax)
dist2 = Mongoid::Spacial::Formulas.n_vector(lax, bna)
# target is 0.45306
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/functional/mongoid/spacial_spec.rb | spec/functional/mongoid/spacial_spec.rb | require "spec_helper"
describe Mongoid::Spacial do
describe '#distance' do
it "should calculate 2d by default" do
Mongoid::Spacial.distance([0,0],[3,4]).should == 5
end
it "should calculate 2d distances using degrees" do
Mongoid::Spacial.distance([0,0],[3,4], :unit=>:mi).should == 5*Mongoid:... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/functional/mongoid/criterion/inclusion_spec.rb | spec/functional/mongoid/criterion/inclusion_spec.rb | require "spec_helper"
describe Mongoid::Criterion::Inclusion do
before do
Person.delete_all
end
describe "#where" do
let(:dob) do
33.years.ago.to_date
end
let(:lunch_time) do
30.minutes.ago
end
let!(:person) do
Person.create(
:title => "Sir",
:dob =>... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/functional/mongoid/spacial/geo_near_results_spec.rb | spec/functional/mongoid/spacial/geo_near_results_spec.rb | require "spec_helper"
describe Mongoid::Spacial::GeoNearResults do
before(:all) do
Bar.delete_all
Bar.create_indexes
50.times do |i|
Bar.create(:name => i.to_s, :location => [rand(358)-179,rand(358)-179])
end
end
before(:each) do
while Bar.count < 50
end
end
context ":paginat... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/spec/functional/mongoid/contexts/mongo_spec.rb | spec/functional/mongoid/contexts/mongo_spec.rb | require "spec_helper"
describe Mongoid::Contexts::Mongo do
describe "#geo_near" do
before do
Bar.delete_all
Bar.create_indexes
end
let!(:jfk) do
Bar.create(:name => 'jfk', :location => [-73.77694444, 40.63861111 ])
end
let!(:lax) do
Bar.create(:name => 'lax', :location ... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial.rb | lib/mongoid_spacial.rb | require 'mongoid'
require 'active_support/core_ext/string/inflections'
require 'active_support/concern'
require 'mongoid_spacial/contexts/mongo'
require 'mongoid_spacial/criteria'
require 'mongoid_spacial/criterion'
require 'mongoid_spacial/extentions/hash/criteria_helpers'
require 'mongoid_spacial/extentions/symbol/in... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/finders.rb | lib/mongoid_spacial/finders.rb | module Mongoid #:nodoc:
module Finders
delegate :geo_near, :to => :criteria
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/spacial.rb | lib/mongoid_spacial/spacial.rb | require 'mongoid_spacial/spacial/core_ext'
require 'mongoid_spacial/spacial/formulas'
require 'mongoid_spacial/spacial/document'
require 'mongoid_spacial/spacial/geo_near_results'
module Mongoid
module Spacial
EARTH_RADIUS_KM = 6371 # taken directly from mongodb
EARTH_RADIUS = {
:km => EARTH_RADIUS_KM... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/field_option.rb | lib/mongoid_spacial/field_option.rb | require 'ostruct'
# Field changes to Fields from mongoid 2.0 to mongoid 2.1
field = (defined?(Mongoid::Field)) ? Mongoid::Field : Mongoid::Fields
field.option :spacial do |model,field,options|
options = {} unless options.kind_of?(Hash)
lat_meth = options[:lat] || :lat
lng_meth = options[:lng] || :lng
model.cla... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/criterion.rb | lib/mongoid_spacial/criterion.rb | require 'mongoid_spacial/criterion/complex'
require 'mongoid_spacial/criterion/near_spacial'
require 'mongoid_spacial/criterion/within_spacial'
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/criteria.rb | lib/mongoid_spacial/criteria.rb | module Mongoid #:nodoc:
class Criteria
delegate :geo_near, :to => :context
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/criterion/within_spacial.rb | lib/mongoid_spacial/criterion/within_spacial.rb | # encoding: utf-8
module Mongoid #:nodoc:
module Criterion #:nodoc:
# WithinSpecial criterion is used when performing #within with symbols to get
# get a shorthand syntax for where clauses.
#
# @example Conversion of a simple to complex criterion.
# { :field => { "$within" => {'$center' => [20,... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/criterion/near_spacial.rb | lib/mongoid_spacial/criterion/near_spacial.rb | # encoding: utf-8
module Mongoid #:nodoc:
module Criterion #:nodoc:
# NearSpecial criterion is used when performing #near with symbols to get
# get a shorthand syntax for where clauses.
#
# @example Coninputersion of a simple to complex criterion.
# { :field => { "$nearSphere" => => [20,30]}, '... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/criterion/complex.rb | lib/mongoid_spacial/criterion/complex.rb | # encoding: utf-8
module Mongoid #:nodoc:
module Criterion #:nodoc:
# Complex criterion are used when performing operations on symbols to get
# get a shorthand syntax for where clauses.
#
# Example:
#
# <tt>{ :field => { "$lt" => "value" } }</tt>
# becomes:
# <tt> { :field.lt => "value... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/criterion/inclusion.rb | lib/mongoid_spacial/criterion/inclusion.rb | # encoding: utf-8
module Mongoid #:nodoc:
module Criterion #:nodoc:
module Inclusion
def near(attributes = {})
update_selector(attributes, "$near")
end
def near_sphere(attributes = {})
update_selector(attributes, "$near")
end
end
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/extentions/hash/criteria_helpers.rb | lib/mongoid_spacial/extentions/hash/criteria_helpers.rb | # encoding: utf-8
module Mongoid #:nodoc:
module Extensions #:nodoc:
module Hash #:nodoc:
module CriteriaHelpers #:nodoc:
def expand_complex_criteria
hsh = {}
each_pair do |k,v|
if k.respond_to?(:key) && k.respond_to?(:to_mongo_query)
hsh[k.key] ||= {}
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/extentions/symbol/inflections.rb | lib/mongoid_spacial/extentions/symbol/inflections.rb | # encoding: utf-8
module Mongoid #:nodoc:
module Extensions #:nodoc:
module Symbol #:nodoc:
module Inflections #:nodoc:
# return a class that will accept a value to convert the query correctly for near
#
# @param [Symbol] calc This accepts :sphere
#
# @return [Criter... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/spacial/version.rb | lib/mongoid_spacial/spacial/version.rb | module Mongoid
module Spacial
VERSION = "0.2.17"
end
end
| ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/spacial/core_ext.rb | lib/mongoid_spacial/spacial/core_ext.rb | class Array
def to_lng_lat
self[0..1].map(&:to_f)
end
end
class Hash
def to_lng_lat
raise "Hash must have at least 2 items" if self.size < 2
[to_lng, to_lat]
end
def to_lat
v = (Mongoid::Spacial.lat_symbols & self.keys).first
return self[v].to_f if !v.nil? && self[v]
raise "Hash must... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/spacial/formulas.rb | lib/mongoid_spacial/spacial/formulas.rb | module Mongoid
module Spacial
module Formulas
class << self
def n_vector(point1,point2)
p1 = point1.map{|deg| deg * RAD_PER_DEG}
p2 = point2.map{|deg| deg * RAD_PER_DEG}
sin_x1 = Math.sin(p1[0])
cos_x1 = Math.cos(p1[0])
sin_y1 = Math.sin(p1[1])
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/spacial/geo_near_results.rb | lib/mongoid_spacial/spacial/geo_near_results.rb | module Mongoid
module Spacial
class GeoNearResults < Array
attr_reader :stats, :document, :_original_array, :_original_opts
attr_accessor :opts
def initialize(document,results,opts = {})
raise "#{document.name} class must include Mongoid::Spacial::Document" unless document.respond_to?(:... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/spacial/document.rb | lib/mongoid_spacial/spacial/document.rb | module Mongoid
module Spacial
module Document
extend ActiveSupport::Concern
included do
attr_accessor :geo
cattr_accessor :spacial_fields, :spacial_fields_indexed
@@spacial_fields = []
@@spacial_fields_indexed = []
end
module ClassMethods #:nodoc:
... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
ryanong/mongoid_spacial | https://github.com/ryanong/mongoid_spacial/blob/edb363054c4449892f4a0784ad9b826156af79a0/lib/mongoid_spacial/contexts/mongo.rb | lib/mongoid_spacial/contexts/mongo.rb | # encoding: utf-8
module Mongoid #:nodoc:
module Contexts #:nodoc:
class Mongo #:nodoc:
# Fetches rows from the data base sorted by distance.
# In MongoDB versions 1.7 and above it returns a distance.
# Uses all criteria chains except without, only, asc, desc, order_by
#
# @example ... | ruby | MIT | edb363054c4449892f4a0784ad9b826156af79a0 | 2026-01-04T17:44:07.066009Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/serializers/place_serializer.rb | app/serializers/place_serializer.rb | class PlaceSerializer < ActiveModel::Serializer
attributes :id, :date, :lat, :lng
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/serializers/weight_serializer.rb | app/serializers/weight_serializer.rb | class WeightSerializer < ActiveModel::Serializer
attributes :id, :bmi, :value, :lean_mass, :fat_mass, :fat_percent, :date
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/serializers/user_serializer.rb | app/serializers/user_serializer.rb | class UserSerializer < ActiveModel::Serializer
attributes :id, :email, :name, :height
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/serializers/journal_entry_serializer.rb | app/serializers/journal_entry_serializer.rb | class JournalEntrySerializer < ActiveModel::Serializer
attributes :id, :recorded_at, :feelings, :happiness, :strategies
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/serializers/meal_serializer.rb | app/serializers/meal_serializer.rb | class MealSerializer < ActiveModel::Serializer
attributes :id, :date, :calories, :carbohydrates, :fat, :protein,
:carbohydrates_percentage, :fat_percentage, :protein_percentage
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/serializers/sleep_serializer.rb | app/serializers/sleep_serializer.rb | class SleepSerializer < ActiveModel::Serializer
attributes :id, :start, :end, :user_id
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/helpers/dashboard_helper.rb | app/helpers/dashboard_helper.rb | module DashboardHelper
def domain_resize(user_data)
user_data.map do |d|
if d == user_data.min
0
elsif d == user_data.max
1
else
(d-user_data.min) * 1/(user_data.max-user_data.min).to_f
end
end
end
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/helpers/meals_helper.rb | app/helpers/meals_helper.rb | module MealsHelper
def macro_percent_for_meals meals, macro
sum = 0
Meal::MACRO_NUTRIENTS.each do |macro|
sum += meals.to_a.sum(¯o.to_sym)
end
meals.to_a.sum(¯o.to_sym).to_f / sum.to_f * 100
end
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/helpers/sleeps_helper.rb | app/helpers/sleeps_helper.rb | module SleepsHelper
def formatted_duration sleep
pluralize ( sleep.duration / 1.hour).round(1), 'hour'
end
def average_duration opts={}
opts = {
start: 7.days.ago.at_beginning_of_day,
end: Date.today.at_beginning_of_day
}.merge(opts)
sleeps = current_user.sleeps_between(opts[:sta... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/helpers/application_helper.rb | app/helpers/application_helper.rb | module ApplicationHelper
def nav_link text, link, icon={}
icon = {
size: "1x"
}.merge(icon)
content = link_to icon[:type].present? ? fa_icon(icon[:type].to_s, text: text, class: icon[:size].to_s) : text, link
if current_page? link
content_tag :li, class: "active" do
content
... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/extensions/models/users/weights.rb | app/extensions/models/users/weights.rb | module Users
module Weights
def current_weight opts={}
self.weights.current(:value, opts)
end
alias_method :weight, :current_weight
def fat_mass opts={}
self.weights.current(:fat_mass, opts)
end
def fat_percent opts={}
self.weights.current(:fat_percent, opts)
end
... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/extensions/models/users/meals.rb | app/extensions/models/users/meals.rb | module Users
module Meals
def meals_from datetime
meals.where("date >= ?", datetime)
end
def meals_after datetime
meals.where("date > ?", datetime)
end
def meals_before datetime
meals.where("date < ?", datetime)
end
def meals_on datetime
meals.where("date = ?", d... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/extensions/models/users/sleeps.rb | app/extensions/models/users/sleeps.rb | module Users
module Sleeps
def sleeps_from datetime
sleeps.where('start >= ?', datetime)
end
def sleeps_between start_datetime, end_datetime
sleeps.where('start >= ? AND "end" <= ?', start_datetime, end_datetime)
end
def sleeps_after datetime
sleeps.where('start > ?', datetim... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/meals_controller.rb | app/controllers/meals_controller.rb | class MealsController < ApplicationController
before_action :authenticate_user!
before_action :set_meal, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource
# GET /meals
# GET /meals.json
def index
@meals = current_user.meals.order("date DESC")
respond_to do |format|
format.h... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/home_controller.rb | app/controllers/home_controller.rb | class HomeController < ApplicationController
skip_authorization_check
# GET /home
def index
respond_to do |format|
format.html # index.html.erb
end
end
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/omniauth_callbacks_controller.rb | app/controllers/omniauth_callbacks_controller.rb | class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def failure
flash[:alert] = "There was an error connecting your accounts"
end
def withings
if user_signed_in?
if current_user.has_withings_auth?
flash[:success] = "You've already synchronized your scale"
else
... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/journal_entries_controller.rb | app/controllers/journal_entries_controller.rb | class JournalEntriesController < ApplicationController
before_action :authenticate_user!
before_action :set_journal_entry, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource
# GET /journal_entries
# GET /journal_entries.json
def index
@journal_entries = current_user.journal_entries
... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/places_controller.rb | app/controllers/places_controller.rb | class PlacesController < ApplicationController
before_action :authenticate_user!
before_action :set_place, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource
# GET /places
# GET /places.json
def index
@places = current_user.places.order("date DESC")
respond_to do |format|
fo... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/dashboard_controller.rb | app/controllers/dashboard_controller.rb | class DashboardController < ApplicationController
before_action :authenticate_user!
skip_authorization_check
# GET /dashboard
# GET /dashboard.json
def index
respond_to do |format|
format.html # index.html.erb
format.json
end
end
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/weights_controller.rb | app/controllers/weights_controller.rb | class WeightsController < ApplicationController
before_action :authenticate_user!
before_action :set_weight, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource
# GET /weights
# GET /weights.json
def index
@weights = current_user.weights.order("date DESC")
respond_to do |format|
... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/users_controller.rb | app/controllers/users_controller.rb | class UsersController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
# GET /users/:id
# GET /users/:id.json
def show
@user = User.find(params[:id])
begin
@user.sync_all_provider_data
flash[:notice] = "API sources refreshed."
rescue Exceptions::A... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/registrations_controller.rb | app/controllers/registrations_controller.rb | class RegistrationsController < Devise::RegistrationsController
# As suggested by https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password
def update
@user = User.find(current_user.id)
successfully_updated = if needs_password? @user, params
... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/application_controller.rb | app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
protect_from_forgery
before_action :set_timezone
# Provides us with global authentication handling, by assuming that
# every non-devise controller requires authorization, and rescues from
# the case of an access denied error from CanCan (in the case of a
... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/controllers/sleeps_controller.rb | app/controllers/sleeps_controller.rb | class SleepsController < ApplicationController
before_action :authenticate_user!
before_action :set_sleep, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource
# GET /sleeps
# GET /sleeps.json
def index
@sleeps = current_user.sleeps.order("start DESC")
respond_to do |format|
f... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/models/place.rb | app/models/place.rb | # == Schema Information
#
# Table name: places
#
# id :integer not null, primary key
# user_id :integer
# date :datetime
# lat :decimal(, )
# lng :decimal(, )
# created_at :datetime
# updated_at :datetime
# meta :hstore
# source :string(255)
# response :json... | ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
jdjkelly/quant | https://github.com/jdjkelly/quant/blob/b3a1d83466ff5bb3b80e29f4d9999d871c77d280/app/models/ability.rb | app/models/ability.rb | class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
alias_action :create, :read, :update, :destroy, :to => :crud
can :crud, :all, :user_id => user.id
end
end
| ruby | MIT | b3a1d83466ff5bb3b80e29f4d9999d871c77d280 | 2026-01-04T17:44:17.025352Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.