microformats 4.0.6 → 4.0.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 +4 -4
- data/README.md +2 -2
- data/lib/microformats/time_property_parser.rb +52 -30
- data/lib/microformats/version.rb +1 -1
- data/spec/support/lib/edge_cases/vcp-dates.html +13 -0
- data/spec/support/lib/edge_cases/vcp-dates.js +30 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f29e94e3eee963e0c2fc2beb186bbe65573590ae
|
4
|
+
data.tar.gz: 3197d92343b82c60f8f99daeebbaaf77d20a6763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0be09ac2f32fe2c1a5ae72c49c92aacf3de6f4c4a2ca62cadbca0d80aec86733cb8020836a873aad7020981ff7628a6884a0b671a63732e83caec71bec31167
|
7
|
+
data.tar.gz: dd565474811b712d5c15e792ee47be67dd3006cb8712e7595367ece6910daae09da33fa0af711ea76cb2275c60057d19f6cc3c616569be62ad20b74c9ef1d38c
|
data/README.md
CHANGED
@@ -6,6 +6,7 @@ module Microformats
|
|
6
6
|
@duration_value = nil
|
7
7
|
@date_value = nil
|
8
8
|
@time_value = nil
|
9
|
+
@tz_value = nil
|
9
10
|
|
10
11
|
@property_type = element_type
|
11
12
|
|
@@ -14,7 +15,7 @@ module Microformats
|
|
14
15
|
|
15
16
|
parse_value_class_pattern(element)
|
16
17
|
|
17
|
-
if @duration_value.nil? and @time_value.nil? and @date_value.nil?
|
18
|
+
if @duration_value.nil? and @time_value.nil? and @date_value.nil? and @tz_value.nil?
|
18
19
|
|
19
20
|
value = nil
|
20
21
|
if ['time', 'ins', 'del'].include? element.name and not element.attribute('datetime').nil?
|
@@ -31,16 +32,17 @@ module Microformats
|
|
31
32
|
|
32
33
|
end
|
33
34
|
|
34
|
-
if not
|
35
|
+
if not @duration_value.nil?
|
35
36
|
@duration_value
|
36
|
-
elsif not @time_value.nil? and not @date_value.nil?
|
37
|
-
@date_value + ' ' + @time_value
|
38
|
-
elsif not @time_value.nil?
|
39
|
-
@time_value
|
40
|
-
elsif not @date_value.nil?
|
41
|
-
@date_value
|
42
37
|
else
|
43
|
-
nil
|
38
|
+
result = nil
|
39
|
+
result = result.to_s + @date_value unless @date_value.nil?
|
40
|
+
unless @time_value.nil?
|
41
|
+
result = result.to_s + ' ' unless result.nil?
|
42
|
+
result = result.to_s + @time_value
|
43
|
+
end
|
44
|
+
result = result.to_s + @tz_value unless @tz_value.nil?
|
45
|
+
result
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -50,7 +52,7 @@ module Microformats
|
|
50
52
|
|
51
53
|
def parse_element(element)
|
52
54
|
|
53
|
-
if @duration_value.nil? or (@time_value.nil? and @date_value.nil?)
|
55
|
+
if @duration_value.nil? or (@time_value.nil? and @date_value.nil? and @tz_value.nil?)
|
54
56
|
if value_title_classes(element).length >= 1
|
55
57
|
value = element.attribute('title').value.strip
|
56
58
|
elsif value_classes(element).length >= 1
|
@@ -84,31 +86,39 @@ module Microformats
|
|
84
86
|
#TODO this still allows a lot of non correct values such as 39th day of the month, etc
|
85
87
|
begin
|
86
88
|
case data.strip
|
87
|
-
when /^
|
88
|
-
@
|
89
|
-
|
90
|
-
when /^(\d
|
89
|
+
when /^P\d*W$/
|
90
|
+
@duration_value = data if @duration_value.nil?
|
91
|
+
|
92
|
+
when /^P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?$/
|
93
|
+
@duration_value = data if @duration_value.nil?
|
94
|
+
|
95
|
+
when /^(\d{4}-[01]\d-[0-3]\d)[tT ]([0-2]\d:[0-5]\d(:[0-5]\d)?)?([zZ]|[-+][01]?\d:?[0-5]\d)?$/
|
91
96
|
@date_value = $1 if @date_value.nil?
|
92
97
|
@time_value = $2 if @time_value.nil?
|
93
|
-
|
98
|
+
@tz_value = $4.gsub(/z/, 'Z') if @tz_value.nil?
|
99
|
+
|
100
|
+
when /^(\d{4}-[01]\d-[0-3]\d)[tT ]([0-2]\d:[0-5]\d(:[0-5]\d)?)( ?[-+]\d\d:?(\d\d)?)$/
|
94
101
|
@date_value = $1 if @date_value.nil?
|
102
|
+
@time_value = $2 if @time_value.nil?
|
95
103
|
if normalize
|
96
|
-
@
|
104
|
+
@tz_value = $4.gsub(/z/, 'Z').gsub(/:/,'') if @tz_value.nil?
|
97
105
|
else
|
98
|
-
@
|
106
|
+
@tz_value = $4.gsub(/z/, 'Z') if @tz_value.nil?
|
99
107
|
end
|
100
|
-
|
108
|
+
|
109
|
+
when /^(\d{4}-[0-3]\d\d)[tT ]([0-2]\d:[0-5]\d(:[0-5]\d)?)?([zZ]|[-+][01]?\d:?[0-5]\d)?$/
|
101
110
|
@date_value = $1 if @date_value.nil?
|
111
|
+
@time_value = $2 if @time_value.nil?
|
112
|
+
@tz_value = $4.gsub(/z/, 'Z') if @tz_value.nil?
|
113
|
+
|
114
|
+
when /^(\d{4}-[0-3]\d\d)[tT ]([0-2]\d:[0-5]\d(:[0-5]\d)?)( ?[-+]\d\d:?(\d\d)?)$/
|
115
|
+
@date_value = $1 if @date_value.nil?
|
116
|
+
@time_value = $2 if @time_value.nil?
|
102
117
|
if normalize
|
103
|
-
@
|
118
|
+
@tz_value = $4.gsub(/z/, 'Z').gsub(/:/,'') if @tz_value.nil?
|
104
119
|
else
|
105
|
-
@
|
120
|
+
@tz_value = $4.gsub(/z/, 'Z') if @tz_value.nil?
|
106
121
|
end
|
107
|
-
when /^P\d*W$/
|
108
|
-
@duration_value = data if @duration_value.nil?
|
109
|
-
|
110
|
-
when /^P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?$/
|
111
|
-
@duration_value = data if @duration_value.nil?
|
112
122
|
|
113
123
|
when /^(\d{4})-([01]?\d)-([0-3]?\d)$/
|
114
124
|
@date_value = DateTime.new($1.to_i, $2.to_i, $3.to_i).strftime('%F') if @date_value.nil?
|
@@ -119,22 +129,34 @@ module Microformats
|
|
119
129
|
when /^(\d{4})-([01]?\d)$/
|
120
130
|
@date_value = data if @date_value.nil?
|
121
131
|
|
122
|
-
when /^
|
132
|
+
when /^([zZ]|[-+][01]?\d:?[0-5]\d)$/
|
123
133
|
if normalize
|
124
|
-
@
|
134
|
+
@tz_value = $1.gsub(/z/, 'Z').gsub(/:/,'') if @tz_value.nil?
|
125
135
|
else
|
126
|
-
@
|
136
|
+
@tz_value = $1.gsub(/z/, 'Z') if @tz_value.nil?
|
137
|
+
end
|
138
|
+
|
139
|
+
when /^([0-2]\d:[0-5]\d(:[0-5]\d)?)([zZ]|[-+][01]\d:?\d\d)?$/
|
140
|
+
@time_value = $1 if @time_value.nil?
|
141
|
+
if normalize
|
142
|
+
@tz_value = $3.gsub(/z/, 'Z').gsub(/:/,'') if @tz_value.nil?
|
143
|
+
else
|
144
|
+
@tz_value = $3.gsub(/z/, 'Z') if @tz_value.nil?
|
127
145
|
end
|
128
146
|
|
129
147
|
when /^[0-2]\d:[0-5]\d[zZ]?$/
|
130
148
|
@time_value = Time.parse(data).strftime('%H:%M') if @time_value.nil?
|
131
|
-
|
149
|
+
@tz_value = 'Z'
|
150
|
+
|
151
|
+
when /^([0-2]\d:[0-5]\d:[0-5]\d)([-+][01]\d:?[0-5]\d)$/
|
132
152
|
Time.parse(data).strftime('%T') #to make sure this time doesn't throw an error
|
133
153
|
@time_value = $1 if @time_value.nil?
|
154
|
+
@tz_value = $2 if @tz_value.nil?
|
134
155
|
|
135
|
-
when /^([0-2][0-0]:[0-5]\d[-+][01]\d:?[0-5]\d)$/
|
156
|
+
when /^([0-2][0-0]:[0-5]\d)([-+][01]\d:?[0-5]\d)$/
|
136
157
|
Time.parse(data).strftime('%H:%M') #to make sure this time doesn't throw an error
|
137
158
|
@time_value = $1 if @time_value.nil?
|
159
|
+
@tz_value = $2 if @tz_value.nil?
|
138
160
|
|
139
161
|
when /^([01]?\d):?([0-5]\d)?p\.?m\.?$/i
|
140
162
|
@time_value = ($1.to_i + 12).to_s + ':' + $2.to_s.rjust(2,'0') if @time_value.nil?
|
data/lib/microformats/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<base href="http://example.org/">
|
4
|
+
<body>
|
5
|
+
<div class="h-event">
|
6
|
+
<span class="e-summary">HomebrewWebsiteClub Berlin</span> will be next on
|
7
|
+
<span class="dt-start">
|
8
|
+
<span class="value">2017-05-31</span>, from
|
9
|
+
<span class="value">19:00</span> (UTC<span class="value">+02:00</span>)
|
10
|
+
</span> to <span class="dt-end">21:00</span>.
|
11
|
+
</div>
|
12
|
+
</body>
|
13
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"items": [
|
3
|
+
{
|
4
|
+
"type": [
|
5
|
+
"h-event"
|
6
|
+
],
|
7
|
+
"properties": {
|
8
|
+
"summary": [
|
9
|
+
{
|
10
|
+
"value": "HomebrewWebsiteClub Berlin",
|
11
|
+
"html": "HomebrewWebsiteClub Berlin"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"start": [
|
15
|
+
"2017-05-31 19:00+0200"
|
16
|
+
],
|
17
|
+
"end": [
|
18
|
+
"2017-05-31 21:00"
|
19
|
+
],
|
20
|
+
"name": [
|
21
|
+
"HomebrewWebsiteClub Berlin will be next on \n \n 2017-05-31, from\n 19:00 (UTC+02:00)\n to 21:00."
|
22
|
+
]
|
23
|
+
}
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"rels": {
|
27
|
+
},
|
28
|
+
"rel-urls": {
|
29
|
+
}
|
30
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microformats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Becker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-06-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -191,6 +191,8 @@ files:
|
|
191
191
|
- spec/support/lib/edge_cases/blank_value.js
|
192
192
|
- spec/support/lib/edge_cases/relative.html
|
193
193
|
- spec/support/lib/edge_cases/relative.js
|
194
|
+
- spec/support/lib/edge_cases/vcp-dates.html
|
195
|
+
- spec/support/lib/edge_cases/vcp-dates.js
|
194
196
|
- spec/support/lib/microformats/blank_href.html
|
195
197
|
- spec/support/lib/microformats/blank_href.js
|
196
198
|
- spec/support/lib/microformats/implied_property/name-fail.html
|
@@ -553,6 +555,8 @@ test_files:
|
|
553
555
|
- spec/support/lib/edge_cases/blank_value.js
|
554
556
|
- spec/support/lib/edge_cases/relative.html
|
555
557
|
- spec/support/lib/edge_cases/relative.js
|
558
|
+
- spec/support/lib/edge_cases/vcp-dates.html
|
559
|
+
- spec/support/lib/edge_cases/vcp-dates.js
|
556
560
|
- spec/support/lib/microformats/blank_href.html
|
557
561
|
- spec/support/lib/microformats/blank_href.js
|
558
562
|
- spec/support/lib/microformats/implied_property/name-fail.html
|