debug_logger 0.0.4.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 690e37e85ff91ea12767873db8c67b5a77a87e2ccf5ccfee871060408b022c40
4
- data.tar.gz: f657b870ad5e1078c311aa585c0a8005013924353b6516220a7dc9b84a4a6b6f
3
+ metadata.gz: 2239057c2cd0841dbc8a01562cbc9057f2e1dc2b1b9778150fd57322917bfd4e
4
+ data.tar.gz: 0f73a8cea9a9b6b136627c0407da5e533b846a7f4cb9d2c380197654cf5674a8
5
5
  SHA512:
6
- metadata.gz: ab670cb34fd6b1f604450cdbd273fc6cf7b6a0226388ef9c249be54ab5b3223551c140f0c94665d47a7892391744f56f3a8831cbc502ada5dab81c5d866c6ad1
7
- data.tar.gz: ac844829eae9fc24fbfcf7f3b6ac2aa6e6c05dafe768986adfed16da1931b22d42cbd6bfd50e5d0118971fc8d2d677f93d8ee263686c3d5312128b032be90b2f
6
+ metadata.gz: 05aef375ab2b8a7fe41853fd4744b5560ec5e7540a287d202cf5c82a72d885bff30f26e7793d50c41f9ee16a554716c57bc7952dbcb840a2576c0298c7c1685a
7
+ data.tar.gz: c658ea6745266790c975c463e1292747c7f6ae039726fa2b3ecff446e68397e9cdbbad2465fc4072909f41ce806b75be6b2d924e1310b3df54e3ded268c7d3e6
@@ -0,0 +1,36 @@
1
+ class DebugLogger::DebugLoggerUtils
2
+ def self.color_signification(color)
3
+ case color
4
+ when :black
5
+ 30
6
+ when :red
7
+ 31
8
+ when :green
9
+ 32
10
+ when :orange
11
+ 33
12
+ when :blue
13
+ 34
14
+ when :pink
15
+ 35
16
+ when :cyan
17
+ 36
18
+ when :white
19
+ 37
20
+ when :normal
21
+ 38
22
+ when :bold
23
+ 1
24
+ when :italic
25
+ 3
26
+ when :underline
27
+ 4
28
+ else
29
+ 38
30
+ end
31
+ end
32
+
33
+ def self.colors
34
+ [:black, :red, :green, :orange, :blue, :pink, :cyan, :white, :normal, :bold, :italic, :underline]
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ require 'date'
2
+
3
+ class DebugLogger::Log
4
+
5
+ attr_accessor :storing
6
+
7
+ def initialize
8
+ @storing = initialize_storing
9
+ end
10
+
11
+ def store(log_text)
12
+ storing << {
13
+ log_message: log_text,
14
+ date: DateTime.now.strftime('%F %T')
15
+ }
16
+ end
17
+
18
+ def data_storing(date = nil)
19
+ storing.each do |data|
20
+ if date
21
+ puts "#{data[:log_message]} | AT #{data[:date]}"
22
+ elsif
23
+ puts data[:log_message]
24
+ end
25
+ end
26
+
27
+ nil
28
+ end
29
+
30
+ private
31
+
32
+ def initialize_storing
33
+ [
34
+ {
35
+ log_message: 'Initialize DebugLogger log',
36
+ date: DateTime.now.strftime('%F %T')
37
+ }
38
+ ]
39
+ end
40
+ end
data/lib/debug_logger.rb CHANGED
@@ -1,64 +1,28 @@
1
1
  class DebugLogger
2
- def self.log(color, text, variables = nil, space = nil)
3
- requires = Requires.new(color, space)
4
- if variables
5
- puts "#{requires.space_signification} \e[#{requires.color_signification}m #{text}====================>#{variables}====================\e[0m #{requires.space_signification}"
6
- else
7
- puts "#{requires.space_signification} \e[#{requires.color_signification}m #{text}\e[0m #{requires.space_signification}"
8
- end
9
- end
10
-
11
- def self.color_lists
12
- requires = Requires.new
13
- puts requires.colors.join(' - ')
14
- end
15
- end
16
2
 
17
- class DebugLogger::Requires
3
+ attr_reader :color, :storage, :log
18
4
 
19
- attr_reader :color, :space
20
-
21
- def initialize(color = nil, space = nil)
5
+ def initialize(color = nil, storage = nil)
22
6
  @color = color
23
- @space = space
7
+ @storage = storage
8
+ @log = Log.new
24
9
  end
25
10
 
26
- def color_signification
27
- case color
28
- when :black
29
- 30
30
- when :red
31
- 31
32
- when :green
33
- 32
34
- when :orange
35
- 33
36
- when :blue
37
- 34
38
- when :pink
39
- 35
40
- when :cyan
41
- 36
42
- when :white
43
- 37
44
- when :normal
45
- 38
46
- when :bold
47
- 1
48
- when :italic
49
- 3
50
- when :underline
51
- 4
52
- else
53
- 38
54
- end
11
+ def log(log_text, log_color = nil, log_variables = nil, log_storage = nil)
12
+ log_text = "\e[#{DebugLoggerUtils::color_signification(log_color ? log_color : color)}m #{log_text}====================#{log_variables ? log_variables : ''}====================\e[0m"
13
+
14
+ log.store(log_text) if storage || log_storage
15
+ puts log_text
55
16
  end
56
17
 
57
- def space_signification
58
- space ? "\n\n" : nil
18
+ def logs(date = false)
19
+ log.data_storing(date)
59
20
  end
60
21
 
61
- def colors
62
- [:black, :red, :green, :orange, :blue, :pink, :cyan, :white, :normal, :bold, :italic, :underline]
22
+ def color_lists
23
+ puts DebugLoggerUtils::colors.join(' - ')
63
24
  end
64
25
  end
26
+
27
+ require 'debug_logger/debug_logger_utils'
28
+ require 'debug_logger/log'
metadata CHANGED
@@ -1,28 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonin Touron
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-13 00:00:00.000000000 Z
12
- dependencies: []
13
- description: A simple gem to help debug.
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.7'
27
+ description: This very simple gem was created to simplify your life in creating your
28
+ log in your programs. It simply allows you to display logs of different colors,
29
+ whether for a web application like RubyOnRails or for scripts.
14
30
  email: antonintouron@gmail.com
15
31
  executables: []
16
32
  extensions: []
17
33
  extra_rdoc_files: []
18
34
  files:
19
35
  - lib/debug_logger.rb
36
+ - lib/debug_logger/debug_logger_utils.rb
37
+ - lib/debug_logger/log.rb
20
38
  homepage: https://rubygems.org/gems/debug_logger
21
39
  licenses:
22
40
  - MIT
23
41
  metadata:
24
42
  source_code_uri: https://github.com/antonintouron/debug_logger
25
- post_install_message:
43
+ post_install_message:
26
44
  rdoc_options: []
27
45
  require_paths:
28
46
  - lib
@@ -38,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
56
  version: '0'
39
57
  requirements: []
40
58
  rubygems_version: 3.0.4
41
- signing_key:
59
+ signing_key:
42
60
  specification_version: 4
43
- summary: DebugLogger !
61
+ summary: DebugLogger is a simple gem to help debug.
44
62
  test_files: []