vobject 1.0.2 → 1.1.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: 9c54d59511de33be6814b5ce91402fd8a02610348d15834d3a91627192d97d21
4
- data.tar.gz: 97c5e8257ec8497f3bec04a79e1071c1cd6eb90b2752ed011067f585596a9656
3
+ metadata.gz: 4225cf5502ffcc41e7f940a822d75f04d480cf4453987116b2214a008d6fdba6
4
+ data.tar.gz: 894dbf2973bf0b0f532cdcd13b7c88198642298bff87c0750e71007c7ba9c770
5
5
  SHA512:
6
- metadata.gz: 4b441314c4cf98b28c0d44d5ab8d9d2ea0c18f7bf7781ae69671b8e18f40ea72a100c48c32dc426001c494779cd06d6c504aa6ee27547018cbb33a6775d4fb06
7
- data.tar.gz: 0b980732360e3a10ce83e9877fae5df1c91b4f601d0969b5cc9cdc86339add88405229b077d64c02948b2c12d45e59ead44225cc0fa815371def2bd4bd21f4a6
6
+ metadata.gz: 847fc89ba5243445c5df68cbace4bca077d1a501efc259cff5072e51edcf886b579264d5a608e8414a06f7466ae81f1cb72e13c1fab9abed4be382448279da6c
7
+ data.tar.gz: 16d2a911fdb256ca5b5e41be778cdbff220b1130a0d787ec60153ca9779d1aed904b2a96d1b315617fd6f3e9c46771c4351c0470d5e2727b3d8e786491221c41
@@ -1,6 +1,6 @@
1
1
  == Ruby vObject parser
2
2
 
3
- image:https://img.shields.io/gem/v/ruby-vobject.svg["Gem Version", link="https://rubygems.org/gems/vobject"]
3
+ image:https://img.shields.io/gem/v/vobject.svg["Gem Version", link="https://rubygems.org/gems/vobject"]
4
4
  image:https://github.com/riboseinc/ruby-vobject/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/riboseinc/ruby-vobject/actions?workflow=macos"]
5
5
  image:https://github.com/riboseinc/ruby-vobject/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/riboseinc/ruby-vobject/actions?workflow=ubuntu"]
6
6
  image:https://github.com/riboseinc/ruby-vobject/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/riboseinc/ruby-vobject/actions?workflow=windows"]
data/lib/c.rb CHANGED
@@ -9,18 +9,18 @@ module C
9
9
  BOOLEAN = /TRUE/i.r.map { true } | /FALSE/i.r.map { false }
10
10
  IANATOKEN = /[a-zA-Z\d\-]+/.r
11
11
  vendorid_vcal = /[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]/.r
12
- XNAME_VCAL = seq(/[xX]-/, vendorid_vcal, "-", IANATOKEN).map(&:join)
12
+ XNAME_VCAL = seq(/[xX]-/, vendorid_vcal, "-", IANATOKEN).map {|x, _| x.join }
13
13
  vendorid_vcard = /[a-zA-Z0-9]+/.r # different from iCal
14
- XNAME_VCARD = seq(/[xX]-/, vendorid_vcard, "-", IANATOKEN).map(&:join)
14
+ XNAME_VCARD = seq(/[xX]-/, vendorid_vcard, "-", IANATOKEN).map {|x, _| x.join }
15
15
  TEXT = /([ \t\u0021\u0023-\u002b\u002d-\u0039\u003c-\u005b\u005d-\u007e\u0080-\u3ffff:"]|\\[nN;,\\])*/.r
16
16
  TEXT3 = /([ \t\u0021\u0023-\u002b\u002d-\u0039\u003c-\u005b\u005d-\u007e\u0080-\u3ffff:"]|\\[nN;,\\]?)*/.r
17
17
  TEXT4 = /([ \t\u0021\u0023-\u002b\u002d-\u005b\u005d-\u007e\u0080-\u3ffff:"]|\\[nN,\\])*/.r
18
18
  COMPONENT4 = /([ \t\u0021\u0023-\u002b\u002d-\u003a\u003c-\u005b\u005d-\u007e\u0080-\u3ffff:"]|\\[nN,;\\])*/.r
19
- DATE = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |yy, mm, dd|
19
+ DATE = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
20
20
  Vobject::Vcalendar::PropertyValue::Date.new Time.utc(yy, mm, dd)
21
21
  end
22
22
  DATE_TIME = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r << "T".r,
23
- /[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r, /Z/i.r._?) do |yy, mm, dd, h, m, s, z|
23
+ /[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r, /Z/i.r._?) do |(yy, mm, dd, h, m, s, z)|
24
24
  if z.empty?
25
25
  #Vobject::Vcalendar::PropertyValue::DateTimeLocal.new(time: Time.local(yy, mm, dd, h, m, s), zone: "")
26
26
  Vobject::Vcalendar::PropertyValue::DateTimeLocal.new(year: yy, month: mm, day: dd, hour: h, min: m, sec: s, zone: "")
@@ -30,11 +30,11 @@ module C
30
30
  end
31
31
  end
32
32
  DATE_TIME_UTC = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r << "T".r,
33
- /[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r, /Z/i.r._?) do |yy, mm, dd, h, m, s, _z|
33
+ /[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r, /Z/i.r._?) do |(yy, mm, dd, h, m, s, _z)|
34
34
  #Vobject::Vcalendar::PropertyValue::DateTimeUTC.new(time: Time.utc(yy, mm, dd, h, m, s), zone: "Z")
35
35
  Vobject::Vcalendar::PropertyValue::DateTimeUTC.new(year: yy, month: mm, day: dd, hour: h, min: m, sec: s, zone: "Z")
36
36
  end
37
- TIME = seq(/[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r, /Z/i.r._?) do |h, m, s, z|
37
+ TIME = seq(/[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r, /Z/i.r._?) do |(h, m, s, z)|
38
38
  hash = { hour: h, min: m, sec: s }
39
39
  hash[:utc] = not(z.empty?)
40
40
  hash
@@ -69,27 +69,27 @@ module C
69
69
  beginend = /BEGIN/i.r | /END/i.r
70
70
  NAME_VCAL = C::XNAME_VCAL | seq("".r ^ beginend, C::IANATOKEN)[1]
71
71
  NAME_VCARD = C::XNAME_VCARD | seq("".r ^ beginend, C::IANATOKEN)[1]
72
- durday = seq(/[0-9]+/.r, "D") { |d, _| { days: d.to_i } }
73
- dursecond = seq(/[0-9]+/.r, "S") { |d, _| { seconds: d.to_i } }
74
- durminute = seq(/[0-9]+/.r, "M", dursecond._?) do |d, _, s|
72
+ durday = seq(/[0-9]+/.r, "D") { |(d, _)| { days: d.to_i } }
73
+ dursecond = seq(/[0-9]+/.r, "S") { |(d, _)| { seconds: d.to_i } }
74
+ durminute = seq(/[0-9]+/.r, "M", dursecond._?) do |(d, _, s)|
75
75
  hash = { minutes: d.to_i }
76
76
  hash = hash.merge s[0] unless s.empty?
77
77
  hash
78
78
  end
79
- durhour = seq(/[0-9]+/.r, "H", durminute._?) do |d, _, m|
79
+ durhour = seq(/[0-9]+/.r, "H", durminute._?) do |(d, _, m)|
80
80
  hash = { hours: d.to_i }
81
81
  hash = hash.merge m[0] unless m.empty?
82
82
  hash
83
83
  end
84
- durweek = seq(/[0-9]+/.r, "W") { |d, _| { weeks: d.to_i } }
84
+ durweek = seq(/[0-9]+/.r, "W") { |(d, _)| { weeks: d.to_i } }
85
85
  durtime1 = durhour | durminute | dursecond
86
- durtime = seq("T", durtime1) { |_, d| d }
87
- durdate = seq(durday, durtime._?) do |d, t|
86
+ durtime = seq("T", durtime1) { |(_, d)| d }
87
+ durdate = seq(durday, durtime._?) do |(d, t)|
88
88
  d = d.merge t[0] unless t.empty?
89
89
  d
90
90
  end
91
91
  duration1 = durdate | durtime | durweek
92
- DURATION = seq(SIGN._?, "P", duration1) do |s, _, d|
92
+ DURATION = seq(SIGN._?, "P", duration1) do |(s, _, d)|
93
93
  d[:sign] = s[0] unless s.empty?
94
94
  d
95
95
  end
@@ -105,11 +105,11 @@ module C
105
105
 
106
106
  QUOTEDSTRING_VCAL = seq(/"/.r >> q_safe_char_vcal.star <<
107
107
  /"/.r) { |q| q.join("") }
108
- PTEXT_VCAL = safe_char_vcal.star.map(&:join)
108
+ PTEXT_VCAL = safe_char_vcal.star.map {|x, _| x.join }
109
109
  QUOTEDSTRING_VCARD = seq(/"/.r >> q_safe_char_vcard.star <<
110
110
  /"/.r) { |q| q.join("") }
111
- PTEXT_VCARD = safe_char_vcard.star.map(&:join)
112
- VALUE = value_char.star.map(&:join)
111
+ PTEXT_VCARD = safe_char_vcard.star.map {|x, _| x.join }
112
+ VALUE = value_char.star.map {|x, _| x.join }
113
113
 
114
114
  rfc5646irregular = /en-GB-oed/i.r | /i-ami/i.r | /i-bnn/i.r | /i-default/i.r | /i-enochian/i.r |
115
115
  /i-hak/i.r | /i-klingon/i.r | /i-lux/i.r | /i-mingo/i.r |
@@ -129,7 +129,7 @@ module C
129
129
  rfc5646extlang = seq(/[A-Za-z]{3}/.r, /[A-Za-z]{3}/.r._?, /[A-Za-z]{3}/.r._?)
130
130
  rfc5646language = seq(/[A-Za-z]{2,3}/.r, rfc5646extlang._?) | /[A-Za-z]{4}/.r | /[A-Za-z]{5,8}/.r
131
131
  rfc5646langtag = seq(rfc5646language, rfc5646script._?, rfc5646region._?,
132
- rfc5646variant.star, rfc5646extension.star, rfc5646privateuse._?) do |a, b, c, d, e, f|
132
+ rfc5646variant.star, rfc5646extension.star, rfc5646privateuse._?) do |(a, b, c, d, e, f)|
133
133
  [a, b, c, d, e, f].flatten.join("")
134
134
  end
135
135
  RFC5646LANGVALUE = rfc5646langtag | rfc5646privateuse | rfc5646grandfathered
@@ -163,7 +163,7 @@ module C
163
163
  /SpringGreen/i.r | /SteelBlue/i.r | /Tan/i.r | /Teal/i.r | /Thistle/i.r | /Tomato/i.r |
164
164
  /Turquoise/i.r | /Violet/i.r | /Wheat/i.r | /White/i.r | /WhiteSmoke/i.r | /Yellow/i.r | /YellowGreen/i.r
165
165
 
166
- UTC_OFFSET = seq(C::SIGN, /[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r._?) do |s, h, m, z|
166
+ UTC_OFFSET = seq(C::SIGN, /[0-9]{2}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r._?) do |(s, h, m, z)|
167
167
  h = { sign: s, hour: h, min: m }
168
168
  h[:sec] = z[0] unless z.empty?
169
169
  h
@@ -76,18 +76,18 @@ module Vobject::Vcalendar
76
76
  rangevalue = /THISANDFUTURE/i.r
77
77
  relatedvalue = /START/i.r | /END/i.r
78
78
  reltypevalue = /PARENT/i.r | /CHILD/i.r | /SIBLING/i.r | C::XNAME_VCAL | C::IANATOKEN
79
- tzidvalue = seq("/".r._?, C::PTEXT_VCAL).map { |_, val| val }
79
+ tzidvalue = seq("/".r._?, C::PTEXT_VCAL).map { |(_, val)| val }
80
80
  valuetype = /BINARY/i.r | /BOOLEAN/i.r | /CAL-ADDRESS/i.r | /DATE-TIME/i.r | /DATE/i.r |
81
81
  /DURATION/i.r | /FLOAT/i.r | /INTEGER/i.r | /PERIOD/i.r | /RECUR/i.r | /TEXT/i.r |
82
82
  /TIME/i.r | /URI/i.r | /UTC-OFFSET/i.r | C::XNAME_VCAL | C::IANATOKEN
83
83
  rolevalue = /CHAIR/i.r | /REQ-PARTICIPANT/i.r | /OPT-PARTICIPANT/i.r | /NON-PARTICIPANT/i.r |
84
84
  C::XNAME_VCAL | C::IANATOKEN
85
- pvalue_list = (seq(paramvalue << ",".r, lazy { pvalue_list }) & /[;:]/.r).map do |e, list|
85
+ pvalue_list = (seq(paramvalue << ",".r, lazy { pvalue_list }) & /[;:]/.r).map do |(e, list)|
86
86
  [e.sub(Regexp.new("^\"(.+)\"$"), '\1').gsub(/\\n/, "\n"), list].flatten
87
87
  end | (paramvalue & /[;:]/.r).map do |e|
88
88
  [e.sub(Regexp.new("^\"(.+)\"$"), '\1').gsub(/\\n/, "\n")]
89
89
  end
90
- quoted_string_list = (seq(C::QUOTEDSTRING_VCAL << ",".r, lazy { quoted_string_list }) & /[;:]/.r).map do |e, list|
90
+ quoted_string_list = (seq(C::QUOTEDSTRING_VCAL << ",".r, lazy { quoted_string_list }) & /[;:]/.r).map do |(e, list)|
91
91
  [self.class.rfc6868decode(e.sub(Regexp.new("^\"(.+)\"$"), "\1").gsub(/\\n/, "\n")), list].flatten
92
92
  end | (C::QUOTEDSTRING_VCAL & /[;:]/.r).map do |e|
93
93
  [self.class.rfc6868decode(e.sub(Regexp.new("^\"(.+)\"$"), "\1").gsub(/\\n/, "\n"))]
@@ -96,79 +96,79 @@ module Vobject::Vcalendar
96
96
  rfc4288regname = /[A-Za-z0-9!#$&.+^+-]{1,127}/.r
97
97
  rfc4288typename = rfc4288regname
98
98
  rfc4288subtypename = rfc4288regname
99
- fmttypevalue = seq(rfc4288typename, "/", rfc4288subtypename).map(&:join)
99
+ fmttypevalue = seq(rfc4288typename, "/", rfc4288subtypename).map {|x, _| x.join }
100
100
 
101
101
  # RFC 7986
102
102
  displayval = /BADGE/i.r | /GRAPHIC/i.r | /FULLSIZE/i.r | /THUMBNAIL/i.r | C::XNAME_VCAL | C::IANATOKEN
103
- displayvallist = seq(displayval << ",".r, lazy { displayvallist }) do |d, l|
103
+ displayvallist = seq(displayval << ",".r, lazy { displayvallist }) do |(d, l)|
104
104
  [d, l].flatten
105
105
  end | displayval.map { |d| [d] }
106
106
  featureval = /AUDIO/i.r | /CHAT/i.r | /FEED/i.r | /MODERATOR/i.r | /PHONE/i.r | /SCREEN/i.r |
107
107
  /VIDEO/i.r | C::XNAME_VCAL | C::IANATOKEN
108
- featurevallist = seq(featureval << ",".r, lazy { featurevallist }) do |d, l|
108
+ featurevallist = seq(featureval << ",".r, lazy { featurevallist }) do |(d, l)|
109
109
  [d, l].flatten
110
110
  end | featureval.map { |d| [d] }
111
111
 
112
- param = seq(/ALTREP/i.r, "=", quotedparamvalue) do |name, _, val|
112
+ param = seq(/ALTREP/i.r, "=", quotedparamvalue) do |(name, _, val)|
113
113
  { name.upcase.tr("-", "_").to_sym => val }
114
- end | seq(/CN/i.r, "=", paramvalue) do |name, _, val|
114
+ end | seq(/CN/i.r, "=", paramvalue) do |(name, _, val)|
115
115
  { name.upcase.tr("-", "_").to_sym => val }
116
- end | seq(/CUTYPE/i.r, "=", cutypevalue) do |name, _, val|
116
+ end | seq(/CUTYPE/i.r, "=", cutypevalue) do |(name, _, val)|
117
117
  { name.upcase.tr("-", "_").to_sym => val.upcase }
118
- end | seq(/DELEGATED-FROM/i.r, "=", quoted_string_list) do |name, _, val|
118
+ end | seq(/DELEGATED-FROM/i.r, "=", quoted_string_list) do |(name, _, val)|
119
119
  val = val[0] if val.length == 1
120
120
  { name.upcase.tr("-", "_").to_sym => val }
121
- end | seq(/DELEGATED-TO/i.r, "=", quoted_string_list) do |name, _, val|
121
+ end | seq(/DELEGATED-TO/i.r, "=", quoted_string_list) do |(name, _, val)|
122
122
  val = val[0] if val.length == 1
123
123
  { name.upcase.tr("-", "_").to_sym => val }
124
- end | seq(/DIR/i.r, "=", quotedparamvalue) do |name, _, val|
124
+ end | seq(/DIR/i.r, "=", quotedparamvalue) do |(name, _, val)|
125
125
  { name.upcase.tr("-", "_").to_sym => val }
126
- end | seq(/ENCODING/i.r, "=", encodingvalue) do |name, _, val|
126
+ end | seq(/ENCODING/i.r, "=", encodingvalue) do |(name, _, val)|
127
127
  { name.upcase.tr("-", "_").to_sym => val.upcase }
128
- end | seq(/FMTTYPE/i.r, "=", fmttypevalue) do |name, _, val|
128
+ end | seq(/FMTTYPE/i.r, "=", fmttypevalue) do |(name, _, val)|
129
129
  { name.upcase.tr("-", "_").to_sym => val.downcase }
130
- end | seq(/FBTYPE/i.r, "=", fbtypevalue) do |name, _, val|
130
+ end | seq(/FBTYPE/i.r, "=", fbtypevalue) do |(name, _, val)|
131
131
  { name.upcase.tr("-", "_").to_sym => val.upcase }
132
- end | seq(/LANGUAGE/i.r, "=", C::RFC5646LANGVALUE) do |name, _, val|
132
+ end | seq(/LANGUAGE/i.r, "=", C::RFC5646LANGVALUE) do |(name, _, val)|
133
133
  { name.upcase.tr("-", "_").to_sym => val.upcase }
134
- end | seq(/MEMBER/i.r, "=", quoted_string_list) do |name, _, val|
134
+ end | seq(/MEMBER/i.r, "=", quoted_string_list) do |(name, _, val)|
135
135
  val = val[0] if val.length == 1
136
136
  { name.upcase.tr("-", "_").to_sym => val }
137
- end | seq(/PARTSTAT/i.r, "=", partstatvalue) do |name, _, val|
137
+ end | seq(/PARTSTAT/i.r, "=", partstatvalue) do |(name, _, val)|
138
138
  { name.upcase.tr("-", "_").to_sym => val.upcase }
139
- end | seq(/RANGE/i.r, "=", rangevalue) do |name, _, val|
139
+ end | seq(/RANGE/i.r, "=", rangevalue) do |(name, _, val)|
140
140
  { name.upcase.tr("-", "_").to_sym => val.upcase }
141
- end | seq(/RELATED/i.r, "=", relatedvalue) do |name, _, val|
141
+ end | seq(/RELATED/i.r, "=", relatedvalue) do |(name, _, val)|
142
142
  { name.upcase.tr("-", "_").to_sym => val.upcase }
143
- end | seq(/RELTYPE/i.r, "=", reltypevalue) do |name, _, val|
143
+ end | seq(/RELTYPE/i.r, "=", reltypevalue) do |(name, _, val)|
144
144
  { name.upcase.tr("-", "_").to_sym => val.upcase }
145
- end | seq(/ROLE/i.r, "=", rolevalue) do |name, _, val|
145
+ end | seq(/ROLE/i.r, "=", rolevalue) do |(name, _, val)|
146
146
  { name.upcase.tr("-", "_").to_sym => val.upcase }
147
- end | seq(/RSVP/i.r, "=", C::BOOLEAN) do |name, _, val|
147
+ end | seq(/RSVP/i.r, "=", C::BOOLEAN) do |(name, _, val)|
148
148
  { name.upcase.tr("-", "_").to_sym => val }
149
- end | seq(/SENT-BY/i.r, "=", quotedparamvalue) do |name, _, val|
149
+ end | seq(/SENT-BY/i.r, "=", quotedparamvalue) do |(name, _, val)|
150
150
  { name.upcase.tr("-", "_").to_sym => val }
151
- end | seq(/TZID/i.r, "=", tzidvalue) do |name, _, val|
151
+ end | seq(/TZID/i.r, "=", tzidvalue) do |(name, _, val)|
152
152
  { name.upcase.tr("-", "_").to_sym => val }
153
- end | seq(/VALUE/i.r, "=", valuetype) do |name, _, val|
153
+ end | seq(/VALUE/i.r, "=", valuetype) do |(name, _, val)|
154
154
  { name.upcase.tr("-", "_").to_sym => val }
155
155
  # RFC 7986
156
- end | seq(/DISPLAY/i.r, "=", displayvallist) do |name, _, val|
156
+ end | seq(/DISPLAY/i.r, "=", displayvallist) do |(name, _, val)|
157
157
  { name.upcase.tr("-", "_").to_sym => val }
158
- end | seq(/FEATURE/i.r, "=", featurevallist) do |name, _, val|
158
+ end | seq(/FEATURE/i.r, "=", featurevallist) do |(name, _, val)|
159
159
  { name.upcase.tr("-", "_").to_sym => val }
160
- end | seq(/EMAIL/i.r, "=", paramvalue) do |name, _, val|
160
+ end | seq(/EMAIL/i.r, "=", paramvalue) do |(name, _, val)|
161
161
  { name.upcase.tr("-", "_").to_sym => val }
162
- end | seq(/LABEL/i.r, "=", paramvalue) do |name, _, val|
162
+ end | seq(/LABEL/i.r, "=", paramvalue) do |(name, _, val)|
163
163
  { name.upcase.tr("-", "_").to_sym => val }
164
- end | seq(otherparamname, "=", pvalue_list) do |name, _, val|
164
+ end | seq(otherparamname, "=", pvalue_list) do |(name, _, val)|
165
165
  val = val[0] if val.length == 1
166
166
  { name.upcase.tr("-", "_").to_sym => val }
167
- end | seq(paramname, "=", pvalue_list) do |name, _, val|
167
+ end | seq(paramname, "=", pvalue_list) do |(name, _, val)|
168
168
  parse_err("Violated format of parameter value #{name} = #{val}")
169
169
  end
170
170
 
171
- params = seq(";".r >> param & ";", lazy { params }) do |p, ps|
171
+ params = seq(";".r >> param & ";", lazy { params }) do |(p, ps)|
172
172
  p.merge(ps) do |key, old, new|
173
173
  if @cardinality1[:PARAM].include?(key)
174
174
  parse_err("Violated cardinality of parameter #{key}")
@@ -179,7 +179,7 @@ module Vobject::Vcalendar
179
179
  end | seq(";".r >> param).map { |e| e[0] }
180
180
 
181
181
  contentline = seq(linegroup._?, C::NAME_VCAL, params._? << ":".r,
182
- C::VALUE, /(\r|\n|\r\n)/) do |g, name, p, value, _|
182
+ C::VALUE, /(\r|\n|\r\n)/) do |(g, name, p, value, _)|
183
183
  key = name.upcase.tr("-", "_").to_sym
184
184
  hash = { key => { value: value } }
185
185
  hash[key][:group] = g[0] unless g.empty?
@@ -189,7 +189,7 @@ module Vobject::Vcalendar
189
189
  end
190
190
 
191
191
  props = ("".r & beginend).map { {} } |
192
- seq(contentline, lazy { props }) do |c, rest|
192
+ seq(contentline, lazy { props }) do |(c, rest)|
193
193
  k = c.keys[0]
194
194
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :GENERIC, c[k][:value], @ctx)
195
195
  errors << errors1
@@ -199,7 +199,7 @@ module Vobject::Vcalendar
199
199
  end
200
200
  end
201
201
  alarmprops = ("".r & beginend).map { {} } |
202
- seq(contentline, lazy { alarmprops }) do |c, rest|
202
+ seq(contentline, lazy { alarmprops }) do |(c, rest)|
203
203
  k = c.keys[0]
204
204
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :ALARM, c[k][:value], @ctx)
205
205
  errors << errors1
@@ -211,7 +211,7 @@ module Vobject::Vcalendar
211
211
  end
212
212
  end
213
213
  fbprops = ("".r & beginend).map { {} } |
214
- seq(contentline, lazy { fbprops }) do |c, rest|
214
+ seq(contentline, lazy { fbprops }) do |(c, rest)|
215
215
  k = c.keys[0]
216
216
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :FREEBUSY, c[k][:value], @ctx)
217
217
  errors << errors1
@@ -223,7 +223,7 @@ module Vobject::Vcalendar
223
223
  end
224
224
  end
225
225
  journalprops = ("".r & beginend).map { {} } |
226
- seq(contentline, lazy { journalprops }) do |c, rest|
226
+ seq(contentline, lazy { journalprops }) do |(c, rest)|
227
227
  k = c.keys[0]
228
228
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :JOURNAL, c[k][:value], @ctx)
229
229
  errors << errors1
@@ -235,7 +235,7 @@ module Vobject::Vcalendar
235
235
  end
236
236
  end
237
237
  tzprops = ("".r & beginend).map { {} } |
238
- seq(contentline, lazy { tzprops }) do |c, rest|
238
+ seq(contentline, lazy { tzprops }) do |(c, rest)|
239
239
  k = c.keys[0]
240
240
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :TZ, c[k][:value], @ctx)
241
241
  errors << errors1
@@ -246,24 +246,24 @@ module Vobject::Vcalendar
246
246
  [old, new].flatten
247
247
  end
248
248
  end
249
- standardc = seq(/BEGIN:STANDARD(\r|\n|\r\n)/i.r, tzprops, /END:STANDARD(\r|\n|\r\n)/i.r) do |_, e, _|
249
+ standardc = seq(/BEGIN:STANDARD(\r|\n|\r\n)/i.r, tzprops, /END:STANDARD(\r|\n|\r\n)/i.r) do |(_, e, _)|
250
250
  parse_err("Missing DTSTART property") unless e.has_key?(:DTSTART)
251
251
  parse_err("Missing TZOFFSETTO property") unless e.has_key?(:TZOFFSETTO)
252
252
  parse_err("Missing TZOFFSETFROM property") unless e.has_key?(:TZOFFSETFROM)
253
253
  { STANDARD: { component: [e] } }
254
254
  end
255
- daylightc = seq(/BEGIN:DAYLIGHT(\r|\n|\r\n)/i.r, tzprops, /END:DAYLIGHT(\r|\n|\r\n)/i.r) do |_, e, _|
255
+ daylightc = seq(/BEGIN:DAYLIGHT(\r|\n|\r\n)/i.r, tzprops, /END:DAYLIGHT(\r|\n|\r\n)/i.r) do |(_, e, _)|
256
256
  parse_err("Missing DTSTART property") unless e.has_key?(:DTSTART)
257
257
  parse_err("Missing TZOFFSETTO property") unless e.has_key?(:TZOFFSETTO)
258
258
  parse_err("Missing TZOFFSETFROM property") unless e.has_key?(:TZOFFSETFROM)
259
259
  { DAYLIGHT: { component: [e] } }
260
260
  end
261
261
  timezoneprops =
262
- seq(standardc, lazy { timezoneprops }) do |e, rest|
262
+ seq(standardc, lazy { timezoneprops }) do |(e, rest)|
263
263
  e.merge(rest) { |_, old, new| { component: [old[:component], new[:component]].flatten } }
264
- end | seq(daylightc, lazy { timezoneprops }) do |e, rest|
264
+ end | seq(daylightc, lazy { timezoneprops }) do |(e, rest)|
265
265
  e.merge(rest) { |_, old, new| { component: [old[:component], new[:component]].flatten } }
266
- end | seq(contentline, lazy { timezoneprops }) do |e, rest|
266
+ end | seq(contentline, lazy { timezoneprops }) do |(e, rest)|
267
267
  k = e.keys[0]
268
268
  e[k][:value], errors1 = Typegrammars.typematch(strict, k, e[k][:params], :TIMEZONE, e[k][:value], @ctx)
269
269
  errors << errors1
@@ -276,7 +276,7 @@ module Vobject::Vcalendar
276
276
  end |
277
277
  ("".r & beginend).map { {} }
278
278
  todoprops = ("".r & beginend).map { {} } |
279
- seq(contentline, lazy { todoprops }) do |c, rest|
279
+ seq(contentline, lazy { todoprops }) do |(c, rest)|
280
280
  k = c.keys[0]
281
281
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :TODO, c[k][:value], @ctx)
282
282
  errors << errors1
@@ -287,7 +287,7 @@ module Vobject::Vcalendar
287
287
  [old, new].flatten
288
288
  end
289
289
  end
290
- eventprops = seq(contentline, lazy { eventprops }) do |c, rest|
290
+ eventprops = seq(contentline, lazy { eventprops }) do |(c, rest)|
291
291
  k = c.keys[0]
292
292
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :EVENT, c[k][:value], @ctx)
293
293
  errors << errors1
@@ -299,7 +299,7 @@ module Vobject::Vcalendar
299
299
  end
300
300
  end |
301
301
  ("".r & beginend).map { {} }
302
- alarmc = seq(/BEGIN:VALARM(\r|\n|\r\n)/i.r, alarmprops, /END:VALARM(\r|\n|\r\n)/i.r) do |_, e, _|
302
+ alarmc = seq(/BEGIN:VALARM(\r|\n|\r\n)/i.r, alarmprops, /END:VALARM(\r|\n|\r\n)/i.r) do |(_, e, _)|
303
303
  parse_err("Missing ACTION property") unless e.has_key?(:ACTION)
304
304
  parse_err("Missing TRIGGER property") unless e.has_key?(:TRIGGER)
305
305
  if e.has_key?(:DURATION) && !e.has_key?(:REPEAT) || !e.has_key?(:DURATION) && e.has_key?(:REPEAT)
@@ -320,24 +320,24 @@ module Vobject::Vcalendar
320
320
  end
321
321
  { VALARM: { component: [e] } }
322
322
  end
323
- freebusyc = seq(/BEGIN:VFREEBUSY(\r|\n|\r\n)/i.r, fbprops, /END:VFREEBUSY(\r|\n|\r\n)/i.r) do |_, e, _|
323
+ freebusyc = seq(/BEGIN:VFREEBUSY(\r|\n|\r\n)/i.r, fbprops, /END:VFREEBUSY(\r|\n|\r\n)/i.r) do |(_, e, _)|
324
324
  parse_err("Missing DTSTAMP property") unless e.has_key?(:DTSTAMP)
325
325
  parse_err("Missing UID property") unless e.has_key?(:UID)
326
326
  parse_err("DTEND before DTSTART") if e.has_key?(:DTEND) && e.has_key?(:DTSTART) &&
327
327
  e[:DTEND][:value] < e[:DTSTART][:value]
328
328
  { VFREEBUSY: { component: [e] } }
329
329
  end
330
- journalc = seq(/BEGIN:VJOURNAL(\r|\n|\r\n)/i.r, journalprops, /END:VJOURNAL(\r|\n|\r\n)/i.r) do |_, e, _|
330
+ journalc = seq(/BEGIN:VJOURNAL(\r|\n|\r\n)/i.r, journalprops, /END:VJOURNAL(\r|\n|\r\n)/i.r) do |(_, e, _)|
331
331
  parse_err("Missing DTSTAMP property") unless e.has_key?(:DTSTAMP)
332
332
  parse_err("Missing UID property") unless e.has_key?(:UID)
333
333
  parse_err("Missing DTSTART property with RRULE property") if e.has_key?(:RRULE) && !e.has_key?(:DTSTART)
334
334
  { VJOURNAL: { component: [e] } }
335
335
  end
336
- timezonec = seq(/BEGIN:VTIMEZONE(\r|\n|\r\n)/i.r, timezoneprops, /END:VTIMEZONE(\r|\n|\r\n)/i.r) do |_, e, _|
336
+ timezonec = seq(/BEGIN:VTIMEZONE(\r|\n|\r\n)/i.r, timezoneprops, /END:VTIMEZONE(\r|\n|\r\n)/i.r) do |(_, e, _)|
337
337
  parse_err("Missing STANDARD || DAYLIGHT property") unless e.has_key?(:STANDARD) || e.has_key?(:DAYLIGHT)
338
338
  { VTIMEZONE: { component: [e] } }
339
339
  end
340
- todoc = seq(/BEGIN:VTODO(\r|\n|\r\n)/i.r, todoprops, alarmc.star, /END:VTODO(\r|\n|\r\n)/i.r) do |_, e, a, _|
340
+ todoc = seq(/BEGIN:VTODO(\r|\n|\r\n)/i.r, todoprops, alarmc.star, /END:VTODO(\r|\n|\r\n)/i.r) do |(_, e, a, _)|
341
341
  parse_err("Missing DTSTAMP property") unless e.has_key?(:DTSTAMP)
342
342
  parse_err("Missing UID property") unless e.has_key?(:UID)
343
343
  parse_err("Coocurring DUE && DURATION properties") if e.has_key?(:DUE) && e.has_key?(:DURATION)
@@ -354,7 +354,7 @@ module Vobject::Vcalendar
354
354
  end
355
355
  { VTODO: { component: [e] } }
356
356
  end
357
- eventc = seq(/BEGIN:VEVENT(\r|\n|\r\n)/i.r, eventprops, alarmc.star, /END:VEVENT(\r|\n|\r\n)/i.r) do |_, e, a, _|
357
+ eventc = seq(/BEGIN:VEVENT(\r|\n|\r\n)/i.r, eventprops, alarmc.star, /END:VEVENT(\r|\n|\r\n)/i.r) do |(_, e, a, _)|
358
358
  parse_err("Missing DTSTAMP property") unless e.has_key?(:DTSTAMP)
359
359
  parse_err("Missing UID property") unless e.has_key?(:UID)
360
360
  parse_err("Coocurring DTEND && DURATION properties") if e.has_key?(:DTEND) && e.has_key?(:DURATION)
@@ -368,20 +368,20 @@ module Vobject::Vcalendar
368
368
  end
369
369
  { VEVENT: { component: [e] } }
370
370
  end
371
- xcomp = seq(/BEGIN:/i.r, C::XNAME_VCAL, /(\r|\n|\r\n)/i.r, props, /END:/i.r, C::XNAME_VCAL, /(\r|\n|\r\n)/i.r) do |_, n, _, p, _, n1, _|
371
+ xcomp = seq(/BEGIN:/i.r, C::XNAME_VCAL, /(\r|\n|\r\n)/i.r, props, /END:/i.r, C::XNAME_VCAL, /(\r|\n|\r\n)/i.r) do |(_, n, _, p, _, n1, _)|
372
372
  n = n.upcase
373
373
  n1 = n1.upcase
374
374
  parse_err("Mismatch BEGIN:#{n}, END:#{n1}") if n != n1
375
375
  { n1.to_sym => { component: [p] } }
376
376
  end
377
- ianacomp = seq(/BEGIN:/i.r ^ C::ICALPROPNAMES, C::IANATOKEN, /(\r|\n|\r\n)/i.r, props, /END:/i.r ^ C::ICALPROPNAMES, C::IANATOKEN, /(\r|\n|\r\n)/i.r) do |_, n, _, p, _, n1, _|
377
+ ianacomp = seq(/BEGIN:/i.r ^ C::ICALPROPNAMES, C::IANATOKEN, /(\r|\n|\r\n)/i.r, props, /END:/i.r ^ C::ICALPROPNAMES, C::IANATOKEN, /(\r|\n|\r\n)/i.r) do |(_, n, _, p, _, n1, _)|
378
378
  n = n.upcase
379
379
  n1 = n1.upcase
380
380
  parse_err("Mismatch BEGIN:#{n}, END:#{n1}") if n != n1
381
381
  { n1.to_sym => { component: [p] } }
382
382
  end
383
383
  # RFC 7953
384
- availableprops = seq(contentline, lazy { availableprops }) do |c, rest|
384
+ availableprops = seq(contentline, lazy { availableprops }) do |(c, rest)|
385
385
  k = c.keys[0]
386
386
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :AVAILABLE, c[k][:value], @ctx)
387
387
  errors << errors1
@@ -392,14 +392,14 @@ module Vobject::Vcalendar
392
392
  [old, new].flatten
393
393
  end
394
394
  end | ("".r & beginend).map { {} }
395
- availablec = seq(/BEGIN:AVAILABLE(\r|\n|\r\n)/i.r, availableprops, /END:AVAILABLE(\r|\n|\r\n)/i.r) do |_, e, _|
395
+ availablec = seq(/BEGIN:AVAILABLE(\r|\n|\r\n)/i.r, availableprops, /END:AVAILABLE(\r|\n|\r\n)/i.r) do |(_, e, _)|
396
396
  # parse_err("Missing DTSTAMP property") unless e.has_key?(:DTSTAMP) # required in spec, but not in examples
397
397
  parse_err("Missing DTSTART property") unless e.has_key?(:DTSTART)
398
398
  parse_err("Missing UID property") unless e.has_key?(:UID)
399
399
  parse_err("Coocurring DTEND && DURATION properties") if e.has_key?(:DTEND) && e.has_key?(:DURATION)
400
400
  { AVAILABLE: { component: [e] } }
401
401
  end
402
- availabilityprops = seq(contentline, lazy { availabilityprops }) do |c, rest|
402
+ availabilityprops = seq(contentline, lazy { availabilityprops }) do |(c, rest)|
403
403
  k = c.keys[0]
404
404
  c[k][:value], errors1 = Typegrammars.typematch(strict, k, c[k][:params], :VAVAILABILITY, c[k][:value], @ctx)
405
405
  errors << errors1
@@ -410,7 +410,7 @@ module Vobject::Vcalendar
410
410
  [old, new].flatten
411
411
  end
412
412
  end | ("".r & beginend).map { {} }
413
- vavailabilityc = seq(/BEGIN:VAVAILABILITY(\r|\n|\r\n)/i.r, availabilityprops, availablec.star, /END:VAVAILABILITY(\r|\n|\r\n)/i.r) do |_, e, a, _|
413
+ vavailabilityc = seq(/BEGIN:VAVAILABILITY(\r|\n|\r\n)/i.r, availabilityprops, availablec.star, /END:VAVAILABILITY(\r|\n|\r\n)/i.r) do |(_, e, a, _)|
414
414
  parse_err("Missing DTSTAMP property") unless e.has_key?(:DTSTAMP)
415
415
  parse_err("Missing UID property") unless e.has_key?(:UID)
416
416
  parse_err("Coocurring DTEND && DURATION properties") if e.has_key?(:DTEND) && e.has_key?(:DURATION)
@@ -425,7 +425,7 @@ module Vobject::Vcalendar
425
425
  end
426
426
 
427
427
  component = eventc | todoc | journalc | freebusyc | timezonec | ianacomp | xcomp | vavailabilityc
428
- components = seq(component, lazy { components }) do |c, r|
428
+ components = seq(component, lazy { components }) do |(c, r)|
429
429
  c.merge(r) do |_key, old, new|
430
430
  { component: [old[:component], new[:component]].flatten }
431
431
  end
@@ -435,7 +435,7 @@ module Vobject::Vcalendar
435
435
  /UID/i.r | /LAST-MOD/i.r | /URL/i.r | /REFRESH/i.r | /SOURCE/i.r | /COLOR/i.r | # RFC 7986
436
436
  /NAME/i.r | /DESCRIPTION/i.r | /CATEGORIES/i.r | /IMAGE/i.r | # RFC 7986
437
437
  C::XNAME_VCAL | C::IANATOKEN
438
- calprop = seq(calpropname, params._? << ":".r, C::VALUE, /(\r|\n|\r\n)/) do |key, p, value, _|
438
+ calprop = seq(calpropname, params._? << ":".r, C::VALUE, /(\r|\n|\r\n)/) do |(key, p, value, _)|
439
439
  key = key.upcase.tr("-", "_").to_sym
440
440
  val, errors1 = Typegrammars.typematch(strict, key, p[0], :CALENDAR, value, @ctx)
441
441
  errors << errors1
@@ -446,7 +446,7 @@ module Vobject::Vcalendar
446
446
  # TODO not doing constraint that each description must be in a different language
447
447
  end
448
448
  calprops = ("".r & beginend).map { {} } |
449
- seq(calprop, lazy { calprops }) do |c, rest|
449
+ seq(calprop, lazy { calprops }) do |(c, rest)|
450
450
  c.merge(rest) do |key, old, new|
451
451
  if @cardinality1[:ICAL].include?(key.upcase)
452
452
  parse_err("Violated cardinality of property #{key}")
@@ -454,7 +454,7 @@ module Vobject::Vcalendar
454
454
  [old, new].flatten
455
455
  end
456
456
  end
457
- vobject = seq(/BEGIN:VCALENDAR(\r|\n|\r\n)/i.r, calprops, components, /END:VCALENDAR(\r|\n|\r\n)/i.r) do |_b, v, rest, _e|
457
+ vobject = seq(/BEGIN:VCALENDAR(\r|\n|\r\n)/i.r, calprops, components, /END:VCALENDAR(\r|\n|\r\n)/i.r) do |(_b, v, rest, _e)|
458
458
  parse_err("Missing PRODID attribute") unless v.has_key?(:PRODID)
459
459
  parse_err("Missing VERSION attribute") unless v.has_key?(:VERSION)
460
460
  rest.delete(:END)