add_to_calendar 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: 3067d7dd6fcf157682aa1e25172ad8fd591262168b42f7a453712c5d7483b36d
4
- data.tar.gz: 8152eee8b227acecaf7e7abba6625b7a785e18f2cd786f2f56b777179d9b1647
3
+ metadata.gz: 2c0a0f2f9901bd47c14f386ec09c72207eeebf34e04e592473c57e2b00bc3d18
4
+ data.tar.gz: f2cb5bf74e64fb36e47d293e8a525b784018280851a16b08817eb716c4453393
5
5
  SHA512:
6
- metadata.gz: b5c7a1dc4e614fcd1d1d819ee788f29689a815f0b944429423586f71b1b4841ea6377eab52400b8a8c507daf84280f99171fa04d1c98f583145ddd249e40eb0e
7
- data.tar.gz: 1f2419f32a56d07bcfd9d632a700aae5f89d79cf87a4255fd8ddeb5e302cd809b2c17b166efb33e31f267137f81ba3e15c91804ff80ab5e0fdb99f6fa3f31ddd
6
+ metadata.gz: ab6dee17a03164fce02ce552f522b4fdda9414328063355611e39784e89b8d85cad3a800d9c3360d5128d2187cbaa9094596451fb2dce702c3acd91faead4024
7
+ data.tar.gz: 66eb54a91cba9b7adcf625e25a89ea1c64018b36e045130ba3a01a1cc317c55072fc42607903eee88103eecd102022610fb7e1b9315d284922d46eedfb6c0ce9
data/Gemfile.lock CHANGED
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- add_to_calendar (0.3.0)
4
+ add_to_calendar (0.4.0)
5
5
  tzinfo (>= 1.1, < 3)
6
6
  tzinfo-data (~> 1.2020)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- coderay (1.1.2)
12
- concurrent-ruby (1.1.6)
11
+ coderay (1.1.3)
12
+ concurrent-ruby (1.1.10)
13
13
  method_source (1.0.0)
14
14
  minitest (5.18.0)
15
- pry (0.13.1)
15
+ pry (0.14.2)
16
16
  coderay (~> 1.1)
17
17
  method_source (~> 1.0)
18
18
  rake (13.0.1)
19
19
  timecop (0.9.6)
20
- tzinfo (2.0.2)
20
+ tzinfo (2.0.5)
21
21
  concurrent-ruby (~> 1.0)
22
22
  tzinfo-data (1.2020.1)
23
23
  tzinfo (>= 1.0.0)
@@ -29,9 +29,9 @@ DEPENDENCIES
29
29
  add_to_calendar!
30
30
  bundler (~> 2.0)
31
31
  minitest (~> 5.0)
32
- pry (~> 0.13.1)
32
+ pry (~> 0.14)
33
33
  rake (~> 13.0.1)
34
34
  timecop (~> 0.9)
35
35
 
36
36
  BUNDLED WITH
37
- 2.4.12
37
+ 2.3.9
data/README.md CHANGED
@@ -78,8 +78,12 @@ event_attributes = {
78
78
  location: "20 W 34th St, New York, NY 10001",
79
79
  url: "https://www.ruby-lang.org/en/",
80
80
  description: "Join us to learn all about Ruby.",
81
- add_url_to_description: true # defaults to true,
82
- all_day: true # defaults to false
81
+ add_url_to_description: true, # defaults to true
82
+ all_day: true, # defaults to false
83
+ organizer: {
84
+ name: "First Last",
85
+ email: "email@example.com"
86
+ }
83
87
  }
84
88
 
85
89
  cal = AddToCalendar::URLs.new(**event_attributes)
@@ -96,6 +100,7 @@ cal = AddToCalendar::URLs.new(**event_attributes)
96
100
  | description | No | String | Accepts newlines by passing `\n` Eg. `"Join us for fun & drinks\n\nPS. Smart casual"` |
97
101
  | add_url_to_description | No | true/false | Defaults to `true`. Set `add_url_to_description: false` to stop the URL from being added to the description |
98
102
  | all_day | No | true/false | <ul><li>Defaults to `false`.</li><li>When set to `true` the times will be ignored.</li><li>If no end_datetime provided it will be a single day event.</li><li>When providing end_datetime, use the final day of the event (eg. 1 day event start: 2023-05-01, end: 2023-05-01; 3 day event start: 2023-05-01, end: 2023-05-03).</li><li>Some calendars require you to specify the _day after_ as the end date which feels counterintuitive, this Gem takes care of that for you.</li></ul> |
103
+ | organizer | No | Hash | <ul><li>Only supported by ical</li><li>If used you must provide both `name` and `email`</li><li>Must be in format `{ name: "First Last", email: "email@example.com" }`</li></ul> |
99
104
 
100
105
  ### Timezones and offsets
101
106
 
@@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "bundler", "~> 2.0"
35
35
  spec.add_development_dependency "rake", "~> 13.0.1"
36
36
  spec.add_development_dependency "minitest", "~> 5.0"
37
- spec.add_development_dependency "pry", "~> 0.13.1"
37
+ spec.add_development_dependency "pry", "~> 0.14"
38
38
  spec.add_development_dependency "timecop", "~> 0.9"
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module AddToCalendar
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -8,13 +8,12 @@ require 'tzinfo'
8
8
  require 'date'
9
9
  # require 'pry'
10
10
 
11
-
12
11
  module AddToCalendar
13
12
  class Error < StandardError; end
14
13
 
15
14
  class URLs
16
- attr_accessor :start_datetime, :end_datetime, :title, :timezone, :location, :url, :description, :add_url_to_description, :all_day
17
- def initialize(start_datetime:, end_datetime: nil, title:, timezone:, location: nil, url: nil, description: nil, add_url_to_description: true, all_day: false)
15
+ attr_accessor :start_datetime, :end_datetime, :title, :timezone, :location, :url, :description, :add_url_to_description, :all_day, :organizer
16
+ def initialize(start_datetime:, end_datetime: nil, title:, timezone:, location: nil, url: nil, description: nil, add_url_to_description: true, all_day: false, organizer: nil)
18
17
  @start_datetime = start_datetime
19
18
  @end_datetime = end_datetime
20
19
  @title = title
@@ -24,6 +23,7 @@ module AddToCalendar
24
23
  @description = description
25
24
  @add_url_to_description = add_url_to_description
26
25
  @all_day = all_day
26
+ @organizer = organizer
27
27
 
28
28
  validate_attributes
29
29
  end
@@ -126,6 +126,9 @@ module AddToCalendar
126
126
  end
127
127
  end
128
128
  params[:SUMMARY] = url_encode_ical(title)
129
+ if organizer
130
+ params[:ORGANIZER] = url_encode_ical("CN=\"#{organizer[:name]}\":mailto:#{organizer[:email]}")
131
+ end
129
132
  params[:URL] = url_encode(url) if url
130
133
  params[:DESCRIPTION] = url_encode_ical(description) if description
131
134
  if add_url_to_description && url
@@ -141,7 +144,11 @@ module AddToCalendar
141
144
 
142
145
  new_line = "%0A"
143
146
  params.each do |key, value|
144
- calendar_url << "#{new_line}#{key}:#{value}"
147
+ if key == :ORGANIZER
148
+ calendar_url << "#{new_line}#{key};#{value}"
149
+ else
150
+ calendar_url << "#{new_line}#{key}:#{value}"
151
+ end
145
152
  end
146
153
 
147
154
  calendar_url << "%0AEND:VEVENT%0AEND:VCALENDAR"
@@ -181,6 +188,12 @@ module AddToCalendar
181
188
  if description
182
189
  raise(ArgumentError, ":description must be a string") unless self.description.kind_of? String
183
190
  end
191
+
192
+ if organizer
193
+ unless self.organizer.is_a?(Hash) && self.organizer[:name].is_a?(String) && self.organizer[:email].is_a?(String)
194
+ raise(ArgumentError, ":organizer must be a Hash of format { name: \"First Last\", email: \"email@example.com\" }")
195
+ end
196
+ end
184
197
  end
185
198
 
186
199
  def microsoft(service)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: add_to_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Turner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-01 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 0.13.1
95
+ version: '0.14'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.13.1
102
+ version: '0.14'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: timecop
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.3.26
159
+ rubygems_version: 3.2.32
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: Generate 'Add To Calendar' URLs for Android, Apple, Google, Office 365, Outlook,