Module: ShellCommandConstructor

Defined in:
lib/addon/shell_command_constructor.rb

Class Method Summary collapse

Class Method Details

.construct_command(strings_or_list, connector = " && ") ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/addon/shell_command_constructor.rb', line 2

def self.construct_command strings_or_list, connector = " && "
    list = case strings_or_list
    when Array
      strings_or_list
    when String
      strings_or_list.split(/\n/)
    end
    list.each_with_object([]) do |line, obj|
        line.strip!
        next if line.empty?
        next if line =~ /^#/
        obj.push line
    end.join connector
end