https://github.com/tomasc/mongoid_recurring
Recurring date time fields for Mongoid models
https://github.com/tomasc/mongoid_recurring
Last synced: 8 months ago
JSON representation
Recurring date time fields for Mongoid models
- Host: GitHub
- URL: https://github.com/tomasc/mongoid_recurring
- Owner: tomasc
- License: mit
- Created: 2015-10-22T09:19:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-07-19T21:00:11.000Z (almost 2 years ago)
- Last Synced: 2025-10-07T23:42:38.043Z (9 months ago)
- Language: Ruby
- Size: 23.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Mongoid Recurring
[](https://travis-ci.org/tomasc/mongoid_recurring) [](http://badge.fury.io/rb/mongoid_recurring) [](https://coveralls.io/r/tomasc/mongoid_recurring)
Recurring date time fields for Mongoid models, using [IceCube](https://github.com/seejohnrun/ice_cube/).
When included in a model, this gem expands the recurring rules set of an `IceCube` schedule on save into an array of embedded `MongoidRecurring::Occurrence` models.
It also adds definitions of several scopes that allow for convenient querying of models stored in the db.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'mongoid_recurring'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongoid_recurring
## Usage
```ruby
class MyModel
include Mongoid::Document
include MongoidRecurring::HasRecurringFields
has_recurring_fields
end
```
Which will then add `dtstart`, `dtend`, `all_day`, `schedule` and `schedule_dtend` fields to the model.
The model will generate all occurrences on before save, and store them as `MongoidRecurring::Occurrence` documents in the `:occurrences` embedded relation.
A scope named `.for_datetime_range` can be then used to query for documents with occurrences in specified DateTime range:
```ruby
MyModel.for_datetime_range( Date.today, Date.today+1.week )
```
## Configuration
By default, when `schedule_dtend` is not specified, the `occurrences` are populated for 1 year in advance. This duration can be configured as follows:
has_recurring_fields schedule_duration: 2.weeks
## See also
* [MongoidIceCubeExtension](https://github.com/tomasc/mongoid_ice_cube_extension) for storing `IceCube` schedule in Mongoid documents
* [SimpleFormRecurringSelect](https://github.com/tomasc/simple_form_recurring_select) for adding `IceCube` rules via `SimpleForm` input fields
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
1. Fork it ( https://github.com/tomasc/mongoid_recurring/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request