Skip to content

Commit

Permalink
Add Cask#install_time method.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed May 31, 2019
1 parent b12623f commit 17f6d19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def installed?
!versions.empty?
end

def install_time
_, time = timestamped_versions.last
return unless time

Time.strptime(time, Metadata::TIMESTAMP_FORMAT)
end

def installed_caskfile
installed_version = timestamped_versions.last
metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
Expand Down
8 changes: 2 additions & 6 deletions Library/Homebrew/cask/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Cask
module Metadata
METADATA_SUBDIR = ".metadata"
TIMESTAMP_FORMAT = "%Y%m%d%H%M%S.%L"

def metadata_master_container_path
@metadata_master_container_path ||= caskroom_path.join(METADATA_SUBDIR)
Expand Down Expand Up @@ -58,12 +59,7 @@ def metadata_subdir(leaf, version: self.version, timestamp: :latest, create: fal
private

def new_timestamp(time = Time.now)
time = time.utc

timestamp = time.strftime("%Y%m%d%H%M%S")
fraction = format("%.3f", time.to_f - time.to_i)[1..-1]

timestamp.concat(fraction)
time.utc.strftime(TIMESTAMP_FORMAT)
end
end
end

0 comments on commit 17f6d19

Please sign in to comment.