ical_importer 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/ical_importer/parser.rb +8 -1
- data/lib/ical_importer/version.rb +1 -1
- data/spec/ical_importer/parser_spec.rb +18 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/ical_importer/parser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module IcalImporter
|
2
2
|
class Parser
|
3
|
-
attr_reader :feed, :bare_feed, :url, :timezone
|
3
|
+
attr_reader :feed, :bare_feed, :url, :timezone, :name
|
4
4
|
attr_accessor :timeout
|
5
5
|
|
6
6
|
DEFAULT_TIMEOUT = 8
|
@@ -23,6 +23,7 @@ module IcalImporter
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
@timezone = get_timezone
|
26
|
+
@name = get_name
|
26
27
|
end
|
27
28
|
|
28
29
|
def should_parse?
|
@@ -62,6 +63,12 @@ module IcalImporter
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
66
|
+
def get_name
|
67
|
+
if feed.present? && feed.first.x_properties["X-WR-CALNAME"].present?
|
68
|
+
feed.first.x_properties["X-WR-CALNAME"].first.value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
65
72
|
def tap_and_each(list)
|
66
73
|
list.tap do |r|
|
67
74
|
r.each do |event|
|
@@ -116,6 +116,24 @@ module IcalImporter
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
describe "#get_name" do
|
120
|
+
it "finds the feed's name out of the x properties" do
|
121
|
+
@value = stub
|
122
|
+
@value.should_receive(:value)
|
123
|
+
subject.stub :feed => [stub(x_properties: { "X-WR-CALNAME" => [@value] })]
|
124
|
+
subject.send(:get_name)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "fails silently if no feed exists" do
|
128
|
+
subject.send(:get_name).should == nil
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns nil if no timezone x property exists" do
|
132
|
+
subject.stub :feed => [stub(x_properties: { "X-WR-DERPHERP" => [@value] })]
|
133
|
+
subject.send(:get_name).should be_nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
119
137
|
describe "#open_ical" do
|
120
138
|
it 'cleans up and tries to open an HTTP URL' do
|
121
139
|
subject.stub :open => bare_stuff
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ical_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
segments:
|
161
161
|
- 0
|
162
|
-
hash:
|
162
|
+
hash: 4363646983789960929
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
none: false
|
165
165
|
requirements:
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
segments:
|
170
170
|
- 0
|
171
|
-
hash:
|
171
|
+
hash: 4363646983789960929
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
174
|
rubygems_version: 1.8.24
|