ariadne 0.0.1 → 0.0.3

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: 9c5b693660af05c17570b71a98e6ed6899932f9b2571fd6f8e4fd7d66d61e4fc
4
+ data.tar.gz: 8a3697425b580d3f40568b8b5a33d80e6d149197b0ede9fa2d35042b5ad90c8a
5
5
  SHA512:
6
- metadata.gz: 7512bf90d2dde907c79a2aa7fbb6d52f751062ecb2851a52c8a921159e43e5ee2044746630d404b7c22946065a81e86b4d3006a529c40ad3ca3d107d1be3ff6a
7
- data.tar.gz: 40dcdd1799bf14bdd3873a2d50206fb97ada9e0585ace1d9dc5ab1ca6e3ac37d9f8a700d08179f53474de61e9a6c4bd01882f3ee27c798f53ce14bde0b0bbf05
6
+ metadata.gz: 9d41649519721ea428249d049823a82ecaf4530dc436b27b4bd643e815e12f70eec38895e752b46ca57154ed7e9b5c9133bc799903b69479876c6d9c3577732f
7
+ data.tar.gz: 70555aa75a6656cf16e199abb1b3b29ce960f806b3b68846edbf378072d7a4129c3268cfd2d8e06d44dde667f2682b9cee8766d63f9e98138df6f190b8a1ea7f
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,22 +6,25 @@ 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
 
12
13
  def initialize(include_paths: nil, exclude_paths: nil)
13
14
  @include_paths = include_paths || DEFAULT_INCLUDE_PATHS
14
15
  @exclude_paths = exclude_paths || DEFAULT_EXCLUDE_PATHS
15
- @seams = []
16
- @rank = 0
17
16
  end
18
17
 
19
18
  def call
19
+ @rank = 0
20
+ @seams = []
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.3"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Piron