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_directory, check_is_file, check_is_link, check_is_mounted, check_is_pipe, check_is_socket, check_is_symlink, copy, create_as_directory, get_content, get_link_target, get_owner_group, get_owner_user, link_to, move, remove

Methods inherited from Base

create, escape

Class Method Details

.check_has_mode(file, mode) ⇒ Object


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

def check_has_mode(file, mode)
  regexp = "^#{mode}$"
  "stat -f%Lp #{escape(file)} | grep -- #{escape(regexp)}"
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


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

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

.check_is_owned_by(file, owner) ⇒ Object


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

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

.get_md5sum(file) ⇒ Object


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

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

.get_mode(file) ⇒ Object


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

def get_mode(file)
  "stat -f%Lp #{escape(file)}"
end

.get_mtime(file) ⇒ Object


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

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

.get_sha256sum(file) ⇒ Object


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

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

.get_size(file) ⇒ Object


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

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