lex-google-calendar 0.1.1
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 +7 -0
- data/.github/workflows/ci.yml +16 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +53 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +12 -0
- data/README.md +47 -0
- data/lex-google-calendar.gemspec +30 -0
- data/lib/legion/extensions/google_calendar/client.rb +31 -0
- data/lib/legion/extensions/google_calendar/helpers/client.rb +22 -0
- data/lib/legion/extensions/google_calendar/runners/calendars.rb +29 -0
- data/lib/legion/extensions/google_calendar/runners/events.rb +55 -0
- data/lib/legion/extensions/google_calendar/version.rb +9 -0
- data/lib/legion/extensions/google_calendar.rb +15 -0
- metadata +72 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1e2f3f02758a614a6daaac2899daa76a8ee8bbfe8dd4ff745aeb394ce011689e
|
|
4
|
+
data.tar.gz: b0fd914a07ef8b5b2de17a9478b100279088b852cf0beae2bc1e71e34a7d08cd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0c3fefbb9b67ba2c9c9ffd3a40b76f8fd7d834776c95883c7521554205441386f0456a1593ff47e3d47c19f98914825c5d728798c9c86a07262f525e34b88aa6
|
|
7
|
+
data.tar.gz: 7e3d248b1f690331f1a0cb2720038b3fe4eac45a915d020e5239d7007dceb84cb10c5994471a0c2fa1d607153b5a030d4e853814f8b955fad7e73cfffd68a04c
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [origin]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ci:
|
|
9
|
+
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
|
+
|
|
11
|
+
release:
|
|
12
|
+
needs: ci
|
|
13
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/origin'
|
|
14
|
+
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
15
|
+
secrets:
|
|
16
|
+
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
6
|
+
Layout/LineLength:
|
|
7
|
+
Max: 160
|
|
8
|
+
|
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
+
EnforcedStyle: space
|
|
11
|
+
|
|
12
|
+
Layout/HashAlignment:
|
|
13
|
+
EnforcedHashRocketStyle: table
|
|
14
|
+
EnforcedColonStyle: table
|
|
15
|
+
|
|
16
|
+
Metrics/MethodLength:
|
|
17
|
+
Max: 50
|
|
18
|
+
|
|
19
|
+
Metrics/ClassLength:
|
|
20
|
+
Max: 1500
|
|
21
|
+
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Max: 1500
|
|
24
|
+
|
|
25
|
+
Metrics/BlockLength:
|
|
26
|
+
Max: 40
|
|
27
|
+
Exclude:
|
|
28
|
+
- 'spec/**/*'
|
|
29
|
+
|
|
30
|
+
Metrics/ParameterLists:
|
|
31
|
+
Max: 10
|
|
32
|
+
|
|
33
|
+
Metrics/AbcSize:
|
|
34
|
+
Max: 60
|
|
35
|
+
|
|
36
|
+
Metrics/CyclomaticComplexity:
|
|
37
|
+
Max: 15
|
|
38
|
+
|
|
39
|
+
Metrics/PerceivedComplexity:
|
|
40
|
+
Max: 17
|
|
41
|
+
|
|
42
|
+
Style/Documentation:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Style/SymbolArray:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
Style/FrozenStringLiteralComment:
|
|
49
|
+
Enabled: true
|
|
50
|
+
EnforcedStyle: always
|
|
51
|
+
|
|
52
|
+
Naming/FileName:
|
|
53
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-03-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Initial release
|
|
7
|
+
- `Helpers::Client` — Faraday connection builder targeting Google Calendar API v3 with Bearer token auth
|
|
8
|
+
- `Runners::Calendars` — list_calendars, get_calendar, create_calendar
|
|
9
|
+
- `Runners::Events` — list_events, get_event, create_event, update_event, delete_event
|
|
10
|
+
- Standalone `Client` class for use outside the Legion framework
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# lex-google-calendar
|
|
2
|
+
|
|
3
|
+
LegionIO extension for Google Calendar integration via the Google Calendar REST API v3.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add to your Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'lex-google-calendar'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Standalone Usage
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require 'legion/extensions/google_calendar'
|
|
17
|
+
|
|
18
|
+
client = Legion::Extensions::GoogleCalendar::Client.new(token: 'your-oauth2-access-token')
|
|
19
|
+
|
|
20
|
+
# Calendars
|
|
21
|
+
client.list_calendars
|
|
22
|
+
client.get_calendar(calendar_id: 'primary')
|
|
23
|
+
client.create_calendar(summary: 'Team Calendar', time_zone: 'America/Chicago')
|
|
24
|
+
|
|
25
|
+
# Events
|
|
26
|
+
client.list_events(calendar_id: 'primary')
|
|
27
|
+
client.list_events(calendar_id: 'primary', time_min: '2026-03-01T00:00:00Z', time_max: '2026-03-31T23:59:59Z')
|
|
28
|
+
client.get_event(calendar_id: 'primary', event_id: 'event_id_here')
|
|
29
|
+
client.create_event(
|
|
30
|
+
calendar_id: 'primary',
|
|
31
|
+
summary: 'Team Standup',
|
|
32
|
+
start_time: '2026-03-25T10:00:00-06:00',
|
|
33
|
+
end_time: '2026-03-25T10:30:00-06:00',
|
|
34
|
+
description: 'Daily sync',
|
|
35
|
+
location: 'Conference Room A'
|
|
36
|
+
)
|
|
37
|
+
client.update_event(calendar_id: 'primary', event_id: 'event_id_here', summary: 'Updated Title')
|
|
38
|
+
client.delete_event(calendar_id: 'primary', event_id: 'event_id_here')
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Authentication
|
|
42
|
+
|
|
43
|
+
Google Calendar uses OAuth2 Bearer tokens. Obtain an access token via the Google OAuth2 flow with the `https://www.googleapis.com/auth/calendar` scope.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/legion/extensions/google_calendar/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'lex-google-calendar'
|
|
7
|
+
spec.version = Legion::Extensions::GoogleCalendar::VERSION
|
|
8
|
+
spec.authors = ['Esity']
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'LEX::GoogleCalendar'
|
|
12
|
+
spec.description = 'Used to connect Legion to Google Calendar'
|
|
13
|
+
spec.homepage = 'https://github.com/LegionIO/lex-google-calendar'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 3.4'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-google-calendar'
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-google-calendar/blob/main/CHANGELOG.md'
|
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
21
|
+
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
spec.bindir = 'exe'
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ['lib']
|
|
28
|
+
|
|
29
|
+
spec.add_dependency 'faraday', '~> 2.0'
|
|
30
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/calendars'
|
|
5
|
+
require_relative 'runners/events'
|
|
6
|
+
|
|
7
|
+
module Legion
|
|
8
|
+
module Extensions
|
|
9
|
+
module GoogleCalendar
|
|
10
|
+
class Client
|
|
11
|
+
include Helpers::Client
|
|
12
|
+
include Runners::Calendars
|
|
13
|
+
include Runners::Events
|
|
14
|
+
|
|
15
|
+
attr_reader :opts
|
|
16
|
+
|
|
17
|
+
def initialize(token:, **extra)
|
|
18
|
+
@opts = { token: token, **extra }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def settings
|
|
22
|
+
{ options: @opts }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def connection(**override)
|
|
26
|
+
super(**@opts, **override)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module GoogleCalendar
|
|
8
|
+
module Helpers
|
|
9
|
+
module Client
|
|
10
|
+
def connection(token: nil, **_opts)
|
|
11
|
+
Faraday.new(url: 'https://www.googleapis.com/calendar/v3') do |conn|
|
|
12
|
+
conn.request :json
|
|
13
|
+
conn.response :json, content_type: /\bjson$/
|
|
14
|
+
conn.headers['Authorization'] = "Bearer #{token}" if token
|
|
15
|
+
conn.adapter Faraday.default_adapter
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module GoogleCalendar
|
|
6
|
+
module Runners
|
|
7
|
+
module Calendars
|
|
8
|
+
def list_calendars(**)
|
|
9
|
+
resp = connection(**).get('/users/me/calendarList')
|
|
10
|
+
{ calendars: resp.body }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_calendar(calendar_id:, **)
|
|
14
|
+
resp = connection(**).get("/calendars/#{calendar_id}")
|
|
15
|
+
{ calendar: resp.body }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create_calendar(summary:, description: nil, time_zone: nil, **)
|
|
19
|
+
body = { summary: summary }
|
|
20
|
+
body[:description] = description if description
|
|
21
|
+
body[:timeZone] = time_zone if time_zone
|
|
22
|
+
resp = connection(**).post('/calendars', body)
|
|
23
|
+
{ calendar: resp.body }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module GoogleCalendar
|
|
6
|
+
module Runners
|
|
7
|
+
module Events
|
|
8
|
+
def list_events(calendar_id:, time_min: nil, time_max: nil, **)
|
|
9
|
+
params = {}
|
|
10
|
+
params[:timeMin] = time_min if time_min
|
|
11
|
+
params[:timeMax] = time_max if time_max
|
|
12
|
+
params[:singleEvents] = true
|
|
13
|
+
params[:orderBy] = 'startTime'
|
|
14
|
+
resp = connection(**).get("/calendars/#{calendar_id}/events", params)
|
|
15
|
+
{ events: resp.body }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_event(calendar_id:, event_id:, **)
|
|
19
|
+
resp = connection(**).get("/calendars/#{calendar_id}/events/#{event_id}")
|
|
20
|
+
{ event: resp.body }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_event(calendar_id:, summary:, start_time:, end_time:, description: nil, location: nil, **)
|
|
24
|
+
body = {
|
|
25
|
+
summary: summary,
|
|
26
|
+
start: { dateTime: start_time },
|
|
27
|
+
end: { dateTime: end_time }
|
|
28
|
+
}
|
|
29
|
+
body[:description] = description if description
|
|
30
|
+
body[:location] = location if location
|
|
31
|
+
resp = connection(**).post("/calendars/#{calendar_id}/events", body)
|
|
32
|
+
{ event: resp.body }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def update_event(calendar_id:, event_id:, summary: nil, start_time: nil, end_time: nil,
|
|
36
|
+
description: nil, location: nil, **)
|
|
37
|
+
body = {}
|
|
38
|
+
body[:summary] = summary if summary
|
|
39
|
+
body[:start] = { dateTime: start_time } if start_time
|
|
40
|
+
body[:end] = { dateTime: end_time } if end_time
|
|
41
|
+
body[:description] = description if description
|
|
42
|
+
body[:location] = location if location
|
|
43
|
+
resp = connection(**).patch("/calendars/#{calendar_id}/events/#{event_id}", body)
|
|
44
|
+
{ event: resp.body }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def delete_event(calendar_id:, event_id:, **)
|
|
48
|
+
resp = connection(**).delete("/calendars/#{calendar_id}/events/#{event_id}")
|
|
49
|
+
{ deleted: resp.status == 204, event_id: event_id }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/google_calendar/version'
|
|
4
|
+
require 'legion/extensions/google_calendar/helpers/client'
|
|
5
|
+
require 'legion/extensions/google_calendar/runners/calendars'
|
|
6
|
+
require 'legion/extensions/google_calendar/runners/events'
|
|
7
|
+
require 'legion/extensions/google_calendar/client'
|
|
8
|
+
|
|
9
|
+
module Legion
|
|
10
|
+
module Extensions
|
|
11
|
+
module GoogleCalendar
|
|
12
|
+
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lex-google-calendar
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Esity
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: faraday
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.0'
|
|
26
|
+
description: Used to connect Legion to Google Calendar
|
|
27
|
+
email:
|
|
28
|
+
- matthewdiverson@gmail.com
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- ".github/workflows/ci.yml"
|
|
34
|
+
- ".gitignore"
|
|
35
|
+
- ".rspec"
|
|
36
|
+
- ".rubocop.yml"
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- Gemfile
|
|
39
|
+
- README.md
|
|
40
|
+
- lex-google-calendar.gemspec
|
|
41
|
+
- lib/legion/extensions/google_calendar.rb
|
|
42
|
+
- lib/legion/extensions/google_calendar/client.rb
|
|
43
|
+
- lib/legion/extensions/google_calendar/helpers/client.rb
|
|
44
|
+
- lib/legion/extensions/google_calendar/runners/calendars.rb
|
|
45
|
+
- lib/legion/extensions/google_calendar/runners/events.rb
|
|
46
|
+
- lib/legion/extensions/google_calendar/version.rb
|
|
47
|
+
homepage: https://github.com/LegionIO/lex-google-calendar
|
|
48
|
+
licenses:
|
|
49
|
+
- MIT
|
|
50
|
+
metadata:
|
|
51
|
+
homepage_uri: https://github.com/LegionIO/lex-google-calendar
|
|
52
|
+
source_code_uri: https://github.com/LegionIO/lex-google-calendar
|
|
53
|
+
changelog_uri: https://github.com/LegionIO/lex-google-calendar/blob/main/CHANGELOG.md
|
|
54
|
+
rubygems_mfa_required: 'true'
|
|
55
|
+
rdoc_options: []
|
|
56
|
+
require_paths:
|
|
57
|
+
- lib
|
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '3.4'
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
requirements: []
|
|
69
|
+
rubygems_version: 3.6.9
|
|
70
|
+
specification_version: 4
|
|
71
|
+
summary: LEX::GoogleCalendar
|
|
72
|
+
test_files: []
|