Sha256: cda159bee725d76c23fe9458329d1f1bdf9bf80743ce2525967d6bb08add9f65

Contents?: true

Size: 1.24 KB

Versions: 64

Compression:

Stored size: 1.24 KB

Contents

class Specinfra::Command::Darwin::Base::File < Specinfra::Command::Base::File
  class << self
    def check_is_accessible_by_user(file, user, access)
      "sudo -u #{user} -s /bin/test -#{access} #{file}"
    end

    def get_md5sum(file)
      "openssl md5 #{escape(file)} | cut -d'=' -f2 | cut -c 2-"
    end

    def get_sha256sum(file)
      "ruby -e \"require 'digest'; puts Digest::SHA256.hexdigest File.read '#{escape(file)}'\""
    end

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

    def get_link_target(link)
      "readlink #{escape(link)}"
    end

    def check_has_mode(file, mode)
      regexp = "^#{mode}$"
      "stat -f%Lp #{escape(file)} | grep -- #{escape(regexp)}"
    end

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

    def check_is_grouped(file, group)
      regexp = "^#{group}$"
      "stat -f %Sg #{escape(file)} | grep -- #{escape(regexp)}"
    end

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

    def get_owner_user(file)
      "stat -f %Su #{escape(file)}"
    end

    def get_owner_group(file)
      "stat -f %Sg #{escape(file)}"
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
specinfra-2.33.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.32.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.31.1 lib/specinfra/command/darwin/base/file.rb
specinfra-2.31.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.30.4 lib/specinfra/command/darwin/base/file.rb
specinfra-2.30.3 lib/specinfra/command/darwin/base/file.rb
specinfra-2.30.2 lib/specinfra/command/darwin/base/file.rb
specinfra-2.30.1 lib/specinfra/command/darwin/base/file.rb
specinfra-2.30.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.29.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.28.4 lib/specinfra/command/darwin/base/file.rb
specinfra-2.28.3 lib/specinfra/command/darwin/base/file.rb
specinfra-2.28.2 lib/specinfra/command/darwin/base/file.rb
specinfra-2.28.1 lib/specinfra/command/darwin/base/file.rb
specinfra-2.28.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.27.1 lib/specinfra/command/darwin/base/file.rb
specinfra-2.27.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.26.1 lib/specinfra/command/darwin/base/file.rb
specinfra-2.26.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.25.1 lib/specinfra/command/darwin/base/file.rb