log_parser 2.0.1 → 2.0.2

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: 0d5d06fb8731c7a83ec6f3b319d96748891724c2
4
- data.tar.gz: 6913f0eb1ca82e496ba08a04dbf097b51204a6fd
3
+ metadata.gz: 234abf7d078d9cc9f0638a0e161850adea23cb0e
4
+ data.tar.gz: 480cfb8ca189dc6abb07a529f41b361e8548d08e
5
5
  SHA512:
6
- metadata.gz: f0e7456703fce5563ab791a01b457b270198a755e5147e5f3a545f5e61cd9fac7d3f66a69bb0a73679bb7c3351a8bbcb1754032fb220b8067473e472c73fb326
7
- data.tar.gz: a5ef9c3c63da66ec9c61b9a123d9093f54ae2e39f05bf1c069c3332a56ce50286ae9554f00d104dc5a9f261c9bb0ff326f7fc062b5d80c9361646e852b7e290d
6
+ metadata.gz: bddbb96b52a46334907e36a170a2e70ccad3c2860e35d8be03c1064cd21e3c050ca4a5ce9bf4c0e3299c8033462faa02b4443d33dbf8a8c65d68747bb27fd2d6
7
+ data.tar.gz: a042e2502d53ee48fecd595053fea7223a54648e57329f9d82a1b1a0f90eb438ddca39791353e38ecd69fa6c049383e165b1b6acfd8a5a84215bf3a3519d5489
data/README.md CHANGED
@@ -22,7 +22,7 @@ The class offers a some methods for scanning through a log `by_message(msg)`, `e
22
22
  These methods can be chained together to refine your search. For example:
23
23
 
24
24
  ```Ruby
25
- log = LogParser::Client.new('some.log')
25
+ log = LogParser::Client.new('some.log', line_pattern: LogParser::LOGGER_PATTERN)
26
26
  log.errors.by_message('authentication failed').since(1.day.ago)
27
27
  #=> ["[2014-11-13T23:12:14-07:00] ERROR [page_id 95239] Authentication failed with token ..."]
28
28
  ```
@@ -130,7 +130,7 @@ module LogParser
130
130
  line = nil
131
131
  begin
132
132
  line = f.gets
133
- line_items << LineItem.new($1, $3, $5, $6) if line =~ line_pattern
133
+ line_items << LineItem.new($1, $3, $5, $6) if line =~ @line_pattern
134
134
  end while line
135
135
  end
136
136
  line_items
@@ -1,3 +1,3 @@
1
1
  module LogParser
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
@@ -4,8 +4,9 @@ require 'log_parser'
4
4
  class LogParser::ClientTest < MiniTest::Unit::TestCase
5
5
 
6
6
  def setup
7
- @file = Pathname.new(File.join(Dir.pwd, 'test', 'fixtures', 'example.log'))
7
+ @file = Pathname.new(File.expand_path(File.join('..', '..', 'fixtures', 'example.log'), __FILE__))
8
8
  @log = LogParser::Client.new(@file)
9
+ @date = DateTime.parse('2014-11-13T23:12:12-07:00')
9
10
  end
10
11
 
11
12
  def test_initialize_with_string
@@ -66,10 +67,25 @@ class LogParser::ClientTest < MiniTest::Unit::TestCase
66
67
  assert_equal ['page_id 24323', 'page_id 75645', 'page_id 95239'], prefixes
67
68
  end
68
69
 
69
- def test_chaining_methods
70
- date = DateTime.parse('2014-11-13T23:12:12-07:00')
71
- lines = @log.by_prefix('page_id 24323').by_message(/saved \d+ reviews/i).since(date).uniq
70
+ #
71
+ # Chaining
72
+ #
73
+
74
+ def test_prefix_is_chainable
75
+ prefix_lines = @log.by_prefix('foobar')
76
+ assert_respond_to prefix_lines, :by_message
77
+ assert_respond_to prefix_lines, :by_type
78
+ assert_respond_to prefix_lines, :since
79
+ end
80
+
81
+ def test_filtering_by_chaining
82
+ lines = @log.by_prefix('page_id 24323').by_message(/saved \d+ reviews/i).since(@date).uniq
72
83
  assert_equal 1, lines.count
73
84
  assert_equal '[page_id 24323] Saved 10 reviews', lines.first.full_message
74
85
  end
86
+
87
+ def test_no_chain_mutation
88
+ @log.by_prefix('page_id 24323').by_message(/saved \d+ reviews/i).since(@date).uniq
89
+ assert_equal 7, @log.lines.count
90
+ end
75
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.4.3
82
+ rubygems_version: 2.2.2
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Easily search log files