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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bff5cf76ce93fa19c9d0f5c488363dd5b86d10fd
4
- data.tar.gz: 05f02b03ef8e63810a21bd3f6e9061eff6c1b325
3
+ metadata.gz: 20c89e242f1560045deef189787a1a36e03c6316
4
+ data.tar.gz: e384c0d183ee76ec5496d44f7b235c19b098f20b
5
5
  SHA512:
6
- metadata.gz: 3fcba57cac34ad776f065f98169ba2c00bcf8040ad59de87037a37ce0573ef28ee8187804d48875e19cba7b1fb62223b9e2bec9665542b235571050e573a56b6
7
- data.tar.gz: 2f496cd73c38b7910a1851de88fe4a3e27873d9f2a935354bac3e81868033c144055c2a184ed8ff3688cec7c792bce296af412439e8e91c2588022bc70ed4e43
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
@@ -1,3 +1,3 @@
1
1
  module SmsLogparser
2
- VERSION = "0.15.1"
2
+ VERSION = "0.15.3"
3
3
  end
@@ -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 '?position=22'
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms-logparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - niwo