helium-console 0.1.3 → 0.1.7
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/module.rb +16 -0
- data/lib/helium/console/registry/object.rb +21 -7
- data/lib/helium/console/registry/string.rb +6 -3
- data/lib/helium/console/registry/table.rb +33 -7
- data/lib/helium/console/table.rb +2 -2
- data/lib/helium/console/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ab396ea29a8624295988320add6f5e930e63189df18d760f5a5d7b940757564
|
4
|
+
data.tar.gz: 67585b90c765f5c21085d142f09177062e09b7aaea8adab81405cfd78909f04f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f8c86fb6604d3be3a7c0de4485875da9be8b2b2ab0f62a39678cee552d55c4d6cb296d10803ca0b1962ada3e9b490525f5e05cff9c1905311afa27df6db4472
|
7
|
+
data.tar.gz: a960dc8a18594015a44d5fd83469869e96f8d33cae658c7a825a9fc45c73d53ce06e6386a187a3387ae6d9c9a0cf50cfc0495250ee122dbb109ae9d14ea8110b
|
data/Gemfile.lock
CHANGED
data/lib/helium/console.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Helium
|
2
|
+
class Console
|
3
|
+
define_formatter_for Module do
|
4
|
+
def call
|
5
|
+
light_yellow(object.name || anonymus_text)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def anonymus_text
|
11
|
+
closest = object.ancestors.find(&:name).name
|
12
|
+
"(anonymous #{closest})"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -16,9 +16,9 @@ module Helium
|
|
16
16
|
end
|
17
17
|
|
18
18
|
[
|
19
|
-
|
20
|
-
format(table
|
21
|
-
].join($/)
|
19
|
+
table_header,
|
20
|
+
format(table),
|
21
|
+
].reject(&:empty?).join($/)
|
22
22
|
end
|
23
23
|
|
24
24
|
def format_inline_with_truncation
|
@@ -27,13 +27,12 @@ module Helium
|
|
27
27
|
|
28
28
|
def format_inline_with_no_truncation
|
29
29
|
joined = nil
|
30
|
-
one_complex = false
|
31
30
|
|
32
31
|
object.each do |key, value|
|
33
32
|
return unless simple?(value)
|
34
33
|
|
35
|
-
formatted_key = format(key,
|
36
|
-
formatted_value = format(value,
|
34
|
+
formatted_key = format(key, level: 3, max_with: 15)
|
35
|
+
formatted_value = format(value, level: 3, max_width: 15)
|
37
36
|
formatted = "#{formatted_key} => #{formatted_value}"
|
38
37
|
|
39
38
|
joined = [joined, formatted].compact.join(", ")
|
@@ -44,8 +43,23 @@ module Helium
|
|
44
43
|
["{", joined, "}"].compact.join
|
45
44
|
end
|
46
45
|
|
46
|
+
def table_header
|
47
|
+
type = case object
|
48
|
+
when Class then :class
|
49
|
+
when Module then :module
|
50
|
+
else :instance
|
51
|
+
end
|
52
|
+
klass = type == :instance ? object.class : object
|
53
|
+
klass_name = klass.name
|
54
|
+
if !klass_name
|
55
|
+
named_ancestor = klass.ancestors.find(&:name)
|
56
|
+
klass_name = ['anonymous', named_ancestor&.name].compact.join(" ")
|
57
|
+
end
|
58
|
+
"#{light_black('#')} #{light_yellow(klass_name)} #{type}"
|
59
|
+
end
|
60
|
+
|
47
61
|
def force_inline?
|
48
|
-
|
62
|
+
level > 2
|
49
63
|
end
|
50
64
|
|
51
65
|
def all_symbol?
|
@@ -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
|
-
|
10
|
-
formatted_value = format_nested(value, max_width: max_value_width)
|
12
|
+
rows.flat_map do |key, value, options = {}|
|
13
|
+
formatted_value = format_nested(value, max_width: max_value_width, **options)
|
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
|
data/lib/helium/console/table.rb
CHANGED
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.7
|
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-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/helium/console/registry/array.rb
|
68
68
|
- lib/helium/console/registry/booleans.rb
|
69
69
|
- lib/helium/console/registry/hash.rb
|
70
|
+
- lib/helium/console/registry/module.rb
|
70
71
|
- lib/helium/console/registry/nil.rb
|
71
72
|
- lib/helium/console/registry/numeric.rb
|
72
73
|
- lib/helium/console/registry/object.rb
|