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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d6969e929cebeb85281888cf5be5ba9b2460345d217e1572b32888f13eb6d06
4
- data.tar.gz: bee2a2b5bd7b8160af83b79f4a1197370edcba60096c395730dfd28428887acf
3
+ metadata.gz: ac18d5128d638d11ca1502358949723bb82776e481a4662f7cd211731db5ab54
4
+ data.tar.gz: 4a6b83751337c9f0431dbcbf97dea7bd965d9dac426d02d9801bd3f33353015a
5
5
  SHA512:
6
- metadata.gz: 7512bf90d2dde907c79a2aa7fbb6d52f751062ecb2851a52c8a921159e43e5ee2044746630d404b7c22946065a81e86b4d3006a529c40ad3ca3d107d1be3ff6a
7
- data.tar.gz: 40dcdd1799bf14bdd3873a2d50206fb97ada9e0585ace1d9dc5ab1ca6e3ac37d9f8a700d08179f53474de61e9a6c4bd01882f3ee27c798f53ce14bde0b0bbf05
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?(Class) ? __getobj__.self.name : __getobj__.self.class.name
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?(Class) ? "." : "#"
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#{self}\e[0m"
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#{self}\e[0m"
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ariadne
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ariadne
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Piron