cal-invite 0.1.3 → 0.1.4
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 +4 -4
- data/.DS_Store +0 -0
- data/.rdoc_options +85 -0
- data/CHANGELOG.md +8 -0
- data/README.md +6 -0
- data/Rakefile +26 -0
- data/lib/.DS_Store +0 -0
- data/lib/cal_invite/.DS_Store +0 -0
- data/lib/cal_invite/configuration.rb +28 -0
- data/lib/cal_invite/event.rb +83 -1
- data/lib/cal_invite/providers/base_provider.rb +19 -0
- data/lib/cal_invite/providers/google.rb +56 -4
- data/lib/cal_invite/providers/ical.rb +64 -6
- data/lib/cal_invite/providers/ics.rb +70 -4
- data/lib/cal_invite/providers/ics_content.rb +80 -7
- data/lib/cal_invite/providers/office365.rb +57 -3
- data/lib/cal_invite/providers/outlook.rb +64 -3
- data/lib/cal_invite/providers/yahoo.rb +57 -0
- data/lib/cal_invite/providers.rb +6 -1
- data/lib/cal_invite/version.rb +1 -1
- data/lib/cal_invite.rb +33 -0
- data/lib/tasks/rdoc.rake +13 -0
- metadata +35 -2
@@ -3,9 +3,44 @@
|
|
3
3
|
# lib/cal_invite/providers/yahoo.rb
|
4
4
|
module CalInvite
|
5
5
|
module Providers
|
6
|
+
# Yahoo Calendar provider for generating calendar event URLs.
|
7
|
+
# This provider generates URLs that open the Yahoo Calendar with a pre-filled
|
8
|
+
# event creation form. Supports all-day events, regular events, and multi-day
|
9
|
+
# sessions with proper timezone handling.
|
10
|
+
#
|
11
|
+
# Note: Yahoo Calendar handles multi-day sessions differently from other providers,
|
12
|
+
# generating separate event URLs for each session.
|
13
|
+
#
|
14
|
+
# @example Creating a regular event URL
|
15
|
+
# event = CalInvite::Event.new(
|
16
|
+
# title: "Team Meeting",
|
17
|
+
# start_time: Time.now,
|
18
|
+
# end_time: Time.now + 3600,
|
19
|
+
# description: "Weekly team sync",
|
20
|
+
# timezone: "America/New_York"
|
21
|
+
# )
|
22
|
+
# yahoo = CalInvite::Providers::Yahoo.new(event)
|
23
|
+
# url = yahoo.generate
|
24
|
+
#
|
25
|
+
# @example Creating a multi-day event URL
|
26
|
+
# event = CalInvite::Event.new(
|
27
|
+
# title: "Conference",
|
28
|
+
# multi_day_sessions: [
|
29
|
+
# { start_time: Time.parse("2024-04-01 09:00"), end_time: Time.parse("2024-04-01 17:00") },
|
30
|
+
# { start_time: Time.parse("2024-04-02 09:00"), end_time: Time.parse("2024-04-02 17:00") }
|
31
|
+
# ]
|
32
|
+
# )
|
33
|
+
# urls = CalInvite::Providers::Yahoo.new(event).generate # Returns multiple URLs
|
6
34
|
class Yahoo < BaseProvider
|
35
|
+
# Base URL for Yahoo Calendar
|
7
36
|
BASE_URL = "https://calendar.yahoo.com"
|
8
37
|
|
38
|
+
# Generates Yahoo Calendar URL(s) for the event.
|
39
|
+
# Handles all event types: all-day, regular, and multi-day sessions.
|
40
|
+
#
|
41
|
+
# @return [String] A single URL for regular or all-day events, or
|
42
|
+
# multiple URLs (separated by newlines) for multi-day sessions
|
43
|
+
# @raise [ArgumentError] If required time fields are missing for non-all-day events
|
9
44
|
def generate
|
10
45
|
if event.all_day
|
11
46
|
generate_all_day_event
|
@@ -18,6 +53,10 @@ module CalInvite
|
|
18
53
|
|
19
54
|
private
|
20
55
|
|
56
|
+
# Generates a URL for an all-day event.
|
57
|
+
# Uses simplified date format and sets the allday flag.
|
58
|
+
#
|
59
|
+
# @return [String] The Yahoo Calendar URL for an all-day event
|
21
60
|
def generate_all_day_event
|
22
61
|
start_date = event.start_time || Time.now
|
23
62
|
end_date = event.end_time || (start_date + 86400)
|
@@ -38,6 +77,11 @@ module CalInvite
|
|
38
77
|
"#{BASE_URL}/?#{URI.encode_www_form(params)}"
|
39
78
|
end
|
40
79
|
|
80
|
+
# Generates a URL for a regular (time-specific) event.
|
81
|
+
# Includes specific start and end times with timezone information.
|
82
|
+
#
|
83
|
+
# @return [String] The Yahoo Calendar URL for a regular event
|
84
|
+
# @raise [ArgumentError] If start_time or end_time is missing
|
41
85
|
def generate_single_event
|
42
86
|
raise ArgumentError, "Start time is required" unless event.start_time
|
43
87
|
raise ArgumentError, "End time is required" unless event.end_time
|
@@ -61,6 +105,10 @@ module CalInvite
|
|
61
105
|
"#{BASE_URL}/?#{URI.encode_www_form(params)}"
|
62
106
|
end
|
63
107
|
|
108
|
+
# Generates multiple URLs for multi-day events, one for each session.
|
109
|
+
# Yahoo Calendar doesn't support multiple sessions in a single URL.
|
110
|
+
#
|
111
|
+
# @return [String] Multiple Yahoo Calendar URLs, one per line
|
64
112
|
def generate_multi_day_event
|
65
113
|
sessions = event.multi_day_sessions.map do |session|
|
66
114
|
params = {
|
@@ -81,10 +129,19 @@ module CalInvite
|
|
81
129
|
sessions.join("\n")
|
82
130
|
end
|
83
131
|
|
132
|
+
# Formats a time object as a date string for Yahoo Calendar.
|
133
|
+
#
|
134
|
+
# @param time [Time] The time to format
|
135
|
+
# @return [String] The formatted date (YYYYMMDD)
|
84
136
|
def format_date(time)
|
85
137
|
time.strftime("%Y%m%d")
|
86
138
|
end
|
87
139
|
|
140
|
+
# Formats a time object as a UTC timestamp for Yahoo Calendar.
|
141
|
+
# Yahoo Calendar accepts timezone separately in the crnd parameter.
|
142
|
+
#
|
143
|
+
# @param time [Time] The time to format
|
144
|
+
# @return [String] The formatted UTC time (YYYYMMDDTHHmmSSZ)
|
88
145
|
def format_time(time)
|
89
146
|
# Always use UTC format for the URL, timezone is passed separately
|
90
147
|
time.utc.strftime("%Y%m%dT%H%M%SZ")
|
data/lib/cal_invite/providers.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# lib/cal_invite/providers.rb
|
4
3
|
require_relative 'providers/base_provider'
|
5
4
|
|
5
|
+
# lib/cal_invite/providers.rb
|
6
|
+
# Namespace module for all calendar providers supported by CalInvite.
|
7
|
+
# Each provider implements the interface defined by BaseProvider.
|
8
|
+
#
|
9
|
+
# @see CalInvite::Providers::BaseProvider
|
6
10
|
module CalInvite
|
7
11
|
module Providers
|
12
|
+
# List of supported calendar provider symbols
|
8
13
|
SUPPORTED_PROVIDERS = %i[google ical outlook yahoo ics office365].freeze
|
9
14
|
|
10
15
|
autoload :Google, 'cal_invite/providers/google'
|
data/lib/cal_invite/version.rb
CHANGED
data/lib/cal_invite.rb
CHANGED
@@ -11,17 +11,50 @@ require 'cal_invite/caching'
|
|
11
11
|
require 'cal_invite/event'
|
12
12
|
require 'cal_invite/providers'
|
13
13
|
|
14
|
+
# The main module for the CalInvite gem. This module provides functionality for generating
|
15
|
+
# calendar invites across different calendar providers.
|
16
|
+
#
|
17
|
+
# @example Configure the gem
|
18
|
+
# CalInvite.configure do |config|
|
19
|
+
# config.timezone = 'America/New_York'
|
20
|
+
# config.cache_store = :memory_store
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# @example Create and generate a calendar URL
|
24
|
+
# event = CalInvite::Event.new(
|
25
|
+
# title: "Team Meeting",
|
26
|
+
# start_time: Time.now,
|
27
|
+
# end_time: Time.now + 3600
|
28
|
+
# )
|
29
|
+
# google_url = event.generate_calendar_url(:google)
|
30
|
+
#
|
14
31
|
module CalInvite
|
15
32
|
class Error < StandardError; end
|
16
33
|
|
17
34
|
class << self
|
35
|
+
# Returns the current configuration object.
|
36
|
+
# @return [CalInvite::Configuration] The current configuration object
|
18
37
|
attr_accessor :configuration
|
19
38
|
|
39
|
+
# Configures the CalInvite gem through a block.
|
40
|
+
#
|
41
|
+
# @yield [config] The configuration object to be modified
|
42
|
+
# @yieldparam config [CalInvite::Configuration] The configuration object
|
43
|
+
# @return [void]
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# CalInvite.configure do |config|
|
47
|
+
# config.timezone = 'UTC'
|
48
|
+
# config.cache_store = :memory_store
|
49
|
+
# end
|
20
50
|
def configure
|
21
51
|
self.configuration ||= Configuration.new
|
22
52
|
yield(configuration)
|
23
53
|
end
|
24
54
|
|
55
|
+
# Resets the configuration to default values.
|
56
|
+
#
|
57
|
+
# @return [void]
|
25
58
|
def reset_configuration!
|
26
59
|
self.configuration = Configuration.new
|
27
60
|
end
|
data/lib/tasks/rdoc.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# lib/tasks/rdoc.rake
|
2
|
+
require 'rdoc/task'
|
3
|
+
|
4
|
+
RDoc::Task.new do |rdoc|
|
5
|
+
rdoc.rdoc_dir = 'doc'
|
6
|
+
rdoc.title = 'CalInvite Documentation'
|
7
|
+
rdoc.main = 'README.md'
|
8
|
+
rdoc.options << '--line-numbers'
|
9
|
+
rdoc.options << '--charset' << 'UTF-8'
|
10
|
+
rdoc.options << '--markup' << 'markdown'
|
11
|
+
rdoc.rdoc_files.include('README.md', 'LICENSE', 'lib/**/*.rb')
|
12
|
+
rdoc.rdoc_files.exclude('lib/cal_invite/version.rb')
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cal-invite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephane Paquet
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.5'
|
27
41
|
description: CalInvite provides a simple way to generate calendar invite URLs for
|
28
42
|
various providers (Google, Outlook, Yahoo) and ICS files
|
29
43
|
email:
|
@@ -32,6 +46,8 @@ executables: []
|
|
32
46
|
extensions: []
|
33
47
|
extra_rdoc_files: []
|
34
48
|
files:
|
49
|
+
- ".DS_Store"
|
50
|
+
- ".rdoc_options"
|
35
51
|
- ".rubocop.yml"
|
36
52
|
- CACHING.md
|
37
53
|
- CHANGELOG.md
|
@@ -42,7 +58,9 @@ files:
|
|
42
58
|
- gemfiles/Gemfile.rails6
|
43
59
|
- gemfiles/Gemfile.rails7
|
44
60
|
- gemfiles/Gemfile.rails8
|
61
|
+
- lib/.DS_Store
|
45
62
|
- lib/cal_invite.rb
|
63
|
+
- lib/cal_invite/.DS_Store
|
46
64
|
- lib/cal_invite/caching.rb
|
47
65
|
- lib/cal_invite/configuration.rb
|
48
66
|
- lib/cal_invite/event.rb
|
@@ -56,6 +74,7 @@ files:
|
|
56
74
|
- lib/cal_invite/providers/outlook.rb
|
57
75
|
- lib/cal_invite/providers/yahoo.rb
|
58
76
|
- lib/cal_invite/version.rb
|
77
|
+
- lib/tasks/rdoc.rake
|
59
78
|
- sig/cal/invite.rbs
|
60
79
|
homepage: https://github.com/the-pew-inc/cal-invite
|
61
80
|
licenses:
|
@@ -65,7 +84,21 @@ metadata:
|
|
65
84
|
source_code_uri: https://github.com/the-pew-inc/cal-invite
|
66
85
|
changelog_uri: https://github.com/the-pew-inc/cal-invite/blob/master/CHANGELOG.md
|
67
86
|
post_install_message:
|
68
|
-
rdoc_options:
|
87
|
+
rdoc_options:
|
88
|
+
- "--title"
|
89
|
+
- CalInvite Documentation
|
90
|
+
- "--main"
|
91
|
+
- README.md
|
92
|
+
- "--line-numbers"
|
93
|
+
- "--all"
|
94
|
+
- "--charset"
|
95
|
+
- UTF-8
|
96
|
+
- "--markup"
|
97
|
+
- markdown
|
98
|
+
- "--exclude"
|
99
|
+
- "^(test|spec|features)/"
|
100
|
+
- "--exclude"
|
101
|
+
- lib/cal_invite/version.rb
|
69
102
|
require_paths:
|
70
103
|
- lib
|
71
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|