ruboty-google_calendar 0.0.2 → 0.1.0

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
  SHA1:
3
- metadata.gz: a97771d0adce7cd67b047cabc68a2efa008e636a
4
- data.tar.gz: 460d244eb4fc39f228b6c4f39a7d78cff270f7be
3
+ metadata.gz: 4610104c8327b8134f4d63b118cc991032972e71
4
+ data.tar.gz: a1aabd63f2b130e2339808c87b96afdae8f6e021
5
5
  SHA512:
6
- metadata.gz: c18ef6a25cfb3abe40fdd98cc4d2709538a0045253cd54db3856d4c9a96ed5bcb956b15f4a042bd563211abd62691ebfc52c2174375bb244d2032cb898401f19
7
- data.tar.gz: 4b78f310db751fb27e62aff2edbc3328c5e648060c18fca7daa9c9ea8b3dfff975b70562de2871f253b37e6d9ef98f18edebb86f96607365ae2ac3d7563b4d4a
6
+ metadata.gz: 55312783086a4a429670c91e5ccc5eb0df91908cba4aa11dbbae81f86b2cffdb7f4b36140a0ca4c6e6b0abd50b25ccfca05514a6257ccbcb300d54e1b6947f0f
7
+ data.tar.gz: 01c700322865650e105f848787ea347148eeac12269033499778db79d1045bfe826da553b81f03428e80c7666b859373412d5ec4dfbf8ed66ed28d961a26989a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.0
2
+ - Support duration option: `ruboty list events in 30 minutes` (thx @jabropt)
3
+ - Silence on no event
4
+
1
5
  ## 0.0.2
2
6
  - Support all-day events
3
7
 
data/README.md CHANGED
@@ -6,6 +6,9 @@
6
6
  > @ruboty list events
7
7
  2015-03-04 09:30 - 09:40 Stand-up meeting
8
8
  2015-03-04 14:00 - 15:00 Engineering meeting
9
+ >
10
+ > @ruboty list events in 30 minutes
11
+ 2015-03-04 09:30 - 09:40 Stand-up meeting
9
12
  ```
10
13
 
11
14
  ## ENV
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module GoogleCalendar
3
- VERSION = "0.0.2"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require "active_support/core_ext/date/calculations"
2
2
  require "active_support/core_ext/numeric/time"
3
+ require "active_support/core_ext/object/try"
3
4
  require "google/api_client"
4
5
  require "google/api_client/client_secrets"
5
6
  require "ruboty"
@@ -9,6 +10,7 @@ module Ruboty
9
10
  module Handlers
10
11
  class GoogleCalendar < Base
11
12
  DEFAULT_CALENDAR_ID = "primary"
13
+ DEFAULT_DURATION = 1.day
12
14
 
13
15
  env :GOOGLE_CALENDAR_ID, "Google Calendar ID (default: primary)", optional: true
14
16
  env :GOOGLE_CLIENT_ID, "Client ID"
@@ -17,16 +19,24 @@ module Ruboty
17
19
  env :GOOGLE_REFRESH_TOKEN, "Refresh token issued with access token"
18
20
 
19
21
  on(
20
- /list events\z/,
22
+ /list events( in (?<minute>\d+) minutes)?\z/,
21
23
  description: "List events from Google Calendar",
22
24
  name: "list_events",
23
25
  )
24
26
 
25
27
  def list_events(message)
26
- text = client.list_events(calendar_id: calendar_id).items.map do |item|
27
- ItemView.new(item)
28
- end.join("\n")
29
- message.reply(text, code: true)
28
+ event_items = client.list_events(
29
+ calendar_id: calendar_id,
30
+ duration: message[:minute].try(:to_i).try(:minute) || DEFAULT_DURATION,
31
+ ).items
32
+ if event_items.size > 0
33
+ text = event_items.map do |item|
34
+ ItemView.new(item)
35
+ end.join("\n")
36
+ message.reply(text, code: true)
37
+ else
38
+ true
39
+ end
30
40
  end
31
41
 
32
42
  private
@@ -58,7 +68,9 @@ module Ruboty
58
68
  authenticate!
59
69
  end
60
70
 
61
- def list_events(calendar_id: nil)
71
+ # @param [String] calendar_id
72
+ # @param [ActiveSupport::Duration] duration
73
+ def list_events(calendar_id: nil, duration: nil)
62
74
  api_client.execute(
63
75
  api_method: calendar.events.list,
64
76
  parameters: {
@@ -66,7 +78,7 @@ module Ruboty
66
78
  singleEvents: true,
67
79
  orderBy: "startTime",
68
80
  timeMin: Time.now.iso8601,
69
- timeMax: 1.day.since.iso8601
81
+ timeMax: duration.since.iso8601
70
82
  }
71
83
  ).data
72
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-google_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.2.2
120
+ rubygems_version: 2.4.5
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Ruboty plug-in to read schedule from Google Calendar.