Method: Mac::Exec#modified_at

Defined in:
lib/beaker/host/mac/exec.rb

#modified_at(file, timestamp = nil) ⇒ Object

Update ModifiedDate on a file

Parameters:

  • file (String)

    Path to the file

  • timestamp (String) (defaults to: nil)

    Timestamp to set



41
42
43
44
45
46
# File 'lib/beaker/host/mac/exec.rb', line 41

def modified_at(file, timestamp = nil)
  require 'date'
  time = timestamp ? DateTime.parse("#{timestamp}") : DateTime.now
  timestamp = time.strftime('%Y%m%d%H%M')
  execute("touch -mt #{timestamp} #{file}")
end