Class: Specinfra::Command::Freebsd::Base::File

Inherits:
Base::File show all
Defined in:
lib/specinfra/command/freebsd/base/file.rb

Class Method Summary collapse

Methods inherited from Base::File

change_group, change_mode, change_owner, check_contains, check_contains_lines, check_contains_with_fixed_strings, check_contains_with_regexp, check_contains_within, check_exists, check_is_block_device, check_is_character_device, check_is_directory, check_is_file, check_is_link, check_is_mounted, check_is_pipe, check_is_socket, check_is_symlink, copy, create_as_directory, download, get_content, get_link_target, link_to, move, remove

Methods inherited from Base

create, escape

Class Method Details

.check_has_mode(file, mode) ⇒ Object



21
22
23
# File 'lib/specinfra/command/freebsd/base/file.rb', line 21

def check_has_mode(file, mode)
  "test `stat -f%Mp%Lp #{escape(file)} | sed 's/^0*//'` -eq #{escape(mode)}"
end

.check_is_grouped(file, group) ⇒ Object



3
4
5
6
# File 'lib/specinfra/command/freebsd/base/file.rb', line 3

def check_is_grouped(file, group)
  regexp = "^#{group}$"
  "stat -f%Sg #{escape(file)} | grep -- #{escape(regexp)}"
end

.check_is_linked_to(link, target) ⇒ Object



29
30
31
# File 'lib/specinfra/command/freebsd/base/file.rb', line 29

def check_is_linked_to(link, target)
  "stat -f%Y #{escape(link)} | grep -- #{escape(target)}"
end

.check_is_owned_by(file, owner) ⇒ Object



12
13
14
15
# File 'lib/specinfra/command/freebsd/base/file.rb', line 12

def check_is_owned_by(file, owner)
  regexp = "^#{owner}$"
  "stat -f%Su #{escape(file)} | grep -- #{escape(regexp)}"
end

.get_md5sum(file) ⇒ Object



45
46
47
# File 'lib/specinfra/command/freebsd/base/file.rb', line 45

def get_md5sum(file)
    "md5 #{escape(file)} | cut -d ' ' -f 4"
end

.get_mode(file) ⇒ Object



25
26
27
# File 'lib/specinfra/command/freebsd/base/file.rb', line 25

def get_mode(file)
  "stat -f%Mp%Lp #{escape(file)} | sed 's/^0*//'"
end

.get_mtime(file) ⇒ Object



33
34
35
# File 'lib/specinfra/command/freebsd/base/file.rb', line 33

def get_mtime(file)
  "stat -f%m #{escape(file)}"
end

.get_owner_group(file) ⇒ Object



8
9
10
# File 'lib/specinfra/command/freebsd/base/file.rb', line 8

def get_owner_group(file)
  "stat -f%Sg #{escape(file)}"
end

.get_owner_user(file) ⇒ Object



17
18
19
# File 'lib/specinfra/command/freebsd/base/file.rb', line 17

def get_owner_user(file)
  "stat -f%Su #{escape(file)}"
end

.get_sha256sum(file) ⇒ Object



41
42
43
# File 'lib/specinfra/command/freebsd/base/file.rb', line 41

def get_sha256sum(file)
    "sha256 #{escape(file)} | cut -d ' ' -f 4"
end

.get_size(file) ⇒ Object



37
38
39
# File 'lib/specinfra/command/freebsd/base/file.rb', line 37

def get_size(file)
  "stat -f%z #{escape(file)}"
end