Module: Vow::Helper
- Defined in:
- lib/vow/helper.rb
Class Method Summary collapse
Class Method Details
.printable_command(command) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vow/helper.rb', line 17 def self.printable_command(command) simple_command = true command.each do |word| unless %r|^[[[:alnum:]].+_/-]+$|.match?(word) simple_command = false break end end if simple_command return command.join(' ') else return command.to_s end end |
.refine_command(command) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/vow/helper.rb', line 2 def self.refine_command(command) refined = command.flatten.select {|a| !a.nil?} if refined.length == 0 raise "Nothing to run" end cmdname = refined[0] if cmdname.include?(' ') raise "Command name does not follow safe pattern: '#{cmdname}'" end refined end |