log_analyzer 0.3.1 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3949a52059cfee648c1748f24c7568a188c3b7ae
4
- data.tar.gz: c0bc7095f2140417b1e61ff35421eed7c2c378d0
2
+ SHA256:
3
+ metadata.gz: f31c44a323b2a06f061691818fe51adb618e02b9ba5dd3f92777e73346cd99b8
4
+ data.tar.gz: 59d874b13421caf36ec39811646bbff5f423b7b18cb96e1ae0a83cb88e919320
5
5
  SHA512:
6
- metadata.gz: 02afd22979e2959f38520ef65a03cca3f46e26ccc3317d32bca99e591acab8efc9d23ca28ab02ce6cc09a119c759a90e4dce0d7a8df595cd94e75510926371ce
7
- data.tar.gz: ee999e789c0cc89ee027f2c7a81e8ccb8d6419a16ccaaffe43c453bb23a9a5239d8a87bb9a2425a0482b7564bbe45f7bd91f6d2aaccb1f665208e507f8e00f54
6
+ metadata.gz: f2b7763d08c6e87766dab819850afd4b38787f26144fceaf12692b353529850038d9deb4b02e7661818a31a112b5654d5e055b22adf9663b3e8122db48785690
7
+ data.tar.gz: d8b969921b631130cbe907c6e9e0305278da7bfa68f7fd17668d4a38bb95b1ed8644a5785cdfedeacc138abadcb390b03c1e2e6345ba23b3e4562196df8c8d62
data/Gemfile CHANGED
@@ -4,4 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'simplecov', require: false, group: :test
7
- gem 'rspec'
7
+ gem 'rspec'
8
+ gem 'spreadsheet'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- log_analyzer (0.3.1)
4
+ log_analyzer (0.3.2)
5
5
  colorize
6
6
  prawn
7
7
  prawn-table
@@ -27,7 +27,7 @@ GEM
27
27
  pry (0.11.3)
28
28
  coderay (~> 1.1.0)
29
29
  method_source (~> 0.9.0)
30
- rake (12.3.0)
30
+ rake (13.0.1)
31
31
  rspec (3.7.0)
32
32
  rspec-core (~> 3.7.0)
33
33
  rspec-expectations (~> 3.7.0)
@@ -41,16 +41,19 @@ GEM
41
41
  diff-lcs (>= 1.2.0, < 2.0)
42
42
  rspec-support (~> 3.7.0)
43
43
  rspec-support (3.7.1)
44
+ ruby-ole (1.2.12.2)
44
45
  simplecov (0.13.0)
45
46
  docile (~> 1.1.0)
46
47
  json (>= 1.8, < 3)
47
48
  simplecov-html (~> 0.10.0)
48
49
  simplecov-html (0.10.0)
50
+ spreadsheet (1.2.6)
51
+ ruby-ole (>= 1.0)
49
52
  terminal-table (1.8.0)
50
53
  unicode-display_width (~> 1.1, >= 1.1.1)
51
- thor (0.20.0)
52
- ttfunk (1.5.1)
53
- unicode-display_width (1.3.0)
54
+ thor (1.0.1)
55
+ ttfunk (1.6.2.1)
56
+ unicode-display_width (1.7.0)
54
57
 
55
58
  PLATFORMS
56
59
  ruby
@@ -61,6 +64,7 @@ DEPENDENCIES
61
64
  pry
62
65
  rspec
63
66
  simplecov
67
+ spreadsheet
64
68
 
65
69
  BUNDLED WITH
66
- 1.15.3
70
+ 1.17.3
data/README.md CHANGED
@@ -49,11 +49,13 @@ Samples:
49
49
  * `log_analyzer production.log -pdf`
50
50
  * `log_analyzer -f log/production.log -s name`
51
51
  * `log_analyzer -f log/production.log -s time -f v`
52
+ * `log_analyzer -f log/production.log -s rtime -f v`
52
53
  * `log_analyzer -file log/production.log -sort count`
53
54
  * `log_analyzer -file log/production.log -sort count -filter view`
54
55
  * `log_analyzer -file log/production.log -sort count -filter partial`
55
56
  * `log_analyzer -file log/production.log -sort time -filter p`
56
57
  * `log_analyzer development.log -csv -s time -f p`
58
+ * `log_analyzer development.log -xls -s time -f p`
57
59
  * `log_analyzer log/production.log -pdf --short`
58
60
  * `log_analyzer -file log/production.log --short`
59
61
  * `log_analyzer --help`
@@ -80,6 +82,7 @@ Big thank you to all our contributors:
80
82
  * [@ritaritual](https://github.com/ritaritual)
81
83
  * [@y-yagi](https://github.com/y-yagi)
82
84
  * [@RafaelHashimoto](https://github.com/RafaelHashimoto)
85
+ * [@Quentinchampenois](https://github.com/Quentinchampenois)
83
86
 
84
87
  ## TODO
85
88
 
@@ -35,6 +35,10 @@ parser = OptionParser.new do |opts|
35
35
  options[:format] = 'csv'
36
36
  end
37
37
 
38
+ opts.on('-xls', '--output=xls', 'Export to .xls') do |v|
39
+ options[:format] = 'xls'
40
+ end
41
+
38
42
  opts.on('-h', '--help', 'Displays Help') do
39
43
  puts opts
40
44
  exit
@@ -65,6 +69,8 @@ if options[:file] && options[:sort]
65
69
  analyzer.to_pdf(LogAnalyzer::Utils.report_name('pdf'), short: options[:short])
66
70
  when 'csv'
67
71
  analyzer.to_csv(LogAnalyzer::Utils.report_name('csv'), short: options[:short])
72
+ when 'xls'
73
+ analyzer.to_xls(LogAnalyzer::Utils.report_name('xls'), short: options[:short])
68
74
  else
69
75
  analyzer.visualize(short: options[:short])
70
76
  end
@@ -3,6 +3,7 @@ require "colorize"
3
3
  require "prawn"
4
4
  require "prawn/table"
5
5
  require "csv"
6
+ require 'spreadsheet'
6
7
  require "log_analyzer/version"
7
8
  require "log_analyzer/configuration"
8
9
  require "log_analyzer/utils"
@@ -1,5 +1,5 @@
1
1
  module LogAnalyzer
2
-
2
+
3
3
  class Analyzer
4
4
  DEFAULT_TABLE_WIDTH = 120 # width
5
5
  CONTENT_LENGTH = (0..DEFAULT_TABLE_WIDTH - 20).freeze
@@ -36,6 +36,8 @@ module LogAnalyzer
36
36
  @stats = @stats.sort{|a, b| a[0] <=> b[0] }
37
37
  when :time
38
38
  @stats = @stats.sort{|a, b| a[1].avg <=> b[1].avg }
39
+ when :rtime
40
+ @stats = @stats.sort{|a, b| b[1].avg <=> a[1].avg }
39
41
  when :count
40
42
  @stats = @stats.sort{|a, b| a[1].count <=> b[1].count }
41
43
  end
@@ -98,6 +100,21 @@ module LogAnalyzer
98
100
  end
99
101
  end
100
102
 
103
+ def to_xls(out_filename, short: false)
104
+ xls = Spreadsheet::Workbook.new
105
+ xls.create_worksheet
106
+ #XLS header
107
+ xls.worksheet(0).insert_row(0, HEADER)
108
+ #XLS content
109
+ stats.each do |path, stat|
110
+ xls.worksheet(0).insert_row(
111
+ xls.worksheet(0).last_row_index + 1,
112
+ xls_format_row(path, stat, short)
113
+ )
114
+ end
115
+ xls.write("#{Dir.pwd}/#{out_filename}")
116
+ end
117
+
101
118
  private
102
119
 
103
120
  def console_row(path, stat, short)
@@ -124,6 +141,7 @@ module LogAnalyzer
124
141
 
125
142
  alias :pdf_row :simple_row
126
143
  alias :csv_format_row :simple_row
144
+ alias :xls_format_row :simple_row
127
145
 
128
146
  def new_table
129
147
  Terminal::Table.new(headings: HEADER, width: DEFAULT_TABLE_WIDTH)
@@ -1,3 +1,3 @@
1
1
  module LogAnalyzer
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -191,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
- rubyforge_project:
195
- rubygems_version: 2.6.12
194
+ rubygems_version: 3.0.6
196
195
  signing_key:
197
196
  specification_version: 4
198
197
  summary: log_analyzer gem is created to get statistics about your views rendering