add_to_calendar_links 0.4.2 → 0.4.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2497b47a154707baecaf96e5a06c8bf247a3a4927bac368fe9102d64ab53c139
4
- data.tar.gz: 03d063b6c2083d55d09e7ba710616d5de6337dbf8ba4f0e16c133147ea190607
3
+ metadata.gz: 495a1ab43eeb5602bfcdc9f5eee15799cab1c22a2ff2190f8fa2b0c84242c9e9
4
+ data.tar.gz: 5cfd8e912a027a63f355dededbf5dd66c050b0adab9678d3285227c82191cfef
5
5
  SHA512:
6
- metadata.gz: 045fb5416365467b8b557c981d27a754826750a0efce2d2dbc00ab348b5bdba7e4e37449611fdc828772be5c13bd639b8f78d045ac937f14981345c0d589d9e4
7
- data.tar.gz: c64b76d1d4fa90e10c3e0227e413064330b9adbcf2d0e38a09360a110310fef2a85ae015ff0d723a1e79dae63fd8cb8374d43167db490fa783204e0941ee3386
6
+ metadata.gz: 1d48b9f117fc0dd0b1bb7dfedf5bc1a363e3da547904f964e4cc33bc9952d00a8b26d17b3f0d2e0dd22586172b43477a7d081c785ae99d7a96075c3dc864a1a9
7
+ data.tar.gz: 766601c05aa976fd3692d300aa7e8f7ea2b4c649cd22d90e8b3aef574d9724dfffcf9159efdd417ae82043974fd909b3a5fd43c3defe69f9c8208dd04dd972f7
@@ -12,8 +12,8 @@ module AddToCalendarLinks
12
12
  class Error < StandardError; end
13
13
 
14
14
  class URLs
15
- attr_accessor :start_datetime, :end_datetime, :title, :timezone, :location, :url, :description, :add_url_to_description, :organizer, :strip_html, :sequence, :last_modified
16
- def initialize(start_datetime:, end_datetime: nil, title:, timezone:, location: nil, url: nil, description: nil, add_url_to_description: true, organizer: nil, strip_html: false, sequence: nil, last_modified: Time.now.utc)
15
+ attr_accessor :start_datetime, :end_datetime, :title, :timezone, :location, :url, :description, :add_url_to_description, :organizer, :strip_html, :sequence, :last_modified, :uid
16
+ def initialize(start_datetime:, end_datetime: nil, title:, timezone:, location: nil, url: nil, description: nil, add_url_to_description: true, organizer: nil, strip_html: false, sequence: nil, last_modified: Time.now.utc, uid:)
17
17
  @start_datetime = start_datetime
18
18
  @end_datetime = end_datetime
19
19
  @title = title
@@ -22,9 +22,10 @@ module AddToCalendarLinks
22
22
  @url = url
23
23
  @description = description
24
24
  @add_url_to_description = add_url_to_description
25
- @organizer = URI.parse(organizer) if organizer
25
+ @organizer = organizer if organizer
26
26
  @strip_html = strip_html
27
27
  @sequence = sequence
28
+ @uid = uid
28
29
  @last_modified = last_modified
29
30
  validate_attributes
30
31
  end
@@ -120,15 +121,23 @@ module AddToCalendarLinks
120
121
  end
121
122
  end
122
123
  params[:LOCATION] = strip_html_tags(location) if location
123
- params[:UID] = "-#{url}" if url
124
- params[:UID] = "-#{utc_datetime(start_datetime)}-#{title}" unless params[:UID] # set uid based on starttime and title only if url is unavailable
124
+ if uid
125
+ params[:UID] = uid
126
+ else
127
+ params[:UID] = "-#{urlc}" if url
128
+ params[:UID] = "-#{utc_datetime(start_datetime)}-#{title}" unless params[:UID] # set uid based on starttime and title only if url is unavailable
129
+ end
125
130
  params[:ORGANIZER] = organizer if organizer
126
131
  params[:SEQUENCE] = sequence if sequence
127
132
  params["LAST-MODIFIED"] = format_date_google(last_modified) if last_modified
128
133
  params[:METHOD] = "REQUEST"
129
134
 
130
135
  params.each do |key, value|
131
- calendar_url << "\n#{key}:#{value}"
136
+ if key == :ORGANIZER
137
+ calendar_url << "\n#{key}#{value}"
138
+ else
139
+ calendar_url << "\n#{key}:#{value}"
140
+ end
132
141
  end
133
142
 
134
143
  calendar_url << "\nEND:VEVENT\nEND:VCALENDAR"
@@ -159,15 +168,23 @@ module AddToCalendarLinks
159
168
  end
160
169
  end
161
170
  params[:LOCATION] = url_encode_ical(location) if location
162
- params[:UID] = "-#{url_encode(url)}" if url
163
- params[:UID] = "-#{utc_datetime(start_datetime)}-#{url_encode_ical(title)}" unless params[:UID] # set uid based on starttime and title only if url is unavailable
171
+ if uid
172
+ params[:UID] = uid
173
+ else
174
+ params[:UID] = "-#{url_encode(url)}" if url
175
+ params[:UID] = "-#{utc_datetime(start_datetime)}-#{url_encode_ical(title)}" unless params[:UID] # set uid based on starttime and title only if url is unavailable
176
+ end
164
177
  params[:ORGANIZER] = organizer if organizer
165
178
  params[:SEQUENCE] = sequence if sequence
166
179
  params["LAST-MODIFIED"] = format_date_google(last_modified) if last_modified
167
180
 
168
181
  new_line = "%0A"
169
182
  params.each do |key, value|
170
- calendar_url << "#{new_line}#{key}:#{value}"
183
+ if key == :ORGANIZER
184
+ calendar_url << "\n#{key}#{value}"
185
+ else
186
+ calendar_url << "\n#{key}:#{value}"
187
+ end
171
188
  end
172
189
 
173
190
  calendar_url << "%0AEND:VEVENT%0AEND:VCALENDAR"
@@ -320,6 +337,7 @@ module AddToCalendarLinks
320
337
  string.gsub!("&amp;", "and")
321
338
  string.gsub!("&nbsp;", " ")
322
339
  string.gsub!(/<\/?[^>]*>/, "")
340
+ string.gsub!(/\n/, "\\n")
323
341
  string.gsub!(/(\\n){2,}/, "\\n\\n")
324
342
  string.strip
325
343
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AddToCalendarLinks
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: add_to_calendar_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Turner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-03-30 00:00:00.000000000 Z
12
+ date: 2021-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tzinfo