Class: Specinfra::Command::Solaris::V10::File

Inherits:
Base::File show all
Defined in:
lib/specinfra/command/solaris/v10/file.rb

Class Method Summary collapse

Methods inherited from Base::File

check_contains_within, check_is_accessible_by_user

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_mtime, get_owner_group, get_owner_user, get_sha256sum, get_size, link_to, move, remove

Methods inherited from Base

create, escape

Class Method Details

.check_contain(file, expected_pattern) ⇒ Object


29
30
31
# File 'lib/specinfra/command/solaris/v10/file.rb', line 29

def check_contain(file, expected_pattern)
  "grep -- #{escape(expected_pattern)} #{escape(file)}"
end

.check_has_mode(file, mode) ⇒ Object


4
5
6
7
# File 'lib/specinfra/command/solaris/v10/file.rb', line 4

def check_has_mode(file, mode)
  regexp = "^#{mode}$"
  "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)}  | grep -- #{escape(regexp)}"
end

.check_is_grouped(file, group) ⇒ Object

reference: perldoc.perl.org/functions/stat.html

http://www.tutorialspoint.com/perl/perl_getgrgid.htm

18
19
20
21
# File 'lib/specinfra/command/solaris/v10/file.rb', line 18

def check_is_grouped(file, group)
  regexp = "^#{group}$"
  "perl -e 'printf \"%s\", getgrgid((stat(\"#{escape(file)}\"))[5])'  | grep -- #{escape(regexp)}"
end

.check_is_linked_to(link, target) ⇒ Object


24
25
26
27
# File 'lib/specinfra/command/solaris/v10/file.rb', line 24

def check_is_linked_to(link, target)
  regexp = "^#{target}$"
  "perl -e 'printf \"%s\", readlink(\"#{escape(link)}\")' | grep -- #{escape(regexp)}"
end

.check_is_owned_by(file, owner) ⇒ Object

reference: perldoc.perl.org/functions/stat.html

http://www.tutorialspoint.com/perl/perl_getpwuid.htm

11
12
13
14
# File 'lib/specinfra/command/solaris/v10/file.rb', line 11

def check_is_owned_by(file, owner)
  regexp = "^#{owner}$"
  "perl -e 'printf \"%s\", getpwuid((stat(\"#{escape(file)}\"))[4])' | grep -- #{escape(regexp)}"
end

.get_md5sum(file) ⇒ Object


33
34
35
# File 'lib/specinfra/command/solaris/v10/file.rb', line 33

def get_md5sum(file)
  "digest -a md5 -v #{escape(file)} | cut -d '=' -f 2 |  cut -c 2-"
end

.get_mode(file) ⇒ Object


38
39
40
# File 'lib/specinfra/command/solaris/v10/file.rb', line 38

def get_mode(file)
  "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)}"
end