ariadne 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ariadne/log.rb +12 -4
- data/lib/ariadne/seam.rb +6 -2
- data/lib/ariadne/text.rb +7 -3
- data/lib/ariadne/thread.rb +3 -0
- data/lib/ariadne/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac18d5128d638d11ca1502358949723bb82776e481a4662f7cd211731db5ab54
|
4
|
+
data.tar.gz: 4a6b83751337c9f0431dbcbf97dea7bd965d9dac426d02d9801bd3f33353015a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 077cff36c70f29653f28156e5db4f14c811a2a144522f7a8b7dcb5e2b4fbf21c7ad9ff010918c8b3a0ed9fe82cd0eb7402a87a5be6567744d890b999ff6dfcfe
|
7
|
+
data.tar.gz: 260eb5b30a03d3a7da68b8b629ff5888931da3c5d42d164d33b8ff24ce24ecccd00458f676928e9d49af255198e36ba171bb7f3d2b735e6319a1a05029268cb5
|
data/lib/ariadne/log.rb
CHANGED
@@ -10,17 +10,25 @@ module Ariadne
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
13
|
-
puts
|
13
|
+
puts text
|
14
|
+
write_log
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def write_log
|
20
|
+
File.open(Ariadne::Thread::LOG_FILE, "a") { _1.puts text.bleach }
|
21
|
+
end
|
22
|
+
|
23
|
+
def text
|
24
|
+
@text ||=
|
14
25
|
Text.new(
|
15
26
|
[rank, " ", offset, " ", offset_dashes, class_name, prefix, method_name]
|
16
27
|
.tap { add_parameters(_1) }
|
17
28
|
.join
|
18
29
|
).truncate(200)
|
19
|
-
)
|
20
30
|
end
|
21
31
|
|
22
|
-
private
|
23
|
-
|
24
32
|
def rank
|
25
33
|
Text.new(@seam.rank.to_s.rjust(4)).gray
|
26
34
|
end
|
data/lib/ariadne/seam.rb
CHANGED
@@ -15,7 +15,11 @@ module Ariadne
|
|
15
15
|
|
16
16
|
# Seam.new(@rank, class_name(tp), prefix(tp), tp.method_id, parameters, @seams.size)
|
17
17
|
def class_name
|
18
|
-
__getobj__.self.is_a?(
|
18
|
+
if __getobj__.self.is_a?(Module)
|
19
|
+
__getobj__.self.name
|
20
|
+
else
|
21
|
+
__getobj__.self.class.name
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def method_name
|
@@ -23,7 +27,7 @@ module Ariadne
|
|
23
27
|
end
|
24
28
|
|
25
29
|
def prefix
|
26
|
-
__getobj__.self.is_a?(
|
30
|
+
__getobj__.self.is_a?(Module) ? "." : "#"
|
27
31
|
end
|
28
32
|
|
29
33
|
def parameters
|
data/lib/ariadne/text.rb
CHANGED
@@ -16,11 +16,11 @@ module Ariadne
|
|
16
16
|
COLORS.each.with_index do |color, index|
|
17
17
|
code = index + 30
|
18
18
|
define_method(color) do
|
19
|
-
"\e[#{code}m#{
|
19
|
+
"\e[#{code}m#{bleach}\e[0m"
|
20
20
|
end
|
21
21
|
bg_code = index + 40
|
22
22
|
define_method("bg_#{color}") do
|
23
|
-
"\e[#{bg_code}m#{
|
23
|
+
"\e[#{bg_code}m#{bleach}\e[0m"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,10 +30,14 @@ module Ariadne
|
|
30
30
|
|
31
31
|
def truncate(size)
|
32
32
|
if self.size > size
|
33
|
-
self[..size]
|
33
|
+
Text.new("#{self[..size]}...")
|
34
34
|
else
|
35
35
|
self
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def bleach
|
40
|
+
gsub(/\e\[\d{1,2}m/, "")
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
data/lib/ariadne/thread.rb
CHANGED
@@ -6,6 +6,7 @@ require "ariadne/log"
|
|
6
6
|
|
7
7
|
module Ariadne
|
8
8
|
class Thread
|
9
|
+
LOG_FILE = "thread.log"
|
9
10
|
DEFAULT_INCLUDE_PATHS = Open3.capture3("pwd").first.strip
|
10
11
|
DEFAULT_EXCLUDE_PATHS = [].freeze
|
11
12
|
|
@@ -17,11 +18,13 @@ module Ariadne
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def call
|
21
|
+
file = File.open(LOG_FILE, "w")
|
20
22
|
trace = build_trace
|
21
23
|
trace.enable
|
22
24
|
yield
|
23
25
|
ensure
|
24
26
|
trace.disable
|
27
|
+
file.close
|
25
28
|
end
|
26
29
|
|
27
30
|
private
|
data/lib/ariadne/version.rb
CHANGED