schedule-cli 0.1.1 → 0.1.2

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: 27845260a0b3a6e6dd6b06a498c510b452ae0a69b0b14ef524e0c94c9abea2d6
4
- data.tar.gz: a87f684a45f6621007e489fa6d51653bc5a1a28f22fc2dc437c0261b63832746
3
+ metadata.gz: e7f5856a18a1c3b88cfa3303b4becb495617bacdd061bb96eaa83d470272273d
4
+ data.tar.gz: 1e9f64117af1d689c63094668c7a337b51c7329e310c9df823b72f04fdf648c9
5
5
  SHA512:
6
- metadata.gz: '08667553ba38fde90bce29ea3609ebf2aece59680e18f3c4b1fd7b2af7b305c0baac5e89042b139b5740dc328e4eeb4d9d3070e15416231d2a40071ab54fd86c'
7
- data.tar.gz: ecf30cfa524aee407cd0898e5b84f4339e2d10a356ac6eacffaa92e8b5af88159f8c45ca574fed0290413dc070f71b229af641b7472f6b9d5c1aec62451426cd
6
+ metadata.gz: bda9a3ead7125b766b539f9a19ea7a288c7c57243612f4da125606de365b2942f330836f5ad3fd18f005a05a755a2bc9c8bfc0728c6ce150f947c631ced5dd7d
7
+ data.tar.gz: 43dfe7775c369c3cd837cfaa56c9c53de45c4537720d17d83c9cdec21ee0c927efa913f312f2ad27b6ef7e050433de569c070c97c29b15b428f31e9b93b86c77
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schedule-cli (0.1.1)
4
+ schedule-cli (0.1.2)
5
5
  activesupport (~> 5.2)
6
6
  chronic
7
7
  google-api-client (~> 0.11)
data/README.md CHANGED
@@ -1,28 +1,36 @@
1
1
  # Schedule
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/schedule`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'schedule'
7
+ ```bash
8
+ $ gem install schedule
13
9
  ```
14
10
 
15
- And then execute:
11
+ ## Usage
16
12
 
17
- $ bundle
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
- Or install it yourself as:
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
- $ gem install schedule
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
- ## Usage
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
- TODO: Write usage instructions here
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/[USERNAME]/schedule.
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/karuna-health/schedule.
@@ -28,8 +28,8 @@ module Schedule
28
28
  end
29
29
 
30
30
  def free_slots
31
- center = Date.today + @options[:day_offset].days
32
- (start, end_), events = get_events_in_range(center, @options[:day_buffer])
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.values.slice(:calendars, :day).merge(Config.value(:defaults))
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[:day_offset] = parse_offset offset_string.join(' ')
31
- elsif config[:day_offset].is_a?(String)
32
- config[:day_offset] = parse_offset config[:day_offset]
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)
@@ -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
- day_offset: 'next weekday',
18
- day_buffer: 1,
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Schedule
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
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.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-06 00:00:00.000000000 Z
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler