rslog 0.0.17 → 0.0.18

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
2
  SHA256:
3
- metadata.gz: 52bf0a8fd868cb749fcd759adfb7782a5cba4b148f15f6f52b913147dd6fa95d
4
- data.tar.gz: a15d5b6d9ad034f6ffd962e47757ed7f3878c25aee4bace3d5d27bbe79d033b3
3
+ metadata.gz: eb99fc992d911ae7e46723f3ceac4083d1b29dae2838cd7f20b4ce60e54074d4
4
+ data.tar.gz: 314c33d8074c6b58d467d25da39d977cf9eb8bec352ee3ccb563eb1ec9ef2793
5
5
  SHA512:
6
- metadata.gz: 916951619a9a3949fe6c4b5d3d2f9f684d3eaf7107d5cba15162d5402009a24187a61baea8ce0dab153c2315a06045956e49bf25eb2b9aec6b1b85871f198788
7
- data.tar.gz: 071e2abb7278a4a84aaa2cec1154a5e63c83971746d5cdacd7b32127d5c36225e43f772b22ccff342a73f24d4d4d185743e971d2c9903f5ae2d7f86031594433
6
+ metadata.gz: f2be9106c18ab79fc4db32a72d724135841f343cb275fbafb7c1f8d2415bb899815a43b30a18bcba6051b1b5a7b996be2a8f50ac0b637214e77e6d4134ca57aa
7
+ data.tar.gz: 909c144ab0773bb1a295be24521fcd4e0085f50d654cfe4da45e5054dcbd55687a0748e5a6f3c421d76990cb6998c84e670aef071518529d850e49172d3070fe
data/lib/rslog.rb CHANGED
@@ -5,11 +5,12 @@ require_relative 'rslog/args_handler'
5
5
  require_relative 'rslog/validator'
6
6
  require_relative 'rslog/data_processing'
7
7
  require_relative 'rslog/parser'
8
+ require_relative 'rslog/decorator'
8
9
  require_relative 'rslog/presenter'
9
10
  require 'set'
10
11
 
11
12
  module RSlog
12
- VERSION = '0.0.17'
13
+ VERSION = '0.0.18'
13
14
 
14
15
  # Module to hold main process
15
16
  #
data/lib/rslog/parser.rb CHANGED
@@ -1,16 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
4
-
5
3
  module RSlog
6
4
  # Class to parse data
7
5
  #
8
6
  class Parser
9
7
  attr_reader :data_processing
10
8
 
11
- extend Forwardable
12
- def_delegators :@data_processing, :extract, :group, :calculate, :order
13
-
14
9
  def initialize(data_processing)
15
10
  @data_processing = data_processing
16
11
  end
@@ -12,15 +12,6 @@ module RSlog
12
12
  # "/help_page/1 1 visits" ]
13
13
  #
14
14
  class Presenter
15
- LEFT_UP_CORNER = "\u250c"
16
- RIGHT_UP_CORNER = "\u2510"
17
- LEFT_DOWN_CORNER = "\u2514"
18
- RIGHT_DOWN_CORNER = "\u2518"
19
- VERTICAL_BORDER = "\u2502"
20
- HORIZONTAL_BORDER = "\u2500"
21
- VERTICAL_LEFT_BORDER = "\u251C"
22
- VERTICAL_RIGHT_BORDER = "\u2524"
23
-
24
15
  def initialize(source, conf)
25
16
  @source = source
26
17
  @col_size = conf.fetch(:col_size, 20)
@@ -28,12 +19,13 @@ module RSlog
28
19
  @formatter = conf.fetch(:formatter, "%-#{@col_size}s")
29
20
  @columns = conf.fetch(:columns, @source&.first&.size || 1)
30
21
  @head_titles = conf.fetch(:head_titles, Array.new(@columns, 'title'))
22
+ @decorator = conf.fetch(:decorator, RSlog::Decorator.new(:utf))
31
23
  end
32
24
 
33
25
  def present
34
26
  puts @title
35
27
  puts _top_border
36
- puts VERTICAL_BORDER + format(@formatter * @columns, *@head_titles) + VERTICAL_BORDER
28
+ puts @decorator.vertical_border + _formatted_head_titles + @decorator.vertical_border
37
29
  puts _middle_border
38
30
  puts _formatted_data
39
31
  puts _bottom_border
@@ -43,25 +35,31 @@ module RSlog
43
35
  private
44
36
 
45
37
  def _top_border
46
- LEFT_UP_CORNER + _horisontal_line + RIGHT_UP_CORNER
38
+ @decorator.left_up_corner + _horisontal_line + @decorator.right_up_corner
47
39
  end
48
40
 
49
41
  def _middle_border
50
- VERTICAL_LEFT_BORDER + _horisontal_line + VERTICAL_RIGHT_BORDER
42
+ @decorator.vertical_left_border + _horisontal_line + @decorator.vertical_right_border
51
43
  end
52
44
 
53
45
  def _bottom_border
54
- LEFT_DOWN_CORNER + _horisontal_line + RIGHT_DOWN_CORNER
46
+ @decorator.left_down_corner + _horisontal_line + @decorator.right_down_corner
55
47
  end
56
48
 
57
49
  def _horisontal_line
58
- HORIZONTAL_BORDER * @col_size * @columns
50
+ @decorator.horizontal_border * @col_size * @columns
51
+ end
52
+
53
+ def _formatted_head_titles
54
+ format(@formatter * @columns, *@head_titles)
59
55
  end
60
56
 
61
57
  def _formatted_data
62
58
  @source.map do |row|
63
59
  row = row.map(&:to_s)
64
- VERTICAL_BORDER + format(@formatter * @columns, *row).to_s + VERTICAL_BORDER
60
+ @decorator.vertical_border +
61
+ format(@formatter * @columns, *row).to_s +
62
+ @decorator.vertical_border
65
63
  end
66
64
  end
67
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rslog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Eremeev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-03 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby script to get overall Statistic for weblog logs!
14
14
  email: a.eremeev@outlook.com