rmuh 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +6 -6
- data/Rakefile +3 -6
- data/examples/basic_parsing.rb +41 -0
- data/examples/basic_serverstats.rb +22 -0
- data/examples/serverstats_advanced.rb +26 -0
- data/examples/serverstats_cache.rb +35 -0
- data/lib/rmuh/serverstats/advanced.rb +2 -2
- data/lib/rmuh/serverstats/base.rb +2 -0
- data/lib/rmuh/version.rb +1 -1
- data/spec/examples_spec.rb +46 -0
- data/spec/rmuh_rpt_log_fetch_spec.rb +17 -15
- data/spec/rmuh_rpt_log_parsers_base_spec.rb +30 -7
- data/spec/rmuh_rpt_log_parsers_unitedoperationslog_spec.rb +66 -60
- data/spec/rmuh_rpt_log_parsers_unitedoperationsrpt_spec.rb +21 -20
- data/spec/rmuh_rpt_log_util_unitedoperations_spec.rb +51 -51
- data/spec/rmuh_rpt_log_util_unitedoperationslog_spec.rb +25 -21
- data/spec/rmuh_rpt_log_util_unitedoperationsrpt_spec.rb +68 -63
- data/spec/rmuh_rpt_spec.rb +8 -8
- data/spec/rmuh_serverstats_base_spec.rb +39 -23
- metadata +7 -1
@@ -24,8 +24,9 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should return nil if arg 1 is a Hash' do
|
27
|
-
|
28
|
-
.
|
27
|
+
expect(
|
28
|
+
RMuh::RPT::Log::Parsers::UnitedOperationsLog.validate_opts({})
|
29
|
+
).to be_nil
|
29
30
|
end
|
30
31
|
|
31
32
|
it 'should fail if to_zulu is not boolean' do
|
@@ -63,49 +64,50 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
63
64
|
|
64
65
|
it 'should return an instance of UnitedOperationsLog' do
|
65
66
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new
|
66
|
-
u
|
67
|
+
expect(u)
|
68
|
+
.to be_an_instance_of RMuh::RPT::Log::Parsers::UnitedOperationsLog
|
67
69
|
end
|
68
70
|
|
69
71
|
it 'should not include chat by default' do
|
70
72
|
u = uolog.instance_variable_get(:@include_chat)
|
71
|
-
u.
|
73
|
+
expect(u).to be_false
|
72
74
|
end
|
73
75
|
|
74
76
|
it 'should convert to zulu by default' do
|
75
77
|
u = uolog.instance_variable_get(:@to_zulu)
|
76
|
-
u.
|
78
|
+
expect(u).to be_true
|
77
79
|
end
|
78
80
|
|
79
81
|
it 'should use the UO timezone by default' do
|
80
82
|
t = RMuh::RPT::Log::Util::UnitedOperations::UO_TZ
|
81
83
|
u = uolog.instance_variable_get(:@timezone)
|
82
|
-
u.
|
84
|
+
expect(u).to eql t
|
83
85
|
end
|
84
86
|
|
85
87
|
it 'should not include chat if passed as false' do
|
86
88
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new(chat: false)
|
87
|
-
u.instance_variable_get(:@include_chat).
|
89
|
+
expect(u.instance_variable_get(:@include_chat)).to eql false
|
88
90
|
end
|
89
91
|
|
90
92
|
it 'should include chat if passed as true' do
|
91
93
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new(chat: true)
|
92
|
-
u.instance_variable_get(:@include_chat).
|
94
|
+
expect(u.instance_variable_get(:@include_chat)).to eql true
|
93
95
|
end
|
94
96
|
|
95
97
|
it 'should not convert to zulu if passed as false' do
|
96
98
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new(to_zulu: false)
|
97
|
-
u.instance_variable_get(:@to_zulu).
|
99
|
+
expect(u.instance_variable_get(:@to_zulu)).to eql false
|
98
100
|
end
|
99
101
|
|
100
102
|
it 'should convert to zulu if passed as true' do
|
101
103
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new(to_zulu: true)
|
102
|
-
u.instance_variable_get(:@to_zulu).
|
104
|
+
expect(u.instance_variable_get(:@to_zulu)).to eql true
|
103
105
|
end
|
104
106
|
|
105
107
|
it 'should specify a custom timezone if passed in' do
|
106
108
|
t = TZInfo::Timezone.get('Etc/UTC')
|
107
109
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new(timezone: t)
|
108
|
-
u.instance_variable_get(:@timezone).
|
110
|
+
expect(u.instance_variable_get(:@timezone)).to eql t
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
@@ -119,25 +121,26 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
119
121
|
it 'should return today if it is between 0400 and 2359' do
|
120
122
|
tz = RMuh::RPT::Log::Util::UnitedOperations::UO_TZ
|
121
123
|
t = Time.new(2014, 1, 1, 4, 0, 0)
|
122
|
-
uolog.send(:date_of_line_based_on_now, t).to_s.
|
124
|
+
expect(uolog.send(:date_of_line_based_on_now, t).to_s).to eql tz.now.to_s
|
123
125
|
t = Time.new(2014, 1, 1, 23, 59, 59)
|
124
|
-
uolog.send(:date_of_line_based_on_now, t).to_s.
|
126
|
+
expect(uolog.send(:date_of_line_based_on_now, t).to_s).to eql tz.now.to_s
|
125
127
|
t = Time.new(2014, 1, 1, 0, 0, 0)
|
126
|
-
uolog.send(:date_of_line_based_on_now, t).to_s
|
128
|
+
expect(uolog.send(:date_of_line_based_on_now, t).to_s)
|
129
|
+
.to_not eql tz.now.to_s
|
127
130
|
end
|
128
131
|
|
129
132
|
it 'should return yesterday if it is between 0000 and 0359' do
|
130
133
|
tz = RMuh::RPT::Log::Util::UnitedOperations::UO_TZ
|
131
134
|
d = RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY
|
132
135
|
t = Time.new(2014, 1, 1, 0, 0, 0)
|
133
|
-
uolog.send(:date_of_line_based_on_now, t)
|
134
|
-
.
|
136
|
+
expect(uolog.send(:date_of_line_based_on_now, t).to_s)
|
137
|
+
.to eql((tz.now - d).to_s)
|
135
138
|
t = Time.new(2014, 1, 1, 3, 59, 59)
|
136
|
-
uolog.send(:date_of_line_based_on_now, t)
|
137
|
-
.
|
139
|
+
expect(uolog.send(:date_of_line_based_on_now, t).to_s)
|
140
|
+
.to eql((tz.now - d).to_s)
|
138
141
|
t = Time.new(2014, 1, 1, 4, 0, 0)
|
139
|
-
uolog.send(:date_of_line_based_on_now, t)
|
140
|
-
.
|
142
|
+
expect(uolog.send(:date_of_line_based_on_now, t).to_s)
|
143
|
+
.to_not eql((tz.now - d).to_s)
|
141
144
|
end
|
142
145
|
end
|
143
146
|
|
@@ -158,21 +161,21 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
158
161
|
tz = uolog.instance_variable_get(:@timezone)
|
159
162
|
l = {}
|
160
163
|
uolog.send(:set_line_date!, l)
|
161
|
-
l[:year].
|
164
|
+
expect(l[:year]).to eql tz.now.year
|
162
165
|
end
|
163
166
|
|
164
167
|
it "should set the line's month to this month" do
|
165
168
|
tz = uolog.instance_variable_get(:@timezone)
|
166
169
|
l = {}
|
167
170
|
uolog.send(:set_line_date!, l)
|
168
|
-
l[:month].
|
171
|
+
expect(l[:month]).to eql tz.now.month
|
169
172
|
end
|
170
173
|
|
171
174
|
it "should set the line's date to this day" do
|
172
175
|
tz = uolog.instance_variable_get(:@timezone)
|
173
176
|
l = {}
|
174
177
|
uolog.send(:set_line_date!, l)
|
175
|
-
l[:day].
|
178
|
+
expect(l[:day]).to eql tz.now.day
|
176
179
|
end
|
177
180
|
end
|
178
181
|
|
@@ -197,9 +200,9 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
197
200
|
l = yday_line.dup
|
198
201
|
uolog.stub(:date_of_line_based_on_now) { tz.now }
|
199
202
|
uolog.send(:when_am_i!, l)
|
200
|
-
l[:year].
|
201
|
-
l[:month].
|
202
|
-
l[:day].
|
203
|
+
expect(l[:year]).to eql tz.now.year
|
204
|
+
expect(l[:month]).to eql tz.now.month
|
205
|
+
expect(l[:day]).to eql tz.now.day
|
203
206
|
end
|
204
207
|
|
205
208
|
it 'should set the date as yday if line (0400-2359) now not same range' do
|
@@ -208,18 +211,18 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
208
211
|
l = yday_line.dup
|
209
212
|
uolog.stub(:date_of_line_based_on_now) { tz.now - d }
|
210
213
|
uolog.send(:when_am_i!, l)
|
211
|
-
l[:year].
|
212
|
-
l[:month].
|
213
|
-
l[:day].
|
214
|
+
expect(l[:year]).to eql((tz.now - d).year)
|
215
|
+
expect(l[:month]).to eql((tz.now - d).month)
|
216
|
+
expect(l[:day]).to eql((tz.now - d).day)
|
214
217
|
end
|
215
218
|
|
216
219
|
it 'should set the date as today if time between 0000 and 0359' do
|
217
220
|
tz = uolog.instance_variable_get(:@timezone)
|
218
221
|
l = today_line.dup
|
219
222
|
uolog.send(:when_am_i!, l)
|
220
|
-
l[:year].
|
221
|
-
l[:month].
|
222
|
-
l[:day].
|
223
|
+
expect(l[:year]).to eql tz.now.year
|
224
|
+
expect(l[:month]).to eql tz.now.month
|
225
|
+
expect(l[:day]).to eql tz.now.day
|
223
226
|
end
|
224
227
|
end
|
225
228
|
|
@@ -239,22 +242,22 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
239
242
|
it 'should call where_am_i! and set the year/month/day' do
|
240
243
|
l = { hour: 4, min: 0, sec: 0 }
|
241
244
|
x = uolog.send(:line_modifiers, l)
|
242
|
-
x.key?(:year).
|
243
|
-
x.key?(:month).
|
244
|
-
x.key?(:day).
|
245
|
+
expect(x.key?(:year)).to be_true
|
246
|
+
expect(x.key?(:month)).to be_true
|
247
|
+
expect(x.key?(:day)).to be_true
|
245
248
|
end
|
246
249
|
|
247
250
|
it 'sould call zulu! and set the time to zulu' do
|
248
251
|
l = { hour: 4, min: 0, sec: 0 }
|
249
252
|
x = uolog.send(:line_modifiers, l)
|
250
|
-
x.key?(:iso8601).
|
251
|
-
x.key?(:dtg).
|
253
|
+
expect(x.key?(:iso8601)).to be_true
|
254
|
+
expect(x.key?(:dtg)).to be_true
|
252
255
|
end
|
253
256
|
|
254
257
|
it 'should call add_guid! and add the event_guid' do
|
255
258
|
l = { hour: 4, min: 0, sec: 0 }
|
256
259
|
x = uolog.send(:line_modifiers, l)
|
257
|
-
x.key?(:event_guid).
|
260
|
+
expect(x.key?(:event_guid)).to be_true
|
258
261
|
end
|
259
262
|
end
|
260
263
|
|
@@ -285,44 +288,47 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
285
288
|
end
|
286
289
|
|
287
290
|
it 'should return an Array' do
|
288
|
-
uolog.send(:regex_matches, StringIO.new)
|
291
|
+
expect(uolog.send(:regex_matches, StringIO.new))
|
292
|
+
.to be_an_instance_of Array
|
289
293
|
end
|
290
294
|
|
291
295
|
it 'should iterate over multiple log lines' do
|
292
296
|
x = uolog.send(:regex_matches, loglines)
|
293
|
-
x.
|
294
|
-
x.length.
|
297
|
+
expect(x).to be_an_instance_of Array
|
298
|
+
expect(x.length).to eql 2
|
295
299
|
end
|
296
300
|
|
297
301
|
it 'should properly match a guid line' do
|
298
302
|
x = uolog.send(:regex_matches, StringIO.new(guid_line))
|
299
|
-
x[0][:type].
|
303
|
+
expect(x[0][:type]).to eql :beguid
|
300
304
|
end
|
301
305
|
|
302
306
|
it 'should properly match a chat line' do
|
303
307
|
x = uolog.send(:regex_matches, StringIO.new(chat_line))
|
304
|
-
x[0][:type].
|
308
|
+
expect(x[0][:type]).to eql :chat
|
305
309
|
end
|
306
310
|
|
307
311
|
it 'should not match a chat line if chat matching is disabled' do
|
308
312
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new
|
309
|
-
|
313
|
+
expect(
|
314
|
+
u.send(:regex_matches, StringIO.new(chat_line)).empty?
|
315
|
+
).to be_true
|
310
316
|
end
|
311
317
|
|
312
318
|
it 'should compact the Array' do
|
313
319
|
l = StringIO.new("Something1\nSomething2\n")
|
314
320
|
x = uolog.send(:regex_matches, l)
|
315
|
-
x.include?(nil).
|
321
|
+
expect(x.include?(nil)).to be_false
|
316
322
|
end
|
317
323
|
|
318
324
|
it 'should call #line_modifiers' do
|
319
325
|
x = uolog.send(:regex_matches, StringIO.new(guid_line))
|
320
|
-
x[0].key?(:year).
|
321
|
-
x[0].key?(:month).
|
322
|
-
x[0].key?(:day).
|
323
|
-
x[0].key?(:iso8601).
|
324
|
-
x[0].key?(:dtg).
|
325
|
-
x[0].key?(:event_guid).
|
326
|
+
expect(x[0].key?(:year)).to be_true
|
327
|
+
expect(x[0].key?(:month)).to be_true
|
328
|
+
expect(x[0].key?(:day)).to be_true
|
329
|
+
expect(x[0].key?(:iso8601)).to be_true
|
330
|
+
expect(x[0].key?(:dtg)).to be_true
|
331
|
+
expect(x[0].key?(:event_guid)).to be_true
|
326
332
|
end
|
327
333
|
end
|
328
334
|
|
@@ -341,7 +347,7 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
341
347
|
end
|
342
348
|
|
343
349
|
it 'should not fail if arg1 is a StringIO object' do
|
344
|
-
expect { uolog.parse(StringIO.new) }.
|
350
|
+
expect { uolog.parse(StringIO.new) }.to_not raise_error
|
345
351
|
end
|
346
352
|
|
347
353
|
it 'should fail if arg1 is a String' do
|
@@ -373,18 +379,18 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
373
379
|
end
|
374
380
|
|
375
381
|
it 'should return an Array' do
|
376
|
-
uolog.parse(StringIO.new).
|
382
|
+
expect(uolog.parse(StringIO.new)).to be_an_instance_of Array
|
377
383
|
end
|
378
384
|
|
379
385
|
it 'should call #regex_matches' do
|
380
386
|
x = uolog.parse(StringIO.new(guid_line))
|
381
|
-
x[0].key?(:type).
|
382
|
-
x[0].key?(:year).
|
383
|
-
x[0].key?(:month).
|
384
|
-
x[0].key?(:day).
|
385
|
-
x[0].key?(:iso8601).
|
386
|
-
x[0].key?(:dtg).
|
387
|
-
x[0].key?(:event_guid).
|
387
|
+
expect(x[0].key?(:type)).to be_true
|
388
|
+
expect(x[0].key?(:year)).to be_true
|
389
|
+
expect(x[0].key?(:month)).to be_true
|
390
|
+
expect(x[0].key?(:day)).to be_true
|
391
|
+
expect(x[0].key?(:iso8601)).to be_true
|
392
|
+
expect(x[0].key?(:dtg)).to be_true
|
393
|
+
expect(x[0].key?(:event_guid)).to be_true
|
388
394
|
end
|
389
395
|
end
|
390
396
|
end
|
@@ -21,8 +21,9 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should not fail if arg 1 is a Hash' do
|
24
|
-
|
25
|
-
.validate_opts({})
|
24
|
+
expect(
|
25
|
+
RMuh::RPT::Log::Parsers::UnitedOperationsRPT.validate_opts({})
|
26
|
+
).to be_nil
|
26
27
|
end
|
27
28
|
|
28
29
|
it 'should fail if arg 1 is an Array' do
|
@@ -84,7 +85,7 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
84
85
|
it 'should not fail if arg 1 is a hash' do
|
85
86
|
expect do
|
86
87
|
RMuh::RPT::Log::Parsers::UnitedOperationsRPT.new
|
87
|
-
end.
|
88
|
+
end.to_not raise_error
|
88
89
|
end
|
89
90
|
|
90
91
|
it 'should fail if arg 1 is an Array' do
|
@@ -132,22 +133,22 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
132
133
|
it 'should fail if arg 1 is nil' do
|
133
134
|
expect do
|
134
135
|
RMuh::RPT::Log::Parsers::UnitedOperationsRPT.new(nil)
|
135
|
-
end
|
136
|
+
end.to raise_error ArgumentError
|
136
137
|
end
|
137
138
|
|
138
139
|
it 'should return an instance of itself' do
|
139
|
-
uorpt.
|
140
|
+
expect(uorpt).to be_an_instance_of(
|
140
141
|
RMuh::RPT::Log::Parsers::UnitedOperationsRPT
|
141
142
|
)
|
142
143
|
end
|
143
144
|
|
144
145
|
it 'should set @to_zulu to true if nothing provided' do
|
145
|
-
uorpt.instance_variable_get(:@to_zulu).
|
146
|
+
expect(uorpt.instance_variable_get(:@to_zulu)).to be_true
|
146
147
|
end
|
147
148
|
|
148
149
|
it 'should set @timezone to America/Los_Angeles if nothing provided' do
|
149
150
|
tz = TZInfo::Timezone.get('America/Los_Angeles')
|
150
|
-
uorpt.instance_variable_get(:@timezone).
|
151
|
+
expect(uorpt.instance_variable_get(:@timezone)).to eql tz
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
@@ -165,23 +166,23 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
165
166
|
end
|
166
167
|
|
167
168
|
it 'should return nil if line matches nothing' do
|
168
|
-
uorpt.send(:regex_match, '').
|
169
|
+
expect(uorpt.send(:regex_match, '')).to be_nil
|
169
170
|
end
|
170
171
|
|
171
172
|
it 'should return a Hash if the line matches ANNOUNCEMENT' do
|
172
173
|
l = '2014/02/16, 4:13:10 "############################# Start ' \
|
173
174
|
'CO08_Escape_Chernarus_V1 #############################"'
|
174
175
|
x = uorpt.send(:regex_match, l)
|
175
|
-
x.
|
176
|
-
x[:type].
|
176
|
+
expect(x).to be_an_instance_of Hash
|
177
|
+
expect(x[:type]).to eql :announcement
|
177
178
|
end
|
178
179
|
|
179
180
|
it 'should return a Hash if the line matches WOUNDED' do
|
180
181
|
l = '2014/02/16, 5:22:55 "4152.41 seconds: Sherminator (CIV) has ' \
|
181
182
|
'been team wounded by Xcenocide (WEST) for 1.50828 damage."'
|
182
183
|
x = uorpt.send(:regex_match, l)
|
183
|
-
x.
|
184
|
-
x[:type].
|
184
|
+
expect(x).to be_an_instance_of Hash
|
185
|
+
expect(x[:type]).to eql :wounded
|
185
186
|
end
|
186
187
|
|
187
188
|
it 'should return a Hash if the line matches KILLED' do
|
@@ -191,8 +192,8 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
191
192
|
'[6498.62,6916.71,0.0204163] (GRID 0649806916). Distance between: ' \
|
192
193
|
'71.1653 meters. Near players (100m): None."'
|
193
194
|
x = uorpt.send(:regex_match, l)
|
194
|
-
x.
|
195
|
-
x[:type].
|
195
|
+
expect(x).to be_an_instance_of Hash
|
196
|
+
expect(x[:type]).to eql :killed
|
196
197
|
end
|
197
198
|
|
198
199
|
it 'should return a Hash if the line matches DIED' do
|
@@ -200,8 +201,8 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
200
201
|
'[4602.18,7490.26,2.2435] (GRID 0460207490). Near players (100m): ' \
|
201
202
|
'["Olli","nametag47","Villanyi"]"'
|
202
203
|
x = uorpt.send(:regex_match, l)
|
203
|
-
x.
|
204
|
-
x[:type].
|
204
|
+
expect(x).to be_an_instance_of Hash
|
205
|
+
expect(x[:type]).to eql :died
|
205
206
|
end
|
206
207
|
end
|
207
208
|
|
@@ -239,14 +240,14 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
239
240
|
it 'should return an Array' do
|
240
241
|
ll = StringIO.new
|
241
242
|
x = uorpt.parse(ll)
|
242
|
-
x.
|
243
|
+
expect(x).to be_an_instance_of Array
|
243
244
|
end
|
244
245
|
|
245
246
|
it 'should return an Array of hashes if a line matches' do
|
246
247
|
x = uorpt.parse(loglines)
|
247
|
-
x.
|
248
|
-
x.empty
|
249
|
-
x.each { |y| y.
|
248
|
+
expect(x).to be_an_instance_of Array
|
249
|
+
expect(x.empty?).to be_false
|
250
|
+
x.each { |y| expect(y).to be_an_instance_of Hash }
|
250
251
|
end
|
251
252
|
end
|
252
253
|
end
|
@@ -61,21 +61,21 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
61
61
|
it 'should return a Hash' do
|
62
62
|
ml = @uo_util.m_to_h(@mi.match('2013/12/31 16:00:00'))
|
63
63
|
mr = @uo_util.zulu!(ml, uo_tz)
|
64
|
-
mr.
|
64
|
+
expect(mr).to be_an_instance_of Hash
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should properly convert the time to zulu' do
|
68
|
-
zulued[:iso8601].
|
68
|
+
expect(zulued[:iso8601]).to eql good_time
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should properly format the time in iso8601' do
|
72
72
|
m = /^\d+-\d+-\d+T\d+:\d+:\d+Z$/
|
73
|
-
m.match(zulued[:iso8601]).
|
73
|
+
expect(m.match(zulued[:iso8601])).to be_an_instance_of MatchData
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should properly format the time in DTG' do
|
77
77
|
m = /^\d+Z\s([A-Z]){3}\s\d+$/
|
78
|
-
m.match(zulued[:dtg]).
|
78
|
+
expect(m.match(zulued[:dtg])).to be_an_instance_of MatchData
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -96,23 +96,23 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should return a String if key :iso8601 is there' do
|
99
|
-
@uo_util.__guid_data_base(@full_line).
|
99
|
+
expect(@uo_util.__guid_data_base(@full_line)).to be_an_instance_of String
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'should return a String if key :iso8608 is missing' do
|
103
|
-
@uo_util.__guid_data_base(fline).
|
103
|
+
expect(@uo_util.__guid_data_base(fline)).to be_an_instance_of String
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should return iso8601 + type if key :is8601 is there' do
|
107
107
|
x = @uo_util.__guid_data_base(@full_line)
|
108
|
-
x.
|
108
|
+
expect(x).to eql "#{@full_line[:iso8601]}#{@full_line[:type].to_s}"
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'should be year + month + day + hr + min + sec + type if !iso8601' do
|
112
112
|
x = @uo_util.__guid_data_base(fline)
|
113
113
|
s = "#{fline[:year]}#{fline[:month]}#{fline[:day]}#{fline[:hour]}" \
|
114
114
|
"#{fline[:min]}#{fline[:sec]}#{fline[:type].to_s}"
|
115
|
-
x.
|
115
|
+
expect(x).to eql s
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -131,17 +131,17 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
131
131
|
|
132
132
|
it 'should return a String' do
|
133
133
|
l = {}
|
134
|
-
@uo_util.__guid_add_data(l, :year).
|
134
|
+
expect(@uo_util.__guid_add_data(l, :year)).to be_an_instance_of String
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'should return the key you requested by as a String' do
|
138
138
|
l = { year: 2014 }
|
139
|
-
@uo_util.__guid_add_data(l, :year).
|
139
|
+
expect(@uo_util.__guid_add_data(l, :year)).to eql '2014'
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'should return an empty String if the key does not exist' do
|
143
143
|
l = { year: 2014 }
|
144
|
-
@uo_util.__guid_add_data(l, :month).
|
144
|
+
expect(@uo_util.__guid_add_data(l, :month)).to eql ''
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -157,53 +157,53 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
157
157
|
end
|
158
158
|
|
159
159
|
it 'should return a Hash' do
|
160
|
-
@uo_util.add_guid!(@full_line).
|
160
|
+
expect(@uo_util.add_guid!(@full_line)).to be_an_instance_of Hash
|
161
161
|
end
|
162
162
|
|
163
163
|
it 'should return a Hash that matches the reference' do
|
164
|
-
@uo_util.add_guid!(@full_line).
|
164
|
+
expect(@uo_util.add_guid!(@full_line)).to eql guid_line
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'should properly set the :event_guid for killed' do
|
168
168
|
x = @uo_util.add_guid!(spec_killed_line)
|
169
169
|
y = spec_guid_reference_implementation(spec_killed_line)
|
170
|
-
x.key?(:event_guid).
|
171
|
-
x[:event_guid].
|
170
|
+
expect(x.key?(:event_guid)).to be_true
|
171
|
+
expect(x[:event_guid]).to eql y[:event_guid]
|
172
172
|
end
|
173
173
|
|
174
174
|
it 'should properly set the :event_guid for died' do
|
175
175
|
x = @uo_util.add_guid!(spec_died_line)
|
176
176
|
y = spec_guid_reference_implementation(spec_died_line)
|
177
|
-
x.key?(:event_guid).
|
178
|
-
y[:event_guid].
|
177
|
+
expect(x.key?(:event_guid)).to be_true
|
178
|
+
expect(y[:event_guid]).to eql y[:event_guid]
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'should properly set the :event_guid for wounded' do
|
182
182
|
x = @uo_util.add_guid!(spec_wounded_line)
|
183
183
|
y = spec_guid_reference_implementation(spec_wounded_line)
|
184
|
-
x.key?(:event_guid).
|
185
|
-
x[:event_guid].
|
184
|
+
expect(x.key?(:event_guid)).to be_true
|
185
|
+
expect(x[:event_guid]).to eql y[:event_guid]
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'should properly set the :event_guid for announcements' do
|
189
189
|
x = @uo_util.add_guid!(spec_announcement_line)
|
190
190
|
y = spec_guid_reference_implementation(spec_announcement_line)
|
191
|
-
x.key?(:event_guid).
|
192
|
-
x[:event_guid].
|
191
|
+
expect(x.key?(:event_guid)).to be_true
|
192
|
+
expect(x[:event_guid]).to eql y[:event_guid]
|
193
193
|
end
|
194
194
|
|
195
195
|
it 'should properly set the :event_guid for beguid' do
|
196
196
|
x = @uo_util.add_guid!(spec_beguid_line)
|
197
197
|
y = spec_guid_reference_implementation(spec_beguid_line)
|
198
|
-
x.key?(:event_guid).
|
199
|
-
x[:event_guid].
|
198
|
+
expect(x.key?(:event_guid)).to be_true
|
199
|
+
expect(x[:event_guid]).to eql y[:event_guid]
|
200
200
|
end
|
201
201
|
|
202
202
|
it 'should properly set the :event_guid for chat' do
|
203
203
|
x = @uo_util.add_guid!(spec_chat_line)
|
204
204
|
y = spec_guid_reference_implementation(spec_chat_line)
|
205
|
-
x.key?(:event_guid).
|
206
|
-
x[:event_guid].
|
205
|
+
expect(x.key?(:event_guid)).to be_true
|
206
|
+
expect(x[:event_guid]).to eql y[:event_guid]
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
@@ -238,8 +238,8 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
238
238
|
md = @mf.match('2321.3 0.342 123.45')
|
239
239
|
%w{server_time damage distance}.each do |m|
|
240
240
|
x = @uo_util.__modifiers(md, m)
|
241
|
-
x.
|
242
|
-
x.
|
241
|
+
expect(x).to be_an_instance_of Float
|
242
|
+
expect(x).to eql md[m].to_f
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -247,16 +247,16 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
247
247
|
chat = 'Group'
|
248
248
|
md = /(?<channel>.*)/.match(chat)
|
249
249
|
x = @uo_util.__modifiers(md, 'channel')
|
250
|
-
x.
|
251
|
-
/[[:lower:]]+/.match(x).
|
252
|
-
x.
|
250
|
+
expect(x).to be_an_instance_of String
|
251
|
+
expect(/[[:lower:]]+/.match(x)).to_not be_nil
|
252
|
+
expect(x).to eql chat.downcase
|
253
253
|
end
|
254
254
|
|
255
255
|
it 'should convert the nearby players to Array' do
|
256
256
|
md = @ma.match('["one","two","three"]"')
|
257
257
|
x = @uo_util.__modifiers(md, 'nearby_players')
|
258
|
-
x.
|
259
|
-
x.length.
|
258
|
+
expect(x).to be_an_instance_of Array
|
259
|
+
expect(x.length).to be 3
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
@@ -275,8 +275,8 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
275
275
|
md = @mi.match('2014/02/09 14:44:44')
|
276
276
|
%w{year month day hour min sec}.each do |m|
|
277
277
|
x = @uo_util.__line_modifiers(md, m)
|
278
|
-
x.
|
279
|
-
x.
|
278
|
+
expect(x).to be_an_instance_of Fixnum
|
279
|
+
expect(x).to eql md[m].to_i
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
@@ -284,8 +284,8 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
284
284
|
md = @mf.match('2321.3 0.342 123.45')
|
285
285
|
%w{server_time damage distance}.each do |m|
|
286
286
|
x = @uo_util.__modifiers(md, m)
|
287
|
-
x.
|
288
|
-
x.
|
287
|
+
expect(x).to be_an_instance_of Float
|
288
|
+
expect(x).to eql md[m].to_f
|
289
289
|
end
|
290
290
|
end
|
291
291
|
|
@@ -293,8 +293,8 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
293
293
|
d = '042ZYK'
|
294
294
|
md = /(?<something>.*)/.match(d)
|
295
295
|
x = @uo_util.__line_modifiers(md, 'something')
|
296
|
-
x.
|
297
|
-
x.
|
296
|
+
expect(x).to be_an_instance_of md['something'].class
|
297
|
+
expect(x).to eql md['something']
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
@@ -313,14 +313,14 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
313
313
|
|
314
314
|
it 'should return a Hash' do
|
315
315
|
h = @uo_util.m_to_h(/.*/.match('thing'))
|
316
|
-
h.
|
316
|
+
expect(h).to be_an_instance_of Hash
|
317
317
|
end
|
318
318
|
|
319
319
|
it 'should properly convert the correct values to int' do
|
320
320
|
md = @mi.match('2014/02/09 14:44:44')
|
321
321
|
h = @uo_util.m_to_h(md)
|
322
322
|
[:year, :month, :day, :hour, :min, :sec].each do |m|
|
323
|
-
h[m].
|
323
|
+
expect(h[m]).to be_an_instance_of Fixnum
|
324
324
|
end
|
325
325
|
end
|
326
326
|
|
@@ -328,27 +328,27 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
328
328
|
md = @mf.match('2321.3 0.342 123.45')
|
329
329
|
h = @uo_util.m_to_h(md)
|
330
330
|
[:server_time, :damage, :distance].each do |m|
|
331
|
-
h[m].
|
331
|
+
expect(h[m]).to be_an_instance_of Float
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
335
335
|
it 'should convert the nearby players to an Array of Strings' do
|
336
336
|
md = @ma.match('["one","two","three"]"')
|
337
337
|
h = @uo_util.m_to_h(md)
|
338
|
-
h[:nearby_players].
|
339
|
-
h[:nearby_players].length.
|
338
|
+
expect(h[:nearby_players]).to be_an_instance_of Array
|
339
|
+
expect(h[:nearby_players].length).to be 3
|
340
340
|
|
341
341
|
h[:nearby_players].each do |p|
|
342
|
-
p.
|
343
|
-
p.empty
|
342
|
+
expect(p).to be_an_instance_of String
|
343
|
+
expect(p.empty?).to be false
|
344
344
|
end
|
345
345
|
end
|
346
346
|
|
347
347
|
it 'should convert nearby players to an empty Array if it is None' do
|
348
348
|
md = @ma.match('None."')
|
349
349
|
h = @uo_util.m_to_h(md)
|
350
|
-
h[:nearby_players].
|
351
|
-
h[:nearby_players].empty
|
350
|
+
expect(h[:nearby_players]).to be_an_instance_of Array
|
351
|
+
expect(h[:nearby_players].empty?).to be_true
|
352
352
|
end
|
353
353
|
end
|
354
354
|
|
@@ -367,17 +367,17 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
367
367
|
|
368
368
|
it 'should return nil if the key does not exist' do
|
369
369
|
h = { one: 'two' }
|
370
|
-
@uo_util.validate_bool_opt(h, :two).
|
370
|
+
expect(@uo_util.validate_bool_opt(h, :two)).to be_nil
|
371
371
|
end
|
372
372
|
|
373
373
|
it 'should return nil if the key is true' do
|
374
374
|
h = { x: true }
|
375
|
-
@uo_util.validate_bool_opt(h, :x).
|
375
|
+
expect(@uo_util.validate_bool_opt(h, :x)).to be_nil
|
376
376
|
end
|
377
377
|
|
378
378
|
it 'should return nil if the key is false' do
|
379
379
|
h = { x: false }
|
380
|
-
@uo_util.validate_bool_opt(h, :x).
|
380
|
+
expect(@uo_util.validate_bool_opt(h, :x)).to be_nil
|
381
381
|
end
|
382
382
|
|
383
383
|
it 'should raise ArgumentError if the key is a String' do
|
@@ -431,7 +431,7 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
431
431
|
end
|
432
432
|
|
433
433
|
it 'should return nil if arg 1 is an instance of TZInfo::DataTimezone' do
|
434
|
-
@uo_util.validate_timezone(timezone: uo_tz).
|
434
|
+
expect(@uo_util.validate_timezone(timezone: uo_tz)).to be_nil
|
435
435
|
end
|
436
436
|
|
437
437
|
it 'should raise ArgumentError if arg 1 is a String' do
|