factory_trace 0.1.1 → 0.1.2
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 +4 -4
- data/lib/factory_trace/configuration.rb +2 -1
- data/lib/factory_trace/find_unused.rb +3 -0
- data/lib/factory_trace/printer.rb +24 -8
- data/lib/factory_trace/version.rb +1 -1
- data/lib/factory_trace.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26b7253d7d994cb1f591977dc3bcadc38d6f6cfe80526ef4377d85d411fbd380
|
4
|
+
data.tar.gz: bcde5b14ecfcfbe16b9cada40618ae0c79e38be424b96b9b2967996a6ab1f1c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83ef3b6436248a5ed5c440966337b89e7e1dcbd72b025bbcfb6448cbee188aac24f57d3122c0f41e81f2d9af138aed04ed24d4d5ac5ec0a87ad0ba068dce085a
|
7
|
+
data.tar.gz: fa02e34299d009aea40d99368e67e575152b30479e79a903464f45279ee33afdaa59d5bc51fd42fa1edee3ca7ecfea171705278778c0b1aa41522c81ce203a7f
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module FactoryTrace
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :path, :enabled
|
3
|
+
attr_accessor :path, :enabled, :color
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@enabled = ENV.key?('FB_TRACE') || ENV.key?('FB_TRACE_FILE')
|
7
7
|
@path = ENV['FB_TRACE_FILE']
|
8
|
+
@color = path.nil?
|
8
9
|
end
|
9
10
|
|
10
11
|
def out
|
@@ -1,32 +1,48 @@
|
|
1
1
|
module FactoryTrace
|
2
2
|
class Printer
|
3
|
-
|
3
|
+
COLORS = {
|
4
|
+
blue: "\e[34m",
|
5
|
+
green: "\e[32m",
|
6
|
+
red: "\e[31m"
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
def initialize(io, config: Configuration.new)
|
4
10
|
@io = io
|
11
|
+
@config = config
|
5
12
|
end
|
6
13
|
|
7
14
|
# @param [Array<Hash>] results
|
8
15
|
def print(results)
|
16
|
+
total_color = results.size == 2 ? :green : :red
|
17
|
+
|
9
18
|
results.each do |result|
|
10
|
-
io.puts(convert(result))
|
19
|
+
io.puts(convert(result, total_color: total_color))
|
11
20
|
end
|
12
21
|
end
|
13
22
|
|
14
23
|
private
|
15
24
|
|
16
25
|
# @param [Hash<Symbol, Object>] result
|
17
|
-
|
26
|
+
# @param [Symbol] total_color
|
27
|
+
def convert(result, total_color:)
|
18
28
|
case
|
19
29
|
when result[:value]
|
20
|
-
"total number of unique #{result[:code]} factories & traits: #{result[:value]}"
|
30
|
+
colorize(total_color, "total number of unique #{result[:code]} factories & traits: #{result[:value]}")
|
21
31
|
when result[:factory] && result[:trait]
|
22
|
-
"#{result[:code]} trait
|
32
|
+
"#{result[:code]} trait #{colorize(:blue, result[:trait].name)} of factory #{colorize(:blue, result[:factory].name)}"
|
23
33
|
when result[:factory]
|
24
|
-
"#{result[:code]} factory
|
34
|
+
"#{result[:code]} factory #{colorize(:blue, result[:factory].name)}"
|
25
35
|
else
|
26
|
-
"#{result[:code]} global trait
|
36
|
+
"#{result[:code]} global trait #{colorize(:blue, result[:trait].name)}"
|
27
37
|
end
|
28
38
|
end
|
29
39
|
|
30
|
-
|
40
|
+
def colorize(color, msg)
|
41
|
+
return msg unless config.color
|
42
|
+
|
43
|
+
"#{COLORS[color]}#{msg}\e[0m"
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_reader :io, :config
|
31
47
|
end
|
32
48
|
end
|
data/lib/factory_trace.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_trace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- djezzzl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|