sms-logparser 0.15.1 → 0.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sms-logparser/log_message.rb +3 -3
- data/lib/sms-logparser/version.rb +1 -1
- data/spec/log_message_spec.rb +14 -1
- data/spec/parser_spec.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c89e242f1560045deef189787a1a36e03c6316
|
4
|
+
data.tar.gz: e384c0d183ee76ec5496d44f7b235c19b098f20b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bac5632a23b1d03b17494254d03df1aee6c4335243e9e94339f1d836a57191dfb9eb021143a31b642ffdcc8126f119ba9730127bd2ae3198ad418c6bbbff31a2
|
7
|
+
data.tar.gz: 0cf8ac3de610af40966095a76c5bf88f32ae4499f0ee602280f744d78d46ec5f56abd32a6b256b31408d426d92e3d7417c11f36506bcabac9c73ae64769874fb
|
@@ -21,7 +21,7 @@ module SmsLogparser
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def args
|
24
|
-
match[5]
|
24
|
+
match[5][1..-1] if match[5]
|
25
25
|
end
|
26
26
|
|
27
27
|
def status
|
@@ -33,7 +33,7 @@ module SmsLogparser
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def file_extname
|
36
|
-
File.extname(file)
|
36
|
+
File.extname(file) if file
|
37
37
|
end
|
38
38
|
|
39
39
|
def user_agent
|
@@ -65,7 +65,7 @@ module SmsLogparser
|
|
65
65
|
private
|
66
66
|
|
67
67
|
def match
|
68
|
-
@match ||= @message.match /\/content\/(\d+)\/(\d+)\/(\d+)\/(\w+\.\w+)(\?\S*)*\s.*\"\s(\d+)\s(\d+).+"(.*)"$/
|
68
|
+
@match ||= @message.match /\/content\/(\d+)\/(\d+)\/(\d+)\/(\w+\.\w+)*(\?\S*)*\s.*\"\s(\d+)\s(\d+).+"(.*)"$/
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
data/spec/log_message_spec.rb
CHANGED
@@ -23,9 +23,22 @@ describe SmsLogparser::LogMessage do
|
|
23
23
|
log_message.status.must_equal 206
|
24
24
|
log_message.bytes.must_equal 100708
|
25
25
|
log_message.file.must_equal 'simvid_1_40.flv'
|
26
|
-
log_message.args.must_equal '
|
26
|
+
log_message.args.must_equal 'position=22'
|
27
27
|
log_message.file_extname.must_equal '.flv'
|
28
28
|
log_message.user_agent.must_equal 'Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0'
|
29
29
|
end
|
30
30
|
|
31
|
+
it "can extract the correct values from messages without files" do
|
32
|
+
log_message = SmsLogparser::LogMessage.new('- - [23/Apr/2014:17:47:32 +0200] "GET /content/51/52/42624/ HTTP/1.1" 200 1181 "-" "Googlebot-Video/1.0"')
|
33
|
+
log_message.customer_id.must_equal '51'
|
34
|
+
log_message.author_id.must_equal '52'
|
35
|
+
log_message.project_id.must_equal '42624'
|
36
|
+
log_message.status.must_equal 200
|
37
|
+
log_message.bytes.must_equal 1181
|
38
|
+
log_message.file.must_equal nil
|
39
|
+
log_message.args.must_equal nil
|
40
|
+
log_message.file_extname.must_equal nil
|
41
|
+
log_message.user_agent.must_equal 'Googlebot-Video/1.0'
|
42
|
+
end
|
43
|
+
|
31
44
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -111,6 +111,17 @@ describe SmsLogparser::Parser do
|
|
111
111
|
data.first[:value].must_equal 100708
|
112
112
|
end
|
113
113
|
|
114
|
+
it "count traffic with status 200 and no file from bot as webcast visit" do
|
115
|
+
message = '- - [23/Apr/2014:17:47:32 +0200] "GET /content/51/52/42624/ HTTP/1.1" 200 1181 "-" "Googlebot-Video/1.0"'
|
116
|
+
data = SmsLogparser::Parser.new.extract_data_from_msg(message)
|
117
|
+
data.size.must_equal 1
|
118
|
+
data.first[:customer_id].must_equal "51"
|
119
|
+
data.first[:author_id].must_equal "52"
|
120
|
+
data.first[:project_id].must_equal "42624"
|
121
|
+
data.first[:type].must_equal 'TRAFFIC_WEBCAST'
|
122
|
+
data.first[:value].must_equal 1181
|
123
|
+
end
|
124
|
+
|
114
125
|
it "do not count *.css with status 200 as visit" do
|
115
126
|
message = '- - [22/Apr/2014:18:00:50 +0200] "GET /content/51/52/42431/application.css HTTP/1.1" 200 192 "http://blick.simplex.tv/NubesPlayer/player.swf" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"'
|
116
127
|
data = SmsLogparser::Parser.new.extract_data_from_msg(message)
|