Class: Artifactory::Cleaner::DiscoveredArtifact
- Inherits:
-
Resource::Artifact
- Object
- Resource::Artifact
- Artifactory::Cleaner::DiscoveredArtifact
- Defined in:
- lib/artifactory/cleaner/discovered_artifact.rb
Overview
An Artifact discovered during a repository search
This class is a wrapper of Artifactory::Resource::Artifact because the parent class does not have a concept of ‘last_downloaded` nor the most recent date for any action on an Artifact. These are important to deciding if an Artifcat should be deleted
Class Method Summary collapse
-
.earliest_date_from(artifact) ⇒ Object
Given an Artifactory::Resource::Artifact, return the value of the earliest date property on that object.
-
.latest_date_from(artifact) ⇒ Object
Given an Artifactory::Resource::Artifact, return the value of the latest date property on that object.
Instance Method Summary collapse
-
#earliest_date ⇒ Object
What’s the earliest Time of any of the date/time properties on this object?.
-
#filename ⇒ Object
The filename componet (basename) of this artifact’s URL.
-
#last_downloaded ⇒ Object
Time representing the date and time this artifact was last downloaded by a client (presumably to be installed).
-
#latest_date ⇒ Object
What’s the most recent Time of any of the date/time properties on this object?.
-
#to_s ⇒ Object
A string representation of this artifact.
Class Method Details
.earliest_date_from(artifact) ⇒ Object
Given an Artifactory::Resource::Artifact, return the value of the earliest date property on that object
Designed to answer the question “what’s the first time anything happened to a given Artifact?”, this method returns the earliest (longest ago) date from the given artifact’s created, last modified and last downloaded timestamps.
48 49 50 51 52 53 54 |
# File 'lib/artifactory/cleaner/discovered_artifact.rb', line 48 def self.earliest_date_from(artifact) [ artifact.created, artifact.last_modified, artifact.respond_to?(:last_downloaded) ? artifact.last_downloaded : nil, ].compact.sort.first end |
.latest_date_from(artifact) ⇒ Object
Given an Artifactory::Resource::Artifact, return the value of the latest date property on that object
Designed to answer the question “what’s the most recent interaction with a given Artifact?”, this method returns the latest (most recent) date from the given artifact’s created, last modified and last downloaded timestamps.
62 63 64 65 66 67 68 |
# File 'lib/artifactory/cleaner/discovered_artifact.rb', line 62 def self.latest_date_from(artifact) [ artifact.created, artifact.last_modified, artifact.respond_to?(:last_downloaded) ? artifact.last_downloaded : nil, ].compact.sort.last end |
Instance Method Details
#earliest_date ⇒ Object
What’s the earliest Time of any of the date/time properties on this object?
19 20 21 |
# File 'lib/artifactory/cleaner/discovered_artifact.rb', line 19 def earliest_date self.class.earliest_date_from(self) end |
#filename ⇒ Object
The filename componet (basename) of this artifact’s URL
31 32 33 34 |
# File 'lib/artifactory/cleaner/discovered_artifact.rb', line 31 def filename uri = URI(self.uri) File.basename(uri.path) end |
#last_downloaded ⇒ Object
Time representing the date and time this artifact was last downloaded by a client (presumably to be installed)
15 |
# File 'lib/artifactory/cleaner/discovered_artifact.rb', line 15 attribute :last_downloaded |
#latest_date ⇒ Object
What’s the most recent Time of any of the date/time properties on this object?
25 26 27 |
# File 'lib/artifactory/cleaner/discovered_artifact.rb', line 25 def latest_date self.class.latest_date_from(self) end |
#to_s ⇒ Object
A string representation of this artifact
38 39 40 |
# File 'lib/artifactory/cleaner/discovered_artifact.rb', line 38 def to_s "#<DiscoveredArtifact #{filename} last accessed #{latest_date}>" end |