class Aruba::Platforms::UnixPlatform
WARNING: All methods found here are not considered part of the public API of aruba.
Those methods can be changed at any time in the feature or removed without any further notice.
This includes all methods for the UNIX platform
@private
Public Class Methods
# File lib/aruba/platforms/unix_platform.rb, line 33 def self.match? !Gem.win_platform? end
Public Instance Methods
Is absolute path
# File lib/aruba/platforms/unix_platform.rb, line 179 def absolute_path?(path) Pathname.new(path).absolute? end
# File lib/aruba/platforms/unix_platform.rb, line 49 def announcer Announcer end
# File lib/aruba/platforms/unix_platform.rb, line 240 def builtin_shell_commands [] end
Change to directory
# File lib/aruba/platforms/unix_platform.rb, line 125 def chdir(dir_name, &block) dir_name = ::File.expand_path(dir_name.to_s) with_environment "OLDPWD" => getwd, "PWD" => dir_name do ::Dir.chdir(dir_name, &block) end end
Change mode of file/directory
# File lib/aruba/platforms/unix_platform.rb, line 149 def chmod(mode, args, options) FileUtils.chmod_R(mode, args, **options) end
Check if command is relative
@return [Boolean]
true * command.sh false * /bin/command.sh * bin/command.sh
# File lib/aruba/platforms/unix_platform.rb, line 211 def command?(path) p = Pathname.new(path) p.relative? && p.basename == p end
# File lib/aruba/platforms/unix_platform.rb, line 53 def command_monitor CommandMonitor end
# File lib/aruba/platforms/unix_platform.rb, line 41 def command_string UnixCommandString end
Copy file/directory
# File lib/aruba/platforms/unix_platform.rb, line 139 def cp(src, dest) FileUtils.cp_r(src, dest) end
# File lib/aruba/platforms/unix_platform.rb, line 69 def create_file(*args) ArubaFileCreator.new.call(*args) end
# File lib/aruba/platforms/unix_platform.rb, line 73 def create_fixed_size_file(*args) ArubaFixedSizeFileCreator.new.call(*args) end
# File lib/aruba/platforms/unix_platform.rb, line 97 def current_ruby ::File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"]) end
# File lib/aruba/platforms/unix_platform.rb, line 81 def default_shell "bash" end
# File lib/aruba/platforms/unix_platform.rb, line 93 def deprecated(msg) warn(format("%s. Called by %s", msg, caller[1])) end
# File lib/aruba/platforms/unix_platform.rb, line 85 def detect_ruby(cmd) if /^ruby\s/.match?(cmd) cmd.gsub(/^ruby\s/, "#{current_ruby} ") else cmd end end
# File lib/aruba/platforms/unix_platform.rb, line 65 def determine_disk_usage(paths) DetermineDiskUsage.new.call(paths) end
# File lib/aruba/platforms/unix_platform.rb, line 61 def determine_file_size(*args) DetermineFileSize.new.call(*args) end
Exists and is directory
# File lib/aruba/platforms/unix_platform.rb, line 159 def directory?(f) File.directory? f end
# File lib/aruba/platforms/unix_platform.rb, line 37 def environment_variables UnixEnvironmentVariables end
Path is executable
# File lib/aruba/platforms/unix_platform.rb, line 169 def executable?(f) File.executable?(f) end
Path Exists
# File lib/aruba/platforms/unix_platform.rb, line 164 def exist?(f) File.exist? f end
Expand path
# File lib/aruba/platforms/unix_platform.rb, line 174 def expand_path(path, base) File.expand_path(path, base) end
Exists and is file
# File lib/aruba/platforms/unix_platform.rb, line 154 def file?(f) File.file? f end
# File lib/aruba/platforms/unix_platform.rb, line 45 def filesystem_status FilesystemStatus end
Get current working directory
# File lib/aruba/platforms/unix_platform.rb, line 120 def getwd Dir.getwd end
# File lib/aruba/platforms/unix_platform.rb, line 57 def logger ArubaLogger end
Create directory and subdirectories
# File lib/aruba/platforms/unix_platform.rb, line 106 def mkdir(dir_name) dir_name = ::File.expand_path(dir_name) ::FileUtils.mkdir_p(dir_name) unless ::File.directory?(dir_name) end
Move file/directory
# File lib/aruba/platforms/unix_platform.rb, line 144 def mv(src, dest) FileUtils.mv(src, dest) end
Check if command is relative
@return [Boolean]
true * bin/command.sh false * /bin/command.sh * command.sh
# File lib/aruba/platforms/unix_platform.rb, line 197 def relative_command?(path) p = Pathname.new(path) p.relative? && p.basename != p end
Is relative path
# File lib/aruba/platforms/unix_platform.rb, line 184 def relative_path?(path) Pathname.new(path).relative? end
# File lib/aruba/platforms/unix_platform.rb, line 101 def require_matching_files(pattern, base) ::Dir.glob(::File.expand_path(pattern, base)).each { |f| require_relative f } end
Remove file, directory + sub-directories
# File lib/aruba/platforms/unix_platform.rb, line 113 def rm(paths, options = {}) paths = Array(paths).map { |p| ::File.expand_path(p) } FileUtils.rm_r(paths, **options) end
Transform hash to a string table which can be output on stderr/stdout
# File lib/aruba/platforms/unix_platform.rb, line 222 def simple_table(hash, opts = {}) SimpleTable.new(hash, opts).to_s end
Touch file, directory
# File lib/aruba/platforms/unix_platform.rb, line 134 def touch(args, options) FileUtils.touch(args, **options) end
Resolve path for command using the PATH-environment variable
Mostly taken from here: github.com/djberg96/ptools
@param [#to_s] program
The name of the program which should be resolved
@param [String] path
The PATH, a string concatenated with ":", e.g. /usr/bin/:/bin on a UNIX-system
# File lib/aruba/platforms/unix_platform.rb, line 236 def which(program, path = ENV["PATH"]) UnixWhich.new.call(program, path) end
# File lib/aruba/platforms/unix_platform.rb, line 77 def with_environment(env = {}, &block) LocalEnvironment.new.call(env, &block) end
Write to file
# File lib/aruba/platforms/unix_platform.rb, line 217 def write_file(path, content) File.write(path, content) end