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
Source
# File lib/aruba/platforms/unix_platform.rb, line 36 def self.match? !Gem.win_platform? end
Public Instance Methods
Source
# File lib/aruba/platforms/unix_platform.rb, line 182 def absolute_path?(path) Pathname.new(path).absolute? end
Is absolute path
Source
# File lib/aruba/platforms/unix_platform.rb, line 52 def announcer Announcer end
Source
# File lib/aruba/platforms/unix_platform.rb, line 243 def builtin_shell_commands [] end
Source
# File lib/aruba/platforms/unix_platform.rb, line 128 def chdir(dir_name, &block) dir_name = ::File.expand_path(dir_name.to_s) with_replaced_environment 'OLDPWD' => getwd, 'PWD' => dir_name do ::Dir.chdir(dir_name, &block) end end
Change to directory
Source
# File lib/aruba/platforms/unix_platform.rb, line 152 def chmod(mode, args, options) FileUtils.chmod_R(mode, args, **options) end
Change mode of file/directory
Source
# File lib/aruba/platforms/unix_platform.rb, line 214 def command?(path) p = Pathname.new(path) p.relative? && p.basename == p end
Check if command is relative
@return [Boolean]
true * command.sh false * /bin/command.sh * bin/command.sh
Source
# File lib/aruba/platforms/unix_platform.rb, line 56 def command_monitor CommandMonitor end
Source
# File lib/aruba/platforms/unix_platform.rb, line 44 def command_string UnixCommandString end
Source
# File lib/aruba/platforms/unix_platform.rb, line 142 def cp(src, dest) FileUtils.cp_r(src, dest) end
Copy file/directory
Source
# File lib/aruba/platforms/unix_platform.rb, line 72 def create_file(*args) ArubaFileCreator.new.call(*args) end
Source
# File lib/aruba/platforms/unix_platform.rb, line 76 def create_fixed_size_file(*args) ArubaFixedSizeFileCreator.new.call(*args) end
Source
# File lib/aruba/platforms/unix_platform.rb, line 100 def current_ruby ::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) end
Source
# File lib/aruba/platforms/unix_platform.rb, line 84 def default_shell 'bash' end
Source
# File lib/aruba/platforms/unix_platform.rb, line 96 def deprecated(msg) warn(format('%s. Called by %s', msg, caller[1])) end
Source
# File lib/aruba/platforms/unix_platform.rb, line 88 def detect_ruby(cmd) if /^ruby\s/.match?(cmd) cmd.gsub(/^ruby\s/, "#{current_ruby} ") else cmd end end
Source
# File lib/aruba/platforms/unix_platform.rb, line 68 def determine_disk_usage(paths) DetermineDiskUsage.new.call(paths) end
Source
# File lib/aruba/platforms/unix_platform.rb, line 64 def determine_file_size(*args) DetermineFileSize.new.call(*args) end
Source
# File lib/aruba/platforms/unix_platform.rb, line 162 def directory?(f) File.directory? f end
Exists and is directory
Source
# File lib/aruba/platforms/unix_platform.rb, line 40 def environment_variables UnixEnvironmentVariables end
Source
# File lib/aruba/platforms/unix_platform.rb, line 172 def executable?(f) File.executable?(f) end
Path is executable
Source
# File lib/aruba/platforms/unix_platform.rb, line 167 def exist?(f) File.exist? f end
Path Exists
Source
# File lib/aruba/platforms/unix_platform.rb, line 177 def expand_path(path, base) File.expand_path(path, base) end
Expand path
Source
# File lib/aruba/platforms/unix_platform.rb, line 157 def file?(f) File.file? f end
Exists and is file
Source
# File lib/aruba/platforms/unix_platform.rb, line 48 def filesystem_status FilesystemStatus end
Source
# File lib/aruba/platforms/unix_platform.rb, line 123 def getwd Dir.getwd end
Get current working directory
Source
# File lib/aruba/platforms/unix_platform.rb, line 109 def mkdir(dir_name) dir_name = ::File.expand_path(dir_name) ::FileUtils.mkdir_p(dir_name) unless ::File.directory?(dir_name) end
Create directory and subdirectories
Source
# File lib/aruba/platforms/unix_platform.rb, line 147 def mv(src, dest) FileUtils.mv(src, dest) end
Move file/directory
Source
# File lib/aruba/platforms/unix_platform.rb, line 200 def relative_command?(path) p = Pathname.new(path) p.relative? && p.basename != p end
Check if command is relative
@return [Boolean]
true * bin/command.sh false * /bin/command.sh * command.sh
Source
# File lib/aruba/platforms/unix_platform.rb, line 187 def relative_path?(path) Pathname.new(path).relative? end
Is relative path
Source
# File lib/aruba/platforms/unix_platform.rb, line 104 def require_matching_files(pattern, base) ::Dir.glob(::File.expand_path(pattern, base)).each { |f| require_relative f } end
Source
# File lib/aruba/platforms/unix_platform.rb, line 116 def rm(paths, options = {}) paths = Array(paths).map { |p| ::File.expand_path(p) } FileUtils.rm_r(paths, **options) end
Remove file, directory + sub-directories
Source
# File lib/aruba/platforms/unix_platform.rb, line 225 def simple_table(hash, opts = {}) SimpleTable.new(hash, opts).to_s end
Transform hash to a string table which can be output on stderr/stdout
Source
# File lib/aruba/platforms/unix_platform.rb, line 247 def term_signal_supported? true end
Source
# File lib/aruba/platforms/unix_platform.rb, line 137 def touch(args, options) FileUtils.touch(args, **options) end
Touch file, directory
Source
# File lib/aruba/platforms/unix_platform.rb, line 239 def which(program, path = ENV['PATH']) UnixWhich.new.call(program, path) 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
Source
# File lib/aruba/platforms/unix_platform.rb, line 80 def with_replaced_environment(env = {}, &block) LocalEnvironment.new(self).call(env, &block) end
Source
# File lib/aruba/platforms/unix_platform.rb, line 220 def write_file(path, content) File.write(path, content) end
Write to file