everyday_thor_util 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/everyday_thor_util/plugin-helper.rb +14 -1
- data/lib/everyday_thor_util/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f2ff93497c638d7141ef4808dd5bc51e4bdbbca
|
4
|
+
data.tar.gz: 8d8972ecb3d42e3ed94559c3efe61638218bceb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|