helium-console 0.1.3 → 0.1.4
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/Gemfile.lock +1 -1
- data/lib/helium/console.rb +0 -1
- data/lib/helium/console/registry/hash.rb +1 -1
- data/lib/helium/console/registry/string.rb +6 -3
- data/lib/helium/console/registry/table.rb +32 -6
- data/lib/helium/console/version.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: 0d7b3d187641aabf02e4a6971fcc115c28d513fa46ce8532ded30f0a372b4a72
|
4
|
+
data.tar.gz: b81ba7655d8e2f80db96b87ee22d3e5e529cf49628813ba4ca8a41cff3362126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d128544877758a58ac1d98042c50cbe5d10452d37b57b8422de7eb2143dfa22498be54a37c2c7b0f1a301c8032e7e30e5b95d7d5d5ba72f191412be4c9b1d3f
|
7
|
+
data.tar.gz: d5f528534253ae54e0dff195216284d9ff9033affc5afbbb9f2849972aa0f84ad2e4538da6487e9bd4a4f72c7ada036783af13f90658d85f7913c80e94c13e62
|
data/Gemfile.lock
CHANGED
data/lib/helium/console.rb
CHANGED
@@ -2,17 +2,20 @@ module Helium
|
|
2
2
|
class Console
|
3
3
|
define_formatter_for String do
|
4
4
|
def call
|
5
|
-
|
5
|
+
formatted = Helium::Console.format_string(
|
6
6
|
object.dump.gsub('\n', "\n"),
|
7
7
|
max_width: max_width,
|
8
8
|
max_lines: max_lines,
|
9
9
|
overflow: overflow,
|
10
10
|
ellipses: "...\""
|
11
|
-
)
|
11
|
+
)
|
12
|
+
|
13
|
+
formatted.lines
|
14
|
+
.map { |line| light_green(line) }
|
15
|
+
.join
|
12
16
|
end
|
13
17
|
|
14
18
|
def max_lines
|
15
|
-
return options[:max_lines] if options[:max_lines]
|
16
19
|
case level
|
17
20
|
when 1 then nil
|
18
21
|
when 2 then 3
|
@@ -2,17 +2,20 @@ module Helium
|
|
2
2
|
class Console
|
3
3
|
define_formatter_for Table do
|
4
4
|
def call
|
5
|
-
|
5
|
+
[
|
6
|
+
*formatted_values,
|
7
|
+
truncation,
|
8
|
+
].compact.join($/)
|
6
9
|
end
|
7
10
|
|
8
11
|
def formatted_values
|
9
|
-
|
12
|
+
rows.flat_map do |key, value|
|
10
13
|
formatted_value = format_nested(value, max_width: max_value_width)
|
11
14
|
|
12
15
|
formatted_value.lines.map.with_index do |line, index|
|
13
16
|
[
|
14
17
|
object.runner,
|
15
|
-
index.zero? ? format_key(key)
|
18
|
+
index.zero? ? rjust(format_key(key), key_width) : " " * key_width,
|
16
19
|
index.zero? ? object.after_key : " " * length_of(object.after_key),
|
17
20
|
line.chomp,
|
18
21
|
].join
|
@@ -20,8 +23,18 @@ module Helium
|
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
26
|
+
def truncation
|
27
|
+
return unless object.rows.length > rows.length
|
28
|
+
|
29
|
+
[
|
30
|
+
object.runner,
|
31
|
+
light_black("(#{object.rows.length - rows.length} more)")
|
32
|
+
].join
|
33
|
+
end
|
34
|
+
|
35
|
+
|
23
36
|
def key_width
|
24
|
-
@key_width ||=
|
37
|
+
@key_width ||= rows
|
25
38
|
.map(&:first)
|
26
39
|
.map(&method(:format_key))
|
27
40
|
.map(&method(:length_of))
|
@@ -33,8 +46,11 @@ module Helium
|
|
33
46
|
end
|
34
47
|
|
35
48
|
def format_key(key)
|
36
|
-
|
37
|
-
|
49
|
+
object.format_keys ? format(key, max_width: 15, level: 3) : key
|
50
|
+
end
|
51
|
+
|
52
|
+
def rjust(string, width)
|
53
|
+
" " * (width - length_of(string)) + string
|
38
54
|
end
|
39
55
|
|
40
56
|
def length_of(string)
|
@@ -44,6 +60,16 @@ module Helium
|
|
44
60
|
string.length
|
45
61
|
end
|
46
62
|
end
|
63
|
+
|
64
|
+
def rows
|
65
|
+
@rows ||= case level
|
66
|
+
when 1 then object.rows
|
67
|
+
when 2
|
68
|
+
object.rows.count < 10 ? object.rows : object.rows.first(9)
|
69
|
+
else
|
70
|
+
object.rows.count < 3 ? object.rows : object.rows.first(2)
|
71
|
+
end
|
72
|
+
end
|
47
73
|
end
|
48
74
|
end
|
49
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helium-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislaw Klajn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|