anthonyw-dyno 0.0.3 → 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/README.markdown +62 -7
- data/Rakefile +4 -3
- data/VERSION.yml +2 -2
- data/lib/dyno.rb +10 -6
- data/lib/dyno/competitor.rb +36 -0
- data/lib/dyno/parsers/gtr2_parser.rb +13 -0
- data/lib/dyno/parsers/race07_parser.rb +11 -14
- data/lib/dyno/parsers/rfactor_parser.rb +138 -0
- data/spec/competitor_spec.rb +59 -4
- data/spec/fixtures/gtr2/full.ini +0 -0
- data/spec/fixtures/gtr2/header_no_track.ini +0 -0
- data/spec/fixtures/gtr2/header_only.ini +0 -0
- data/spec/fixtures/gtr2/no_header_section.ini +0 -0
- data/spec/fixtures/gtr2/single_driver.ini +0 -0
- data/spec/fixtures/race07/single_driver_dnf.ini +34 -0
- data/spec/fixtures/race07/single_driver_dsq.ini +34 -0
- data/spec/fixtures/{race07/readme.markdown → readme.markdown} +2 -2
- data/spec/fixtures/rfactor/arca.xml +187 -0
- data/spec/fixtures/rfactor/event_only.xml +43 -0
- data/spec/fixtures/rfactor/full.xml +1023 -0
- data/spec/fixtures/rfactor/missing_root.xml +6 -0
- data/spec/fixtures/rfactor/single_driver.xml +85 -0
- data/spec/fixtures/rfactor/single_driver_dnf.xml +80 -0
- data/spec/fixtures/rfactor/single_driver_dsq.xml +79 -0
- data/spec/parsers/gtr2_parser_spec.rb +199 -0
- data/spec/parsers/race07_parser_spec.rb +13 -1
- data/spec/parsers/rfactor_parser_spec.rb +158 -0
- metadata +23 -3
- data/MIT-LICENSE +0 -19
@@ -25,7 +25,7 @@ describe Dyno::Parsers::Race07Parser do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should set the game' do
|
28
|
-
@event.game.should == '
|
28
|
+
@event.game.should == 'RACE 07'
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should correctly set the game version' do
|
@@ -139,5 +139,17 @@ describe Dyno::Parsers::Race07Parser do
|
|
139
139
|
event.competitors[4].name.should == 'Reino Lintula'
|
140
140
|
event.competitors[4].position.should == 5
|
141
141
|
end
|
142
|
+
|
143
|
+
it 'should set a competitor as "did not finish" when necessary' do
|
144
|
+
Dyno::Parsers::Race07Parser.parse_file(
|
145
|
+
'spec/fixtures/race07/single_driver_dnf.ini'
|
146
|
+
).competitors[0].should be_dnf
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should set a competitor as "disqualified" when necessary' do
|
150
|
+
Dyno::Parsers::Race07Parser.parse_file(
|
151
|
+
'spec/fixtures/race07/single_driver_dsq.ini'
|
152
|
+
).competitors[0].should be_dsq
|
153
|
+
end
|
142
154
|
end
|
143
155
|
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), '..', 'spec_helper' )
|
2
|
+
|
3
|
+
describe Dyno::Parsers::RFactorParser do
|
4
|
+
|
5
|
+
it 'should respond to .parse' do
|
6
|
+
Dyno::Parsers::RFactorParser.should respond_to(:parse)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should respond to .parse_file' do
|
10
|
+
Dyno::Parsers::RFactorParser.should respond_to(:parse_file)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should respond to #parse' do
|
14
|
+
Dyno::Parsers::RFactorParser.public_instance_methods.should include('parse')
|
15
|
+
end
|
16
|
+
|
17
|
+
# --------------
|
18
|
+
# Event parsing.
|
19
|
+
|
20
|
+
describe 'parse_event!' do
|
21
|
+
before(:all) do
|
22
|
+
@event = Dyno::Parsers::RFactorParser.parse_file(
|
23
|
+
'spec/fixtures/rfactor/event_only.xml'
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should set the game' do
|
28
|
+
@event.game.should == 'JF3 2007'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should correctly set the game version' do
|
32
|
+
# 1.255
|
33
|
+
@event.game_version.should == '1.255'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should correctly set the event time' do
|
37
|
+
# 2008/12/21 21:56:13
|
38
|
+
@event.time.should == Time.local(2008, 12, 21, 21, 56, 13)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should correctly set the track' do
|
42
|
+
@event.track.should == 'Suzuka 2005'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should whine loudly if there is no "RaceResults" node' do
|
46
|
+
lambda {
|
47
|
+
Dyno::Parsers::RFactorParser.parse_file(
|
48
|
+
'spec/fixtures/rfactor/missing_root.xml'
|
49
|
+
)
|
50
|
+
}.should raise_error(Dyno::MalformedInputError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# -------------------
|
55
|
+
# Competitor parsing.
|
56
|
+
|
57
|
+
describe 'parse_competitors!' do
|
58
|
+
before(:all) do
|
59
|
+
@event = Dyno::Parsers::RFactorParser.parse_file(
|
60
|
+
'spec/fixtures/rfactor/single_driver.xml'
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should set the driver name correctly' do
|
65
|
+
@event.competitors.first.name.should == 'Zach Evans'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should set the vehicle correctly' do
|
69
|
+
@event.competitors.first.vehicle.should == 'JF3 2007'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should set the lap count correctly' do
|
73
|
+
@event.competitors.first.laps.should == 17
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should convert the race time to a float' do
|
77
|
+
@event.competitors.first.race_time.should == 2049.6411
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should convert the best lap time to a float' do
|
81
|
+
@event.competitors.first.best_lap.should == 119.3561
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should correctly set the competitors lap times" do
|
85
|
+
@event.competitors.first.lap_times.should == [
|
86
|
+
130.5218, # <Lap num="1" [...] >130.5218</Lap>
|
87
|
+
119.7023, # <Lap num="2" [...] >119.7023</Lap>
|
88
|
+
120.2195, # <Lap num="3" [...] >120.2195</Lap>
|
89
|
+
119.6123, # <Lap num="4" [...] >119.6123</Lap>
|
90
|
+
120.2735, # <Lap num="5" [...] >120.2735</Lap>
|
91
|
+
119.6417, # <Lap num="6" [...] >119.6417</Lap>
|
92
|
+
119.6810, # <Lap num="7" [...] >119.6810</Lap>
|
93
|
+
119.9735, # <Lap num="8" [...] >119.9735</Lap>
|
94
|
+
120.0426, # <Lap num="9" [...] >120.0426</Lap>
|
95
|
+
120.0213, # <Lap num="10" [...] >120.0213</Lap>
|
96
|
+
120.5605, # <Lap num="11" [...] >120.5605</Lap>
|
97
|
+
119.3561, # <Lap num="12" [...] >119.3561</Lap>
|
98
|
+
120.2949, # <Lap num="13" [...] >120.2949</Lap>
|
99
|
+
120.5171, # <Lap num="14" [...] >120.5171</Lap>
|
100
|
+
120.1576, # <Lap num="15" [...] >120.1576</Lap>
|
101
|
+
119.3593, # <Lap num="16" [...] >119.3593</Lap>
|
102
|
+
119.7063 # <Lap num="17" [...] >119.7063</Lap>
|
103
|
+
]
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should correctly sort drivers by their finishing time, and assign their position' do
|
107
|
+
event = Dyno::Parsers::RFactorParser.parse_file(
|
108
|
+
'spec/fixtures/rfactor/full.xml'
|
109
|
+
)
|
110
|
+
|
111
|
+
[ [ "Zach Evans", 1 ],
|
112
|
+
[ "Archie Gray", 2 ],
|
113
|
+
[ "Jonathan Mistry", 3 ],
|
114
|
+
[ "Sjef Petersen", 4 ],
|
115
|
+
[ "Topi Keskinen", 5 ],
|
116
|
+
[ "Evan Hanson", 6 ],
|
117
|
+
[ "Tom M. Hall", 7 ],
|
118
|
+
[ "Oliver Baker", 8 ],
|
119
|
+
[ "Jamie Norman", 9 ],
|
120
|
+
[ "Haruaki Gotou", 10 ],
|
121
|
+
[ "Hiromitsu Kishimoto", 11 ],
|
122
|
+
[ "Edgar Est\303\251vez Guajardo", 12 ],
|
123
|
+
[ "Sabahudin Smerkolj", 13 ]
|
124
|
+
].each do |(name, position)|
|
125
|
+
event.competitors[position - 1].name.should == name
|
126
|
+
event.competitors[position - 1].position.should == position
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should set a competitor as "did not finish" when necessary' do
|
131
|
+
Dyno::Parsers::RFactorParser.parse_file(
|
132
|
+
'spec/fixtures/rfactor/single_driver_dnf.xml'
|
133
|
+
).competitors.first.should be_dnf
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should set a competitor as "disqualified" when necessary' do
|
137
|
+
Dyno::Parsers::RFactorParser.parse_file(
|
138
|
+
'spec/fixtures/rfactor/single_driver_dsq.xml'
|
139
|
+
).competitors.first.should be_dsq
|
140
|
+
end
|
141
|
+
|
142
|
+
describe 'when parsing ARCA results' do
|
143
|
+
it 'should not raise an error' do
|
144
|
+
lambda{
|
145
|
+
Dyno::Parsers::RFactorParser.parse_file(
|
146
|
+
'spec/fixtures/rfactor/arca.xml'
|
147
|
+
)
|
148
|
+
}.should_not raise_error
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should have the correct number of competitors' do
|
152
|
+
Dyno::Parsers::RFactorParser.parse_file(
|
153
|
+
'spec/fixtures/rfactor/arca.xml'
|
154
|
+
).competitors.size.should == 3
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anthonyw-dyno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Williams
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-21 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,21 +39,41 @@ files:
|
|
39
39
|
- lib/dyno/competitor.rb
|
40
40
|
- lib/dyno/event.rb
|
41
41
|
- lib/dyno/parsers
|
42
|
+
- lib/dyno/parsers/gtr2_parser.rb
|
42
43
|
- lib/dyno/parsers/race07_parser.rb
|
44
|
+
- lib/dyno/parsers/rfactor_parser.rb
|
43
45
|
- lib/dyno.rb
|
44
46
|
- spec/competitor_spec.rb
|
45
47
|
- spec/event_spec.rb
|
46
48
|
- spec/fixtures
|
49
|
+
- spec/fixtures/gtr2
|
50
|
+
- spec/fixtures/gtr2/full.ini
|
51
|
+
- spec/fixtures/gtr2/header_no_track.ini
|
52
|
+
- spec/fixtures/gtr2/header_only.ini
|
53
|
+
- spec/fixtures/gtr2/no_header_section.ini
|
54
|
+
- spec/fixtures/gtr2/single_driver.ini
|
47
55
|
- spec/fixtures/race07
|
48
56
|
- spec/fixtures/race07/full.ini
|
49
57
|
- spec/fixtures/race07/header_no_track.ini
|
50
58
|
- spec/fixtures/race07/header_only.ini
|
51
59
|
- spec/fixtures/race07/no_header_section.ini
|
52
60
|
- spec/fixtures/race07/no_steam_id.ini
|
53
|
-
- spec/fixtures/race07/readme.markdown
|
54
61
|
- spec/fixtures/race07/single_driver.ini
|
62
|
+
- spec/fixtures/race07/single_driver_dnf.ini
|
63
|
+
- spec/fixtures/race07/single_driver_dsq.ini
|
64
|
+
- spec/fixtures/readme.markdown
|
65
|
+
- spec/fixtures/rfactor
|
66
|
+
- spec/fixtures/rfactor/arca.xml
|
67
|
+
- spec/fixtures/rfactor/event_only.xml
|
68
|
+
- spec/fixtures/rfactor/full.xml
|
69
|
+
- spec/fixtures/rfactor/missing_root.xml
|
70
|
+
- spec/fixtures/rfactor/single_driver.xml
|
71
|
+
- spec/fixtures/rfactor/single_driver_dnf.xml
|
72
|
+
- spec/fixtures/rfactor/single_driver_dsq.xml
|
55
73
|
- spec/parsers
|
74
|
+
- spec/parsers/gtr2_parser_spec.rb
|
56
75
|
- spec/parsers/race07_parser_spec.rb
|
76
|
+
- spec/parsers/rfactor_parser_spec.rb
|
57
77
|
- spec/spec_helper.rb
|
58
78
|
has_rdoc: true
|
59
79
|
homepage: http://github.com/anthonyw/dyno
|
data/MIT-LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2008 Anthony Williams
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
11
|
-
copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
SOFTWARE.
|