icalendar 1.4.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 370af2e2d4636f906480c2a2d9faa6f71d00c572
4
- data.tar.gz: a9bf492ff26c0d75dbe138f2a08841910882105d
3
+ metadata.gz: bac1e484f0c1f2c316989f0fb092e799cdcbc768
4
+ data.tar.gz: 43df9e195316a6fa72ea53ef22b615c62dccf807
5
5
  SHA512:
6
- metadata.gz: 4f73cd84ce78cb0c7bc9cb5c65a08de0c09d1cffe087ad5b9b17ef92e6ad32e0f470b23ecd53255d99198e7fd980a9eac28b317574adca005bada4294001201b
7
- data.tar.gz: a3fae6aef26214cda39e5974cc9c38556a4626a2aff24af82a5310319a76dd79cc7f18a3cc46e093b37c809664f9ec99b694e237b06d2f3d1a88b216d58f4b93
6
+ metadata.gz: 8f3facfc15d82ac4d1364d82fd8f9dbca4d6101e725a93acd182a86a35571ec8180dd3fcf85b92fdce31b79a1cb7e7ef68aa07eca27bfc5bb81bcfb41b16bcc5
7
+ data.tar.gz: b9732aa49cfe06380fc0a401499bca6334c3dafdaad1a640f50d7e7d97d32be9f8651904064653436f892293896e0b5280651a77d48523e81e2b2eb926f809d2
@@ -1,3 +1,7 @@
1
+ === 1.4.1 2013-06-25
2
+ * Don't escape semicolon in GEO property - temirov
3
+ * Allow access to various parts of RRule class
4
+
1
5
  === 1.4.0 2013-05-21
2
6
  * Implement ACKNOWLEDGED property for VALARM - tsuzuki08
3
7
  * Output VERSION property as first line after BEGIN:VCALENDAR
@@ -11,7 +11,7 @@ require 'logger'
11
11
 
12
12
  module Icalendar #:nodoc:
13
13
 
14
- VERSION = '1.4.0'
14
+ VERSION = '1.4.1'
15
15
 
16
16
  # A simple error class to differentiate iCalendar library exceptions
17
17
  # from ruby language exceptions or others.
@@ -136,22 +136,19 @@ module Icalendar
136
136
  end
137
137
 
138
138
  # Property name
139
- unless multiline_property?(key)
140
- prelude = "#{key.gsub(/_/, '-').upcase}" +
141
-
142
- # Possible parameters
143
- print_parameters(val)
139
+ if !multiline_property?(key)
140
+ prelude = "#{key.gsub(/_/, '-').upcase}#{print_parameters val}"
144
141
 
145
142
  # Property value
146
143
  value = ":#{val.to_ical}"
147
- value = escape_chars(value) unless %w[rrule categories exdate].include?(key)
144
+ value = escape_chars(value) unless %w[geo rrule categories exdate].include?(key)
148
145
  add_sliced_text(s, prelude + value)
149
146
  else
150
147
  prelude = "#{key.gsub(/_/, '-').upcase}"
151
148
  val.each do |v|
152
149
  params = print_parameters(v)
153
150
  value = ":#{v.to_ical}"
154
- value = escape_chars(value) unless key == "rrule"
151
+ value = escape_chars(value)
155
152
  add_sliced_text(s, prelude + params + value)
156
153
  end
157
154
  end
@@ -174,7 +171,7 @@ module Icalendar
174
171
  # Print the parameters for a specific property.
175
172
  def print_parameters(value)
176
173
  s = ""
177
- return s unless value.respond_to?(:ical_params) and not value.ical_params.nil?
174
+ return s unless value.respond_to?(:ical_params) && !value.ical_params.nil?
178
175
 
179
176
  value.ical_params.each do |key, val|
180
177
  s << ";#{key}"
@@ -213,12 +210,12 @@ module Icalendar
213
210
  # Make it protected so we can monitor usage...
214
211
  protected
215
212
 
216
- def Component.ical_component(*syms)
213
+ def self.ical_component(*syms)
217
214
  hash_accessor :@components, *syms
218
215
  end
219
216
 
220
217
  # Define a set of methods supporting a new property
221
- def Component.ical_property(property, alias_name = nil, prop_name = nil)
218
+ def self.ical_property(property, alias_name = nil, prop_name = nil)
222
219
  property = "#{property}".strip.downcase
223
220
  alias_name = "#{alias_name}".strip.downcase unless alias_name.nil?
224
221
  # If a prop_name was given then we use that for the actual storage
@@ -231,7 +228,7 @@ module Icalendar
231
228
 
232
229
  # Define a set of methods defining a new property, which
233
230
  # supports multiple values for the same property name.
234
- def Component.ical_multi_property(property, singular, plural)
231
+ def self.ical_multi_property(property, singular, plural)
235
232
  property = "#{property}".strip.downcase.gsub(/-/, '_')
236
233
  plural = "#{plural}".strip.downcase
237
234
 
@@ -248,7 +245,7 @@ module Icalendar
248
245
 
249
246
  # Define a set of methods defining a new property, which
250
247
  # supports multiple values in multiple lines with same property name
251
- def Component.ical_multiline_property(property, singular, plural)
248
+ def self.ical_multiline_property(property, singular, plural)
252
249
  @@multiline_properties["#{property}"] = true
253
250
  ical_multi_property(property, singular, plural)
254
251
  end
@@ -256,7 +253,7 @@ module Icalendar
256
253
 
257
254
  private
258
255
 
259
- def Component.generate_getter(property, alias_name)
256
+ def self.generate_getter(property, alias_name)
260
257
  unless instance_methods.include? property
261
258
  code = <<-code
262
259
  def #{property}(val = nil, params = nil)
@@ -284,7 +281,7 @@ module Icalendar
284
281
  end
285
282
  end
286
283
 
287
- def Component.generate_setter(property, alias_name)
284
+ def self.generate_setter(property, alias_name)
288
285
  setter = property + '='
289
286
  unless instance_methods.include? setter
290
287
  code = <<-code
@@ -298,7 +295,7 @@ module Icalendar
298
295
  end
299
296
  end
300
297
 
301
- def Component.generate_query(property, alias_name)
298
+ def self.generate_query(property, alias_name)
302
299
  query = "#{property}?"
303
300
  unless instance_methods.include? query
304
301
  code = <<-code
@@ -313,7 +310,7 @@ module Icalendar
313
310
  end
314
311
  end
315
312
 
316
- def Component.generate_multi_getter(property, plural)
313
+ def self.generate_multi_getter(property, plural)
317
314
  # Getter for whole array
318
315
  unless instance_methods.include? plural
319
316
  code = <<-code
@@ -330,7 +327,7 @@ module Icalendar
330
327
  end
331
328
  end
332
329
 
333
- def Component.generate_multi_setter(property, plural)
330
+ def self.generate_multi_setter(property, plural)
334
331
  # Setter for whole array
335
332
  unless instance_methods.include? plural+'+'
336
333
  code = <<-code
@@ -353,7 +350,7 @@ module Icalendar
353
350
  end
354
351
  end
355
352
 
356
- def Component.generate_multi_query(property, plural)
353
+ def self.generate_multi_query(property, plural)
357
354
  # Query for any of these properties
358
355
  unless instance_methods.include? plural+'?'
359
356
  code = <<-code
@@ -366,7 +363,7 @@ module Icalendar
366
363
  end
367
364
  end
368
365
 
369
- def Component.generate_multi_adder(property, singular)
366
+ def self.generate_multi_adder(property, singular)
370
367
  adder = "add_"+singular.to_s
371
368
  # Add another item to this properties array
372
369
  unless instance_methods.include? adder
@@ -397,7 +394,7 @@ module Icalendar
397
394
  end
398
395
  end
399
396
 
400
- def Component.generate_multi_remover(property, singular)
397
+ def self.generate_multi_remover(property, singular)
401
398
  # Remove an item from this properties array
402
399
  unless instance_methods.include? "remove_#{singular}"
403
400
  code = <<-code
@@ -350,7 +350,7 @@ module Icalendar
350
350
  end
351
351
 
352
352
  def parse_recur(name, params, value)
353
- ::Icalendar::RRule.new(name, params, value, self)
353
+ ::Icalendar::RRule.new(name, params, value)
354
354
  end
355
355
 
356
356
  # Durations
@@ -33,15 +33,15 @@ module Icalendar
33
33
  "#{@position}#{@day}"
34
34
  end
35
35
  end
36
-
37
- def initialize(name, params, value, parser)
36
+
37
+ attr_accessor :frequency, :until, :count, :interval, :by_list, :wkst
38
+
39
+ def initialize(name, params, value)
38
40
  @value = value
39
41
  frequency_match = value.match(/FREQ=(SECONDLY|MINUTELY|HOURLY|DAILY|WEEKLY|MONTHLY|YEARLY)/)
40
- raise Icalendar::InvalidPropertyValue.new("FREQ must be specified for RRULE values") unless frequency_match
41
42
  @frequency = frequency_match[1]
42
43
  @until = parse_date_val("UNTIL", value)
43
44
  @count = parse_int_val("COUNT", value)
44
- raise Icalendar::InvalidPropertyValue.new("UNTIL and COUNT must not both be specified for RRULE values") if [@until, @count].compact.length > 1
45
45
  @interval = parse_int_val("INTERVAL", value)
46
46
  @by_list = {:bysecond => parse_int_list("BYSECOND", value)}
47
47
  @by_list[:byminute] = parse_int_list("BYMINUTE",value)
@@ -59,23 +59,25 @@ module Icalendar
59
59
  def orig_value
60
60
  @value
61
61
  end
62
-
62
+
63
63
  def to_ical
64
- result = ["FREQ=#{@frequency}"]
65
- result << ";UNTIL=#{@until.to_ical}" if @until
66
- result << ";COUNT=#{@count}" if @count
67
- result << ";INTERVAL=#{@interval}" if @interval
68
- @by_list.each do |key, value|
64
+ raise Icalendar::InvalidPropertyValue.new("FREQ must be specified for RRULE values") unless frequency
65
+ raise Icalendar::InvalidPropertyValue.new("UNTIL and COUNT must not both be specified for RRULE values") if [self.until, count].compact.length > 1
66
+ result = ["FREQ=#{frequency}"]
67
+ result << "UNTIL=#{self.until.to_ical}" if self.until
68
+ result << "COUNT=#{count}" if count
69
+ result << "INTERVAL=#{interval}" if interval
70
+ by_list.each do |key, value|
69
71
  if value
70
72
  if key == :byday
71
- result << ";BYDAY=#{value.join ','}"
73
+ result << "BYDAY=#{value.join ','}"
72
74
  else
73
- result << ";#{key.to_s.upcase}=#{value}"
75
+ result << "#{key.to_s.upcase}=#{value}"
74
76
  end
75
77
  end
76
78
  end
77
- result << ";WKST=#{@wkst}" if @wkst
78
- result.join
79
+ result << "WKST=#{wkst}" if wkst
80
+ result.join ';'
79
81
  end
80
82
 
81
83
  def parse_date_val(name, string)
@@ -122,11 +124,11 @@ module Icalendar
122
124
  # TODO: Incomplete
123
125
  def occurrences_of_event_starting(event, datetime)
124
126
  initial_start = event.dtstart
125
- (0...@count).map {|day_offset|
126
- occurrence = event.clone
127
- occurrence.dtstart = initial_start + day_offset
128
- occurrence.clone
129
- }
127
+ (0...count).map do |day_offset|
128
+ occurrence = event.clone
129
+ occurrence.dtstart = initial_start + day_offset
130
+ occurrence.clone
131
+ end
130
132
  end
131
133
  end
132
134
 
@@ -19,7 +19,7 @@ DESCRIPTION:desc
19
19
  DTSTAMP:20060720T174052
20
20
  DTSTART:20060720
21
21
  EXDATE:20121012T170000Z,20121102T170000Z
22
- GEO:46.01\\;8.57
22
+ GEO:46.01;8.57
23
23
  LAST-MODIFIED:19960817T133000
24
24
  ORGANIZER:mailto:joe@example.com?subject=Ruby
25
25
  RRULE:FREQ=WEEKLY;UNTIL=20130220T180000Z;BYDAY=FR
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icalendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ahearn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2013-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyforge
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '3.10'
33
+ version: '4.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '3.10'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: newgem
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '3.5'
61
+ version: '3.6'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '3.5'
68
+ version: '3.6'
69
69
  description: "This is a Ruby library for dealing with iCalendar files. Rather than\nexplaining
70
70
  myself, here is the introduction from RFC-2445, which\ndefines the format:\n\nThe
71
71
  use of calendaring and scheduling has grown considerably in the\nlast decade. Enterprise