ariadne 0.0.5 → 0.0.6

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: a71929c19a3e8fff0abc484843c1762edf12ecf6f45d90a6e0394cb4743aa243
4
- data.tar.gz: e5959ac737aaf0392957164769dcb56e72ca73362da8431fcbb4a9d47fcc835b
3
+ metadata.gz: e535df4d44ee5c90e5b93476249641ddf9a5a34264e69fda50d0559c17deb453
4
+ data.tar.gz: 42311c562c1bd5f2dac05d99f2fc0623ac5c3bfb26320bae4f8d0c246b867936
5
5
  SHA512:
6
- metadata.gz: 1bec945c8243605fb555b88e817c9cfe84268e06b4ae110ef2c5b472f86360deb5c91d4cfa3a8e3cf9220f90259bddcfe902fcd829fbe53d2090722bb6f454d9
7
- data.tar.gz: fbb773617d74362a76c461c0c01283239175fea01d8915e3b810299b13b7849863cdefb1f8875592c3421da5a19945236736c7ec2df296a0d4fc72f8d666082c
6
+ metadata.gz: 24c4e890adacdb42d81c3c3f36fbb1bca05db60f3bc71fdf8eddc0a97eebe76e9edd6e5e9b2cdfc27b621e0fa478304feb6befb49cebfbf709f157f208884ce3
7
+ data.tar.gz: ea9e7d7e09af8e5d52e7d22cf3231ec9a69daec8da26c7dbef47c9f788f31f64e6fc8bc520a8c6d453e9ae9f76971378d3e889a93472c258c2fee0f336b2ee72
data/lib/ariadne/log.rb CHANGED
@@ -1,72 +1,79 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "open3"
4
- require "ariadne/string/color"
3
+ require "colorize"
5
4
 
6
5
  module Ariadne
7
6
  class Log
7
+ TEXTS = {
8
+ rank: :white,
9
+ depth_dashes: :white,
10
+ class_name: :green,
11
+ prefix: :blue,
12
+ method_name: :blue,
13
+ parameters: :magenta,
14
+ return_value_type: :yellow
15
+ }.freeze
16
+
8
17
  def initialize(seam)
9
18
  @seam = seam
10
19
  end
11
20
 
12
21
  def call
13
- puts text
22
+ puts log
14
23
  write_log
15
24
  end
16
25
 
17
26
  private
18
27
 
19
- def write_log
20
- File.open(Ariadne::Thread::LOG_FILE, "a") { _1.puts text.bleach }
28
+ def log
29
+ @log ||=
30
+ TEXTS.map do |method, color|
31
+ __send__(method).colorize(color)
32
+ end.join
21
33
  end
22
34
 
23
- def text
24
- @text ||=
25
- [
26
- rank,
27
- " ",
28
- depth_dashes,
29
- class_name,
30
- prefix,
31
- method_name,
32
- parameters,
33
- return_value_type
34
- ].join
35
+ def write_log
36
+ File.open(Ariadne::Thread::LOG_FILE, "a") { _1.puts log.uncolorize }
35
37
  end
36
38
 
37
39
  def rank
38
- @seam.rank.to_s.rjust(4).gray
40
+ @seam.rank.to_s.rjust(4)
39
41
  end
40
42
 
41
43
  def depth_dashes
42
- ("-" * @seam.depth).gray.tap { _1 << " " if @seam.depth.positive? }
44
+ str = +" "
45
+ if @seam.depth.positive?
46
+ str << ("-" * @seam.depth)
47
+ str << " "
48
+ end
49
+ str
43
50
  end
44
51
 
45
52
  def class_name
46
- @seam.klass.name.green
53
+ @seam.klass.name
47
54
  end
48
55
 
49
56
  def prefix
50
- @seam.prefix.gray
57
+ @seam.prefix
51
58
  end
52
59
 
53
60
  def method_name
54
- @seam.method_name.to_s.cyan
61
+ @seam.method_name.to_s
55
62
  end
56
63
 
57
64
  def return_value_type
58
65
  value = type(@seam.return_value)
59
- " -> #{value}".yellow
66
+ " -> #{value}"
60
67
  end
61
68
 
62
69
  def parameters
63
- return if @seam.parameters.empty?
70
+ return "" if @seam.parameters.empty?
64
71
 
65
72
  [
66
73
  "(",
67
74
  @seam.parameters.flat_map { "#{_1.param}: #{arg(_1)}" }.join(", "),
68
75
  ")"
69
- ].join.magenta
76
+ ].join
70
77
  end
71
78
 
72
79
  def arg(parameter)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ariadne
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ariadne
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Piron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-25 00:00:00.000000000 Z
11
+ date: 2023-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: yard
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  description: Follow the code
98
84
  email:
99
85
  - ed.piron@gmail.com
@@ -104,7 +90,6 @@ files:
104
90
  - lib/ariadne.rb
105
91
  - lib/ariadne/log.rb
106
92
  - lib/ariadne/seam.rb
107
- - lib/ariadne/string/color.rb
108
93
  - lib/ariadne/thread.rb
109
94
  - lib/ariadne/version.rb
110
95
  homepage: https://github.com/BigBigDoudou/ariadne
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- module String
5
- module Color
6
- COLORS = %w[
7
- black
8
- red
9
- green
10
- yellow
11
- blue
12
- magenta
13
- cyan
14
- gray
15
- ].freeze
16
-
17
- COLORS.each.with_index do |color, index|
18
- code = index + 30
19
- define_method(color) do
20
- "\e[#{code}m#{bleach}\e[0m"
21
- end
22
- bg_code = index + 40
23
- define_method("bg_#{color}") do
24
- "\e[#{bg_code}m#{bleach}\e[0m"
25
- end
26
- end
27
-
28
- def bleach
29
- gsub(/\e\[\d{1,2}m/, "")
30
- end
31
- end
32
- end
33
- end
34
-
35
- String.include Ariadne::String::Color