Class: Specinfra::Command::Solaris::Base::File

Inherits:
Base::File show all
Defined in:
lib/specinfra/command/solaris/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_exists, check_has_mode, check_is_directory, check_is_file, check_is_grouped, check_is_link, check_is_linked_to, check_is_mounted, check_is_owned_by, check_is_pipe, check_is_socket, check_is_symlink, copy, create_as_directory, get_content, get_link_target, get_md5sum, get_mode, 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_contains_within(file, expected_pattern, from = nil, to = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/specinfra/command/solaris/base/file.rb', line 3

def check_contains_within(file, expected_pattern, from=nil, to=nil)
  from ||= '1'
  to ||= '$'
  sed = "sed -n #{escape(from)},#{escape(to)}p #{escape(file)}"
  sed_end = "sed -n 1,#{escape(to)}p"
  checker_with_regexp = check_contains_with_regexp("/dev/stdin", expected_pattern)
  checker_with_fixed  = check_contains_with_fixed_strings("/dev/stdin", expected_pattern)
  "#{sed} | #{sed_end} | #{checker_with_regexp}|| #{sed} | #{sed_end} | #{checker_with_fixed}"
end

.check_is_accessible_by_user(file, user, access) ⇒ Object



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

def check_is_accessible_by_user(file, user, access)
  # http://docs.oracle.com/cd/E23823_01/html/816-5166/su-1m.html
  ## No need for login shell as it seems that behavior as superuser is favorable for us, but needs
  ## to be better tested under real solaris env
  "su #{user} -c \"test -#{access} #{file}\""
end