ruboty-google_calendar 0.1.0 → 0.2.0
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 +5 -5
- data/.github/release.yml +23 -0
- data/.github/workflows/actions.lock +37 -0
- data/.github/workflows/bump-request.yml +26 -0
- data/.github/workflows/ci.yml +26 -0
- data/.github/workflows/release.yml +11 -0
- data/README.md +1 -1
- data/lib/ruboty/google_calendar/version.rb +1 -1
- data/lib/ruboty/handlers/google_calendar.rb +32 -49
- data/ruboty-google_calendar.gemspec +10 -3
- metadata +26 -24
- data/CHANGELOG.md +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f42fc9ff1731f00e719f55a7c26cda9f30f38a1b180711041cbe39ef48edcc70
|
|
4
|
+
data.tar.gz: 2448e92d2e95743fed05a2177beb172ad8a7980939e7500853285b50492aa807
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3d54de93b251f7a25a2d2d9ade9c41177f63e25ccea25bb96fce55babd5490801a85656302fcaf12c4deca98026a5ad2af5a66fa095fde875763bd16fd472c1
|
|
7
|
+
data.tar.gz: 0be51d8272633e245776280175e130cc06af7c0a7f463273932f8d2d35034026a5f9cbc6c0bb842da4e8d4f7b06ee280f609a557f1dac8612a01b5549a648144
|
data/.github/release.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
changelog:
|
|
2
|
+
categories:
|
|
3
|
+
- title: Added
|
|
4
|
+
labels:
|
|
5
|
+
- add
|
|
6
|
+
- title: Changed
|
|
7
|
+
labels:
|
|
8
|
+
- change
|
|
9
|
+
- title: Deprecated
|
|
10
|
+
labels:
|
|
11
|
+
- deprecate
|
|
12
|
+
- title: Fixed
|
|
13
|
+
labels:
|
|
14
|
+
- fix
|
|
15
|
+
- title: Removed
|
|
16
|
+
labels:
|
|
17
|
+
- remove
|
|
18
|
+
- title: Security
|
|
19
|
+
labels:
|
|
20
|
+
- security
|
|
21
|
+
- title: Others
|
|
22
|
+
labels:
|
|
23
|
+
- "*"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This file is machine-generated by `gh actions-lock`.
|
|
2
|
+
# Do not edit by hand; run `gh actions-lock` to update.
|
|
3
|
+
# Docs: https://gh.io/actions-lockfile
|
|
4
|
+
version: 'v0.0.3'
|
|
5
|
+
workflows:
|
|
6
|
+
'.github/workflows/bump-request.yml':
|
|
7
|
+
- 'actions/checkout@v7.0.1'
|
|
8
|
+
- 'r7kamura/bump-request@v0.7.1'
|
|
9
|
+
- 'ruby/setup-ruby@v1.336.0'
|
|
10
|
+
'.github/workflows/ci.yml':
|
|
11
|
+
- 'actions/checkout@v7.0.1'
|
|
12
|
+
- 'ruby/setup-ruby@v1.336.0'
|
|
13
|
+
'.github/workflows/release.yml': []
|
|
14
|
+
dependencies:
|
|
15
|
+
'actions/checkout@v7.0.1':
|
|
16
|
+
ref: 'v7.0.1'
|
|
17
|
+
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
|
|
18
|
+
owner_id: 44036562
|
|
19
|
+
repo_id: 197814629
|
|
20
|
+
'actions/setup-node@v7.1.0':
|
|
21
|
+
ref: 'v7.1.0'
|
|
22
|
+
commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
|
|
23
|
+
owner_id: 44036562
|
|
24
|
+
repo_id: 189476904
|
|
25
|
+
'r7kamura/bump-request@v0.7.1':
|
|
26
|
+
ref: 'v0.7.1'
|
|
27
|
+
commit: 'sha1-b27937188d404bc0c2fd442403e6de1d20f9b349'
|
|
28
|
+
owner_id: 111689
|
|
29
|
+
repo_id: 533135195
|
|
30
|
+
uses:
|
|
31
|
+
- 'actions/checkout@v7.0.1'
|
|
32
|
+
- 'actions/setup-node@v7.1.0'
|
|
33
|
+
'ruby/setup-ruby@v1.336.0':
|
|
34
|
+
ref: 'v1.336.0'
|
|
35
|
+
commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94'
|
|
36
|
+
owner_id: 210414
|
|
37
|
+
repo_id: 231208785
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: bump-request
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: Version to change to.
|
|
8
|
+
required: true
|
|
9
|
+
type: string
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
run:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7.0.1
|
|
16
|
+
- name: Set up Ruby
|
|
17
|
+
uses: ruby/setup-ruby@v1.336.0
|
|
18
|
+
with:
|
|
19
|
+
ruby-version: 3.3
|
|
20
|
+
bundler-cache: true
|
|
21
|
+
- uses: r7kamura/bump-request@v0.7.1
|
|
22
|
+
with:
|
|
23
|
+
command: |
|
|
24
|
+
sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/ruboty/google_calendar/version.rb
|
|
25
|
+
bundle install
|
|
26
|
+
version: ${{ inputs.version }}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
name: Ruby ${{ matrix.ruby }}
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
ruby:
|
|
17
|
+
- '3.3'
|
|
18
|
+
- '3.4'
|
|
19
|
+
- '4.0'
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v7.0.1
|
|
22
|
+
- uses: ruby/setup-ruby@v1.336.0
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
- run: bundle exec ruby -e 'require "ruboty"; require "ruboty/google_calendar"'
|
data/README.md
CHANGED
|
@@ -45,7 +45,7 @@ curl \
|
|
|
45
45
|
-d "client_id=${GOOGLE_CLIENT_ID}"\
|
|
46
46
|
-d "client_secret=${GOOGLE_CLIENT_SECRET}"\
|
|
47
47
|
-d "redirect_uri=http://localhost"\
|
|
48
|
-
-d "grant_type=authorization_code"
|
|
48
|
+
-d "grant_type=authorization_code"\
|
|
49
49
|
-d "code=${CODE}"\
|
|
50
50
|
"https://accounts.google.com/o/oauth2/token"
|
|
51
51
|
```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require "active_support/core_ext/date/calculations"
|
|
2
2
|
require "active_support/core_ext/numeric/time"
|
|
3
3
|
require "active_support/core_ext/object/try"
|
|
4
|
-
require "google/
|
|
5
|
-
require "
|
|
4
|
+
require "google/apis/calendar_v3"
|
|
5
|
+
require "googleauth"
|
|
6
6
|
require "ruboty"
|
|
7
7
|
require "time"
|
|
8
8
|
|
|
@@ -25,10 +25,10 @@ module Ruboty
|
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
def list_events(message)
|
|
28
|
-
event_items = client.list_events(
|
|
28
|
+
event_items = Array(client.list_events(
|
|
29
29
|
calendar_id: calendar_id,
|
|
30
30
|
duration: message[:minute].try(:to_i).try(:minute) || DEFAULT_DURATION,
|
|
31
|
-
).items
|
|
31
|
+
).items)
|
|
32
32
|
if event_items.size > 0
|
|
33
33
|
text = event_items.map do |item|
|
|
34
34
|
ItemView.new(item)
|
|
@@ -56,9 +56,8 @@ module Ruboty
|
|
|
56
56
|
|
|
57
57
|
class Client
|
|
58
58
|
APPLICATION_NAME = "ruboty-google_calendar"
|
|
59
|
-
AUTH_URI = "https://accounts.google.com/o/oauth2/auth"
|
|
60
59
|
SCOPE = "https://www.googleapis.com/auth/calendar"
|
|
61
|
-
TOKEN_URI = "https://
|
|
60
|
+
TOKEN_URI = "https://oauth2.googleapis.com/token"
|
|
62
61
|
|
|
63
62
|
def initialize(client_id: nil, client_secret: nil, redirect_uri: nil, refresh_token: nil)
|
|
64
63
|
@client_id = client_id
|
|
@@ -71,56 +70,40 @@ module Ruboty
|
|
|
71
70
|
# @param [String] calendar_id
|
|
72
71
|
# @param [ActiveSupport::Duration] duration
|
|
73
72
|
def list_events(calendar_id: nil, duration: nil)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
timeMax: duration.since.iso8601
|
|
82
|
-
}
|
|
83
|
-
).data
|
|
73
|
+
service.list_events(
|
|
74
|
+
calendar_id,
|
|
75
|
+
single_events: true,
|
|
76
|
+
order_by: "startTime",
|
|
77
|
+
time_min: Time.now.iso8601,
|
|
78
|
+
time_max: duration.since.iso8601,
|
|
79
|
+
)
|
|
84
80
|
end
|
|
85
81
|
|
|
86
82
|
private
|
|
87
83
|
|
|
88
|
-
def api_client
|
|
89
|
-
@api_client ||= begin
|
|
90
|
-
_api_client = Google::APIClient.new(
|
|
91
|
-
application_name: APPLICATION_NAME,
|
|
92
|
-
application_version: Ruboty::GoogleCalendar::VERSION,
|
|
93
|
-
)
|
|
94
|
-
_api_client.authorization = authorization
|
|
95
|
-
_api_client.authorization.scope = SCOPE
|
|
96
|
-
_api_client
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
84
|
def authenticate!
|
|
101
|
-
|
|
85
|
+
authorization.fetch_access_token!
|
|
102
86
|
end
|
|
103
87
|
|
|
104
88
|
def authorization
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
auth_uri: AUTH_URI,
|
|
113
|
-
client_id: @client_id,
|
|
114
|
-
client_secret: @client_secret,
|
|
115
|
-
redirect_uris: [@redirect_uri],
|
|
116
|
-
refresh_token: @refresh_token,
|
|
117
|
-
token_uri: TOKEN_URI,
|
|
118
|
-
},
|
|
89
|
+
@authorization ||= Google::Auth::UserRefreshCredentials.new(
|
|
90
|
+
client_id: @client_id,
|
|
91
|
+
client_secret: @client_secret,
|
|
92
|
+
redirect_uri: @redirect_uri,
|
|
93
|
+
refresh_token: @refresh_token,
|
|
94
|
+
scope: SCOPE,
|
|
95
|
+
token_credential_uri: TOKEN_URI,
|
|
119
96
|
)
|
|
120
97
|
end
|
|
121
98
|
|
|
122
|
-
def
|
|
123
|
-
@
|
|
99
|
+
def service
|
|
100
|
+
@service ||= begin
|
|
101
|
+
_service = Google::Apis::CalendarV3::CalendarService.new
|
|
102
|
+
_service.client_options.application_name = APPLICATION_NAME
|
|
103
|
+
_service.client_options.application_version = Ruboty::GoogleCalendar::VERSION
|
|
104
|
+
_service.authorization = authorization
|
|
105
|
+
_service
|
|
106
|
+
end
|
|
124
107
|
end
|
|
125
108
|
end
|
|
126
109
|
|
|
@@ -144,21 +127,21 @@ module Ruboty
|
|
|
144
127
|
when all_day?
|
|
145
128
|
"--:--"
|
|
146
129
|
when finished_in_same_day?
|
|
147
|
-
@item.end.date_time.localtime.strftime("%H:%M")
|
|
130
|
+
@item.end.date_time.to_time.localtime.strftime("%H:%M")
|
|
148
131
|
else
|
|
149
|
-
@item.end.date_time.localtime.strftime("%Y-%m-%d %H:%M")
|
|
132
|
+
@item.end.date_time.to_time.localtime.strftime("%Y-%m-%d %H:%M")
|
|
150
133
|
end
|
|
151
134
|
end
|
|
152
135
|
|
|
153
136
|
def finished_in_same_day?
|
|
154
|
-
@item.start.date_time.localtime.day == @item.end.date_time.localtime.day
|
|
137
|
+
@item.start.date_time.to_time.localtime.day == @item.end.date_time.to_time.localtime.day
|
|
155
138
|
end
|
|
156
139
|
|
|
157
140
|
def started_at
|
|
158
141
|
if all_day?
|
|
159
142
|
"#{@item.start.date} --:--"
|
|
160
143
|
else
|
|
161
|
-
@item.start.date_time.localtime.strftime("%Y-%m-%d %H:%M")
|
|
144
|
+
@item.start.date_time.to_time.localtime.strftime("%Y-%m-%d %H:%M")
|
|
162
145
|
end
|
|
163
146
|
end
|
|
164
147
|
|
|
@@ -11,14 +11,21 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.homepage = "https://github.com/r7kamura/ruboty-google_calendar"
|
|
12
12
|
spec.license = "MIT"
|
|
13
13
|
|
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
15
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
16
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"
|
|
17
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
18
|
+
|
|
14
19
|
spec.files = `git ls-files -z`.split("\x0")
|
|
15
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
16
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
17
22
|
spec.require_paths = ["lib"]
|
|
18
23
|
|
|
24
|
+
spec.required_ruby_version = ">= 3.3"
|
|
25
|
+
|
|
19
26
|
spec.add_runtime_dependency "activesupport"
|
|
20
|
-
spec.add_runtime_dependency "google-
|
|
27
|
+
spec.add_runtime_dependency "google-apis-calendar_v3"
|
|
28
|
+
spec.add_runtime_dependency "googleauth"
|
|
21
29
|
spec.add_runtime_dependency "ruboty"
|
|
22
|
-
spec.add_development_dependency "
|
|
23
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
30
|
+
spec.add_development_dependency "rake"
|
|
24
31
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruboty-google_calendar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryo Nakamura
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -25,7 +24,7 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: google-
|
|
27
|
+
name: google-apis-calendar_v3
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - ">="
|
|
@@ -39,7 +38,7 @@ dependencies:
|
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: googleauth
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - ">="
|
|
@@ -53,42 +52,45 @@ dependencies:
|
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: '0'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
55
|
+
name: ruboty
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
|
-
- - "
|
|
58
|
+
- - ">="
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
62
|
-
type: :
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :runtime
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
|
-
- - "
|
|
65
|
+
- - ">="
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
67
|
+
version: '0'
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
70
69
|
name: rake
|
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
|
73
|
-
- - "
|
|
72
|
+
- - ">="
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
74
|
+
version: '0'
|
|
76
75
|
type: :development
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
|
-
- - "
|
|
79
|
+
- - ">="
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
83
|
-
description:
|
|
81
|
+
version: '0'
|
|
84
82
|
email:
|
|
85
83
|
- r7kamura@gmail.com
|
|
86
84
|
executables: []
|
|
87
85
|
extensions: []
|
|
88
86
|
extra_rdoc_files: []
|
|
89
87
|
files:
|
|
88
|
+
- ".github/release.yml"
|
|
89
|
+
- ".github/workflows/actions.lock"
|
|
90
|
+
- ".github/workflows/bump-request.yml"
|
|
91
|
+
- ".github/workflows/ci.yml"
|
|
92
|
+
- ".github/workflows/release.yml"
|
|
90
93
|
- ".gitignore"
|
|
91
|
-
- CHANGELOG.md
|
|
92
94
|
- Gemfile
|
|
93
95
|
- LICENSE.txt
|
|
94
96
|
- README.md
|
|
@@ -100,8 +102,11 @@ files:
|
|
|
100
102
|
homepage: https://github.com/r7kamura/ruboty-google_calendar
|
|
101
103
|
licenses:
|
|
102
104
|
- MIT
|
|
103
|
-
metadata:
|
|
104
|
-
|
|
105
|
+
metadata:
|
|
106
|
+
homepage_uri: https://github.com/r7kamura/ruboty-google_calendar
|
|
107
|
+
source_code_uri: https://github.com/r7kamura/ruboty-google_calendar
|
|
108
|
+
changelog_uri: https://github.com/r7kamura/ruboty-google_calendar/releases
|
|
109
|
+
rubygems_mfa_required: 'true'
|
|
105
110
|
rdoc_options: []
|
|
106
111
|
require_paths:
|
|
107
112
|
- lib
|
|
@@ -109,17 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
109
114
|
requirements:
|
|
110
115
|
- - ">="
|
|
111
116
|
- !ruby/object:Gem::Version
|
|
112
|
-
version: '
|
|
117
|
+
version: '3.3'
|
|
113
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
119
|
requirements:
|
|
115
120
|
- - ">="
|
|
116
121
|
- !ruby/object:Gem::Version
|
|
117
122
|
version: '0'
|
|
118
123
|
requirements: []
|
|
119
|
-
|
|
120
|
-
rubygems_version: 2.4.5
|
|
121
|
-
signing_key:
|
|
124
|
+
rubygems_version: 4.0.20
|
|
122
125
|
specification_version: 4
|
|
123
126
|
summary: Ruboty plug-in to read schedule from Google Calendar.
|
|
124
127
|
test_files: []
|
|
125
|
-
has_rdoc:
|