sms-logparser 0.15.0 → 0.15.1
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 +11 -7
- data/lib/sms-logparser/version.rb +1 -1
- data/spec/log_message_spec.rb +15 -1
- data/spec/parser_spec.rb +10 -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: bff5cf76ce93fa19c9d0f5c488363dd5b86d10fd
|
4
|
+
data.tar.gz: 05f02b03ef8e63810a21bd3f6e9061eff6c1b325
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fcba57cac34ad776f065f98169ba2c00bcf8040ad59de87037a37ce0573ef28ee8187804d48875e19cba7b1fb62223b9e2bec9665542b235571050e573a56b6
|
7
|
+
data.tar.gz: 2f496cd73c38b7910a1851de88fe4a3e27873d9f2a935354bac3e81868033c144055c2a184ed8ff3688cec7c792bce296af412439e8e91c2588022bc70ed4e43
|
@@ -16,16 +16,20 @@ module SmsLogparser
|
|
16
16
|
match[3]
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
match[
|
19
|
+
def file
|
20
|
+
match[4]
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def args
|
24
|
+
match[5]
|
25
|
+
end
|
26
|
+
|
27
|
+
def status
|
24
28
|
match[6].to_i
|
25
29
|
end
|
26
30
|
|
27
|
-
def
|
28
|
-
match[
|
31
|
+
def bytes
|
32
|
+
match[7].to_i
|
29
33
|
end
|
30
34
|
|
31
35
|
def file_extname
|
@@ -33,7 +37,7 @@ module SmsLogparser
|
|
33
37
|
end
|
34
38
|
|
35
39
|
def user_agent
|
36
|
-
match[
|
40
|
+
match[8]
|
37
41
|
end
|
38
42
|
|
39
43
|
def account_info
|
@@ -61,7 +65,7 @@ module SmsLogparser
|
|
61
65
|
private
|
62
66
|
|
63
67
|
def match
|
64
|
-
@match ||= @message.match /\/content\/(\d+)\/(\d+)\/(\d+)\/(\w+\.\w+)
|
68
|
+
@match ||= @message.match /\/content\/(\d+)\/(\d+)\/(\d+)\/(\w+\.\w+)(\?\S*)*\s.*\"\s(\d+)\s(\d+).+"(.*)"$/
|
65
69
|
end
|
66
70
|
end
|
67
71
|
end
|
data/spec/log_message_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SmsLogparser::LogMessage do
|
4
4
|
|
5
|
-
it "can extract the correct values from messages" do
|
5
|
+
it "can extract the correct values from messages without arg string" do
|
6
6
|
log_message = SmsLogparser::LogMessage.new('127.0.0.1 - - [13/Apr/2014:05:33:23 +0200] "GET /content/51/102/42481/simvid_1.mp4 HTTP/1.1" 206 7865189 "-" "iTunes/11.1.5 (Windows; Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601)) AppleWebKit/537.60.11"')
|
7
7
|
log_message.customer_id.must_equal '51'
|
8
8
|
log_message.author_id.must_equal '102'
|
@@ -10,8 +10,22 @@ describe SmsLogparser::LogMessage do
|
|
10
10
|
log_message.status.must_equal 206
|
11
11
|
log_message.bytes.must_equal 7865189
|
12
12
|
log_message.file.must_equal 'simvid_1.mp4'
|
13
|
+
log_message.args.must_equal nil
|
13
14
|
log_message.file_extname.must_equal '.mp4'
|
14
15
|
log_message.user_agent.must_equal 'iTunes/11.1.5 (Windows; Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601)) AppleWebKit/537.60.11'
|
15
16
|
end
|
16
17
|
|
18
|
+
it "can extract the correct values from messages wit arg string" do
|
19
|
+
log_message = SmsLogparser::LogMessage.new('- - [23/Apr/2014:17:36:33 +0200] "GET /content/51/52/42721/simvid_1_40.flv?position=22 HTTP/1.1" 206 100708 "http://blick.simplex.tv/NubesPlayer/player.swf" "Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0"')
|
20
|
+
log_message.customer_id.must_equal '51'
|
21
|
+
log_message.author_id.must_equal '52'
|
22
|
+
log_message.project_id.must_equal '42721'
|
23
|
+
log_message.status.must_equal 206
|
24
|
+
log_message.bytes.must_equal 100708
|
25
|
+
log_message.file.must_equal 'simvid_1_40.flv'
|
26
|
+
log_message.args.must_equal '?position=22'
|
27
|
+
log_message.file_extname.must_equal '.flv'
|
28
|
+
log_message.user_agent.must_equal 'Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0'
|
29
|
+
end
|
30
|
+
|
17
31
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -101,6 +101,16 @@ describe SmsLogparser::Parser do
|
|
101
101
|
data[1][:value].must_equal 1
|
102
102
|
end
|
103
103
|
|
104
|
+
it "count traffic with status 206 and a argumenst string and user agent Firefox on Windows as webcast visit" do
|
105
|
+
message = '- - [23/Apr/2014:17:36:33 +0200] "GET /content/51/52/42721/simvid_1_40.flv?position=22 HTTP/1.1" 206 100708 "http://blick.simplex.tv/NubesPlayer/player.swf" "Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0"'
|
106
|
+
data = SmsLogparser::Parser.new.extract_data_from_msg(message)
|
107
|
+
data.first[:customer_id].must_equal "51"
|
108
|
+
data.first[:author_id].must_equal "52"
|
109
|
+
data.first[:project_id].must_equal "42721"
|
110
|
+
data.first[:type].must_equal 'TRAFFIC_WEBCAST'
|
111
|
+
data.first[:value].must_equal 100708
|
112
|
+
end
|
113
|
+
|
104
114
|
it "do not count *.css with status 200 as visit" do
|
105
115
|
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"'
|
106
116
|
data = SmsLogparser::Parser.new.extract_data_from_msg(message)
|