[why] The multi-args is like this "test|nr_threads", if user add it like this "test |nr_threads" or the value like "- shell1 | 1 ". So we need to delete the space
Signed-off-by: Bai Jing 799286817@qq.com --- lib/job.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 2869dcb3..47fd56d3 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -290,11 +290,11 @@ class Job hash.each { |key, value| next unless key =~ /^\w.*|.*\w$/
- key_array = key.split('|') + key_array = key.split('|').map!{ |ele| ele.strip } [value].flatten.each do |v| next unless v =~ /^\w.*|.*\w$/
- v_array = v.split('|') + v_array = v.split('|').map!{ |v_ele| v_ele.strip } next unless key_array.size == v_array.size
hash_job = hash.clone
@@ -290,11 +290,11 @@ class Job hash.each { |key, value| next unless key =~ /^\w.*|.*\w$/
key_array = key.split('|')
key_array = key.split('|').map!{ |ele| ele.strip } [value].flatten.each do |v| next unless v =~ /^\w.*\|.*\w$/
v_array = v.split('|')
v_array = v.split('|').map!{ |v_ele| v_ele.strip } next unless key_array.size == v_array.size hash_job = hash.clone
for your reguler expression, you just wang to get the hash which has k, v that have same splited values.
hash.each { |key, value| next unless key =~ /^\w.*|.*\w$/
k_size = key.scan('|').size [value].flatten.each do |v| next unless v =~ /^\w.*|.*\w$/
v_size = v.scan('|').size
next unless k_size == v_size
Thanks, Luan Shengde
-- 2.23.0