mongoid_recurring 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb70c676c42a5424af0bdf634c7560adde98edc
|
4
|
+
data.tar.gz: bb6b1ef7c7289d47af554149365efe65ca03c217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ecde7e7953dccb1c7715c8a277e51ffc38839d3f09508df8115ed00030dd59a4647e54ec0b51e4d1e6d8f8df8c1446568161b318df72b5c03243afdb3ac704d
|
7
|
+
data.tar.gz: 6cb606eee0f746deb327420bf797bf8c3c99a11611f9ac572769631829199e5a8fffaa4c2a6a310e3ac1c17ad6204217d5f9537b03d5b02c0be55c3963096add
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# Mongoid Recurring
|
2
2
|
|
3
3
|
[](https://travis-ci.org/tomasc/mongoid_recurring) [](http://badge.fury.io/rb/mongoid_recurring) [](https://coveralls.io/r/tomasc/mongoid_recurring)
|
4
4
|
|
5
5
|
Recurring date time fields for Mongoid models, using [IceCube](https://github.com/seejohnrun/ice_cube/).
|
6
6
|
|
7
|
-
When included in a model, this gem expands the recurring rules set of an `IceCube` schedule on save into an array of embedded `MongoidRecurring::
|
7
|
+
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.
|
8
8
|
|
9
9
|
It also adds definitions of several scopes that allow for convenient querying of models stored in the db.
|
10
10
|
|
@@ -26,7 +26,7 @@ module MongoidRecurring
|
|
26
26
|
|
27
27
|
# ---------------------------------------------------------------------
|
28
28
|
|
29
|
-
embeds_many :occurrences, class_name: 'MongoidRecurring::
|
29
|
+
embeds_many :occurrences, class_name: 'MongoidRecurring::Occurrence', order: :dtstart.asc
|
30
30
|
|
31
31
|
validates :dtstart, presence: true
|
32
32
|
|
@@ -35,15 +35,15 @@ module MongoidRecurring
|
|
35
35
|
# ---------------------------------------------------------------------
|
36
36
|
|
37
37
|
scope :for_datetime_range, -> (dtstart, dtend) {
|
38
|
-
where({ occurrences: { "$elemMatch" =>
|
38
|
+
where({ occurrences: { "$elemMatch" => Occurrence.for_datetime_range(dtstart, dtend).selector } })
|
39
39
|
}
|
40
40
|
|
41
41
|
scope :from_datetime, -> (dtstart) {
|
42
|
-
where( occurrences: { "$elemMatch" =>
|
42
|
+
where( occurrences: { "$elemMatch" => Occurrence.from_datetime(dtstart).selector } )
|
43
43
|
}
|
44
44
|
|
45
45
|
scope :to_datetime, -> (dtend) {
|
46
|
-
where( occurrences: { "$elemMatch" =>
|
46
|
+
where( occurrences: { "$elemMatch" => Occurrence.to_datetime(dtend).selector } )
|
47
47
|
}
|
48
48
|
end
|
49
49
|
end
|
@@ -55,11 +55,11 @@ module MongoidRecurring
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def occurrences_from_schedule
|
58
|
-
schedule.occurrences(schedule_dtend || (schedule.start_time + @@schedule_duration)).collect { |o| MongoidRecurring::
|
58
|
+
schedule.occurrences(schedule_dtend || (schedule.start_time + @@schedule_duration)).collect { |o| MongoidRecurring::Occurrence.new( dtstart: o.start_time, dtend: o.end_time, all_day: all_day ) }
|
59
59
|
end
|
60
60
|
|
61
61
|
def occurrences_from_model
|
62
|
-
[ MongoidRecurring::
|
62
|
+
[ MongoidRecurring::Occurrence.new( dtstart: dtstart, dtend: dtend, all_day: all_day ) ]
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'mongoid'
|
2
2
|
|
3
3
|
module MongoidRecurring
|
4
|
-
class
|
4
|
+
class Occurrence
|
5
5
|
include Mongoid::Document
|
6
6
|
|
7
7
|
field :dtstart, type: DateTime
|
@@ -9,7 +9,7 @@ module MongoidRecurring
|
|
9
9
|
|
10
10
|
attr_accessor :all_day
|
11
11
|
|
12
|
-
embedded_in :schedule, class_name: 'MongoidRecurring::
|
12
|
+
embedded_in :schedule, class_name: 'MongoidRecurring::Occurrence'
|
13
13
|
|
14
14
|
validates :dtstart, presence: true
|
15
15
|
validates :dtend, presence: true
|
data/lib/mongoid_recurring.rb
CHANGED
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.3
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -183,7 +183,7 @@ files:
|
|
183
183
|
- bin/setup
|
184
184
|
- lib/mongoid_recurring.rb
|
185
185
|
- lib/mongoid_recurring/has_recurring_fields.rb
|
186
|
-
- lib/mongoid_recurring/
|
186
|
+
- lib/mongoid_recurring/occurrence.rb
|
187
187
|
- lib/mongoid_recurring/version.rb
|
188
188
|
- mongoid_recurring.gemspec
|
189
189
|
homepage: https://github.com/tomasc/mongoid_recurring
|