ess 0.9.3 → 1.0.0

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.
@@ -1,45 +1,224 @@
1
1
  require 'spec_helper'
2
+ require 'time'
2
3
 
3
4
  module ESS
4
5
  describe "Big examples" do
5
6
  describe "Examples::from_essfeeds_org_home" do
7
+ let(:ess) { Examples::from_essfeeds_org_home }
6
8
  it 'should be a valid ESS feed' do
7
9
  lambda {
8
- Examples::from_essfeeds_org_home.push_to_aggregators
10
+ ess.push_to_aggregators
9
11
  }.should_not raise_error
10
12
  end
13
+
14
+ describe '#find_coming' do
15
+ it 'should interpret it correctly' do
16
+ events = ess.find_coming(10, Time.parse("2011-12-10T18:30:02Z"))
17
+ events.length.should == 8
18
+ events[0][:time].should == Time.parse("2011-12-17T18:30:02Z")
19
+ events[1][:time].should == Time.parse("2011-12-18T18:30:02Z")
20
+ events[2][:time].should == Time.parse("2011-12-24T18:30:02Z")
21
+ events[3][:time].should == Time.parse("2011-12-25T18:30:02Z")
22
+ events[4][:time].should == Time.parse("2011-12-31T18:30:02Z")
23
+ events[5][:time].should == Time.parse("2012-01-01T18:30:02Z")
24
+ events[6][:time].should == Time.parse("2012-01-07T18:30:02Z")
25
+ events[7][:time].should == Time.parse("2012-01-08T18:30:02Z")
26
+
27
+ events = ess.find_coming(10, Time.parse("2011-12-26T18:30:02Z"))
28
+ events.length.should == 4
29
+ events[0][:time].should == Time.parse("2011-12-31T18:30:02Z")
30
+ events[1][:time].should == Time.parse("2012-01-01T18:30:02Z")
31
+ events[2][:time].should == Time.parse("2012-01-07T18:30:02Z")
32
+ events[3][:time].should == Time.parse("2012-01-08T18:30:02Z")
33
+
34
+ events = ess.find_coming(10, Time.parse("2012-12-26T18:30:02Z"))
35
+ events.should be_empty
36
+ end
37
+ end
38
+
39
+ describe '#find_between' do
40
+ it 'should interpret it correctly' do
41
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
42
+ Time.parse("2012-02-08T18:30:02Z"))
43
+ events.length.should == 8
44
+ events[0][:time].should == Time.parse("2011-12-17T18:30:02Z")
45
+ events[1][:time].should == Time.parse("2011-12-18T18:30:02Z")
46
+ events[6][:time].should == Time.parse("2012-01-07T18:30:02Z")
47
+ events[7][:time].should == Time.parse("2012-01-08T18:30:02Z")
48
+
49
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
50
+ Time.parse("2012-01-01T18:30:02Z"))
51
+ events.length.should == 6
52
+ events[5][:time].should == Time.parse("2012-01-01T18:30:02Z")
53
+
54
+ events = ess.find_between(Time.parse("2012-12-10T18:30:02Z"),
55
+ Time.parse("2013-01-01T18:30:02Z"))
56
+ events.should be_empty
57
+ end
58
+ end
11
59
  end
12
60
 
13
61
  describe "Examples::paying_attendees" do
62
+ let(:ess) { Examples::paying_attendees }
63
+
14
64
  it 'should be a valid ESS feed' do
15
65
  lambda {
16
- Examples::paying_attendees.push_to_aggregators
66
+ ess.push_to_aggregators
17
67
  }.should_not raise_error
18
68
  end
69
+
70
+ describe '#find_coming' do
71
+ it 'should interpret it correctly' do
72
+ events = ess.find_coming(10, Time.parse("2011-12-10T18:30:02Z"))
73
+ events.length.should == 1
74
+ events[0][:time].should == Time.parse("2013-10-25T15:30:00Z")
75
+
76
+ events = ess.find_coming(10, Time.parse("2013-12-10T18:30:02Z"))
77
+ events.should be_empty
78
+ end
79
+ end
80
+
81
+ describe '#find_between' do
82
+ it 'should interpret it correctly' do
83
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
84
+ Time.parse("2013-12-08T18:30:02Z"))
85
+ events.length.should == 1
86
+ events[0][:time].should == Time.parse("2013-10-25T15:30:00Z")
87
+
88
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
89
+ Time.parse("2012-12-08T18:30:02Z"))
90
+ events.should be_empty
91
+
92
+ events = ess.find_between(Time.parse("2013-12-10T18:30:02Z"),
93
+ Time.parse("2014-12-08T18:30:02Z"))
94
+ events.should be_empty
95
+ end
96
+ end
19
97
  end
20
98
 
21
99
  describe "Examples::osteopathy_course" do
100
+ let(:ess) { Examples::osteopathy_course }
101
+
22
102
  it 'should be a valid ESS feed' do
23
103
  lambda {
24
- Examples::osteopathy_course.push_to_aggregators
104
+ ess.push_to_aggregators
25
105
  }.should_not raise_error
26
106
  end
107
+
108
+ describe '#find_coming' do
109
+ it 'should interpret it correctly' do
110
+ events = ess.find_coming(10, Time.parse("2011-12-10T18:30:02Z"))
111
+ events.length.should == 10
112
+ events[0][:time].should == Time.parse("2013-10-05T15:30:00Z")
113
+ events[1][:time].should == Time.parse("2013-10-26T15:30:00Z")
114
+ events[9][:time].should == Time.parse("2014-02-22T15:30:00Z")
115
+
116
+ events = ess.find_coming(20, Time.parse("2011-12-10T18:30:02Z"))
117
+ events.length.should == 12
118
+ events[0][:time].should == Time.parse("2013-10-05T15:30:00Z")
119
+ events[1][:time].should == Time.parse("2013-10-26T15:30:00Z")
120
+ events[9][:time].should == Time.parse("2014-02-22T15:30:00Z")
121
+ events[11][:time].should == Time.parse("2014-03-29T15:30:00Z")
122
+
123
+ events = ess.find_coming(20, Time.parse("2014-03-10T18:30:02Z"))
124
+ events.length.should == 1
125
+ events[0][:time].should == Time.parse("2014-03-29T15:30:00Z")
126
+ end
127
+ end
128
+
129
+ describe '#find_between' do
130
+ it 'should interpret it correctly' do
131
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
132
+ Time.parse("2013-12-15T18:30:02Z"))
133
+ events.length.should == 5
134
+ events[0][:time].should == Time.parse("2013-10-05T15:30:00Z")
135
+ events[4][:time].should == Time.parse("2013-12-07T15:30:00Z")
136
+
137
+ events = ess.find_between(Time.parse("2014-12-10T18:30:02Z"),
138
+ Time.parse("2014-12-15T18:30:02Z"))
139
+ events.should be_empty
140
+ end
141
+ end
27
142
  end
28
143
 
29
144
  describe "Examples::belfast_festival" do
145
+ let(:ess) { Examples::belfast_festival }
146
+
30
147
  it 'should be a valid ESS feed' do
31
148
  lambda {
32
- Examples::belfast_festival.push_to_aggregators
149
+ ess.push_to_aggregators
33
150
  }.should_not raise_error
34
151
  end
152
+
153
+ describe '#find_coming' do
154
+ it 'should interpret it correctly' do
155
+ events = ess.find_coming(10, Time.parse("2011-12-10T18:30:02Z"))
156
+ events.length.should == 2
157
+ events[0][:time].should == Time.parse("2013-10-25T15:30:00Z")
158
+ events[0][:feed].should == ess.channel.feed_list[0]
159
+ events[1][:time].should == Time.parse("2013-12-25T15:30:00Z")
160
+ events[1][:feed].should == ess.channel.feed_list[1]
161
+ events[0][:feed].should_not == events[1][:feed]
162
+
163
+ events = ess.find_coming(10, Time.parse("2013-11-10T18:30:02Z"))
164
+ events.length.should == 1
165
+ events[0][:time].should == Time.parse("2013-12-25T15:30:00Z")
166
+
167
+ events = ess.find_coming(10, Time.parse("2014-01-10T18:30:02Z"))
168
+ events.should be_empty
169
+ end
170
+ end
171
+
172
+ describe '#find_between' do
173
+ it 'should interpret it correctly' do
174
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
175
+ Time.parse("2013-12-15T18:30:02Z"))
176
+ events.length.should == 1
177
+ events[0][:time].should == Time.parse("2013-10-25T15:30:00Z")
178
+ events[0][:feed].should == ess.channel.feed_list[0]
179
+
180
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
181
+ Time.parse("2014-12-15T18:30:02Z"))
182
+ events.length.should == 2
183
+ events[0][:time].should == Time.parse("2013-10-25T15:30:00Z")
184
+ events[1][:time].should == Time.parse("2013-12-25T15:30:00Z")
185
+ end
186
+ end
35
187
  end
36
188
 
37
189
  describe "Examples::ring_cycle" do
190
+ let(:ess) { Examples::ring_cycle }
191
+
38
192
  it 'should be a valid ESS feed' do
39
193
  lambda {
40
- Examples::ring_cycle.push_to_aggregators
194
+ ess.push_to_aggregators
41
195
  }.should_not raise_error
42
196
  end
197
+
198
+ describe '#find_coming' do
199
+ it 'should interpret it correctly' do
200
+ events = ess.find_coming(50, Time.parse("2011-12-10T18:30:02Z"))
201
+ events.length.should == 48
202
+ events[0][:time].should == Time.parse("2013-01-25T08:30:00Z")
203
+ events[1][:time].should == Time.parse("2013-01-28T08:30:00Z")
204
+ events[47][:time].should == Time.parse("2013-12-31T08:30:00Z")
205
+ end
206
+ end
207
+
208
+ describe '#find_between' do
209
+ it 'should interpret it correctly' do
210
+ events = ess.find_between(Time.parse("2011-12-10T18:30:02Z"),
211
+ Time.parse("2014-12-15T18:30:02Z"))
212
+ events.length.should == 48
213
+ events[0][:time].should == Time.parse("2013-01-25T08:30:00Z")
214
+ events[1][:time].should == Time.parse("2013-01-28T08:30:00Z")
215
+ events[47][:time].should == Time.parse("2013-12-31T08:30:00Z")
216
+
217
+ events = ess.find_between(Time.parse("2014-12-10T18:30:02Z"),
218
+ Time.parse("2015-12-15T18:30:02Z"))
219
+ events.should be_empty
220
+ end
221
+ end
43
222
  end
44
223
 
45
224
  end
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ module ESS
4
+ describe Parser do
5
+ describe '.parse' do
6
+ context 'when passed a valid ESS document' do
7
+ let(:doc) { Examples.from_essfeeds_org_home.to_xml! }
8
+ let(:ess) { Parser.parse doc }
9
+
10
+ it 'should return an "ess" element object' do
11
+ ess = Parser.parse doc
12
+ ess.name!.should == :ess
13
+ end
14
+
15
+ it 'should parse the ess elements children - channel' do
16
+ ess.channel_list.should_not be_empty
17
+ end
18
+
19
+ it 'should parse also the channel\'s children elements' do
20
+ ess.channel.title_list.should_not be_empty
21
+ ess.channel.link_list.should_not be_empty
22
+ end
23
+
24
+ it 'should parse also the channel\'s children\' children elements' do
25
+ ess.channel.feed_list.should_not be_empty
26
+ ess.channel.feed_list[0].title_list.should_not be_empty
27
+ end
28
+
29
+ it 'should parse childrens text' do
30
+ ess.channel.feed_list[0].title.text!.should == "Football match of saturday"
31
+ end
32
+
33
+ it 'should parse ess attributes' do
34
+ ess.xmlns_attr.should == "http://essfeed.org/history/0.9"
35
+ end
36
+
37
+ it 'should parse ess children\'s attributes' do
38
+ ess.channel.feed.dates.item.type_attr.should == "recurrent"
39
+ end
40
+
41
+ it 'should return a valid ESS feed' do
42
+ lambda {
43
+ ess.validate
44
+ }.should_not raise_error
45
+ end
46
+ end
47
+
48
+ context 'when passed an invalid ESS document' do
49
+ it 'should raise an exception' do
50
+ expect {
51
+ Parser.parse "hello"
52
+ }.to raise_error(ArgumentError)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
@@ -1,4 +1,5 @@
1
1
  require 'ess'
2
+ require 'ess/parser'
2
3
 
3
4
  # Using the validation service for running tests
4
5
  ESS::Pusher.aggregators = ["http://api.hypecal.com/v1/ess/validator.json"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-01 00:00:00.000000000 Z
13
+ date: 2013-06-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: builder
@@ -50,13 +50,16 @@ files:
50
50
  - lib/ess/examples.rb
51
51
  - lib/ess/helpers.rb
52
52
  - lib/ess/maker.rb
53
+ - lib/ess/parser.rb
53
54
  - lib/ess/postprocessing.rb
54
55
  - lib/ess/pusher.rb
55
56
  - lib/ess/validation.rb
56
57
  - lib/ess/version.rb
57
58
  - spec/ess/element_spec.rb
59
+ - spec/ess/ess_spec.rb
58
60
  - spec/ess/full_spec.rb
59
61
  - spec/ess/maker_spec.rb
62
+ - spec/ess/parser_spec.rb
60
63
  - spec/spec_helper.rb
61
64
  homepage: https://github.com/essfeed/ruby-ess
62
65
  licenses: []
@@ -84,6 +87,8 @@ specification_version: 3
84
87
  summary: Generate ESS XML feeds with Ruby
85
88
  test_files:
86
89
  - spec/ess/element_spec.rb
90
+ - spec/ess/ess_spec.rb
87
91
  - spec/ess/full_spec.rb
88
92
  - spec/ess/maker_spec.rb
93
+ - spec/ess/parser_spec.rb
89
94
  - spec/spec_helper.rb