ics_validator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +11 -2
- data/ics_validator.gemspec +1 -0
- data/lib/ics_validator/file_validator.rb +49 -0
- data/lib/ics_validator/snippet_validator.rb +48 -0
- data/lib/ics_validator/version.rb +1 -1
- data/lib/ics_validator.rb +10 -0
- data/spec/fixtures/icalendar/invalid.ics +1 -0
- data/spec/fixtures/icalendar/valid.ics +58 -0
- data/spec/ics_validator/file_validator_spec.rb +33 -0
- data/spec/ics_validator/snippet_validator_spec.rb +57 -0
- metadata +27 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9094e99d026a2ca1cc6bacb08196e71b77c12413
|
4
|
+
data.tar.gz: c323b4ff0934c548e092f8d03708ab85513a0e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e9ca885f5d02941cdf7e8cc37cd907fd5e81ad28e5a8c26a5b1115d034c388cdf0f26f1f8ed0200dbda261f46d4fc8e5522cb68e92da6028cafc754345253a
|
7
|
+
data.tar.gz: e83811376c87f8fcbeb66d9150d247e51ea43b5a0d21a4e726aac3f400fbf2a07d72e0c75122bcdc4a3cad93bc56d5f0d3dd22e6ef1cd4333ff7b8f03615d788
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# IcsValidator
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/mattgillooly/ics_validator.png?branch=master)](https://travis-ci.org/mattgillooly/ics_validator)
|
4
|
+
|
5
|
+
Validate iCalendar feeds by URL, using icalvalid.cloudapp.net
|
6
|
+
|
7
|
+
Used by [http://pvdtechevents.com](http://pvdtechevents.com) to validate its generated feed.
|
8
|
+
|
9
|
+
TODO: Support validating iCalendar snippets and files.
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
@@ -18,7 +24,10 @@ Or install it yourself as:
|
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
```ruby
|
28
|
+
IcsValidator.valid_feed?("http://example.com/valid_feed.ics") # => true
|
29
|
+
IcsValidator.valid_feed?("http://example.com/invalid_feed.ics") # => false
|
30
|
+
```
|
22
31
|
|
23
32
|
## Contributing
|
24
33
|
|
data/ics_validator.gemspec
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'capybara/poltergeist'
|
2
|
+
|
3
|
+
module IcsValidator
|
4
|
+
|
5
|
+
# Validate an iCalendar file.
|
6
|
+
#
|
7
|
+
class FileValidator
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def valid?
|
14
|
+
if r = validation_results
|
15
|
+
results = validation_results.children.map{|c| c.attr(:result)}
|
16
|
+
results.compact.uniq == ['pass']
|
17
|
+
else
|
18
|
+
raise "unexpected markup"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def validator_response
|
25
|
+
session = Capybara::Session.new(:poltergeist)
|
26
|
+
|
27
|
+
session.driver.headers = { 'User-Agent' =>
|
28
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X)" }
|
29
|
+
|
30
|
+
session.visit('http://icalvalid.cloudapp.net/')
|
31
|
+
|
32
|
+
session.attach_file('Content_fileUpload', File.expand_path(@path))
|
33
|
+
|
34
|
+
session.click_button "Content_btnUpload"
|
35
|
+
|
36
|
+
session.html
|
37
|
+
end
|
38
|
+
|
39
|
+
def validator_response_doc
|
40
|
+
Nokogiri::XML(validator_response)
|
41
|
+
end
|
42
|
+
|
43
|
+
def validation_results
|
44
|
+
validator_response_doc.at('validationResults')
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'capybara/poltergeist'
|
2
|
+
|
3
|
+
module IcsValidator
|
4
|
+
|
5
|
+
# Validate a snippet of iCalendar content.
|
6
|
+
#
|
7
|
+
class SnippetValidator
|
8
|
+
|
9
|
+
def initialize(snippet)
|
10
|
+
@snippet = snippet
|
11
|
+
end
|
12
|
+
|
13
|
+
def valid?
|
14
|
+
if r = validation_results
|
15
|
+
results = validation_results.children.map{|c| c.attr(:result)}
|
16
|
+
results.compact.uniq == ['pass']
|
17
|
+
else
|
18
|
+
raise "unexpected markup"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def validator_response
|
25
|
+
session = Capybara::Session.new(:poltergeist)
|
26
|
+
|
27
|
+
session.driver.headers = { 'User-Agent' =>
|
28
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X)" }
|
29
|
+
|
30
|
+
session.visit('http://icalvalid.cloudapp.net/')
|
31
|
+
|
32
|
+
session.fill_in('Content_tbSnippet', with: @snippet)
|
33
|
+
|
34
|
+
session.click_button "Content_btnValidateSnippet"
|
35
|
+
|
36
|
+
session.html
|
37
|
+
end
|
38
|
+
|
39
|
+
def validator_response_doc
|
40
|
+
Nokogiri::XML(validator_response)
|
41
|
+
end
|
42
|
+
|
43
|
+
def validation_results
|
44
|
+
validator_response_doc.at('validationResults')
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/ics_validator.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "ics_validator/version"
|
2
2
|
require "ics_validator/feed_validator"
|
3
|
+
require "ics_validator/snippet_validator"
|
4
|
+
require "ics_validator/file_validator"
|
3
5
|
|
4
6
|
# Use http://icalvalid.cloudapp.net/ to validate iCalendar content.
|
5
7
|
#
|
@@ -9,4 +11,12 @@ module IcsValidator
|
|
9
11
|
FeedValidator.new(url).valid?
|
10
12
|
end
|
11
13
|
|
14
|
+
def self.valid_snippet?(snippet)
|
15
|
+
SnippetValidator.new(snippet).valid?
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.valid_file?(path)
|
19
|
+
FileValidator.new(path).valid?
|
20
|
+
end
|
21
|
+
|
12
22
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
NOT even CLOSE lol
|
@@ -0,0 +1,58 @@
|
|
1
|
+
BEGIN:VCALENDAR
|
2
|
+
VERSION:2.0
|
3
|
+
PRODID:-//ddaysoftware.com//NONSGML DDay.iCal 1.0//EN
|
4
|
+
BEGIN:VTIMEZONE
|
5
|
+
TZID:Eastern Standard Time
|
6
|
+
BEGIN:STANDARD
|
7
|
+
DTSTART:20131102T020000
|
8
|
+
RRULE:FREQ=YEARLY;BYDAY=1SU;BYHOUR=2;BYMINUTE=0;BYMONTH=11
|
9
|
+
TZNAME:Eastern Standard Time
|
10
|
+
TZOFFSETFROM:-0400
|
11
|
+
TZOFFSETTO:-0500
|
12
|
+
END:STANDARD
|
13
|
+
BEGIN:DAYLIGHT
|
14
|
+
DTSTART:20130301T020000
|
15
|
+
RRULE:FREQ=YEARLY;BYDAY=2SU;BYHOUR=2;BYMINUTE=0;BYMONTH=3
|
16
|
+
TZNAME:Eastern Daylight Time
|
17
|
+
TZOFFSETFROM:-0500
|
18
|
+
TZOFFSETTO:-0400
|
19
|
+
END:DAYLIGHT
|
20
|
+
END:VTIMEZONE
|
21
|
+
BEGIN:VEVENT
|
22
|
+
CATEGORIES:art
|
23
|
+
CATEGORIES:ksc
|
24
|
+
CATEGORIES:university
|
25
|
+
DESCRIPTION:2013–14 Redfern Choreographer-in-Residence Rebecca Stenn has pe
|
26
|
+
rformed and toured throughout the world as a principal dancer with Momix a
|
27
|
+
nd Pilobolus. Stenn creates distinctive dance pieces and solo works that c
|
28
|
+
hallenge the unique ways that live music and dance\ncommunicate and intera
|
29
|
+
ct.
|
30
|
+
DTEND;TZID=Eastern Standard Time:20140127T213000
|
31
|
+
DTSTAMP:20140102T024133Z
|
32
|
+
DTSTART;TZID=Eastern Standard Time:20140127T193000
|
33
|
+
LOCATION:
|
34
|
+
SEQUENCE:0
|
35
|
+
SUMMARY:Rebecca Stenn Modern Dance
|
36
|
+
UID:090c4d49-0069-45ee-8190-5f129e73a265
|
37
|
+
URL:http://www.keene.edu/news/events/detail/1232/
|
38
|
+
END:VEVENT
|
39
|
+
BEGIN:VEVENT
|
40
|
+
CATEGORIES:art
|
41
|
+
CATEGORIES:ksc
|
42
|
+
CATEGORIES:theater
|
43
|
+
CATEGORIES:university
|
44
|
+
DESCRIPTION:In their premiere American tour\, this hilarious circus\ntroupe
|
45
|
+
features log-walking\, spoon-clacking\, hatchet-juggling\, clog-dancing\,
|
46
|
+
and even hijinks on an outhouse! A smorgasbord of family fun based on the
|
47
|
+
logging tradition with troupers performing daring knife tricks and acroba
|
48
|
+
tic feats to the toe-tapping sounds of Quebecois folk music.
|
49
|
+
DTEND;TZID=Eastern Standard Time:20140201T160000
|
50
|
+
DTSTAMP:20140102T024133Z
|
51
|
+
DTSTART;TZID=Eastern Standard Time:20140201T140000
|
52
|
+
LOCATION:
|
53
|
+
SEQUENCE:0
|
54
|
+
SUMMARY:Cirque Alfonse in "Timber!"
|
55
|
+
UID:0c66f74f-b253-43dd-a473-60895333b498
|
56
|
+
URL:http://www.keene.edu/news/events/detail/1233/
|
57
|
+
END:VEVENT
|
58
|
+
END:VCALENDAR
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe IcsValidator::FileValidator, :vcr do
|
4
|
+
|
5
|
+
context "given a valid ICS file" do
|
6
|
+
let(:valid_ics_file) {
|
7
|
+
File.expand_path('../../fixtures/icalendar/valid.ics', __FILE__)
|
8
|
+
}
|
9
|
+
|
10
|
+
subject { described_class.new(valid_ics_file) }
|
11
|
+
|
12
|
+
describe "#valid?" do
|
13
|
+
it "returns true" do
|
14
|
+
subject.should be_valid
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "given an invalid ICS file" do
|
20
|
+
let(:invalid_ics_file) {
|
21
|
+
File.expand_path('../../fixtures/icalendar/invalid.ics', __FILE__)
|
22
|
+
}
|
23
|
+
|
24
|
+
subject { described_class.new(invalid_ics_file) }
|
25
|
+
|
26
|
+
describe "#valid?" do
|
27
|
+
it "returns false" do
|
28
|
+
subject.should_not be_valid
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe IcsValidator::SnippetValidator, :vcr do
|
4
|
+
|
5
|
+
context "given a valid ICS snippet" do
|
6
|
+
let(:valid_ics_snippet) {
|
7
|
+
<<-EOF
|
8
|
+
BEGIN:VCALENDAR
|
9
|
+
VERSION:2.0
|
10
|
+
CALSCALE:GREGORIAN
|
11
|
+
METHOD:PUBLISH
|
12
|
+
PRODID:iCalendar-Ruby
|
13
|
+
BEGIN:VTIMEZONE
|
14
|
+
TZID:America/New_York
|
15
|
+
BEGIN:DAYLIGHT
|
16
|
+
DTSTART:19700308T020000
|
17
|
+
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
|
18
|
+
TZNAME:EDT
|
19
|
+
TZOFFSETFROM:-0500
|
20
|
+
TZOFFSETTO:-0400
|
21
|
+
END:DAYLIGHT
|
22
|
+
BEGIN:STANDARD
|
23
|
+
DTSTART:19701101T020000
|
24
|
+
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
|
25
|
+
TZNAME:EST
|
26
|
+
TZOFFSETFROM:-0400
|
27
|
+
TZOFFSETTO:-0500
|
28
|
+
END:STANDARD
|
29
|
+
END:VTIMEZONE
|
30
|
+
END:VCALENDAR
|
31
|
+
EOF
|
32
|
+
}
|
33
|
+
|
34
|
+
subject { described_class.new(valid_ics_snippet) }
|
35
|
+
|
36
|
+
describe "#valid?" do
|
37
|
+
it "returns true" do
|
38
|
+
subject.should be_valid
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "given an invalid ICS snippet" do
|
44
|
+
let(:invalid_ics_snippet) {
|
45
|
+
"LOL. THIS ISN'T EVEN CLOSE"
|
46
|
+
}
|
47
|
+
|
48
|
+
subject { described_class.new(invalid_ics_snippet) }
|
49
|
+
|
50
|
+
describe "#valid?" do
|
51
|
+
it "returns false" do
|
52
|
+
subject.should_not be_valid
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ics_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Gillooly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: poltergeist
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,6 +145,7 @@ extra_rdoc_files: []
|
|
131
145
|
files:
|
132
146
|
- .gitignore
|
133
147
|
- .rspec
|
148
|
+
- .travis.yml
|
134
149
|
- Gemfile
|
135
150
|
- LICENSE.txt
|
136
151
|
- README.md
|
@@ -138,10 +153,16 @@ files:
|
|
138
153
|
- ics_validator.gemspec
|
139
154
|
- lib/ics_validator.rb
|
140
155
|
- lib/ics_validator/feed_validator.rb
|
156
|
+
- lib/ics_validator/file_validator.rb
|
157
|
+
- lib/ics_validator/snippet_validator.rb
|
141
158
|
- lib/ics_validator/version.rb
|
142
159
|
- spec/cassettes/IcsValidator_FeedValidator/given_a_valid_ICS_feed/_valid_/returns_true.yml
|
143
160
|
- spec/cassettes/IcsValidator_FeedValidator/given_an_invalid_ICS_feed/_valid_/returns_false.yml
|
161
|
+
- spec/fixtures/icalendar/invalid.ics
|
162
|
+
- spec/fixtures/icalendar/valid.ics
|
144
163
|
- spec/ics_validator/feed_validator_spec.rb
|
164
|
+
- spec/ics_validator/file_validator_spec.rb
|
165
|
+
- spec/ics_validator/snippet_validator_spec.rb
|
145
166
|
- spec/spec_helper.rb
|
146
167
|
homepage: http://github.com/mattgillooly/ics_validator
|
147
168
|
licenses:
|
@@ -170,5 +191,9 @@ summary: Validate iCalendar content
|
|
170
191
|
test_files:
|
171
192
|
- spec/cassettes/IcsValidator_FeedValidator/given_a_valid_ICS_feed/_valid_/returns_true.yml
|
172
193
|
- spec/cassettes/IcsValidator_FeedValidator/given_an_invalid_ICS_feed/_valid_/returns_false.yml
|
194
|
+
- spec/fixtures/icalendar/invalid.ics
|
195
|
+
- spec/fixtures/icalendar/valid.ics
|
173
196
|
- spec/ics_validator/feed_validator_spec.rb
|
197
|
+
- spec/ics_validator/file_validator_spec.rb
|
198
|
+
- spec/ics_validator/snippet_validator_spec.rb
|
174
199
|
- spec/spec_helper.rb
|