everyday_thor_util 1.1.0 → 1.2.0

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
  SHA1:
3
- metadata.gz: ffc5ff63f2ce4542d3a5c0a10e163d3d0f1b241e
4
- data.tar.gz: a941a5678a0e779462fcf59abf994221d44621b1
3
+ metadata.gz: 8f2ff93497c638d7141ef4808dd5bc51e4bdbbca
4
+ data.tar.gz: 8d8972ecb3d42e3ed94559c3efe61638218bceb7
5
5
  SHA512:
6
- metadata.gz: 3f0c50e48862fbc77bacb630d4186fca3200e634ce58379cede6cb5e0918a907d1296c0d7b44d6e5184f219330ac73f1c804fcaa4928f96119a570e26572848c
7
- data.tar.gz: f39774194f35caa001285f6acacb15ad3d39931bf105521752ac2eff09db38d9320dc9d254981123a8dbb06ab4531042d1f001d3cd409be11f8f9e6fc0889d8f
6
+ metadata.gz: 704df46c8275995fd48ba37fe74891e6ff177e2c65774fcad2a1a258f5349951d11846381c7064ac67eda55334a46568d984410d72104a0557437811fced2d47
7
+ data.tar.gz: 9b4b9b31e720dc2b44d86d38f40345482814fa3c1349e789b27da8e016c8a81030e31791f1288d33b385ab55bc8abc002c6d2f263e5dc7e76cb57063455198d1
@@ -8,6 +8,7 @@ class Thor
8
8
  def create_method(name, &block)
9
9
  self.send(:define_method, name, &block)
10
10
  end
11
+
11
12
  def dup_method(new_name, old_name)
12
13
  self.send(:alias_method, new_name, old_name)
13
14
  end
@@ -20,7 +21,7 @@ module EverydayThorUtil
20
21
  extend TypeHelper
21
22
 
22
23
  class << self
23
- def def_types(command_array_symbol, flag_symbol, command_symbol)
24
+ def def_types(command_array_symbol, flag_symbol, command_symbol, helper_symbol = nil)
24
25
  register_variable command_array_symbol, []
25
26
 
26
27
  register_type(flag_symbol) { |list, parent_class, parent, has_children|
@@ -39,6 +40,7 @@ module EverydayThorUtil
39
40
  }
40
41
 
41
42
  register_type(command_symbol) { |list, parent_class, parent|
43
+ Plugins.get helper_symbol, parent_class, nil unless parent || helper_symbol.nil?
42
44
  Plugins.get flag_symbol, parent_class, nil, true unless parent
43
45
  filtered_list = list.select { |v| v[:options][:parent] == parent || nil }
44
46
  filtered_list.each { |v|
@@ -57,6 +59,7 @@ module EverydayThorUtil
57
59
  Plugins.set_var command_array_symbol, command_ids
58
60
  command_class = Class.new(Thor)
59
61
  command_class.namespace name
62
+ Plugins.get helper_symbol, command_class, id unless helper_symbol.nil?
60
63
  Plugins.get flag_symbol, command_class, id, true
61
64
  Plugins.get command_symbol, command_class, id
62
65
  Plugins.get flag_symbol, parent_class, id, false
@@ -89,6 +92,16 @@ module EverydayThorUtil
89
92
  end
90
93
  }
91
94
  }
95
+
96
+ unless helper_symbol.nil?
97
+ register_type(helper_symbol) { |list, parent_class, parent|
98
+ filtered_list = list.select { |v| v[:options][:parent] == parent }
99
+ filtered_list.each { |v|
100
+ name = v[:options][:name].to_sym
101
+ parent_class.no_commands { parent_class.create_method name, &v[:block] } if v[:block]
102
+ }
103
+ }
104
+ end
92
105
  end
93
106
  end
94
107
  end
@@ -1,3 +1,3 @@
1
1
  module EverydayThorUtil
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everyday_thor_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Henderson