mongoid_recurring 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/mongoid_recurring/has_recurring_fields.rb +17 -1
- data/lib/mongoid_recurring/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94d65ba8e9128113f411305a33c0772f28ec8bdd
|
4
|
+
data.tar.gz: eef1e3fa0d8780d7c249a057e69bf973b6ad5b5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4513dff61f133e65a3395d95fd56cc595f811061ba94a9820d7ec0a8d4e0fc5931eaa31129842535fbf1606837ddc7eee520d7cfcceff010a9a651598f00b99b
|
7
|
+
data.tar.gz: 3befbe40edcaf52f15117caa75ffea84cae1d06eab94c2d00695d5fc35a95fa81d355e472927be4ec25bcf84b1686b18616559463597e600209809b29aff4d70
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ end
|
|
36
36
|
|
37
37
|
Which will then add `dtstart`, `dtend`, `all_day`, `schedule` and `schedule_dtend` fields to the model.
|
38
38
|
|
39
|
-
The model will generate all occurrences on before save, and
|
39
|
+
The model will generate all occurrences on before save, and store them as `MongoidRecurring::Occurrence` documents in the `:occurrences` embedded relation.
|
40
40
|
|
41
41
|
A scope named `.for_datetime_range` can be then used to query for documents with occurrences in specified DateTime range:
|
42
42
|
|
@@ -46,10 +46,15 @@ MyModel.for_datetime_range( Date.today, Date.today+1.week )
|
|
46
46
|
|
47
47
|
## Configuration
|
48
48
|
|
49
|
-
By default, when `schedule_dtend` is not specified, the
|
49
|
+
By default, when `schedule_dtend` is not specified, the `occurrences` are populated for 1 year in advance. This duration can be configured as follows:
|
50
50
|
|
51
51
|
has_recurring_fields schedule_duration: 2.weeks
|
52
52
|
|
53
|
+
## See also
|
54
|
+
|
55
|
+
* [MongoidIceCubeExtension](https://github.com/tomasc/mongoid_ice_cube_extension) for storing `IceCube` schedule in Mongoid documents
|
56
|
+
* [SimpleFormRecurringSelect](https://github.com/tomasc/simple_form_recurring_select) for adding `IceCube` rules via `SimpleForm` input fields
|
57
|
+
|
53
58
|
## Development
|
54
59
|
|
55
60
|
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.
|
@@ -58,7 +63,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
58
63
|
|
59
64
|
## Contributing
|
60
65
|
|
61
|
-
1. Fork it ( https://github.com/
|
66
|
+
1. Fork it ( https://github.com/tomasc/mongoid_recurring/fork )
|
62
67
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
68
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
69
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -24,14 +24,30 @@ module MongoidRecurring
|
|
24
24
|
field :schedule, type: MongoidIceCubeExtension::Schedule
|
25
25
|
field :schedule_dtend, type: DateTime
|
26
26
|
|
27
|
+
# ---------------------------------------------------------------------
|
28
|
+
|
27
29
|
embeds_many :occurrences, class_name: 'MongoidRecurring::Occurence', order: :dtstart.asc
|
28
30
|
|
29
31
|
validates :dtstart, presence: true
|
30
32
|
|
31
33
|
before_save :expand_schedule_to_occurrences
|
32
34
|
|
35
|
+
# ---------------------------------------------------------------------
|
36
|
+
|
33
37
|
scope :for_datetime_range, -> (dtstart, dtend) {
|
34
|
-
|
38
|
+
dtstart = dtstart.beginning_of_day if dtstart.instance_of?(Date)
|
39
|
+
dtend = dtend.end_of_day if dtend.instance_of?(Date)
|
40
|
+
where({ occurrences: { "$elemMatch" => { :dtstart.lte => dtend.to_datetime, :dtend.gte => dtstart.to_datetime } } })
|
41
|
+
}
|
42
|
+
|
43
|
+
scope :from_datetime, -> (dtstart) {
|
44
|
+
dtstart = dtstart.beginning_of_day if dtstart.instance_of?(Date)
|
45
|
+
where( occurrences: { "$elemMatch" => { :dtstart.gte => dtstart.to_datetime } } )
|
46
|
+
}
|
47
|
+
|
48
|
+
scope :to_datetime, -> (dtend) {
|
49
|
+
dtend = dtend.end_of_day if dtend.instance_of?(Date)
|
50
|
+
where( occurrences: { "$elemMatch" => { :dtend.lte => dtend.to_datetime } } )
|
35
51
|
}
|
36
52
|
end
|
37
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_recurring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomáš Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|