Class: Awshark::S3::Artifact
- Inherits:
-
Object
- Object
- Awshark::S3::Artifact
- Defined in:
- lib/awshark/s3/artifact.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #basename ⇒ Object
- #cache_control ⇒ Object
- #content_type ⇒ Object
- #fingerprint? ⇒ Boolean
-
#initialize(key) ⇒ Artifact
constructor
A new instance of Artifact.
Constructor Details
#initialize(key) ⇒ Artifact
Returns a new instance of Artifact.
8 9 10 |
# File 'lib/awshark/s3/artifact.rb', line 8 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/awshark/s3/artifact.rb', line 6 def key @key end |
Instance Method Details
#basename ⇒ Object
33 34 35 |
# File 'lib/awshark/s3/artifact.rb', line 33 def basename ::File.basename(key) end |
#cache_control ⇒ Object
12 13 14 15 16 |
# File 'lib/awshark/s3/artifact.rb', line 12 def cache_control return "public, max-age=#{1.year.to_i}, s-maxage=#{1.year.to_i}" if fingerprint? 'public, max-age=0, s-maxage=120, must-revalidate' end |
#content_type ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/awshark/s3/artifact.rb', line 24 def content_type mime = MiniMime.lookup_by_filename(basename) if mime mime.content_type else 'application/octet-stream' end end |
#fingerprint? ⇒ Boolean
18 19 20 21 22 |
# File 'lib/awshark/s3/artifact.rb', line 18 def fingerprint? return false if key.blank? basename.match(/\.([0-9a-f]{20}|[0-9a-f]{32})\./).present? end |