ops_team 0.9.2 → 0.9.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a168c8803f5f12ecc5ba54fc77e4a304baa300aa100e2d81d92b2f5146551d7
4
- data.tar.gz: dec291b877b6cc0fc056feb794e676abd56f5376b8373f914b6c24dfd3d7462d
3
+ metadata.gz: 15bace4f2993d10f93e68f9b10c506222409556476717a28b1bb7252e1c81ada
4
+ data.tar.gz: f47bd7063e540df0b3bc8037085869cd10ff0b7aa667350e7ee3681d99e173d5
5
5
  SHA512:
6
- metadata.gz: d96bea7054642ba35750f8efa59d6a6e2201dce98aaa5471dda573704ceb66f5daedf38f9cd7a68d2b31f9bd53ad17fff85790f61fe04fca8221ac9299140ddb
7
- data.tar.gz: 86b51b059eca72ba60f30c2be14c83bc40e4e1c872c3edaa91bab6a94080eb34a59eda351ef796d42d903216ca71f1fd8059d031773fb0b1efd2e7f2b498e4f5
6
+ metadata.gz: e2b932596006029a2125f5d58f92dc1b353dbeea24e72d459e8af5ab08b61d46a937f2d9f6812baa86b6820e58337c69306c17c2f4b9bd1290611f9862523911
7
+ data.tar.gz: ba5ebcf1adbe359f35e39e9612ea10b3877aec207c0bd1c6844738ca1d101a264990f01fbc9b9b7a719f9afa632921dc50073db76f000460dabf974a9100a227
@@ -23,14 +23,32 @@ module Builtins
23
23
  private
24
24
 
25
25
  def builtins
26
- builtin_class_names.map do |class_name|
27
- description = Builtins.const_get(class_name).description
28
- format("%<name>-35s %<desc>s", name: class_name.downcase.to_s.yellow, desc: description)
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| Builtins.const_get(c).is_a? Class }
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '0.9.2'
5
+ s.version = '0.9.3'
6
6
  s.authors = [
7
7
  'nickthecook@gmail.com'
8
8
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ops_team
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com