reittiopas 0.0.2 → 0.1.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.
- data/.gemtest +0 -0
- data/.rspec +2 -0
- data/.yardoc/checksums +9 -0
- data/.yardoc/object_types +4 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/History.txt +10 -0
- data/Manifest.txt +11 -2
- data/README.md +103 -0
- data/Rakefile +33 -27
- data/lib/reittiopas.rb +3 -1
- data/lib/reittiopas/coordinates.rb +4 -0
- data/lib/reittiopas/reittiopas.rb +2 -1
- data/lib/reittiopas/routing.rb +310 -0
- data/spec/fixtures/kallion_kirjasto.xml +1 -0
- data/spec/fixtures/no_access +7 -7
- data/spec/fixtures/route_ulvilantie_19-kallion_kirjasto.xml +776 -0
- data/spec/fixtures/ulvilantie_19_helsinki.xml +1 -0
- data/spec/reittiopas_routing_spec.rb +373 -0
- data/spec/reittiopas_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/tasks/rdoc.rake +8 -8
- data/tasks/rspec.rake +9 -15
- metadata +94 -30
- data/README.rdoc +0 -75
- data/spec/spec.opts +0 -4
@@ -0,0 +1 @@
|
|
1
|
+
<LOC name1="Ulvilantie" number="19" city="Helsinki" code="" address="" type="900" category="street" x="2548199" y="6677769" lon="24.86607" lat="60.20861" />
|
@@ -0,0 +1,373 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
require 'reittiopas'
|
3
|
+
|
4
|
+
require 'webmock/rspec'
|
5
|
+
include WebMock::API
|
6
|
+
|
7
|
+
def parse_elem(xml)
|
8
|
+
Nokogiri::XML(xml).children[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
describe Reittiopas do
|
13
|
+
|
14
|
+
before(:all) do
|
15
|
+
account = {:username => 'foo', :password => 'bar'}
|
16
|
+
@reittiopas = Reittiopas.new(account)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#routing" do
|
21
|
+
|
22
|
+
before do
|
23
|
+
@response = File.read(File.dirname(__FILE__) + '/fixtures/route_ulvilantie_19-kallion_kirjasto.xml')
|
24
|
+
stub_request(:any, /.*/).to_return(:body => @response, :status => 200)
|
25
|
+
|
26
|
+
@ulvilantie = Reittiopas::Location.parse(parse_elem(File.read(File.dirname(__FILE__) + '/fixtures/ulvilantie_19_helsinki.xml')))
|
27
|
+
@kallion_kirjasto = Reittiopas::Location.parse(parse_elem(File.read(File.dirname(__FILE__) + '/fixtures/kallion_kirjasto.xml')))
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should require from and to locations with options and return an array of routes" do
|
31
|
+
options = {}
|
32
|
+
@reittiopas.routing(@ulvilantie, @kallion_kirjasto, options).should be_a Array
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should pass options to reittiopas" do
|
36
|
+
options = { :option1 => "value1",
|
37
|
+
:option2 => 2 }
|
38
|
+
|
39
|
+
@reittiopas.routing(@ulvilantie, @kallion_kirjasto, options)
|
40
|
+
|
41
|
+
a_request(:get, /.*option1=value1&option2=2.*/).should have_been_made.once
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe Reittiopas::Routing::Route do
|
48
|
+
|
49
|
+
before(:all) do
|
50
|
+
xml = File.read(File.dirname(__FILE__) + '/fixtures/route_ulvilantie_19-kallion_kirjasto.xml')
|
51
|
+
doc = Nokogiri::XML(xml).search("ROUTE").first
|
52
|
+
|
53
|
+
@route = Reittiopas::Routing::Route.parse(doc)
|
54
|
+
end
|
55
|
+
|
56
|
+
specify { @route.time.should == 34.605 }
|
57
|
+
specify { @route.distance.should == 8150.277 }
|
58
|
+
specify { @route.parts.should be_a(Array) }
|
59
|
+
specify { @route.walks.should be_a(Array) }
|
60
|
+
specify { @route.lines.should be_a(Array) }
|
61
|
+
|
62
|
+
specify { @route.parts.last.should be_a(Reittiopas::Routing::Point)}
|
63
|
+
specify { @route.parts.first.should be_a(Reittiopas::Routing::Point)}
|
64
|
+
|
65
|
+
specify { @route.parts[1].should be_a(Reittiopas::Routing::Walk)}
|
66
|
+
specify { @route.parts[2].should be_a(Reittiopas::Routing::Line)}
|
67
|
+
specify { @route.parts[3].should be_a(Reittiopas::Routing::Walk)}
|
68
|
+
specify { @route.parts[4].should be_a(Reittiopas::Routing::Line)}
|
69
|
+
|
70
|
+
specify { @route.walks[0].should be_a(Reittiopas::Routing::Walk)}
|
71
|
+
specify { @route.walks[1].should be_a(Reittiopas::Routing::Walk)}
|
72
|
+
specify { @route.walks[2].should be_a(Reittiopas::Routing::Walk)}
|
73
|
+
|
74
|
+
specify { @route.lines[0].should be_a(Reittiopas::Routing::Line)}
|
75
|
+
specify { @route.lines[1].should be_a(Reittiopas::Routing::Line)}
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe Reittiopas::Routing::Point do
|
80
|
+
|
81
|
+
before(:all) do
|
82
|
+
doc = Nokogiri::XML(%{<POINT uid="start" x="2548199.0" y="6677769.0">
|
83
|
+
<ARRIVAL date="20101213" time="2102"/>
|
84
|
+
<DEPARTURE date="20101213" time="2102"/>
|
85
|
+
</POINT>})
|
86
|
+
|
87
|
+
element = doc.elements.first
|
88
|
+
@point = Reittiopas::Routing::Point.parse(element)
|
89
|
+
end
|
90
|
+
|
91
|
+
specify { @point.uid.should == "start" }
|
92
|
+
specify { @point.x.should == 2548199.0 }
|
93
|
+
specify { @point.y.should == 6677769.0 }
|
94
|
+
specify { @point.arrival.should be_a Reittiopas::Routing::Arrival }
|
95
|
+
specify { @point.departure.should be_a Reittiopas::Routing::Departure }
|
96
|
+
|
97
|
+
specify { @point.arrival.date_time.should == DateTime.new(2010,12,13,21,02)}
|
98
|
+
specify { @point.departure.date_time.should == DateTime.new(2010,12,13,21,02)}
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
describe Reittiopas::Routing::MapLocation do
|
103
|
+
|
104
|
+
before(:all) do
|
105
|
+
doc = Nokogiri::XML(%{<MAPLOC x="2548250.4" y="6677834.0" type="0">
|
106
|
+
<ARRIVAL date="20101213" time="2104"/>
|
107
|
+
<DEPARTURE date="20101214" time="2105"/>
|
108
|
+
<NAME lang="1" val="Fleminginkatu"/>
|
109
|
+
</MAPLOC>})
|
110
|
+
|
111
|
+
element = doc.elements.first
|
112
|
+
@map_location = Reittiopas::Routing::MapLocation.parse(element)
|
113
|
+
end
|
114
|
+
|
115
|
+
specify { @map_location.x.should == 2548250.4 }
|
116
|
+
specify { @map_location.y.should == 6677834.0 }
|
117
|
+
specify { @map_location.location_type.should == 0 }
|
118
|
+
specify { @map_location.arrival.should be_a Reittiopas::Routing::Arrival }
|
119
|
+
specify { @map_location.departure.should be_a Reittiopas::Routing::Departure }
|
120
|
+
|
121
|
+
specify { @map_location.arrival.date_time.should == DateTime.new(2010,12,13,21,04)}
|
122
|
+
specify { @map_location.departure.date_time.should == DateTime.new(2010,12,14,21,05)}
|
123
|
+
|
124
|
+
specify { @map_location.name.should == "Fleminginkatu" }
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
describe Reittiopas::Routing::Arrival do
|
130
|
+
|
131
|
+
before(:all) do
|
132
|
+
doc = Nokogiri::XML(%{<ARRIVAL date="20101213" time="2102"/>})
|
133
|
+
|
134
|
+
element = doc.elements.first
|
135
|
+
@arrival = Reittiopas::Routing::Arrival.parse(element)
|
136
|
+
end
|
137
|
+
|
138
|
+
specify { @arrival.date_time.should == DateTime.new(2010,12,13,21,02) }
|
139
|
+
end
|
140
|
+
|
141
|
+
describe Reittiopas::Routing::Departure do
|
142
|
+
|
143
|
+
before(:all) do
|
144
|
+
doc = Nokogiri::XML(%{<DEPARTURE date="20101214" time="2103"/>})
|
145
|
+
|
146
|
+
element = doc.elements.first
|
147
|
+
@arrival = Reittiopas::Routing::Departure.parse(element)
|
148
|
+
end
|
149
|
+
|
150
|
+
specify { @arrival.date_time.should == DateTime.new(2010,12,14,21,03) }
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
describe Reittiopas::Routing::Walk do
|
155
|
+
|
156
|
+
before(:all) do
|
157
|
+
doc = Nokogiri::XML(%{<WALK>
|
158
|
+
<LENGTH time="1.257" dist="132.387"/>
|
159
|
+
|
160
|
+
<POINT uid="start" x="2548199.0" y="6677769.0">
|
161
|
+
<ARRIVAL date="20101213" time="2102"/>
|
162
|
+
<DEPARTURE date="20101213" time="2102"/>
|
163
|
+
</POINT>
|
164
|
+
<MAPLOC x="2548250.4" y="6677834.0" type="0">
|
165
|
+
<ARRIVAL date="20101213" time="2104"/>
|
166
|
+
<DEPARTURE date="20101213" time="2104"/>
|
167
|
+
</MAPLOC>
|
168
|
+
<STOP code="6:1304133" x="2548265.0" y="6677828.0" id="1335">
|
169
|
+
|
170
|
+
<ARRIVAL date="20101213" time="2104"/>
|
171
|
+
<DEPARTURE date="20101213" time="2104"/>
|
172
|
+
<NAME lang="1" val="Ulvilantie 21"/>
|
173
|
+
<NAME lang="2" val="Ulfsbyvägen 21"/>
|
174
|
+
</STOP>
|
175
|
+
</WALK>})
|
176
|
+
element = doc.elements.first
|
177
|
+
|
178
|
+
@walk = Reittiopas::Routing::Walk.parse(element)
|
179
|
+
end
|
180
|
+
|
181
|
+
specify { @walk.time.should == 1.257 }
|
182
|
+
specify { @walk.distance.should == 132.387 }
|
183
|
+
specify { @walk.sections.should be_a(Array)}
|
184
|
+
specify { @walk.sections.first.should be_a(Reittiopas::Routing::Point)}
|
185
|
+
specify { @walk.sections[1].should be_a(Reittiopas::Routing::MapLocation)}
|
186
|
+
specify { @walk.sections[2].should be_a(Reittiopas::Routing::Stop)}
|
187
|
+
|
188
|
+
specify { @walk.stops.first.arrival.date_time.should == DateTime.new(2010, 12, 13, 21, 04)}
|
189
|
+
specify { @walk.map_locations.first.arrival.date_time.should == DateTime.new(2010, 12, 13, 21, 04)}
|
190
|
+
specify { @walk.points.first.arrival.date_time.should == DateTime.new(2010, 12, 13, 21, 02)}
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
describe Reittiopas::Routing::Line do
|
195
|
+
|
196
|
+
before(:all) do
|
197
|
+
doc = Nokogiri::XML(%{<LINE id="138" code="1018 2" type="1" mobility="3">
|
198
|
+
<LENGTH time="13.000" dist="5557.353"/>
|
199
|
+
<STOP code="6:1304133" x="2548265.0" y="6677828.0" id="1335" ord="7">
|
200
|
+
|
201
|
+
<ARRIVAL date="20101213" time="2104"/>
|
202
|
+
<DEPARTURE date="20101213" time="2104"/>
|
203
|
+
<NAME lang="1" val="Ulvilantie 21"/>
|
204
|
+
<NAME lang="2" val="Ulfsbyvägen 21"/>
|
205
|
+
</STOP>
|
206
|
+
<STOP code="6:1304134" x="2548692.0" y="6677805.0" id="1336">
|
207
|
+
<ARRIVAL date="20101213" time="2105"/>
|
208
|
+
<DEPARTURE date="20101213" time="2105"/>
|
209
|
+
<NAME lang="1" val="Ulvilantie 27"/>
|
210
|
+
|
211
|
+
<NAME lang="2" val="Ulfsbyvägen 27"/>
|
212
|
+
</STOP>
|
213
|
+
<STOP code="6:1304135" x="2548854.0" y="6677629.0" id="1337">
|
214
|
+
<ARRIVAL date="20101213" time="2106"/>
|
215
|
+
<DEPARTURE date="20101213" time="2106"/>
|
216
|
+
<NAME lang="1" val="Naantalintie"/>
|
217
|
+
<NAME lang="2" val="Nådendalsvägen"/>
|
218
|
+
</STOP>
|
219
|
+
<STOP code="6:1304137" x="2548967.0" y="6677478.0" id="1339">
|
220
|
+
|
221
|
+
<ARRIVAL date="20101213" time="2106"/>
|
222
|
+
<DEPARTURE date="20101213" time="2106"/>
|
223
|
+
<NAME lang="1" val="Munkkivuori"/>
|
224
|
+
<NAME lang="2" val="Munkshöjden"/>
|
225
|
+
</STOP>
|
226
|
+
<STOP code="6:1301158" x="2549077.0" y="6677036.0" id="1303">
|
227
|
+
<ARRIVAL date="20101213" time="2108"/>
|
228
|
+
<DEPARTURE date="20101213" time="2108"/>
|
229
|
+
<NAME lang="1" val="Niemenmäki"/>
|
230
|
+
|
231
|
+
<NAME lang="2" val="Näshöjden"/>
|
232
|
+
</STOP>
|
233
|
+
<STOP code="6:1301126" x="2549163.0" y="6676754.0" id="1296">
|
234
|
+
<ARRIVAL date="20101213" time="2109"/>
|
235
|
+
<DEPARTURE date="20101213" time="2109"/>
|
236
|
+
<NAME lang="1" val="Lokkalantie"/>
|
237
|
+
<NAME lang="2" val="Locklaisvägen"/>
|
238
|
+
</STOP>
|
239
|
+
<STOP code="6:1301124" x="2549280.0" y="6676400.0" id="1294">
|
240
|
+
|
241
|
+
<ARRIVAL date="20101213" time="2110"/>
|
242
|
+
<DEPARTURE date="20101213" time="2110"/>
|
243
|
+
<NAME lang="1" val="Munkkiniemen aukio"/>
|
244
|
+
<NAME lang="2" val="Munksnäsplatsen"/>
|
245
|
+
</STOP>
|
246
|
+
<STOP code="6:1150114" x="2549570.0" y="6676265.0" id="544">
|
247
|
+
<ARRIVAL date="20101213" time="2111"/>
|
248
|
+
<DEPARTURE date="20101213" time="2111"/>
|
249
|
+
<NAME lang="1" val="Paciuksenkaari"/>
|
250
|
+
|
251
|
+
<NAME lang="2" val="Paciussvängen"/>
|
252
|
+
</STOP>
|
253
|
+
<STOP code="6:1150112" x="2549875.0" y="6676008.0" id="542">
|
254
|
+
<ARRIVAL date="20101213" time="2112"/>
|
255
|
+
<DEPARTURE date="20101213" time="2112"/>
|
256
|
+
<NAME lang="1" val="Meilahdentie"/>
|
257
|
+
<NAME lang="2" val="Mejlansvägen"/>
|
258
|
+
</STOP>
|
259
|
+
<STOP code="6:1150132" x="2550190.0" y="6675858.0" id="559">
|
260
|
+
|
261
|
+
<ARRIVAL date="20101213" time="2113"/>
|
262
|
+
<DEPARTURE date="20101213" time="2113"/>
|
263
|
+
<NAME lang="1" val="Mäntytie"/>
|
264
|
+
<NAME lang="2" val="Tallvägen"/>
|
265
|
+
</STOP>
|
266
|
+
<STOP code="6:1150110" x="2550509.0" y="6675806.0" id="540">
|
267
|
+
<ARRIVAL date="20101213" time="2114"/>
|
268
|
+
<DEPARTURE date="20101213" time="2114"/>
|
269
|
+
<NAME lang="1" val="Haartmaninkatu"/>
|
270
|
+
|
271
|
+
<NAME lang="2" val="Haartmansgatan"/>
|
272
|
+
</STOP>
|
273
|
+
<STOP code="6:1150108" x="2550696.0" y="6675654.0" id="538">
|
274
|
+
<ARRIVAL date="20101213" time="2114"/>
|
275
|
+
<DEPARTURE date="20101213" time="2114"/>
|
276
|
+
<NAME lang="1" val="Naistenklinikka"/>
|
277
|
+
<NAME lang="2" val="Kvinnokliniken"/>
|
278
|
+
</STOP>
|
279
|
+
<STOP code="6:1140105" x="2551068.0" y="6675103.0" id="476">
|
280
|
+
|
281
|
+
<ARRIVAL date="20101213" time="2116"/>
|
282
|
+
<DEPARTURE date="20101213" time="2116"/>
|
283
|
+
<NAME lang="1" val="Linnankoskenkatu"/>
|
284
|
+
<NAME lang="2" val="Linnankoskigatan"/>
|
285
|
+
</STOP>
|
286
|
+
<STOP code="6:1140130" x="2551252.0" y="6674769.0" id="496">
|
287
|
+
<ARRIVAL date="20101213" time="2117"/>
|
288
|
+
<DEPARTURE date="20101213" time="2117"/>
|
289
|
+
<NAME lang="1" val="Töölön sairaala"/>
|
290
|
+
|
291
|
+
<NAME lang="2" val="Tölö sjukhus"/>
|
292
|
+
</STOP>
|
293
|
+
<STOP code="6:1140103" x="2551355.0" y="6674571.0" id="474" ord="21">
|
294
|
+
<ARRIVAL date="20101213" time="2117"/>
|
295
|
+
<DEPARTURE date="20101213" time="2117"/>
|
296
|
+
<NAME lang="1" val="Töölöntori"/>
|
297
|
+
<NAME lang="2" val="Tölötorg"/>
|
298
|
+
</STOP>
|
299
|
+
</LINE>
|
300
|
+
})
|
301
|
+
element = doc.elements.first
|
302
|
+
|
303
|
+
@line = Reittiopas::Routing::Line.parse(element)
|
304
|
+
end
|
305
|
+
|
306
|
+
|
307
|
+
specify { @line.line_id.should == "138" }
|
308
|
+
specify { @line.code.should == "1018 2" }
|
309
|
+
specify { @line.line_type.should == 1 }
|
310
|
+
specify { @line.mobility.should == 3 }
|
311
|
+
|
312
|
+
specify { @line.time.should == 13.000 }
|
313
|
+
specify { @line.distance.should == 5557.353 }
|
314
|
+
|
315
|
+
specify { @line.sections.should be_a(Array) }
|
316
|
+
specify { @line.stops.should be_a(Array) }
|
317
|
+
|
318
|
+
specify { @line.stops.first.arrival.date_time.should == DateTime.new(2010, 12, 13, 21, 04)}
|
319
|
+
specify { @line.stops.first.names["1"].should == "Ulvilantie 21" }
|
320
|
+
specify { @line.stops.last.names["1"].should == "Töölöntori" }
|
321
|
+
|
322
|
+
specify { @line.stops.size.should == 15}
|
323
|
+
specify { @line.sections.size.should == 15}
|
324
|
+
|
325
|
+
|
326
|
+
describe "creation" do
|
327
|
+
specify { Reittiopas::Routing::Line.new({}).stops.should == [] }
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
|
333
|
+
describe Reittiopas::Routing::Stop do
|
334
|
+
|
335
|
+
before(:all) do
|
336
|
+
doc = Nokogiri::XML(%{<STOP code="6:1304133" x="2548265.0" y="6677828.0" id="1335">
|
337
|
+
|
338
|
+
<ARRIVAL date="20101213" time="2104"/>
|
339
|
+
<DEPARTURE date="20101213" time="2104"/>
|
340
|
+
<NAME lang="1" val="Ulvilantie 21"/>
|
341
|
+
<NAME lang="2" val="Ulfsbyvägen 21"/>
|
342
|
+
</STOP>})
|
343
|
+
element = doc.elements.first
|
344
|
+
|
345
|
+
@stop = Reittiopas::Routing::Stop.parse(element)
|
346
|
+
end
|
347
|
+
|
348
|
+
specify { @stop.code.should == "6:1304133" }
|
349
|
+
specify { @stop.x.should == 2548265.0 }
|
350
|
+
specify { @stop.y.should == 6677828.0 }
|
351
|
+
specify { @stop.stop_id.should == "1335" }
|
352
|
+
|
353
|
+
specify { @stop.arrival.should be_a(Reittiopas::Routing::Arrival)}
|
354
|
+
specify { @stop.departure.should be_a(Reittiopas::Routing::Departure)}
|
355
|
+
|
356
|
+
specify { @stop.names.should == { "1" => "Ulvilantie 21",
|
357
|
+
"2" => "Ulfsbyvägen 21"}}
|
358
|
+
|
359
|
+
end
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
describe Reittiopas::Location::Coordinates::KKJ do
|
364
|
+
before(:all) do
|
365
|
+
@coordinates = Reittiopas::Location::Coordinates::KKJ.new(:x => 2541494, :y => 6680344)
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should format a routing coordinate string" do
|
369
|
+
@coordinates.to_routing_string.should == "2541494,6680344"
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
data/spec/reittiopas_spec.rb
CHANGED
@@ -125,7 +125,7 @@ describe Reittiopas::HTTP do
|
|
125
125
|
it "should create a request" do
|
126
126
|
stub_request(:get, Regexp.new(BASE_URI))
|
127
127
|
@http.get(@opts)
|
128
|
-
|
128
|
+
a_request(:get, @uri.to_s).should have_been_made
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should return response body on successful request" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
begin
|
2
|
-
require '
|
2
|
+
require 'rspec'
|
3
3
|
rescue LoadError
|
4
4
|
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
5
|
gem 'rspec'
|
6
|
-
require '
|
6
|
+
require 'rspec'
|
7
7
|
end
|
8
8
|
|
9
9
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
10
|
require 'reittiopas'
|
11
11
|
|
12
12
|
require 'webmock/rspec'
|
13
|
-
include WebMock
|
13
|
+
include WebMock::API
|
14
14
|
|
15
15
|
BASE_URI = "http://api.reittiopas.fi/public-ytv/fi/api/"
|
16
16
|
|
data/tasks/rdoc.rake
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
namespace :docs do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
1
|
+
# namespace :docs do
|
2
|
+
# desc "Publish rdoc to Github pages"
|
3
|
+
# task :publish => "docs" do
|
4
|
+
# sh 'cp doc/README_rdoc.html doc/index.html'
|
5
|
+
# sh 'cp -R doc/* .gh_pages/'
|
6
|
+
# sh 'cd .gh_pages; git add .; git commit -m "Update docs"; git push origin gh-pages'
|
7
|
+
# end
|
8
|
+
# end
|
data/tasks/rspec.rake
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
begin
|
2
|
-
require '
|
2
|
+
require 'rspec'
|
3
3
|
rescue LoadError
|
4
4
|
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
-
require '
|
5
|
+
require 'rspec'
|
6
6
|
end
|
7
7
|
begin
|
8
|
-
require '
|
8
|
+
require 'rspec/core/rake_task'
|
9
9
|
rescue LoadError
|
10
10
|
puts <<-EOS
|
11
11
|
To use rspec for testing you must install rspec gem:
|
@@ -14,16 +14,10 @@ EOS
|
|
14
14
|
exit(0)
|
15
15
|
end
|
16
16
|
|
17
|
-
desc "Run the specs under spec/models"
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
-
end
|
22
|
-
|
23
17
|
namespace :spec do
|
24
18
|
desc "Run all examples with RCov"
|
25
|
-
|
26
|
-
t.
|
19
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
20
|
+
t.pattern = 'spec/**/*_spec.rb'
|
27
21
|
t.rcov = true
|
28
22
|
t.rcov_opts = [
|
29
23
|
'--exclude', 'spec'
|
@@ -37,14 +31,14 @@ namespace :spec do
|
|
37
31
|
end
|
38
32
|
|
39
33
|
desc "Generate HTML Specdocs for all specs"
|
40
|
-
|
34
|
+
RSpec::Core::RakeTask.new(:specdoc) do |t|
|
41
35
|
specdoc_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'specdoc'))
|
42
36
|
Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
|
43
37
|
|
44
38
|
output_file = File.join(specdoc_path, 'index.html')
|
45
|
-
t.libs = %w[lib spec]
|
46
|
-
t.
|
47
|
-
t.
|
39
|
+
# t.libs = %w[lib spec]
|
40
|
+
t.pattern = 'spec/**/*_spec.rb'
|
41
|
+
t.rspec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
|
48
42
|
t.fail_on_error = false
|
49
43
|
end
|
50
44
|
end
|