mongoid_occurrences 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c4621a7b3901f05cb2f3d9b79139b8d5ceca2d6cfec3876aa3d7188a205e0a5
4
- data.tar.gz: f7d059e47640eb9dc90f34b58d245b05b46f6006c479ad3ea6d5d3009fdb79c3
3
+ metadata.gz: 8e4691e967789e20737620c8ea0f52adbfe1048b75519cd40f421a56418d5009
4
+ data.tar.gz: ef6ada74ee76687c7adc4b70c2fffb3916d1a61be3dfbf0c94cc39f64abef192
5
5
  SHA512:
6
- metadata.gz: '0651849f06eb33672c2f7f38c5606479cbb2c6eb3705e3db880dae23977b5efcb2f55b03a95ca28dd090433efcb8b7eefbfcbdf67390772f05788179df2d72be'
7
- data.tar.gz: c9dc146e727755a6bc40f30d782e1be2c0c514b0831a12d7b584b03b1330189a9b6e10212c70d2089b8a700320945ba88092039644743307894b073ab8540037
6
+ metadata.gz: b694b25f6f8f1c580a931b36492443c00167f66a781bf96c99da78f610b06724ac853db4404659422b1d14cbc8d6e92a6e39daf29756c91c250c4d9969568422
7
+ data.tar.gz: 211def0bc924d36485ede7146e10f645d632d6aff4c5714c21ce799651918b0a92c31e89fd3327a47ed9799865358e4fceab0f7403a7a240e4dc6e2b6b7b85cb
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.6.3
data/CHANGELOG.md CHANGED
@@ -1,50 +1,55 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.5
4
+
5
+ - FIX: wiping `#daily_occurrences` when removing all `#occurrences`
6
+ - FIX: correctly assign `#daily_occurrences` when changing `#occurrences`
7
+
3
8
  ## 1.1.4
4
9
 
5
- * ADD: default sort order on the `#occurrences` association
10
+ - ADD: default sort order on the `#occurrences` association
6
11
 
7
12
  ## 1.1.2
8
13
 
9
- * FIX: missing minutes when creating daily occurrences from a schedule
14
+ - FIX: missing minutes when creating daily occurrences from a schedule
10
15
 
11
16
  ## 1.1.1
12
17
 
13
- * FIX: issues with handling time zone in daily occurrences and queries
14
- * ADD: validation on `Occurrence` for `dtend` being after `dtstart`
18
+ - FIX: issues with handling time zone in daily occurrences and queries
19
+ - ADD: validation on `Occurrence` for `dtend` being after `dtstart`
15
20
 
16
21
  ## 1.1.0
17
22
 
18
- * CHANGE: `#embedded_in_event` requires `name` (`#embedded_in_event(name, options)`)
23
+ - CHANGE: `#embedded_in_event` requires `name` (`#embedded_in_event(name, options)`)
19
24
 
20
25
  ## 1.0.4
21
26
 
22
- * FIX: We rely on occurrences having their `updated_at` field touched when saving an event, which currently doesn't happen. Adding `cascade_callbacks` fixes that.
27
+ - FIX: We rely on occurrences having their `updated_at` field touched when saving an event, which currently doesn't happen. Adding `cascade_callbacks` fixes that.
23
28
 
24
29
  ## 1.0.3
25
30
 
26
- * ADD: allow to specify `:parent_name` on `.embedded_in_event` macro
31
+ - ADD: allow to specify `:parent_name` on `.embedded_in_event` macro
27
32
 
28
33
  ## 1.0.2
29
34
 
30
- * ADD: `DailyOccurrence` has now `oid (occurrence_id)` referring to the original occurrence
35
+ - ADD: `DailyOccurrence` has now `oid (occurrence_id)` referring to the original occurrence
31
36
 
32
37
  ## 1.0.1
33
38
 
34
- * FIX: spelling of `*occurrences_cache_key*` related methods
39
+ - FIX: spelling of `*occurrences_cache_key*` related methods
35
40
 
36
41
  ## 1.0.0
37
42
 
38
- * REFACTOR: [PR#4](https://github.com/tomasc/mongoid_occurrences/pull/4) Refactor to replace views with aggregations
43
+ - REFACTOR: [PR#4](https://github.com/tomasc/mongoid_occurrences/pull/4) Refactor to replace views with aggregations
39
44
 
40
45
  ## 0.2.0
41
46
 
42
- * [PR#3](https://github.com/tomasc/mongoid_occurrences/pull/3) `all_day` becomes a field
47
+ - [PR#3](https://github.com/tomasc/mongoid_occurrences/pull/3) `all_day` becomes a field
43
48
 
44
49
  ## 0.1.1
45
50
 
46
- * [PR#2](https://github.com/tomasc/mongoid_occurrences/pull/2) allow :assign_daily_occurrences to be triggerred manually
51
+ - [PR#2](https://github.com/tomasc/mongoid_occurrences/pull/2) allow :assign_daily_occurrences to be triggerred manually
47
52
 
48
53
  ## 0.1.0
49
54
 
50
- * initial release
55
+ - initial release
@@ -29,14 +29,15 @@ module MongoidOccurrences
29
29
  end
30
30
 
31
31
  def assign_daily_occurrences!
32
+ return self.daily_occurrences = nil if occurrences.blank?
32
33
  self.daily_occurrences = begin
33
- res = occurrences.with_operators(:append).flat_map(&:daily_occurrences)
34
+ res = occurrences.select(&:append).flat_map(&:daily_occurrences)
34
35
 
35
- occurrences.with_operators(%i[remove replace]).flat_map(&:daily_occurrences).each do |occurrence|
36
+ [occurrences.select(&:remove), occurrences.select(&:replace)].flatten.flat_map(&:daily_occurrences).each do |occurrence|
36
37
  res = res.reject { |res_occurrence| res_occurrence.overlaps?(occurrence) }
37
38
  end
38
39
 
39
- res += occurrences.with_operators(%i[replace]).flat_map(&:daily_occurrences)
40
+ res += occurrences.select(&:replace).flat_map(&:daily_occurrences)
40
41
 
41
42
  res.sort
42
43
  end
@@ -5,6 +5,10 @@ module MongoidOccurrences
5
5
  module HasOperators
6
6
  def self.prepended(base)
7
7
  base.scope :with_operators, ->(operators) { criteria.in(_operator: Array(operators)) }
8
+
9
+ %i[append replace remove].each do |o|
10
+ define_method(o) { operator == o }
11
+ end
8
12
  end
9
13
 
10
14
  module ClassMethods
@@ -1,3 +1,3 @@
1
1
  module MongoidOccurrences
2
- VERSION = '1.1.4'.freeze
2
+ VERSION = '1.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_occurrences
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-06-05 00:00:00.000000000 Z
12
+ date: 2020-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ice_cube
@@ -222,6 +222,7 @@ extensions: []
222
222
  extra_rdoc_files: []
223
223
  files:
224
224
  - ".gitignore"
225
+ - ".tool-versions"
225
226
  - ".travis.yml"
226
227
  - CHANGELOG.md
227
228
  - Gemfile