uber-s3 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/uber-s3/object.rb
CHANGED
@@ -6,7 +6,7 @@ module UberS3::Operation::Object
|
|
6
6
|
base.send :include, InstanceMethods
|
7
7
|
|
8
8
|
base.instance_eval do
|
9
|
-
attr_accessor :content_type
|
9
|
+
# attr_accessor :content_type
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -22,6 +22,9 @@ module UberS3::Operation::Object
|
|
22
22
|
self.content_type ||= 'binary/octet-stream'
|
23
23
|
end
|
24
24
|
|
25
|
+
def content_type=(x); @content_type = x; end
|
26
|
+
def content_type; @content_type; end
|
27
|
+
|
25
28
|
end
|
26
29
|
|
27
30
|
end
|
@@ -2,12 +2,14 @@ module UberS3::Operation::Object
|
|
2
2
|
module HttpCache
|
3
3
|
|
4
4
|
def self.included(base)
|
5
|
-
|
6
|
-
|
5
|
+
# TODO: .. strange behaviour.. can't override these methods in below modules.
|
6
|
+
# requires some metaprogramming debugging
|
7
|
+
# base.instance_eval do
|
8
|
+
# attr_accessor :cache_control, :expires, :pragma, :ttl
|
9
|
+
# end
|
7
10
|
|
8
|
-
base.
|
9
|
-
|
10
|
-
end
|
11
|
+
base.send :extend, ClassMethods
|
12
|
+
base.send :include, InstanceMethods
|
11
13
|
end
|
12
14
|
|
13
15
|
module ClassMethods
|
@@ -15,11 +17,39 @@ module UberS3::Operation::Object
|
|
15
17
|
|
16
18
|
module InstanceMethods
|
17
19
|
|
20
|
+
# TODO: shouldn't need this junk... see above comment
|
21
|
+
def cache_control=(x); @cache_control = x; end
|
22
|
+
def cache_control; @cache_control; end
|
23
|
+
|
24
|
+
def expires=(x); @expires = x; end
|
25
|
+
def expires; @expires; end
|
26
|
+
|
27
|
+
def pragma=(x); @pragma = x; end
|
28
|
+
def pragma; @pragma; end
|
29
|
+
|
30
|
+
def ttl=(x); @ttl = x; end
|
31
|
+
def ttl; @ttl; end
|
32
|
+
|
33
|
+
#----
|
34
|
+
|
18
35
|
# Helper method that will set the max-age for cache-control
|
19
|
-
def ttl=(
|
20
|
-
@ttl =
|
21
|
-
|
36
|
+
def ttl=(val)
|
37
|
+
(@ttl = val).tap { infer_cache_control! }
|
38
|
+
end
|
39
|
+
|
40
|
+
# TODO... there are some edge cases here.. ie. someone sets their own self.content_type ...
|
41
|
+
def infer_cache_control!
|
42
|
+
return if ttl.nil? || content_type.nil?
|
43
|
+
|
44
|
+
if ttl.is_a?(Hash)
|
45
|
+
mime_types = ttl.keys
|
46
|
+
match = mime_types.find {|pattern| !(content_type =~ /#{pattern}/i).nil? }
|
47
|
+
self.cache_control = "public,max-age=#{ttl[match]}" if match
|
48
|
+
else
|
49
|
+
self.cache_control = "public,max-age=#{ttl}"
|
50
|
+
end
|
22
51
|
end
|
52
|
+
|
23
53
|
|
24
54
|
# Expires can take a time or string
|
25
55
|
def expires=(val)
|
data/lib/uber-s3/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uber-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-11 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|
16
|
-
requirement: &
|
16
|
+
requirement: &70136054186780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.17'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70136054186780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70136054186160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70136054186160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70136054185000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 2.7.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70136054185000
|
47
47
|
description: A simple & very fast S3 client supporting sync / async HTTP adapters
|
48
48
|
email:
|
49
49
|
- peter@nulayer.com
|