beaver 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 59b5cde80bdb96a54a47391839e44e5df313920d
4
+ data.tar.gz: 5f34d0b376cf7ebe821a7d451485f92ce6854630
5
+ SHA512:
6
+ metadata.gz: 975399a18858fe522da3d58ec943b3f001b138f94222a5c4a430b81d5785085da35a2e41628c1db7a07424563a9ddf88cea4f3d049b70b5f218162c92a1c2bb9
7
+ data.tar.gz: 76c6e06afdb6a79c89b50dcdd0ca8a9fbe380b7f38c95b5acdd6a253bbacf6886c86afcb4d2d2416e0b184635070afe1c5bb7502e27f65578a78287a1296a3f2
data/bin/beaver CHANGED
File without changes
@@ -3,6 +3,7 @@ begin
3
3
  rescue LoadError
4
4
  $stderr.puts "Zlib not available; compressed log files will be skipped."
5
5
  end
6
+ require 'cgi'
6
7
 
7
8
  require 'beaver/version'
8
9
  require 'beaver/utils'
@@ -38,7 +38,7 @@ module Beaver
38
38
  #
39
39
  # :params_str Rails HTTP Regular expressing matching the Parameters string
40
40
  #
41
- # :params Rails Hash of Symbol=>String/Regexp pairs: {:username => 'bob', :email => /@gmail\.com$/}. All must match.
41
+ # :params Rails HTTP Hash of Symbol=>String/Regexp pairs: {:username => 'bob', :email => /@gmail\.com$/}. All must match (but *not* all must be present).
42
42
  #
43
43
  # :tagged Rails Comma-separated String or Array of Rails Tagged Logger tags. If you specify multiple tags, a request must have *all* of them.
44
44
  #
@@ -7,6 +7,7 @@ module Beaver
7
7
  # The Combined Log Format as an array of symbols
8
8
  FORMAT_SYMBOLS = FORMAT.split(' ').map(&:to_sym) # :nodoc:
9
9
  FHOST, FID, FUSER, FTIME, FREQUEST, FSTATUS, FSIZE, FREFERER, FUA = FORMAT_SYMBOLS # :nodoc:
10
+ REGEX_TIME_FIX = /([0-9]{4}):([0-9]{2})/
10
11
 
11
12
  # Regex matchers keyed by opening quotes, etc.
12
13
  MATCHERS = {'[' => /^\[([^\]]+)\] ?/, '"' => /^"([^"]+)" ?/} # :nodoc:
@@ -37,6 +38,18 @@ module Beaver
37
38
  @path
38
39
  end
39
40
 
41
+ # Parses and returns the request parameters as a Hash
42
+ def parse_params
43
+ params_str.empty? ? BLANK_HASH : CGI::parse(params_str).inject({}) do |hash, (param, value)|
44
+ hash[param] = if value.is_a?(Array) and value.size == 1 and param !~ /\[\d*\]$/
45
+ value[0]
46
+ else
47
+ value
48
+ end
49
+ hash
50
+ end
51
+ end
52
+
40
53
  # Returns the url query string
41
54
  def params_str
42
55
  parse_request! if @params_str.nil?
@@ -86,7 +99,7 @@ module Beaver
86
99
 
87
100
  # Parses and returns the time at which the request was made
88
101
  def parse_time
89
- time_str = @request[FTIME].gsub(/([0-9]{4}):([0-9]{2})/, "#{$1} #{$2}")
102
+ time_str = @request[FTIME].sub(REGEX_TIME_FIX) { "#{$1} #{$2}" }
90
103
  Time.parse(time_str) rescue nil
91
104
  end
92
105
 
@@ -47,11 +47,6 @@ module Beaver
47
47
  @ms ||= REGEX_MS.match(@data) ? $1.to_i : 0
48
48
  end
49
49
 
50
- # Returns the request parameters as a Hash (this is more expensive than Request#params_str)
51
- def params
52
- @params ||= params_str.empty? ? BLANK_HASH : Utils.str_to_hash(params_str)
53
- end
54
-
55
50
  # Returns the tags string associated with the request (e.g. "[tag1] [tag2] ")
56
51
  def tags_str
57
52
  @tags_str ||= REGEX_TAGS.match(@data) ? $1 : nil
@@ -89,6 +84,11 @@ module Beaver
89
84
  REGEX_COMPLETED.match(@data) ? $1.to_i : 0
90
85
  end
91
86
 
87
+ # Parses and returns the request parameters as a Hash
88
+ def parse_params
89
+ params_str.empty? ? BLANK_HASH : Utils.str_to_hash(params_str)
90
+ end
91
+
92
92
  # Parses and returns the request parameters as a String
93
93
  def parse_params_str
94
94
  REGEX_PARAMS_STR.match(@data) ? $1 : BLANK_STR
@@ -56,6 +56,11 @@ module Beaver
56
56
  @status ||= parse_status
57
57
  end
58
58
 
59
+ # Returns the request parameters as a Hash (this is more expensive than Request#params_str)
60
+ def params
61
+ @params ||= parse_params
62
+ end
63
+
59
64
  # Returns the request parameters as a String
60
65
  def params_str
61
66
  @params_str ||= parse_params_str
@@ -127,6 +127,8 @@ module Beaver
127
127
  indicies.all? do |i|
128
128
  if a_values[i].is_a? String
129
129
  a_values[i] == b_values[i]
130
+ elsif a_values[i].is_a? Array
131
+ a_values[i] == b_values[i]
130
132
  elsif a_values[i].is_a?(Regexp) and b_values[i].is_a?(String)
131
133
  a_values[i] =~ b_values[i]
132
134
  elsif a_values[i].is_a?(Hash) and b_values[i].is_a?(Hash)
@@ -1,4 +1,4 @@
1
1
  module Beaver
2
- MAJOR_VERSION, MINOR_VERSION, TINY_VERSION, PRE_VERSION = 1, 4, 0, nil # :nodoc:
2
+ MAJOR_VERSION, MINOR_VERSION, TINY_VERSION, PRE_VERSION = 1, 4, 1, nil # :nodoc:
3
3
  VERSION = [MAJOR_VERSION, MINOR_VERSION, TINY_VERSION, PRE_VERSION].compact.join '.' # :nodoc:
4
4
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
5
- prerelease:
4
+ version: 1.4.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jordan Hollinger
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
11
+ date: 2014-01-28 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A simple DSL and command-line tool for discovering what people are up
15
14
  to in your Rails app
@@ -21,37 +20,36 @@ extra_rdoc_files: []
21
20
  files:
22
21
  - lib/beaver.rb
23
22
  - lib/beaver/dam.rb
24
- - lib/beaver/beaver.rb
25
- - lib/beaver/request.rb
26
23
  - lib/beaver/parsers/rails.rb
27
24
  - lib/beaver/parsers/http.rb
28
- - lib/beaver/utils.rb
25
+ - lib/beaver/beaver.rb
26
+ - lib/beaver/request.rb
29
27
  - lib/beaver/version.rb
28
+ - lib/beaver/utils.rb
30
29
  - README.rdoc
31
30
  - LICENSE
32
31
  - bin/beaver
33
32
  homepage: http://github.com/jhollinger/beaver
34
33
  licenses: []
34
+ metadata: {}
35
35
  post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths:
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
40
  requirements:
42
- - - ! '>='
41
+ - - '>='
43
42
  - !ruby/object:Gem::Version
44
43
  version: '0'
45
44
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
45
  requirements:
48
- - - ! '>='
46
+ - - '>='
49
47
  - !ruby/object:Gem::Version
50
48
  version: '0'
51
49
  requirements: []
52
50
  rubyforge_project:
53
- rubygems_version: 1.8.23
51
+ rubygems_version: 2.0.14
54
52
  signing_key:
55
- specification_version: 3
53
+ specification_version: 4
56
54
  summary: Rails log parser
57
55
  test_files: []