Sha256: 31ef6c66f79fc4f2adfeae53d41c300d05c7521724f943c874b2222050f26d2b

Contents?: true

Size: 1.17 KB

Versions: 214

Compression:

Stored size: 1.17 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 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

214 entries across 214 versions & 3 rubygems

Version Path
specinfra-2.82.16 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.15 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.14 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.13 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.12 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.11 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.10 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.9 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.8 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.7 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.6 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.5 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.4 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.3 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.2 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.1 lib/specinfra/command/darwin/base/file.rb
specinfra-2.82.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.81.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.80.0 lib/specinfra/command/darwin/base/file.rb
specinfra-2.79.0 lib/specinfra/command/darwin/base/file.rb