Sha256: d161386f10a2c1dbc0290ef7c221be6c9b6159a03fb2f419ae2cace85de5c576

Contents?: true

Size: 398 Bytes

Versions: 11

Compression:

Stored size: 398 Bytes

Contents

class Array
	# Join a sequence of arguments together to form a executable command.
	def to_cmd
		collect{|v| v.to_cmd}.join(' ')
	end
end

class Pathname
	def to_cmd
		to_s.to_cmd
	end
end

class Symbol
	def to_cmd
		to_s.to_cmd
	end
end

class String
	# Conditionally quote a string if it contains whitespace or quotes.
	def to_cmd
		if match(/\s|"|'/)
			self.dump
		else
			self
		end
	end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rexec-1.6.3 lib/rexec/to_cmd.rb
rexec-1.6.2 lib/rexec/to_cmd.rb
rexec-1.6.1 lib/rexec/to_cmd.rb
rexec-1.6.0 lib/rexec/to_cmd.rb
rexec-1.5.2 lib/rexec/to_cmd.rb
rexec-1.5.1 lib/rexec/to_cmd.rb
rexec-1.5.0 lib/rexec/to_cmd.rb
rexec-1.4.1 lib/rexec/to_cmd.rb
rexec-1.4.0 lib/rexec/to_cmd.rb
rexec-1.3.0 lib/rexec/to_cmd.rb
rexec-1.2.6 lib/rexec/to_cmd.rb