Sha256: 988978ac2b11937cc76e9834974ee6837c944fda85bb16e3f08e7ce4665dc007

Contents?: true

Size: 1.55 KB

Versions: 367

Compression:

Stored size: 1.55 KB

Contents

class Specinfra::Command::Solaris::V10::File < Specinfra::Command::Solaris::Base::File
  class << self
    # reference: http://perldoc.perl.org/functions/stat.html
    def check_has_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 get_md5sum(file)
      "digest -a md5 -v #{escape(file)} | cut -d '=' -f 2 |  cut -c 2-"
    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
end

Version data entries

367 entries across 367 versions & 3 rubygems

Version Path
specinfra-2.91.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.90.1 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.90.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.89.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.88.2 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.88.1 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.88.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.87.2 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.87.1 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.87.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.86.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.85.1 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.85.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.84.1 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.84.0 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.83.4 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.83.3 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.83.2 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.83.1 lib/specinfra/command/solaris/v10/file.rb
specinfra-2.83.0 lib/specinfra/command/solaris/v10/file.rb