schedule-cli 0.1.1 → 0.1.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 +22 -14
- data/lib/schedule/calendar.rb +2 -2
- data/lib/schedule/cli.rb +10 -5
- data/lib/schedule/config.rb +8 -8
- data/lib/schedule/version.rb +1 -1
- 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: e7f5856a18a1c3b88cfa3303b4becb495617bacdd061bb96eaa83d470272273d
|
4
|
+
data.tar.gz: 1e9f64117af1d689c63094668c7a337b51c7329e310c9df823b72f04fdf648c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bda9a3ead7125b766b539f9a19ea7a288c7c57243612f4da125606de365b2942f330836f5ad3fd18f005a05a755a2bc9c8bfc0728c6ce150f947c631ced5dd7d
|
7
|
+
data.tar.gz: 43dfe7775c369c3cd837cfaa56c9c53de45c4537720d17d83c9cdec21ee0c927efa913f312f2ad27b6ef7e050433de569c070c97c29b15b428f31e9b93b86c77
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,28 +1,36 @@
|
|
1
1
|
# Schedule
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This gem allows you to quickly insert your calendar availability to any plain (or rich) text field. It connects with a single Google account but can pull appointments from various calendars. At Karuna, we have this hooked up to an [Alfred](https://www.alfredapp.com/) workflow.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'schedule'
|
7
|
+
```bash
|
8
|
+
$ gem install schedule
|
13
9
|
```
|
14
10
|
|
15
|
-
|
11
|
+
## Usage
|
16
12
|
|
17
|
-
|
13
|
+
Run `schedule availability` to get your default availability table, which shows slots for a 30 minute meeting in a 3-day span centered on the weekday following today. Weekends are not considered as open slots unless the center date (`offset`) is a weekend.
|
18
14
|
|
19
|
-
|
15
|
+
The command can optionally be passed two arguments. The first is either the name of a named event (see below), or a number of minutes to specify a duration. The second is a string (such as "next wednesday") which specifies the center of the range to be scheduled over.
|
20
16
|
|
21
|
-
|
17
|
+
The command defaults to outputting plain text, but is much more useful when in HTML mode (pass the `--html` flag). This HTML can then be converted to RTF, e.g. using `schedule availability --html | textutil -stdin -format html -convert rtf -stdout`.
|
22
18
|
|
23
|
-
##
|
19
|
+
## Config
|
20
|
+
|
21
|
+
The following configuration flags are available. The YAML config file can be edited by running `schedule config`.
|
22
|
+
|
23
|
+
- `calendars` is a list of Calendar IDs to pull appointments from.
|
24
|
+
- `day` has two keys, `start` and `end`, which respectively indicate the earliest and latest times an event can be held in a day.
|
25
|
+
- `defaults` contains a bunch of options that are applied to events by default, but can be overridden by named events in the `events` list.
|
26
|
+
|
27
|
+
- `align_to` gives the number of minutes to align each event slot to. Defaults to 15.
|
28
|
+
- `day_offset` gives the default offset (center) for a span of days over which an event can be scheduled. Defaults to "next weekday", and can be any simple string describing a relative date.
|
29
|
+
- `day_buffer` gives the number of days on either side of the center to be considered for scheduling events. Defaults to 1.
|
30
|
+
- `duration` gives the number of minutes an event should last for
|
31
|
+
- `min_delay` gives the number of hours in the future that an event must be scheduled after
|
24
32
|
|
25
|
-
|
33
|
+
- `footer` is an HTML string that is inserted after the table. This is used to include something like a Calendly link.
|
26
34
|
|
27
35
|
## Development
|
28
36
|
|
@@ -32,4 +40,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
40
|
|
33
41
|
## Contributing
|
34
42
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/karuna-health/schedule.
|
data/lib/schedule/calendar.rb
CHANGED
@@ -28,8 +28,8 @@ module Schedule
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def free_slots
|
31
|
-
center = Date.today + @options[:
|
32
|
-
(start, end_), events = get_events_in_range(center, @options[:
|
31
|
+
center = Date.today + @options[:day][:offset].days
|
32
|
+
(start, end_), events = get_events_in_range(center, @options[:day][:buffer])
|
33
33
|
|
34
34
|
range = AvailabilityRange.new(
|
35
35
|
start.beginning_of_day,
|
data/lib/schedule/cli.rb
CHANGED
@@ -16,20 +16,20 @@ module Schedule
|
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
desc 'availability type', 'print availability table'
|
19
|
+
desc 'availability type|duration offset', 'print availability table'
|
20
20
|
method_option :html, type: :boolean, default: false
|
21
21
|
method_option :debug, type: :boolean, default: false
|
22
22
|
def availability(type = nil, *offset_string)
|
23
|
-
config = Config.
|
23
|
+
config = Config.value(:defaults)
|
24
24
|
if /\A\d+\z/.match?(type)
|
25
25
|
config[:duration] = type.to_i
|
26
26
|
else
|
27
27
|
config.merge!(Config.value(:events, type&.to_sym) || {})
|
28
28
|
end
|
29
29
|
if offset_string.present?
|
30
|
-
config[:
|
31
|
-
elsif config[:
|
32
|
-
config[:
|
30
|
+
config[:day][:offset] = parse_offset offset_string.join(' ')
|
31
|
+
elsif config[:day][:offset].is_a?(String)
|
32
|
+
config[:day][:offset] = parse_offset config[:day][:offset]
|
33
33
|
end
|
34
34
|
puts config.to_s if options.debug?
|
35
35
|
slots = Schedule::Calendar.new(config).free_slots
|
@@ -41,6 +41,11 @@ module Schedule
|
|
41
41
|
system("${EDITOR:-${VISUAL:-vi}} '#{Config.config_file}'")
|
42
42
|
end
|
43
43
|
|
44
|
+
desc 'reset', 'reset config and auth tokens'
|
45
|
+
def reset
|
46
|
+
system("rm -r #{Config::CONFIG_DIR}")
|
47
|
+
end
|
48
|
+
|
44
49
|
private
|
45
50
|
|
46
51
|
def parse_offset(string)
|
data/lib/schedule/config.rb
CHANGED
@@ -7,15 +7,15 @@ module Schedule
|
|
7
7
|
class Config
|
8
8
|
CONFIG_DIR = "#{Dir.home}/.schedule-cli/"
|
9
9
|
DEFAULT_CONFIG = {
|
10
|
-
calendars: ['primary'],
|
11
|
-
day: {
|
12
|
-
start: 8,
|
13
|
-
end: 18,
|
14
|
-
},
|
15
10
|
defaults: {
|
16
11
|
align_to: 15,
|
17
|
-
|
18
|
-
|
12
|
+
calendars: ['primary'],
|
13
|
+
day: {
|
14
|
+
start: 8,
|
15
|
+
end: 18,
|
16
|
+
offset: 'next weekday',
|
17
|
+
buffer: 1,
|
18
|
+
},
|
19
19
|
duration: 30,
|
20
20
|
min_delay: 4,
|
21
21
|
},
|
@@ -44,7 +44,7 @@ module Schedule
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.values
|
47
|
-
@values ||= YAML.load(File.read(config_file)) # rubocop:disable Security/YAMLLoad
|
47
|
+
@values ||= DEFAULT_CONFIG.merge(YAML.load(File.read(config_file))) # rubocop:disable Security/YAMLLoad
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/schedule/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schedule-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasyf Mohamedali
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|