iniparse 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,133 @@
1
+ ; All names and Steam IDs changed to fake values.
2
+
3
+ [Header]
4
+ Game=RACE 07
5
+ Version=1.1.1.14
6
+ TimeString=2008/09/13 23:26:32
7
+ Aids=0,0,0,0,0,1,1,0,0
8
+
9
+ [Race]
10
+ RaceMode=5
11
+ Scene=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.TRK
12
+ AIDB=GameData\Locations\Anderstorp_2007\2007_ANDERSTORP.AIW
13
+ Race Length=0.100
14
+ Track Length=4018.8376
15
+
16
+ [Slot010]
17
+ Driver=Mark Voss
18
+ SteamUser=mvoss
19
+ SteamId=1865369
20
+ Vehicle=Chevrolet Lacetti 2007
21
+ Team=TEMPLATE_TEAM
22
+ QualTime=1:37.839
23
+ Laps=13
24
+ Lap=(0, -1.000, 1:48.697)
25
+ Lap=(1, 89.397, 1:39.455)
26
+ Lap=(2, 198.095, 1:38.060)
27
+ Lap=(3, 297.550, 1:38.632)
28
+ Lap=(4, 395.610, 1:38.031)
29
+ Lap=(5, 494.242, 1:39.562)
30
+ Lap=(6, 592.273, 1:39.950)
31
+ Lap=(7, 691.835, 1:38.366)
32
+ Lap=(8, 791.785, 1:39.889)
33
+ Lap=(9, 890.151, 1:39.420)
34
+ Lap=(10, 990.040, 1:39.401)
35
+ Lap=(11, 1089.460, 1:39.506)
36
+ Lap=(12, 1188.862, 1:40.017)
37
+ LapDistanceTravelled=3857.750244
38
+ BestLap=1:38.031
39
+ RaceTime=0:21:38.988
40
+
41
+ [Slot016]
42
+ Driver=Corey Ball
43
+ SteamUser=cball
44
+ SteamId=889853
45
+ Vehicle=SEAT Leon 2007
46
+ Team=TEMPLATE_TEAM
47
+ QualTime=1:37.904
48
+ Laps=9
49
+ Lap=(0, -1.000, 1:51.434)
50
+ Lap=(1, 89.397, 1:39.427)
51
+ Lap=(2, 200.831, 1:38.394)
52
+ Lap=(3, 300.258, 1:40.239)
53
+ Lap=(4, 398.653, 1:38.172)
54
+ Lap=(5, 498.891, 1:38.427)
55
+ Lap=(6, 597.063, 1:39.271)
56
+ Lap=(7, 695.490, 1:39.922)
57
+ Lap=(8, 794.761, 1:40.305)
58
+ LapDistanceTravelled=532.898193
59
+ BestLap=1:38.172
60
+ RaceTime=DNF
61
+ Reason=0
62
+
63
+ [Slot013]
64
+ Driver=Gabriel Lloyd
65
+ SteamUser=glloyd
66
+ SteamId=635
67
+ Vehicle=Chevrolet Lacetti 2007
68
+ Team=TEMPLATE_TEAM
69
+ QualTime=1:36.607
70
+ Laps=13
71
+ Lap=(0, -1.000, 1:50.816)
72
+ Lap=(1, 89.397, 1:38.835)
73
+ Lap=(2, 200.213, 1:38.082)
74
+ Lap=(3, 299.048, 1:38.367)
75
+ Lap=(4, 397.131, 1:37.825)
76
+ Lap=(5, 495.497, 1:38.757)
77
+ Lap=(6, 593.322, 1:38.718)
78
+ Lap=(7, 692.080, 1:38.478)
79
+ Lap=(8, 790.797, 1:39.347)
80
+ Lap=(9, 889.275, 1:38.713)
81
+ Lap=(10, 988.622, 1:38.952)
82
+ Lap=(11, 1087.336, 1:39.285)
83
+ Lap=(12, 1186.288, 1:40.555)
84
+ LapDistanceTravelled=3898.517578
85
+ BestLap=1:37.825
86
+ RaceTime=0:21:36.730
87
+
88
+ [Slot018]
89
+ Driver=Reino Lintula
90
+ SteamUser=rlintula
91
+ SteamId=1816
92
+ Vehicle=SEAT Leon 2007
93
+ Team=TEMPLATE_TEAM
94
+ QualTime=1:39.602
95
+ Laps=7
96
+ Lap=(0, -1.000, 1:52.788)
97
+ Lap=(1, 112.593, 1:39.346)
98
+ Lap=(2, 225.381, 1:40.680)
99
+ Lap=(3, 324.727, 1:38.775)
100
+ Lap=(4, 425.407, 1:40.149)
101
+ Lap=(5, 524.182, 1:41.551)
102
+ Lap=(6, 624.331, 1:46.908)
103
+ LapDistanceTravelled=1333.551270
104
+ BestLap=1:38.775
105
+ RaceTime=DNF
106
+ Reason=0
107
+
108
+ [Slot002]
109
+ Driver=Jerry Lalich
110
+ SteamUser=jlalich
111
+ SteamId=236892
112
+ Vehicle=Chevrolet Lacetti 2007
113
+ Team=TEMPLATE_TEAM
114
+ QualTime=1:38.081
115
+ Laps=13
116
+ Lap=(0, -1.000, 1:48.530)
117
+ Lap=(1, 89.397, 1:39.213)
118
+ Lap=(2, 197.927, 1:37.933)
119
+ Lap=(3, 297.140, 1:37.717)
120
+ Lap=(4, 395.073, 1:38.500)
121
+ Lap=(5, 492.790, 1:38.641)
122
+ Lap=(6, 591.290, 1:39.810)
123
+ Lap=(7, 689.931, 1:39.177)
124
+ Lap=(8, 789.742, 1:40.122)
125
+ Lap=(9, 888.918, 1:38.928)
126
+ Lap=(10, 989.040, 1:39.238)
127
+ Lap=(11, 1087.968, 1:39.223)
128
+ Lap=(12, 1187.206, 1:39.888)
129
+ LapDistanceTravelled=3892.720215
130
+ BestLap=1:37.717
131
+ RaceTime=0:21:36.920
132
+
133
+ [END]
@@ -0,0 +1,102 @@
1
+ ; Configuration file for the Samba software suite.
2
+ ; ============================================================================
3
+ ;
4
+ ; For the format of this file and comprehensive descriptions of all the
5
+ ; configuration option, please refer to the man page for smb.conf(5).
6
+ ;
7
+ ; The following configuration should suit most systems for basic usage and
8
+ ; initial testing. It gives all clients access to their home directories and
9
+ ; allows access to all printers specified in /etc/printcap.
10
+
11
+ ; BEGIN required configuration
12
+
13
+ ; Parameters inside the required configuration block should not be altered.
14
+ ; They may be changed at any time by upgrades or other automated processes.
15
+ ;
16
+ ; Site-specific customizations will only be preserved if they are done
17
+ ; outside this block. If you choose to make customizations, it is your
18
+ ; own responsibility to verify that they work correctly with the supported
19
+ ; configuration tools.
20
+
21
+ [global]
22
+ debug pid = yes
23
+ log level = 1
24
+ server string = Mac OS X
25
+
26
+ printcap name = cups
27
+ printing = cups
28
+
29
+ encrypt passwords = yes
30
+ use spnego = yes
31
+
32
+ passdb backend = odsam
33
+
34
+ idmap domains = default
35
+ idmap config default: default = yes
36
+ idmap config default: backend = odsam
37
+ idmap alloc backend = odsam
38
+ idmap negative cache time = 5
39
+
40
+ map to guest = Bad User
41
+ guest account = nobody
42
+
43
+ unix charset = UTF-8-MAC
44
+ display charset = UTF-8-MAC
45
+ dos charset = 437
46
+
47
+ vfs objects = darwinacl,darwin_streams
48
+
49
+ ; Don't become a master browser unless absolutely necessary.
50
+ os level = 2
51
+ domain master = no
52
+
53
+ ; For performance reasons, set the transmit buffer size
54
+ ; to the maximum and enable sendfile support.
55
+ max xmit = 131072
56
+ use sendfile = yes
57
+
58
+ ; The darwin_streams module gives us named streams support.
59
+ stream support = yes
60
+ ea support = yes
61
+
62
+ ; Enable locking coherency with AFP.
63
+ darwin_streams:brlm = yes
64
+
65
+ ; Core files are invariably disabled system-wide, but attempting to
66
+ ; dump core will trigger a crash report, so we still want to try.
67
+ enable core files = yes
68
+
69
+ ; Configure usershares for use by the synchronize-shares tool.
70
+ usershare max shares = 1000
71
+ usershare path = /var/samba/shares
72
+ usershare owner only = no
73
+ usershare allow guests = yes
74
+ usershare allow full config = yes
75
+
76
+ ; Filter inaccessible shares from the browse list.
77
+ com.apple:filter shares by access = yes
78
+
79
+ ; Check in with PAM to enforce SACL access policy.
80
+ obey pam restrictions = yes
81
+
82
+ ; Don't be trying to enforce ACLs in userspace.
83
+ acl check permissions = no
84
+
85
+ ; Make sure that we resolve unqualified names as NetBIOS before DNS.
86
+ name resolve order = lmhosts wins bcast host
87
+
88
+ ; Pull in system-wide preference settings. These are managed by
89
+ ; synchronize-preferences tool.
90
+ include = /var/db/smb.conf
91
+
92
+ [printers]
93
+ comment = All Printers
94
+ path = /tmp
95
+ printable = yes
96
+ guest ok = no
97
+ create mode = 0700
98
+ writeable = no
99
+ browseable = no
100
+
101
+ ; Site-specific parameters can be added below this comment.
102
+ ; END required configuration.
@@ -0,0 +1,104 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ # Tests use of the Generator when used like so:
4
+ #
5
+ # IniParse::Generator.gen do |doc|
6
+ # doc.comment 'My very own comment'
7
+ # doc.my_section do |section|
8
+ # section.my_option = 'my value'
9
+ # end
10
+ # end
11
+ #
12
+
13
+ describe 'When generating a document using Generator with section blocks using method_missing,' do
14
+
15
+ # --
16
+ # ==========================================================================
17
+ # SECTION LINES
18
+ # ==========================================================================
19
+ # ++
20
+
21
+ describe 'adding a section' do
22
+ it 'should yield an object with generator methods' do
23
+ IniParse::Generator.gen do |doc|
24
+ doc.a_section do |section|
25
+ %w( option comment blank ).each do |meth|
26
+ section.should respond_to(meth)
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ it 'should add a Section to the document' do
33
+ IniParse::Generator.gen do |doc|
34
+ doc.a_section { |section| }
35
+ end.should have_section("a_section")
36
+ end
37
+
38
+ it 'should change the Generator context to the section during the section block' do
39
+ IniParse::Generator.gen do |doc|
40
+ doc.a_section do |section|
41
+ section.context.should be_kind_of(IniParse::Lines::Section)
42
+ section.context.key.should == "a_section"
43
+ end
44
+ end
45
+ end
46
+
47
+ it 'should reset the Generator context to the document after the section block' do
48
+ IniParse::Generator.gen do |doc|
49
+ doc.a_section { |section| }
50
+ doc.context.should be_kind_of(IniParse::Document)
51
+ end
52
+ end
53
+
54
+ it 'should append a blank line to the document, after the section' do
55
+ IniParse::Generator.gen do |doc|
56
+ doc.a_section { |section| }
57
+ end.lines.to_a.last.should be_kind_of(IniParse::Lines::Blank)
58
+ end
59
+
60
+ it 'should raise a LineNotAllowed if you attempt to nest a section' do
61
+ lambda do
62
+ IniParse::Generator.gen do |doc|
63
+ doc.a_section do |section_one|
64
+ section_one.another_section { |section_two| }
65
+ end
66
+ end
67
+ end.should raise_error(IniParse::LineNotAllowed)
68
+ end
69
+ end
70
+
71
+ # --
72
+ # ==========================================================================
73
+ # OPTION LINES
74
+ # ==========================================================================
75
+ # ++
76
+
77
+ describe 'adding a option' do
78
+ describe 'when the context is a Document' do
79
+ it "should raise a NoSectionError" do
80
+ lambda do
81
+ IniParse::Generator.gen { |doc| doc.my_option = "a value" }
82
+ end.should raise_error(IniParse::NoSectionError)
83
+ end
84
+ end
85
+
86
+ describe 'when the context is a Section' do
87
+ it 'should add the option to the section' do
88
+ document = IniParse::Generator.gen do |doc|
89
+ doc.a_section do |section|
90
+ section.my_option = "a value"
91
+ end
92
+ end
93
+
94
+ section = document["a_section"]
95
+ section.should have_option("my_option")
96
+ section["my_option"].should == "a value"
97
+ end
98
+ end
99
+ end
100
+
101
+ # Comments and blanks are added in the same way as in the
102
+ # 'with_section_block_spec.rb' specification.
103
+
104
+ end
@@ -0,0 +1,322 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ # Tests use of the Generator when used like so:
4
+ #
5
+ # IniParse::Generator.gen do |doc|
6
+ # doc.comment('My very own comment')
7
+ # doc.section('my_section') do |section|
8
+ # section.option('my_option', 'my value')
9
+ # end
10
+ # end
11
+ #
12
+
13
+ describe 'When generating a document using Generator with section blocks,' do
14
+
15
+ it 'should be able to compile an empty document' do
16
+ lambda { IniParse::Generator.gen { |doc| } }.should_not raise_error
17
+ end
18
+
19
+ it 'should raise LocalJumpError if no block is given' do
20
+ lambda { IniParse::Generator.gen }.should raise_error(LocalJumpError)
21
+ end
22
+
23
+ it "should yield an object with generator methods" do
24
+ IniParse::Generator.gen do |doc|
25
+ %w( section option comment blank ).each do |meth|
26
+ doc.should respond_to(meth)
27
+ end
28
+ end
29
+ end
30
+
31
+ # --
32
+ # ==========================================================================
33
+ # SECTION LINES
34
+ # ==========================================================================
35
+ # ++
36
+
37
+ describe 'adding a section' do
38
+ it 'should yield an object with generator methods' do
39
+ IniParse::Generator.gen do |doc|
40
+ doc.section("a section") do |section|
41
+ %w( option comment blank ).each do |meth|
42
+ section.should respond_to(meth)
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ it 'should add a Section to the document' do
49
+ IniParse::Generator.gen do |doc|
50
+ doc.section("a section") { |section| }
51
+ end.should have_section("a section")
52
+ end
53
+
54
+ it 'should change the Generator context to the section during the section block' do
55
+ IniParse::Generator.gen do |doc|
56
+ doc.section("a section") do |section|
57
+ section.context.should be_kind_of(IniParse::Lines::Section)
58
+ section.context.key.should == "a section"
59
+ end
60
+ end
61
+ end
62
+
63
+ it 'should reset the Generator context to the document after the section block' do
64
+ IniParse::Generator.gen do |doc|
65
+ doc.section("a section") { |section| }
66
+ doc.context.should be_kind_of(IniParse::Document)
67
+ end
68
+ end
69
+
70
+ it "should use the parent document's options as a base" do
71
+ document = IniParse::Generator.gen(:indent => ' ') do |doc|
72
+ doc.section("a section") { |section| }
73
+ end
74
+
75
+ document["a section"].to_ini.should match(/\A /)
76
+ end
77
+
78
+ it 'should pass extra options to the Section instance' do
79
+ document = IniParse::Generator.gen do |doc|
80
+ doc.section("a section", :indent => ' ') { |section| }
81
+ end
82
+
83
+ document["a section"].to_ini.should match(/\A /)
84
+ end
85
+
86
+ it 'should append a blank line to the document, after the section' do
87
+ IniParse::Generator.gen do |doc|
88
+ doc.section("a section") { |section| }
89
+ end.lines.to_a.last.should be_kind_of(IniParse::Lines::Blank)
90
+ end
91
+
92
+ it 'should raise a LineNotAllowed if you attempt to nest a section' do
93
+ lambda do
94
+ IniParse::Generator.gen do |doc|
95
+ doc.section("a section") do |section_one|
96
+ section_one.section("another_section") { |section_two| }
97
+ end
98
+ end
99
+ end.should raise_error(IniParse::LineNotAllowed)
100
+ end
101
+ end
102
+
103
+ # --
104
+ # ==========================================================================
105
+ # OPTION LINES
106
+ # ==========================================================================
107
+ # ++
108
+
109
+ describe 'adding a option' do
110
+
111
+ describe 'when the context is a Document' do
112
+ it "should raise a NoSectionError" do
113
+ lambda do
114
+ IniParse::Generator.gen do |doc|
115
+ doc.option("my option", "a value")
116
+ end
117
+ end.should raise_error(IniParse::NoSectionError)
118
+ end
119
+ end
120
+
121
+ describe 'when the context is a Section' do
122
+ it 'should add the option to the section' do
123
+ document = IniParse::Generator.gen do |doc|
124
+ doc.section("a section") do |section|
125
+ section.option("my option", "a value")
126
+ end
127
+ end
128
+
129
+ section = document["a section"]
130
+ section.should have_option("my option")
131
+ section["my option"].should == "a value"
132
+ end
133
+
134
+ it 'should pass extra options to the Option instance' do
135
+ document = IniParse::Generator.gen do |doc|
136
+ doc.section("a section") do |section|
137
+ section.option("my option", "a value", :indent => " ")
138
+ end
139
+ end
140
+
141
+ document["a section"].option("my option").to_ini.should match(/^ /)
142
+ end
143
+
144
+ it "should use the parent document's options as a base" do
145
+ document = IniParse::Generator.gen(:indent => " ") do |doc|
146
+ doc.section("a section") do |section|
147
+ section.option("my option", "a value")
148
+ end
149
+ end
150
+
151
+ document["a section"].option("my option").to_ini.should match(/^ /)
152
+ end
153
+
154
+ it "should use the parent section's options as a base" do
155
+ document = IniParse::Generator.gen do |doc|
156
+ doc.section("a section", :indent => " ") do |section|
157
+ section.option("my option", "a value")
158
+ end
159
+ end
160
+
161
+ document["a section"].option("my option").to_ini.should match(/^ /)
162
+ end
163
+
164
+ it "should allow customisation of the parent's options" do
165
+ document = IniParse::Generator.gen do |doc|
166
+ doc.section("a section", :indent => " ") do |section|
167
+ section.option("my option", "a value", {
168
+ :comment_sep => "#", :comment => 'a comment'
169
+ })
170
+ end
171
+ end
172
+
173
+ option_ini = document["a section"].option("my option").to_ini
174
+ option_ini.should match(/^ /)
175
+ option_ini.should match(/ # a comment/)
176
+ end
177
+
178
+ it "should not use the parent section's comment when setting line options" do
179
+ document = IniParse::Generator.gen do |doc|
180
+ doc.section("a section", :comment => "My section") do |section|
181
+ section.option("my option", "a value")
182
+ end
183
+ end
184
+
185
+ document["a section"].option("my option").to_ini.should_not match(/My section$/)
186
+ end
187
+ end
188
+ end
189
+
190
+ # --
191
+ # ==========================================================================
192
+ # COMMENT LINES
193
+ # ==========================================================================
194
+ # ++
195
+
196
+ describe 'adding a comment' do
197
+ it 'should pass extra options to the Option instance' do
198
+ document = IniParse::Generator.gen do |doc|
199
+ doc.comment("My comment", :indent => ' ')
200
+ end
201
+
202
+ document.lines.to_a.first.to_ini.should match(/\A /)
203
+ end
204
+
205
+ it 'should ignore any extra :comment option' do
206
+ document = IniParse::Generator.gen do |doc|
207
+ doc.comment("My comment", :comment => 'Ignored')
208
+ end
209
+
210
+ document.lines.to_a.first.to_ini.should match(/My comment/)
211
+ document.lines.to_a.first.to_ini.should_not match(/Ignored/)
212
+ end
213
+
214
+ describe 'when the context is a Document' do
215
+ it 'should add a comment to the document' do
216
+ document = IniParse::Generator.gen do |doc|
217
+ doc.comment("My comment")
218
+ end
219
+
220
+ comment = document.lines.to_a.first
221
+ comment.should be_kind_of(IniParse::Lines::Comment)
222
+ comment.to_ini.should match(/My comment/)
223
+ end
224
+
225
+ it 'should use the default line options as a base' do
226
+ document = IniParse::Generator.gen do |doc|
227
+ doc.comment("My comment")
228
+ end
229
+
230
+ comment_ini = document.lines.to_a.first.to_ini
231
+
232
+ # Match separator (;) and offset (0).
233
+ comment_ini.should == '; My comment'
234
+ end
235
+ end
236
+
237
+ describe 'when the context is a Section' do
238
+ it 'should add a comment to the section' do
239
+ document = IniParse::Generator.gen do |doc|
240
+ doc.section("a section") do |section|
241
+ section.comment("My comment")
242
+ end
243
+ end
244
+
245
+ comment = document['a section'].lines.to_a.first
246
+ comment.should be_kind_of(IniParse::Lines::Comment)
247
+ comment.to_ini.should match(/My comment/)
248
+ end
249
+
250
+ it "should use the parent document's line options as a base" do
251
+ document = IniParse::Generator.gen(:comment_offset => 5) do |doc|
252
+ doc.section("a section") do |section|
253
+ section.comment("My comment")
254
+ end
255
+ end
256
+
257
+ document['a section'].lines.to_a.first.to_ini.should match(/^ ;/)
258
+ end
259
+
260
+ it "should use the parent section's line options as a base" do
261
+ document = IniParse::Generator.gen do |doc|
262
+ doc.section("a section", :comment_offset => 5) do |section|
263
+ section.comment("My comment")
264
+ end
265
+ end
266
+
267
+ document['a section'].lines.to_a.first.to_ini.should match(/^ ;/)
268
+ end
269
+
270
+ it "should allow customisation of the parent's options" do
271
+ document = IniParse::Generator.gen do |doc|
272
+ doc.section("a section", :comment_offset => 5) do |section|
273
+ section.comment("My comment", :comment_sep => "#")
274
+ end
275
+ end
276
+
277
+ # Match separator (#) and offset (5)
278
+ document['a section'].lines.to_a.first.to_ini.should \
279
+ == ' # My comment'
280
+ end
281
+
282
+ it "should not use the parent section's comment when setting line options" do
283
+ document = IniParse::Generator.gen do |doc|
284
+ doc.section("a section", :comment => "My section") do |section|
285
+ section.comment("My comment")
286
+ end
287
+ end
288
+
289
+ comment_ini = document['a section'].lines.to_a.first.to_ini
290
+ comment_ini.should match(/My comment/)
291
+ comment_ini.should_not match(/My section/)
292
+ end
293
+ end
294
+ end
295
+
296
+ # --
297
+ # ==========================================================================
298
+ # BLANK LINES
299
+ # ==========================================================================
300
+ # ++
301
+
302
+ describe 'adding a blank line' do
303
+ it 'should add a blank line to the document when it is the context' do
304
+ document = IniParse::Generator.gen do |doc|
305
+ doc.blank
306
+ end
307
+
308
+ document.lines.to_a.first.should be_kind_of(IniParse::Lines::Blank)
309
+ end
310
+
311
+ it 'should add a blank line to the section when it is the context' do
312
+ document = IniParse::Generator.gen do |doc|
313
+ doc.section("a section") do |section|
314
+ section.blank
315
+ end
316
+ end
317
+
318
+ document['a section'].lines.to_a.first.should be_kind_of(IniParse::Lines::Blank)
319
+ end
320
+ end
321
+
322
+ end