reprise 0.1.1-x86_64-linux → 0.1.2-x86_64-linux
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 +4 -4
- data/Cargo.lock +1 -1
- data/README.md +44 -33
- data/lib/reprise/3.1/reprise.so +0 -0
- data/lib/reprise/3.2/reprise.so +0 -0
- data/lib/reprise/3.3/reprise.so +0 -0
- data/lib/reprise/core/occurrence.rb +2 -2
- data/lib/reprise/schedule.rb +1 -1
- data/lib/reprise/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7131c46eebe9117738a4876a8ab79f7724eba1e5ff2fef8c2ff4f216bbd54288
|
4
|
+
data.tar.gz: 323287de6d54b70f99d434599578414329f5286a903b1e05223afdef82d3eb3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07e227ef61e9133e3a6de73beaccf707fec8bf288b6a0fc5b9e1a6462cc75d0a2c5c64a85c633478f5b9c53226013e834a6dd23c8f7db0d5a107afab1c622f54
|
7
|
+
data.tar.gz: 77e4e5ea23b838d907f3f51f2ecc5a17141d901c2d40b3eae8203aa61fb5fcf9635972864d22fb8ef53b7a9b917cc0dbe1bb5a76e7001eb1d9224d6851cc1bfd
|
data/Cargo.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Reprise
|
2
2
|
|
3
|
-
[](https://github.com/jordanhiltunen/reprise/actions/workflows/test.yml) | [](https://github.com/jordanhiltunen/reprise/actions/workflows/cruby-build-and-install.yml)
|
3
|
+
[](https://badge.fury.io/rb/reprise) | [](https://github.com/jordanhiltunen/reprise/actions/workflows/test.yml) | [](https://github.com/jordanhiltunen/reprise/actions/workflows/cruby-build-and-install.yml)
|
4
4
|
|
5
5
|
Reprise is an experimental performance-first Ruby gem that provides support for defining event recurrence
|
6
6
|
rules and generating & querying their future occurrences. Depending on your use case,
|
@@ -21,9 +21,11 @@ gem "reprise"
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
+
_For a complete reference of all of the methods and options available, please [see our documentation](https://rubydoc.info/gems/reprise)._
|
25
|
+
|
24
26
|
### Initialize a new schedule
|
25
27
|
|
26
|
-
All schedules need to be initialized with
|
28
|
+
All schedules need to be initialized with `starts_at` and `ends_at` time bookends:
|
27
29
|
|
28
30
|
```ruby
|
29
31
|
may_26_2015_four_thirty_pm_in_rome = Time.parse("2015-05-26 10:30:45").in_time_zone("Rome")
|
@@ -64,8 +66,9 @@ started at as the local time for each future occurrence:
|
|
64
66
|
|
65
67
|
```ruby
|
66
68
|
first_occurrence = schedule.occurrences.first
|
67
|
-
# => <Reprise::Core::Occurrence
|
68
|
-
|
69
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-31T14:30:45+00:00" ends_at="2015-05-31T14:45:45+00:00" label="nil">
|
70
|
+
|
71
|
+
first_occurrence.starts_at.in_time_zone("Rome")
|
69
72
|
# => Sun, 31 May 2015 16:30:45.000000000 CEST +02:00 # <- 4:30 PM
|
70
73
|
```
|
71
74
|
|
@@ -75,8 +78,9 @@ either by passing an hour/minute/second hash to `time_of_day`:
|
|
75
78
|
```ruby
|
76
79
|
schedule.repeat_weekly(:sunday, time_of_day: { hour: 9, minute: 30 }, duration_in_seconds: 60)
|
77
80
|
first_occurrence = schedule.occurrences.first
|
78
|
-
# =>
|
79
|
-
|
81
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-31T07:30:00+00:00" ends_at="2015-05-31T07:31:00+00:00" label="nil">
|
82
|
+
|
83
|
+
first_occurrence.starts_at.in_time_zone("Rome")
|
80
84
|
# => Sun, 31 May 2015 09:30:00.000000000 CEST +02:00
|
81
85
|
```
|
82
86
|
|
@@ -85,8 +89,9 @@ Or, by passing a `Time` object instead:
|
|
85
89
|
```ruby
|
86
90
|
ten_forty_five_pm_in_rome = Time.parse("2015-05-27 04:45:00").in_time_zone("Rome")
|
87
91
|
schedule.repeat_weekly(:tuesday, time_of_day: ten_forty_five_pm_in_rome, duration_in_seconds: 60)
|
88
|
-
# => <Reprise::Core::Occurrence
|
89
|
-
|
92
|
+
# => <Reprise::Core::Occurrence starts_at="2015-06-02T08:45:00+00:00" ends_at="2015-06-02T08:46:00+00:00" label="nil">
|
93
|
+
|
94
|
+
first_occurrence.starts_at.in_time_zone("Rome")
|
90
95
|
# => Tue, 02 Jun 2015 10:45:00.000000000 CEST +02:00
|
91
96
|
```
|
92
97
|
|
@@ -102,9 +107,11 @@ schedule = Reprise::Schedule.new(
|
|
102
107
|
|
103
108
|
schedule.repeat_weekly(:wednesday, time_of_day: { hour: 9, minute: 30 }, duration_in_seconds: 10.minutes)
|
104
109
|
occurrences = schedule.occurrences
|
110
|
+
|
105
111
|
puts occurrences.size
|
106
112
|
# => 29
|
107
|
-
|
113
|
+
|
114
|
+
puts (occurrences.last.starts_at.to_date - occurrences.first.starts_at.to_date).to_i
|
108
115
|
# => 196 # days
|
109
116
|
```
|
110
117
|
|
@@ -121,18 +128,20 @@ schedule.repeat_weekly(
|
|
121
128
|
occurrences = schedule.occurrences
|
122
129
|
puts occurrences.size
|
123
130
|
# => 8
|
124
|
-
|
131
|
+
|
132
|
+
puts occurrences.first.starts_at.in_time_zone("Rome")
|
125
133
|
# 2015-07-10 04:01:00 +0200
|
126
|
-
|
134
|
+
|
135
|
+
puts occurrences.last.starts_at.in_time_zone("Rome")
|
127
136
|
# 2015-08-28 04:01:00 +0200
|
128
|
-
|
137
|
+
|
138
|
+
puts (occurrences.last.starts_at.to_date - occurrences.first.starts_at.to_date).to_i
|
129
139
|
# => 49 # days
|
130
140
|
```
|
131
141
|
|
132
142
|
There are many recurring series that you can create; `#repeat_minutely`, `#repeat_hourly`,
|
133
|
-
`#repeat_daily`, `#repeat_weekly`, `#repeat_monthly_by_day`,
|
134
|
-
|
135
|
-
For more information on each method, see the docs.
|
143
|
+
`#repeat_daily`, `#repeat_weekly`, `#repeat_monthly_by_day`, `#repeat_monthly_by_nth_weekday`,
|
144
|
+
and `#repeat_annually_by_day`.
|
136
145
|
|
137
146
|
#### Adding labels to the occurrences of each series
|
138
147
|
|
@@ -142,14 +151,15 @@ you can add an optional label:
|
|
142
151
|
```ruby
|
143
152
|
schedule.repeat_daily(label: "Coffee Time", time_of_day: { hour: 8 }, duration_in_seconds: 15.minutes)
|
144
153
|
schedule.repeat_daily(label: "Tea Time", interval: 3, time_of_day: { hour: 9 }, duration_in_seconds: 10.minutes)
|
154
|
+
|
145
155
|
schedule.occurrences.take(7).map { |o| puts o.inspect }
|
146
|
-
# => <Reprise::Core::Occurrence label="Coffee Time"
|
147
|
-
# => <Reprise::Core::Occurrence label="Tea Time"
|
148
|
-
# => <Reprise::Core::Occurrence label="Coffee Time"
|
149
|
-
# => <Reprise::Core::Occurrence label="Coffee Time"
|
150
|
-
# => <Reprise::Core::Occurrence label="Coffee Time"
|
151
|
-
# => <Reprise::Core::Occurrence label="Tea Time"
|
152
|
-
# => <Reprise::Core::Occurrence label="Coffee Time"
|
156
|
+
# => <Reprise::Core::Occurrence label="Coffee Time" starts_at="2015-05-27T06:00:00+00:00" ends_at="2015-05-27T06:15:00+00:00">
|
157
|
+
# => <Reprise::Core::Occurrence label="Tea Time" starts_at="2015-05-27T07:00:00+00:00" ends_at="2015-05-27T07:10:00+00:00">
|
158
|
+
# => <Reprise::Core::Occurrence label="Coffee Time" starts_at="2015-05-28T06:00:00+00:00" ends_at="2015-05-28T06:15:00+00:00">
|
159
|
+
# => <Reprise::Core::Occurrence label="Coffee Time" starts_at="2015-05-29T06:00:00+00:00" ends_at="2015-05-29T06:15:00+00:00">
|
160
|
+
# => <Reprise::Core::Occurrence label="Coffee Time" starts_at="2015-05-30T06:00:00+00:00" ends_at="2015-05-30T06:15:00+00:00">
|
161
|
+
# => <Reprise::Core::Occurrence label="Tea Time" starts_at="2015-05-30T07:00:00+00:00" ends_at="2015-05-30T07:10:00+00:00">
|
162
|
+
# => <Reprise::Core::Occurrence label="Coffee Time" starts_at="2015-05-31T06:00:00+00:00" ends_at="2015-05-31T06:15:00+00:00">
|
153
163
|
```
|
154
164
|
|
155
165
|
#### Excluding time intervals from the schedule's occurrences
|
@@ -160,11 +170,11 @@ occurrences and need to be excluded, you can add exclusions to your schedule bef
|
|
160
170
|
```ruby
|
161
171
|
schedule.repeat_daily(label: "Standing Meeting", ends_at: may_26_2015_four_thirty_pm_in_rome + 5.days, duration_in_seconds: 15.minutes)
|
162
172
|
schedule.occurrences.map { |o| puts o.inspect }
|
163
|
-
# => <Reprise::Core::Occurrence
|
164
|
-
# => <Reprise::Core::Occurrence
|
165
|
-
# => <Reprise::Core::Occurrence
|
166
|
-
# => <Reprise::Core::Occurrence
|
167
|
-
# => <Reprise::Core::Occurrence
|
173
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-26T14:30:45+00:00" ends_at="2015-05-26T14:45:45+00:00" label="Standing Meeting">
|
174
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-27T14:30:45+00:00" ends_at="2015-05-27T14:45:45+00:00" label="Standing Meeting">
|
175
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-28T14:30:45+00:00" ends_at="2015-05-28T14:45:45+00:00" label="Standing Meeting">
|
176
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-29T14:30:45+00:00" ends_at="2015-05-29T14:45:45+00:00" label="Standing Meeting">
|
177
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-30T14:30:45+00:00" ends_at="2015-05-30T14:45:45+00:00" label="Standing Meeting">
|
168
178
|
|
169
179
|
# You don't need to specify entire days; you can pass time intervals as narrow or wide as you like.
|
170
180
|
schedule.add_exclusion(
|
@@ -174,10 +184,10 @@ schedule.add_exclusion(
|
|
174
184
|
|
175
185
|
schedule.occurrences.map { |o| puts o.inspect }
|
176
186
|
# N.B. The occurrence on 2015-05-28 is now excluded.
|
177
|
-
# => <Reprise::Core::Occurrence
|
178
|
-
# => <Reprise::Core::Occurrence
|
179
|
-
# => <Reprise::Core::Occurrence
|
180
|
-
# => <Reprise::Core::Occurrence
|
187
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-26T14:30:45+00:00" ends_at="2015-05-26T14:45:45+00:00" label="Standing Meeting">
|
188
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-27T14:30:45+00:00" ends_at="2015-05-27T14:45:45+00:00" label="Standing Meeting">
|
189
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-29T14:30:45+00:00" ends_at="2015-05-29T14:45:45+00:00" label="Standing Meeting">
|
190
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-30T14:30:45+00:00" ends_at="2015-05-30T14:45:45+00:00" label="Standing Meeting">
|
181
191
|
```
|
182
192
|
|
183
193
|
#### Querying for occurrences within a given time interval
|
@@ -198,7 +208,7 @@ schedule.occurrences_between(
|
|
198
208
|
may_26_2015_four_thirty_pm_in_rome + 2.days,
|
199
209
|
may_26_2015_four_thirty_pm_in_rome + 3.days,
|
200
210
|
).map { |o| puts o.inspect }
|
201
|
-
# => <Reprise::Core::Occurrence
|
211
|
+
# => <Reprise::Core::Occurrence starts_at="2015-05-28T14:30:45+00:00" ends_at="2015-05-28T14:45:45+00:00" label="Standing Meeting">
|
202
212
|
```
|
203
213
|
|
204
214
|
Both `#occurs_between?` and `#occurrences_between` also support an optional `include_overlapping`
|
@@ -235,6 +245,7 @@ A truism in the Ruby community is that "Ruby is slow, but that doesn't matter fo
|
|
235
245
|
> speed, or throughput that Ruby chokes on. Or because the trade-offs are worth it: Often the
|
236
246
|
> quicker development, cheaper development, faster time-to-market etc is worth the extra resources
|
237
247
|
> (servers, hardware, SAAS) you must throw at your app to keep it performing acceptable.
|
248
|
+
>
|
238
249
|
> https://berk.es/2022/08/09/ruby-slow-database-slow/
|
239
250
|
|
240
251
|
This is often delightfully true, until on the odd occasion Ruby's speed requires that a straightforward feature
|
@@ -305,7 +316,7 @@ and 3:30 - 4:30 PM.
|
|
305
316
|
How do you filter out recurring series occurrences that conflict with other schedule entries that exist
|
306
317
|
in your application?
|
307
318
|
|
308
|
-
At time of writing, alternative gems' solutions to this problem are
|
319
|
+
At time of writing, alternative gems' solutions to this problem are somewhat wanting:
|
309
320
|
- **None**: It is entirely the responsibility of the client application to handle occurrence exclusions,
|
310
321
|
despite this logic being core to the domain of recurring schedule management.
|
311
322
|
- **Date-based exclusion**: Client applications can pass specific dates when occurrences should be excluded.
|
data/lib/reprise/3.1/reprise.so
CHANGED
Binary file
|
data/lib/reprise/3.2/reprise.so
CHANGED
Binary file
|
data/lib/reprise/3.3/reprise.so
CHANGED
Binary file
|
@@ -8,9 +8,9 @@ module Reprise
|
|
8
8
|
# of adding documentation; it is defined dynamically within
|
9
9
|
# the Rust extension.
|
10
10
|
class Occurrence
|
11
|
-
# @!attribute [r]
|
11
|
+
# @!attribute [r] starts_at
|
12
12
|
# @return [Time] The start time of the occurrence, given in the current system time zone.
|
13
|
-
# @!attribute [r]
|
13
|
+
# @!attribute [r] ends_at
|
14
14
|
# @return [Time] The end time of the occurrence, given in the current system time zone.
|
15
15
|
# @!attribute [r] label
|
16
16
|
# @return [String, nil] The label given to the recurring series from which the
|
data/lib/reprise/schedule.rb
CHANGED
@@ -81,7 +81,7 @@ module Reprise
|
|
81
81
|
|
82
82
|
# @!macro [new] duration_in_seconds
|
83
83
|
# @param duration_in_seconds [Integer]
|
84
|
-
# This determines the end time of each occurrence ({Reprise::Core::Occurrence#
|
84
|
+
# This determines the end time of each occurrence ({Reprise::Core::Occurrence#ends_at}), and also
|
85
85
|
# influences occurrence queries, and whether any added exclusions conflict with any of the schedule's
|
86
86
|
# occurrences.
|
87
87
|
|
data/lib/reprise/version.rb
CHANGED