Sha256: 07105d59d2e0141da75261aa2d67cdd8463cc6e1cd8be1907d2e84350bb15ad4

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 KB

Contents

class Specinfra::Command::Solaris::V10::File < Specinfra::Command::Solaris::Base::File
  # reference: http://perldoc.perl.org/functions/stat.html
  def check_mode(file, mode)
    regexp = "^#{mode}$"
    "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)}  | grep -- #{escape(regexp)}"
  end

  # reference: http://perldoc.perl.org/functions/stat.html
  #            http://www.tutorialspoint.com/perl/perl_getpwuid.htm
  def check_is_owned_by(file, owner)
    regexp = "^#{owner}$"
    "perl -e 'printf \"%s\", getpwuid((stat(\"#{escape(file)}\"))[4])' | grep -- #{escape(regexp)}"
  end

  # reference: http://perldoc.perl.org/functions/stat.html
  #            http://www.tutorialspoint.com/perl/perl_getgrgid.htm
  def check_is_grouped(file, group)
    regexp = "^#{group}$"
    "perl -e 'printf \"%s\", getgrgid((stat(\"#{escape(file)}\"))[5])'  | grep -- #{escape(regexp)}"
  end

  # reference: http://www.tutorialspoint.com/perl/perl_readlink.htm
  def check_is_linked_to(link, target)
    regexp = "^#{target}$"
    "perl -e 'printf \"%s\", readlink(\"#{escape(link)}\")' | grep -- #{escape(regexp)}"
  end

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

  def check_has_md5checksum(file, expected)
    "digest -a md5 -v #{escape(file)} | grep -iw -- #{escape(expected)}"
  end

  # reference: http://perldoc.perl.org/functions/stat.html
  def get_mode(file)
    "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
specinfra-2.0.0.beta11 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.0.0.beta10 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.0.0.beta9 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.0.0.beta8 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.0.0.beta7 lib/specinfra/command/solaris/v10/file.rb