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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -0
- data/lib/ruboty/google_calendar/version.rb +1 -1
- data/lib/ruboty/handlers/google_calendar.rb +19 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4610104c8327b8134f4d63b118cc991032972e71
|
4
|
+
data.tar.gz: a1aabd63f2b130e2339808c87b96afdae8f6e021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55312783086a4a429670c91e5ccc5eb0df91908cba4aa11dbbae81f86b2cffdb7f4b36140a0ca4c6e6b0abd50b25ccfca05514a6257ccbcb300d54e1b6947f0f
|
7
|
+
data.tar.gz: 01c700322865650e105f848787ea347148eeac12269033499778db79d1045bfe826da553b81f03428e80c7666b859373412d5ec4dfbf8ed66ed28d961a26989a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -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
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
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:
|
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
|
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-
|
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.
|
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.
|