antw-dyno 0.1.2
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/LICENSE +19 -0
- data/README.markdown +68 -0
- data/Rakefile +45 -0
- data/VERSION.yml +4 -0
- data/lib/dyno.rb +22 -0
- data/lib/dyno/competitor.rb +55 -0
- data/lib/dyno/event.rb +16 -0
- data/lib/dyno/parsers/gtr2_parser.rb +13 -0
- data/lib/dyno/parsers/race07_parser.rb +130 -0
- data/lib/dyno/parsers/rfactor_parser.rb +138 -0
- data/spec/competitor_spec.rb +129 -0
- data/spec/event_spec.rb +59 -0
- 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/full.ini +131 -0
- data/spec/fixtures/race07/header_no_track.ini +11 -0
- data/spec/fixtures/race07/header_only.ini +12 -0
- data/spec/fixtures/race07/no_header_section.ini +6 -0
- data/spec/fixtures/race07/no_steam_id.ini +37 -0
- data/spec/fixtures/race07/single_driver.ini +37 -0
- data/spec/fixtures/race07/single_driver_dnf.ini +34 -0
- data/spec/fixtures/race07/single_driver_dsq.ini +34 -0
- data/spec/fixtures/readme.markdown +5 -0
- 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 +155 -0
- data/spec/parsers/rfactor_parser_spec.rb +158 -0
- data/spec/spec_helper.rb +3 -0
- metadata +107 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Dyno::Competitor do
|
4
|
+
before(:each) do
|
5
|
+
@competitor = Dyno::Competitor.new("Jake Lucas")
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have a +name+ accessor' do
|
9
|
+
@competitor.should respond_to(:name)
|
10
|
+
@competitor.should respond_to(:name=)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have a +uid+ accessor' do
|
14
|
+
@competitor.should respond_to(:uid)
|
15
|
+
@competitor.should respond_to(:uid=)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have a +position+ accessor' do
|
19
|
+
@competitor.should respond_to(:position)
|
20
|
+
@competitor.should respond_to(:position=)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have a +vehicle+ accessor' do
|
24
|
+
@competitor.should respond_to(:vehicle)
|
25
|
+
@competitor.should respond_to(:vehicle=)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have a +laps+ accessor' do
|
29
|
+
@competitor.should respond_to(:laps)
|
30
|
+
@competitor.should respond_to(:laps=)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have a +race_time+ accessor' do
|
34
|
+
@competitor.should respond_to(:race_time)
|
35
|
+
@competitor.should respond_to(:race_time=)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should have a +best_lap+ accessor' do
|
39
|
+
@competitor.should respond_to(:best_lap)
|
40
|
+
@competitor.should respond_to(:best_lap=)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should respond_to #finished?' do
|
44
|
+
@competitor.should respond_to(:finished?)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should respond_to #dnf?' do
|
48
|
+
@competitor.should respond_to(:dnf?)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should respond_to #dsq?' do
|
52
|
+
@competitor.should respond_to(:dsq?)
|
53
|
+
end
|
54
|
+
|
55
|
+
# ----------
|
56
|
+
# initialize
|
57
|
+
|
58
|
+
it 'should use the given values when creating a Event' do
|
59
|
+
properties = {
|
60
|
+
:uid => 1337,
|
61
|
+
:position => 3,
|
62
|
+
:vehicle => "BMW 320si E90 2007",
|
63
|
+
:laps => 13,
|
64
|
+
:race_time => "0:21:31.183",
|
65
|
+
:best_lap => "1:37.960"
|
66
|
+
}
|
67
|
+
|
68
|
+
competitor = Dyno::Competitor.new("Jake Lucas", properties)
|
69
|
+
competitor.name.should == "Jake Lucas"
|
70
|
+
|
71
|
+
properties.each do |prop, value|
|
72
|
+
competitor.send(prop).should == value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should require that a name be supplied' do
|
77
|
+
lambda { Dyno::Competitor.new }.should raise_error(ArgumentError)
|
78
|
+
end
|
79
|
+
|
80
|
+
# ---------------------------------
|
81
|
+
# finished / dnf / disqualification
|
82
|
+
|
83
|
+
describe 'when the competitor finished the event' do
|
84
|
+
it 'should return true to #finished?' do
|
85
|
+
@competitor.should be_finished
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should return false to #dnf?' do
|
89
|
+
@competitor.should_not be_dnf
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should return false to #dsq?' do
|
93
|
+
@competitor.should_not be_dsq
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'when the competitor did not finish' do
|
98
|
+
before { @competitor.dnf! }
|
99
|
+
|
100
|
+
it 'should return false to #finished?' do
|
101
|
+
@competitor.should_not be_finished
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return true to #dnf?' do
|
105
|
+
@competitor.should be_dnf
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should return false to #dsq?' do
|
109
|
+
@competitor.should_not be_dsq
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'when the competitor was disqualified' do
|
114
|
+
before { @competitor.dsq! }
|
115
|
+
|
116
|
+
it 'should return false to #finished?' do
|
117
|
+
@competitor.should_not be_finished
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should return false to #dnf?' do
|
121
|
+
@competitor.should_not be_dnf
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should return true to #dsq?' do
|
125
|
+
@competitor.should be_dsq
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
data/spec/event_spec.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Dyno::Event do
|
4
|
+
before(:all) do
|
5
|
+
@event = Dyno::Event.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have a +time+ accessor' do
|
9
|
+
@event.should respond_to(:time)
|
10
|
+
@event.should respond_to(:time=)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have a +track+ accessor' do
|
14
|
+
@event.should respond_to(:track)
|
15
|
+
@event.should respond_to(:track=)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have a +game+ accessor' do
|
19
|
+
@event.should respond_to(:game)
|
20
|
+
@event.should respond_to(:game=)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have a +game_version+ accessor' do
|
24
|
+
@event.should respond_to(:game_version)
|
25
|
+
@event.should respond_to(:game_version=)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have a +competitors+ accessor' do
|
29
|
+
@event.should respond_to(:competitors)
|
30
|
+
@event.should respond_to(:competitors=)
|
31
|
+
end
|
32
|
+
|
33
|
+
# -----------
|
34
|
+
# #initialize
|
35
|
+
|
36
|
+
it 'should use the given values when creating a Event' do
|
37
|
+
event = Dyno::Event.new(
|
38
|
+
:time => Time.now - 10,
|
39
|
+
:track => "Anderstorp 2007",
|
40
|
+
:game => "Event 07",
|
41
|
+
:game_version => "1.1.1.14",
|
42
|
+
:competitors => [1]
|
43
|
+
)
|
44
|
+
|
45
|
+
event.time.should be_close(Time.now - 10, 0.5)
|
46
|
+
event.track.should == "Anderstorp 2007"
|
47
|
+
event.game.should == "Event 07"
|
48
|
+
event.game_version.should == "1.1.1.14"
|
49
|
+
event.competitors.should == [1]
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should set a default time if none is given' do
|
53
|
+
Dyno::Event.new.time.should be_close(Time.now, 1)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should default competitors to [] if none are given' do
|
57
|
+
Dyno::Event.new.competitors.should == []
|
58
|
+
end
|
59
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,131 @@
|
|
1
|
+
[Header]
|
2
|
+
Game=RACE 07
|
3
|
+
Version=1.1.1.14
|
4
|
+
TimeString=2008/09/13 23:26:32
|
5
|
+
Aids=0,0,0,0,0,1,1,0,0
|
6
|
+
|
7
|
+
[Race]
|
8
|
+
RaceMode=5
|
9
|
+
Scene=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.TRK
|
10
|
+
AIDB=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.AIW
|
11
|
+
Race Length=0.100
|
12
|
+
Track Length=4018.8376
|
13
|
+
|
14
|
+
[Slot010]
|
15
|
+
Driver=Mark Voss
|
16
|
+
SteamUser=mvoss
|
17
|
+
SteamId=1865369
|
18
|
+
Vehicle=Chevrolet Lacetti 2007
|
19
|
+
Team=TEMPLATE_TEAM
|
20
|
+
QualTime=1:37.839
|
21
|
+
Laps=13
|
22
|
+
Lap=(0, -1.000, 1:48.697)
|
23
|
+
Lap=(1, 89.397, 1:39.455)
|
24
|
+
Lap=(2, 198.095, 1:38.060)
|
25
|
+
Lap=(3, 297.550, 1:38.632)
|
26
|
+
Lap=(4, 395.610, 1:38.031)
|
27
|
+
Lap=(5, 494.242, 1:39.562)
|
28
|
+
Lap=(6, 592.273, 1:39.950)
|
29
|
+
Lap=(7, 691.835, 1:38.366)
|
30
|
+
Lap=(8, 791.785, 1:39.889)
|
31
|
+
Lap=(9, 890.151, 1:39.420)
|
32
|
+
Lap=(10, 990.040, 1:39.401)
|
33
|
+
Lap=(11, 1089.460, 1:39.506)
|
34
|
+
Lap=(12, 1188.862, 1:40.017)
|
35
|
+
LapDistanceTravelled=3857.750244
|
36
|
+
BestLap=1:38.031
|
37
|
+
RaceTime=0:21:38.988
|
38
|
+
|
39
|
+
[Slot016]
|
40
|
+
Driver=Corey Ball
|
41
|
+
SteamUser=cball
|
42
|
+
SteamId=889853
|
43
|
+
Vehicle=SEAT Leon 2007
|
44
|
+
Team=TEMPLATE_TEAM
|
45
|
+
QualTime=1:37.904
|
46
|
+
Laps=9
|
47
|
+
Lap=(0, -1.000, 1:51.434)
|
48
|
+
Lap=(1, 89.397, 1:39.427)
|
49
|
+
Lap=(2, 200.831, 1:38.394)
|
50
|
+
Lap=(3, 300.258, 1:40.239)
|
51
|
+
Lap=(4, 398.653, 1:38.172)
|
52
|
+
Lap=(5, 498.891, 1:38.427)
|
53
|
+
Lap=(6, 597.063, 1:39.271)
|
54
|
+
Lap=(7, 695.490, 1:39.922)
|
55
|
+
Lap=(8, 794.761, 1:40.305)
|
56
|
+
LapDistanceTravelled=532.898193
|
57
|
+
BestLap=1:38.172
|
58
|
+
RaceTime=DNF
|
59
|
+
Reason=0
|
60
|
+
|
61
|
+
[Slot013]
|
62
|
+
Driver=Gabriel Lloyd
|
63
|
+
SteamUser=glloyd
|
64
|
+
SteamId=635
|
65
|
+
Vehicle=Chevrolet Lacetti 2007
|
66
|
+
Team=TEMPLATE_TEAM
|
67
|
+
QualTime=1:36.607
|
68
|
+
Laps=13
|
69
|
+
Lap=(0, -1.000, 1:50.816)
|
70
|
+
Lap=(1, 89.397, 1:38.835)
|
71
|
+
Lap=(2, 200.213, 1:38.082)
|
72
|
+
Lap=(3, 299.048, 1:38.367)
|
73
|
+
Lap=(4, 397.131, 1:37.825)
|
74
|
+
Lap=(5, 495.497, 1:38.757)
|
75
|
+
Lap=(6, 593.322, 1:38.718)
|
76
|
+
Lap=(7, 692.080, 1:38.478)
|
77
|
+
Lap=(8, 790.797, 1:39.347)
|
78
|
+
Lap=(9, 889.275, 1:38.713)
|
79
|
+
Lap=(10, 988.622, 1:38.952)
|
80
|
+
Lap=(11, 1087.336, 1:39.285)
|
81
|
+
Lap=(12, 1186.288, 1:40.555)
|
82
|
+
LapDistanceTravelled=3898.517578
|
83
|
+
BestLap=1:37.825
|
84
|
+
RaceTime=0:21:36.730
|
85
|
+
|
86
|
+
[Slot018]
|
87
|
+
Driver=Reino Lintula
|
88
|
+
SteamUser=rlintula
|
89
|
+
SteamId=1816
|
90
|
+
Vehicle=SEAT Leon 2007
|
91
|
+
Team=TEMPLATE_TEAM
|
92
|
+
QualTime=1:39.602
|
93
|
+
Laps=7
|
94
|
+
Lap=(0, -1.000, 1:52.788)
|
95
|
+
Lap=(1, 112.593, 1:39.346)
|
96
|
+
Lap=(2, 225.381, 1:40.680)
|
97
|
+
Lap=(3, 324.727, 1:38.775)
|
98
|
+
Lap=(4, 425.407, 1:40.149)
|
99
|
+
Lap=(5, 524.182, 1:41.551)
|
100
|
+
Lap=(6, 624.331, 1:46.908)
|
101
|
+
LapDistanceTravelled=1333.551270
|
102
|
+
BestLap=1:38.775
|
103
|
+
RaceTime=DNF
|
104
|
+
Reason=0
|
105
|
+
|
106
|
+
[Slot002]
|
107
|
+
Driver=Jerry Lalich
|
108
|
+
SteamUser=jlalich
|
109
|
+
SteamId=236892
|
110
|
+
Vehicle=Chevrolet Lacetti 2007
|
111
|
+
Team=TEMPLATE_TEAM
|
112
|
+
QualTime=1:38.081
|
113
|
+
Laps=13
|
114
|
+
Lap=(0, -1.000, 1:48.530)
|
115
|
+
Lap=(1, 89.397, 1:39.213)
|
116
|
+
Lap=(2, 197.927, 1:37.933)
|
117
|
+
Lap=(3, 297.140, 1:37.717)
|
118
|
+
Lap=(4, 395.073, 1:38.500)
|
119
|
+
Lap=(5, 492.790, 1:38.641)
|
120
|
+
Lap=(6, 591.290, 1:39.810)
|
121
|
+
Lap=(7, 689.931, 1:39.177)
|
122
|
+
Lap=(8, 789.742, 1:40.122)
|
123
|
+
Lap=(9, 888.918, 1:38.928)
|
124
|
+
Lap=(10, 989.040, 1:39.238)
|
125
|
+
Lap=(11, 1087.968, 1:39.223)
|
126
|
+
Lap=(12, 1187.206, 1:39.888)
|
127
|
+
LapDistanceTravelled=3892.720215
|
128
|
+
BestLap=1:37.717
|
129
|
+
RaceTime=0:21:36.920
|
130
|
+
|
131
|
+
[END]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
[Header]
|
2
|
+
Game=RACE 07
|
3
|
+
Version=1.1.1.14
|
4
|
+
TimeString=2008/09/13 23:00:50
|
5
|
+
Aids=0,0,0,0,0,1,1,0,0
|
6
|
+
|
7
|
+
[Race]
|
8
|
+
RaceMode=5
|
9
|
+
Scene=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.TRK
|
10
|
+
AIDB=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.AIW
|
11
|
+
Race Length=0.100
|
12
|
+
Track Length=4018.8376
|
@@ -0,0 +1,37 @@
|
|
1
|
+
[Header]
|
2
|
+
Game=RACE 07
|
3
|
+
Version=1.1.1.14
|
4
|
+
TimeString=2008/09/13 23:26:32
|
5
|
+
Aids=0,0,0,0,0,1,1,0,0
|
6
|
+
|
7
|
+
[Race]
|
8
|
+
RaceMode=5
|
9
|
+
Scene=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.TRK
|
10
|
+
AIDB=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.AIW
|
11
|
+
Race Length=0.100
|
12
|
+
Track Length=4018.8376
|
13
|
+
|
14
|
+
[Slot013]
|
15
|
+
Driver=Gabriel Lloyd
|
16
|
+
SteamUser=
|
17
|
+
SteamId=
|
18
|
+
Vehicle=Chevrolet Lacetti 2007
|
19
|
+
Team=TEMPLATE_TEAM
|
20
|
+
QualTime=1:36.607
|
21
|
+
Laps=13
|
22
|
+
Lap=(0, -1.000, 1:50.816)
|
23
|
+
Lap=(1, 89.397, 1:38.835)
|
24
|
+
Lap=(2, 200.213, 1:38.082)
|
25
|
+
Lap=(3, 299.048, 1:38.367)
|
26
|
+
Lap=(4, 397.131, 1:37.825)
|
27
|
+
Lap=(5, 495.497, 1:38.757)
|
28
|
+
Lap=(6, 593.322, 1:38.718)
|
29
|
+
Lap=(7, 692.080, 1:38.478)
|
30
|
+
Lap=(8, 790.797, 1:39.347)
|
31
|
+
Lap=(9, 889.275, 1:38.713)
|
32
|
+
Lap=(10, 988.622, 1:38.952)
|
33
|
+
Lap=(11, 1087.336, 1:39.285)
|
34
|
+
Lap=(12, 1186.288, 1:40.555)
|
35
|
+
LapDistanceTravelled=3898.517578
|
36
|
+
BestLap=1:37.825
|
37
|
+
RaceTime=0:21:36.730
|
@@ -0,0 +1,37 @@
|
|
1
|
+
[Header]
|
2
|
+
Game=RACE 07
|
3
|
+
Version=1.1.1.14
|
4
|
+
TimeString=2008/09/13 23:26:32
|
5
|
+
Aids=0,0,0,0,0,1,1,0,0
|
6
|
+
|
7
|
+
[Race]
|
8
|
+
RaceMode=5
|
9
|
+
Scene=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.TRK
|
10
|
+
AIDB=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.AIW
|
11
|
+
Race Length=0.100
|
12
|
+
Track Length=4018.8376
|
13
|
+
|
14
|
+
[Slot013]
|
15
|
+
Driver=Gabriel Lloyd
|
16
|
+
SteamUser=glloyd
|
17
|
+
SteamId=635
|
18
|
+
Vehicle=Chevrolet Lacetti 2007
|
19
|
+
Team=TEMPLATE_TEAM
|
20
|
+
QualTime=1:36.607
|
21
|
+
Laps=13
|
22
|
+
Lap=(0, -1.000, 1:50.816)
|
23
|
+
Lap=(1, 89.397, 1:38.835)
|
24
|
+
Lap=(2, 200.213, 1:38.082)
|
25
|
+
Lap=(3, 299.048, 1:38.367)
|
26
|
+
Lap=(4, 397.131, 1:37.825)
|
27
|
+
Lap=(5, 495.497, 1:38.757)
|
28
|
+
Lap=(6, 593.322, 1:38.718)
|
29
|
+
Lap=(7, 692.080, 1:38.478)
|
30
|
+
Lap=(8, 790.797, 1:39.347)
|
31
|
+
Lap=(9, 889.275, 1:38.713)
|
32
|
+
Lap=(10, 988.622, 1:38.952)
|
33
|
+
Lap=(11, 1087.336, 1:39.285)
|
34
|
+
Lap=(12, 1186.288, 1:40.555)
|
35
|
+
LapDistanceTravelled=3898.517578
|
36
|
+
BestLap=1:37.825
|
37
|
+
RaceTime=0:21:36.730
|
@@ -0,0 +1,34 @@
|
|
1
|
+
[Header]
|
2
|
+
Game=RACE 07
|
3
|
+
Version=1.1.1.14
|
4
|
+
TimeString=2008/09/13 23:26:32
|
5
|
+
Aids=0,0,0,0,0,1,1,0,0
|
6
|
+
|
7
|
+
[Race]
|
8
|
+
RaceMode=5
|
9
|
+
Scene=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.TRK
|
10
|
+
AIDB=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.AIW
|
11
|
+
Race Length=0.100
|
12
|
+
Track Length=4018.8376
|
13
|
+
|
14
|
+
[Slot016]
|
15
|
+
Driver=Corey Ball
|
16
|
+
SteamUser=cball
|
17
|
+
SteamId=889853
|
18
|
+
Vehicle=SEAT Leon 2007
|
19
|
+
Team=TEMPLATE_TEAM
|
20
|
+
QualTime=1:37.904
|
21
|
+
Laps=9
|
22
|
+
Lap=(0, -1.000, 1:51.434)
|
23
|
+
Lap=(1, 89.397, 1:39.427)
|
24
|
+
Lap=(2, 200.831, 1:38.394)
|
25
|
+
Lap=(3, 300.258, 1:40.239)
|
26
|
+
Lap=(4, 398.653, 1:38.172)
|
27
|
+
Lap=(5, 498.891, 1:38.427)
|
28
|
+
Lap=(6, 597.063, 1:39.271)
|
29
|
+
Lap=(7, 695.490, 1:39.922)
|
30
|
+
Lap=(8, 794.761, 1:40.305)
|
31
|
+
LapDistanceTravelled=532.898193
|
32
|
+
BestLap=1:38.172
|
33
|
+
RaceTime=DNF
|
34
|
+
Reason=0
|