periodoxical 0.3.2 → 0.4.2
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/Gemfile.lock +1 -1
- data/README.md +27 -16
- data/lib/periodoxical/version.rb +1 -1
- data/lib/periodoxical.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95c80ef1e3008c4279f58b029a0790353aae3b346d809390c38961b719c635a9
|
|
4
|
+
data.tar.gz: 8531378c87459b8dc1945984da0c12b11238a6895668885751923779df3c1bd3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 899994a59c14f4c6dcf3e8534e7812496ebf53a8b902506e2efebd695d193abf9a93844ccd42389dc2be35c22f2ca829a0d19e3d1de44f7fa4b28d0f5baf3e79
|
|
7
|
+
data.tar.gz: fdc25739ed5cf90e3aa1a71617c927382ed56dcbf7b2b292844bc3c3bbd5f4688fc9bf6c03ccddc58e8e930435835833d9fd092c30a31cdef0a243d19c1ad19d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
_"Up, and down, and in the end, it's only round and round and round..._" - Pink Floyd, "Us and Them"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
<div align="center">
|
|
6
|
+
<img width="558" alt="pink_floyd_time" src="https://github.com/StevenJL/periodoxical/assets/2191808/8bab4a14-2df7-42d0-b6ae-f6b57a353500">
|
|
7
|
+
<p><i>(Image Courtesy of "Pink Floyd: Time," directed by Ian Eames , ©1973)</i></p>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<br>
|
|
11
|
+
|
|
12
|
+
Generate periodic datetime blocks based on provided rules/conditions. Great for (but not limited to) calendar and scheduling applications. See Usage for detailed examples.
|
|
7
13
|
|
|
8
14
|
## Installation
|
|
9
15
|
|
|
@@ -23,15 +29,14 @@ Or install it yourself as:
|
|
|
23
29
|
|
|
24
30
|
## Usage
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
As a Ruby dev, I want to generate all the datetimes blocks of 9:00AM - 10:30AM and 2:00PM - 2:30PM
|
|
32
|
+
#### Example 1
|
|
33
|
+
As a Ruby dev, I want to generate all the datetimes blocks of **9:00AM - 10:30AM** and **2:00PM - 2:30PM**, on **Mondays**, **Wednesdays**, and **Thursdays**, between the dates of **May 23, 2024** and **June 12, 2024**, inclusive. This can be represented visually as:
|
|
28
34
|
|
|
29
35
|
<div align="center">
|
|
30
|
-
<img width="558" alt="
|
|
36
|
+
<img width="558" alt="calendar_image_1" src="https://github.com/StevenJL/periodoxical/assets/2191808/e92fc6ff-03fd-44ed-a955-d3a0dd0f5d0a">
|
|
31
37
|
<p><i>(image courtesy of Cal.com)</i></p>
|
|
32
38
|
</div>
|
|
33
39
|
|
|
34
|
-
|
|
35
40
|
<br>
|
|
36
41
|
|
|
37
42
|
```rb
|
|
@@ -48,8 +53,8 @@ Periodoxical.generate(
|
|
|
48
53
|
end_time: '2:30PM'
|
|
49
54
|
}
|
|
50
55
|
],
|
|
51
|
-
start_date:
|
|
52
|
-
end_date:
|
|
56
|
+
start_date: '2024-05-23',
|
|
57
|
+
end_date: '2024-06-12',
|
|
53
58
|
)
|
|
54
59
|
# returns an array of hashes, each with :start and :end keys
|
|
55
60
|
#=>
|
|
@@ -74,10 +79,9 @@ Periodoxical.generate(
|
|
|
74
79
|
]
|
|
75
80
|
```
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
#### Example 2 - using the `limit` key.
|
|
78
83
|
|
|
79
|
-
As a ruby dev, I want to generate the next 3 datetime blocks of 9:00AM - 10:30AM and 2:00PM - 2:30PM on Sundays
|
|
80
|
-
using the `limit` key.
|
|
84
|
+
As a ruby dev, I want to generate the next 3 datetime blocks of **9:00AM - 10:30AM** and **2:00PM - 2:30PM** on **Sundays**, after **May 23, 2024** using the `limit` key.
|
|
81
85
|
|
|
82
86
|
```rb
|
|
83
87
|
Periodoxical.generate(
|
|
@@ -93,7 +97,7 @@ Periodoxical.generate(
|
|
|
93
97
|
end_time: '2:30PM'
|
|
94
98
|
}
|
|
95
99
|
],
|
|
96
|
-
start_date: Date.parse('2024-05-23'),
|
|
100
|
+
start_date: Date.parse('2024-05-23'), # Can also pass in `Date` object.
|
|
97
101
|
limit: 3
|
|
98
102
|
)
|
|
99
103
|
# =>
|
|
@@ -113,15 +117,22 @@ Periodoxical.generate(
|
|
|
113
117
|
]
|
|
114
118
|
```
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
#### Example 3 - when time blocks vary between days
|
|
117
121
|
|
|
118
|
-
As a ruby dev, I want to generate all the timeblocks between May 23, 2024 and June 12, 2024 where the time should be 8AM-9AM on Mondays
|
|
122
|
+
As a ruby dev, I want to generate all the timeblocks between **May 23, 2024** and **June 12, 2024** where the time should be **8AM-9AM** on **Mondays**, but **10:45AM-12:00PM** and **2:00PM-4:00PM** on **Wednesdays**, and **2:30PM-4:15PM** on **Thursdays**.
|
|
123
|
+
|
|
124
|
+
<div align="center">
|
|
125
|
+
<img width="628" alt="calendar_image_2" src="https://github.com/StevenJL/periodoxical/assets/2191808/26d14824-08ff-481a-97e2-9b6b11beea29">
|
|
126
|
+
<p><i>(image courtesy of Cal.com)</i></p>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<br>
|
|
119
130
|
|
|
120
131
|
```rb
|
|
121
132
|
Periodoxical.generate(
|
|
122
133
|
time_zone: 'America/Los_Angeles',
|
|
123
|
-
start_date: Date.parse('2024-05-23'),
|
|
124
|
-
end_date: Date.parse('2024-06-12'),
|
|
134
|
+
start_date: Date.parse('2024-05-23'), # can also pass in Date objects
|
|
135
|
+
end_date: Date.parse('2024-06-12'), # can also pass in Date objects,
|
|
125
136
|
day_of_week_time_blocks: {
|
|
126
137
|
mon: [
|
|
127
138
|
{ start_time: '8:00AM', end_time: '9:00AM' },
|
data/lib/periodoxical/version.rb
CHANGED
data/lib/periodoxical.rb
CHANGED
|
@@ -15,8 +15,8 @@ module Periodoxical
|
|
|
15
15
|
# @param [String] time_zone
|
|
16
16
|
# Ex: 'America/Los_Angeles', 'America/Chicago',
|
|
17
17
|
# TZInfo::DataTimezone#name from the tzinfo gem (https://github.com/tzinfo/tzinfo)
|
|
18
|
-
# @param [Date] start_date
|
|
19
|
-
# @param [Date] end_date
|
|
18
|
+
# @param [Date, String] start_date
|
|
19
|
+
# @param [Date, String] end_date
|
|
20
20
|
# @param [Array<Hash>] time_blocks
|
|
21
21
|
# Ex: [
|
|
22
22
|
# {
|
|
@@ -47,8 +47,8 @@ module Periodoxical
|
|
|
47
47
|
@days_of_week = days_of_week
|
|
48
48
|
@time_blocks = time_blocks
|
|
49
49
|
@day_of_week_time_blocks = day_of_week_time_blocks
|
|
50
|
-
@start_date = start_date
|
|
51
|
-
@end_date = end_date
|
|
50
|
+
@start_date = start_date.is_a?(String) ? Date.parse(start_date) : start_date
|
|
51
|
+
@end_date = end_date.is_a?(String) ? Date.parse(end_date) : end_date
|
|
52
52
|
@limit = limit
|
|
53
53
|
validate!
|
|
54
54
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: periodoxical
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Li
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-06-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: tzinfo
|