bullet_log_parser 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: d44e398a26b680c801f106de1efba1b73eeb854aedfd204712eb05a8a7fc2770
4
- data.tar.gz: 04e5cb8c0c54f5274a415883b34868f8e806978ffd2bcc2b9ca11a00bb241c36
3
+ metadata.gz: 8db8d410f8bec07c6e097981787585a6c1e4ff2be0d3c13f22f4fb573c771514
4
+ data.tar.gz: 036afc6d764a855572429ff3dab10d494da823f87af4340cc4e7b4205f4c0a66
5
5
  SHA512:
6
- metadata.gz: 2d452a2b730d1ea0d0a3963ee05a47e438ae9c83392f4bbb9f1a3622d57c3d176866a58f59b8ec5b6974362501f1ec512b3c290edb68e02861a30b122a723d03
7
- data.tar.gz: 504f4a137bcf5aba63bb1d6876999390d9a8ad9ede26e8547081013edf9e8916eaae47f50e682397a2f686ae1becf30f514041f90acd734c2f60f53961191906
6
+ metadata.gz: 7ab35e4516ea3269e8cd5824095794a04ec76efdd93cea8bc9d9c48d52a039bb4ef1b8723835b85dbf9140dfc6de21cef6ed01633102e275948eabb19306284a
7
+ data.tar.gz: baad9b1e9775d92e6a39e808f01322387121e0f14d48cf2b96012f9076f909375e57fac4e0e2430cce59278e82f6df90059bc1306f5428133439f828e453fba9
@@ -1,3 +1,10 @@
1
+ ## [1.0.1](https://github.com/satoruk/bullet_log_parser/compare/v1.0.0...v1.0.1) (2020-08-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix to parse last boundary log ([37b54d5](https://github.com/satoruk/bullet_log_parser/commit/37b54d52ef50a61f2cc6f1e699584d57ac6bbf6b))
7
+
1
8
  # 1.0.0 (2020-07-31)
2
9
 
3
10
 
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  <h1 align="center">bullet log parser</h2>
2
2
 
3
3
  <p align="center">
4
- <a href="https://github.com/satoruk/bullet_log_parser/actions?query=workflow%3ACI"><img src="https://github.com/satoruk/bullet_log_parser/workflows/CI/badge.svg" /></a>
4
+ <a href="https://github.com/satoruk/bullet_log_parser/actions?query=workflow%3ACI"><img src="https://github.com/satoruk/bullet_log_parser/workflows/CI/badge.svg" height="20"/></a>
5
+ <a href="https://badge.fury.io/rb/bullet_log_parser"><img src="https://badge.fury.io/rb/bullet_log_parser.svg" alt="Gem Version" height="20"></a>
5
6
  </p>
6
7
 
7
8
  This parser can help to convert the Bullet logs to prefer format you want.
@@ -26,7 +27,12 @@ cat log/bullet.log | bullet_log_filter.rb
26
27
  #!/usr/bin/env ruby
27
28
  # frozen_string_literal: true
28
29
 
29
- require 'bullet_log_parser'
30
+ begin
31
+ require 'bullet_log_parser'
32
+ rescue LoadError => _e
33
+ require 'bundler/setup'
34
+ require 'bullet_log_parser'
35
+ end
30
36
 
31
37
  if __FILE__ == $PROGRAM_NAME
32
38
  results = BulletLogParser.uniq_log($stdin) do |ast|
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'bullet_log_parser/version'
4
4
  require 'bullet_log_parser/parser'
5
+ require 'set'
5
6
 
6
7
  module BulletLogParser # :nodoc:
7
8
  def self.generate_bare_ast(ast)
@@ -11,7 +12,7 @@ module BulletLogParser # :nodoc:
11
12
  end
12
13
 
13
14
  def self.uniq_log(io)
14
- memo = Hash.new { |h, k| h[k] = [] }
15
+ memo = Hash.new { |h, k| h[k] = Set.new }
15
16
  parse(io) do |ast|
16
17
  bare_ast = generate_bare_ast(ast)
17
18
  detection = memo[bare_ast[:detection]]
@@ -23,18 +24,24 @@ module BulletLogParser # :nodoc:
23
24
  memo
24
25
  end
25
26
 
26
- def self.parse(io)
27
+ def self.parse(io, &block)
27
28
  parser = Parser.new
28
29
  loop do
29
- str = io.gets
30
- break unless str
30
+ line = io.gets
31
+ unless line
32
+ parse_line(parser, '', &block)
33
+ break
34
+ end
31
35
 
32
- parser.puts(str.chomp)
33
- next unless parser.terminated?
36
+ parser = Parser.new if parse_line(parser, line.chomp, &block)
37
+ end
38
+ end
34
39
 
35
- yield parser.ast unless parser.failed?
40
+ def self.parse_line(parser, line)
41
+ parser.puts(line)
42
+ return false unless parser.completed?
36
43
 
37
- parser = Parser.new
38
- end
44
+ yield parser.ast
45
+ true
39
46
  end
40
47
  end
@@ -9,7 +9,10 @@ module BulletLogParser # :nodoc:
9
9
 
10
10
  def initialize
11
11
  @parse_method = :parse_line1
12
- @ast = {}
12
+ @ast = {
13
+ details: [],
14
+ stack: []
15
+ }
13
16
  @terminated = false
14
17
  @failed = false
15
18
  end
@@ -32,6 +35,10 @@ module BulletLogParser # :nodoc:
32
35
  @terminated || @failed
33
36
  end
34
37
 
38
+ def completed?
39
+ @terminated && @failed == false
40
+ end
41
+
35
42
  def puts(str)
36
43
  perse_proc = method(@parse_method).curry
37
44
  perse_proc.call(str)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulletLogParser
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_log_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - satoruk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-31 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Bullet log perser.
14
14
  email: