printable_calendar 0.0.4 → 0.0.5
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/README.md +7 -7
- data/exe/printable_calendar +7 -7
- data/lib/printable_calendar/range.rb +20 -13
- data/lib/printable_calendar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e8fb99c08f3caffd178871c00f9babb4b1d2acb
|
4
|
+
data.tar.gz: cffef9e42bc08938773cac99d5e09f5305e17453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0567d2b04fa5bd6dec284b4119862cd70d0080b4f38ae734f1a2ab88dbee64178668f75c244be9dddc8b9eaac5aae5131574826dabf7ab8251a0329dda7ad79
|
7
|
+
data.tar.gz: 1d3f9cb69a71041cb2e0de4ead581051b153c6ea516afda96cb856d7175713bcb2d1ca944b07968b99925aba16ca4ef5b72a2b785bcecb25215a10edd2aec3b7
|
data/README.md
CHANGED
@@ -25,16 +25,16 @@ There are a few other options. They're available in both the JSON file and as co
|
|
25
25
|
|
26
26
|
```
|
27
27
|
usage: printable_calendar [options]
|
28
|
-
-g, --generate
|
29
|
-
-h, --help
|
30
|
-
-v, --version
|
31
|
-
-c, --config
|
28
|
+
-g, --generate Generate a token
|
29
|
+
-h, --help Print help
|
30
|
+
-v, --version Print version info
|
31
|
+
-c, --config Use a JSON config file
|
32
32
|
--client-id Google client id
|
33
33
|
--client-secret Google client secret
|
34
34
|
--refresh-token Google refresh token
|
35
|
-
--period
|
36
|
-
--title
|
37
|
-
--starting-from
|
35
|
+
-p, --period Time period to use. Accepts workweek, american_week, intl_week, month, day
|
36
|
+
--title Title for this calendar
|
37
|
+
--starting-from Date to anchor on. Defaults to today. Format as YYYY-MM-DD
|
38
38
|
--calendar-ids Google calendar IDs
|
39
39
|
```
|
40
40
|
|
data/exe/printable_calendar
CHANGED
@@ -14,16 +14,16 @@ def load_config_file(file)
|
|
14
14
|
end
|
15
15
|
|
16
16
|
opts = Slop.parse do |o|
|
17
|
-
o.bool "-g", "--generate", "
|
18
|
-
o.bool "-h", "--help", "
|
19
|
-
o.bool "-v", "--version", "
|
20
|
-
o.string "-c", "--config", "
|
17
|
+
o.bool "-g", "--generate", "Generate a token"
|
18
|
+
o.bool "-h", "--help", "Print help"
|
19
|
+
o.bool "-v", "--version", "Print version info"
|
20
|
+
o.string "-c", "--config", "Use a JSON config file"
|
21
21
|
o.string "--client-id", "Google client id"
|
22
22
|
o.string "--client-secret", "Google client secret"
|
23
23
|
o.string "--refresh-token", "Google refresh token"
|
24
|
-
o.string "--period", "
|
25
|
-
o.string "--title", "
|
26
|
-
o.string "--starting-from", "
|
24
|
+
o.string "-p", "--period", "Time period to use. Accepts #{PrintableCalendar::Range.supported_periods.join(", ")}"
|
25
|
+
o.string "--title", "Title for this calendar"
|
26
|
+
o.string "--starting-from", "Date to anchor on. Defaults to today. Format as YYYY-MM-DD"
|
27
27
|
o.array "--calendar-ids", "Google calendar IDs"
|
28
28
|
end
|
29
29
|
|
@@ -5,21 +5,28 @@ require "active_support/all"
|
|
5
5
|
module PrintableCalendar
|
6
6
|
class Range
|
7
7
|
|
8
|
+
def self.range_map
|
9
|
+
{
|
10
|
+
workweek: ->(t){[t.beginning_of_week(:monday), t.beginning_of_week(:monday) + 4]},
|
11
|
+
american_week: ->(t){[t.beginning_of_week(:sunday), t.end_of_week(:sunday)]},
|
12
|
+
intl_week: ->(t){[t.beginning_of_week(:monday), t.end_of_week(:sunday)]},
|
13
|
+
month: ->(t){[t.beginning_of_month, t.end_of_month]},
|
14
|
+
day: ->(t){[t, t]}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.supported_periods
|
19
|
+
range_map.keys.map{|k| k.to_s}
|
20
|
+
end
|
21
|
+
|
8
22
|
def self.compute(period, startingFrom)
|
9
23
|
t = startingFrom
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
when "intlweek"
|
17
|
-
[t.beginning_of_week(:monday), t.end_of_week(:sunday)]
|
18
|
-
when "month"
|
19
|
-
[t.beginning_of_month, t.end_of_month]
|
20
|
-
else
|
21
|
-
abort("Period must be one of 'workweek', 'americanweek', 'intlweek', or 'month'")
|
22
|
-
end
|
24
|
+
|
25
|
+
mapper = range_map[period.to_sym]
|
26
|
+
|
27
|
+
abort "Unknown period #{period}. Use one of {#{supported_periods.join(", ")}}" unless mapper
|
28
|
+
|
29
|
+
s, e = mapper.(t)
|
23
30
|
[s.beginning_of_day, e.end_of_day]
|
24
31
|
end
|
25
32
|
end
|