ops_team 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/builtins/help.rb +23 -5
- data/ops_team.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15bace4f2993d10f93e68f9b10c506222409556476717a28b1bb7252e1c81ada
|
4
|
+
data.tar.gz: f47bd7063e540df0b3bc8037085869cd10ff0b7aa667350e7ee3681d99e173d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2b932596006029a2125f5d58f92dc1b353dbeea24e72d459e8af5ab08b61d46a937f2d9f6812baa86b6820e58337c69306c17c2f4b9bd1290611f9862523911
|
7
|
+
data.tar.gz: ba5ebcf1adbe359f35e39e9612ea10b3877aec207c0bd1c6844738ca1d101a264990f01fbc9b9b7a719f9afa632921dc50073db76f000460dabf974a9100a227
|
data/lib/builtins/help.rb
CHANGED
@@ -23,14 +23,32 @@ module Builtins
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def builtins
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
builtin_class_map.map do |klass, name|
|
27
|
+
format("%<name>-35s %<desc>s", name: name.downcase.to_s.yellow, desc: klass.description)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def builtin_class_map
|
32
|
+
builtin_class_names.each_with_object({}) do |name, hash|
|
33
|
+
# get the class reference for this name
|
34
|
+
constant = const_for(name)
|
35
|
+
# check hash for an existing entry for the same class
|
36
|
+
existing_name = hash[constant]
|
37
|
+
|
38
|
+
# if there is an existing key for the same class, and it's longer than the one we just found,
|
39
|
+
# skip adding this one one to avoid duplicates, leaving the shortest name for each class
|
40
|
+
next if existing_name && existing_name.length <= name.length
|
41
|
+
|
42
|
+
hash[constant] = name
|
29
43
|
end
|
30
44
|
end
|
31
45
|
|
32
46
|
def builtin_class_names
|
33
|
-
Builtins.constants.select { |c|
|
47
|
+
@builtin_class_names ||= Builtins.constants.select { |c| const_for(c).is_a?(Class) }.sort
|
48
|
+
end
|
49
|
+
|
50
|
+
def const_for(name)
|
51
|
+
Builtins.const_get(name, false)
|
34
52
|
end
|
35
53
|
|
36
54
|
def actions
|
@@ -39,7 +57,7 @@ module Builtins
|
|
39
57
|
name: name.yellow,
|
40
58
|
desc: value["description"] || value["command"]
|
41
59
|
)
|
42
|
-
end
|
60
|
+
end.sort
|
43
61
|
end
|
44
62
|
end
|
45
63
|
end
|
data/ops_team.gemspec
CHANGED