defog 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/README.rdoc +20 -8
- data/Rakefile +2 -0
- data/lib/defog/fog_wrapper.rb +5 -3
- data/lib/defog/handle.rb +15 -9
- data/lib/defog/version.rb +1 -1
- data/spec/file_spec.rb +2 -2
- data/spec/handle_spec.rb +12 -0
- data/spec/proxy_spec.rb +2 -2
- metadata +17 -16
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
= defog
|
2
2
|
|
3
|
+
{<img src="https://secure.travis-ci.org/ronen/defog.png"/>}[http://travis-ci.org/ronen/defog]
|
4
|
+
{<img src="https://gemnasium.com/ronen/defog.png" alt="Dependency Status" />}[https://gemnasium.com/ronen/defog]
|
5
|
+
|
3
6
|
Defog wraps the fog[https://rubygems.org/gems/fog] gem (specifically,
|
4
7
|
{Fog::Storage}[http://fog.io/1.3.1/storage/]), providing access to files
|
5
8
|
stored in the cloud via proxy files on the local file system.
|
@@ -19,12 +22,6 @@ Defog also provides a few simple remote-file management methods to minimize
|
|
19
22
|
the need to dig down into the Fog layer; but full access to the underlying
|
20
23
|
fog objects is available should it be needed.
|
21
24
|
|
22
|
-
<b>NOTE:</b> Currently the only supported providers are :local and :AWS since
|
23
|
-
those are what the author currently uses. Please fork and add others!
|
24
|
-
(There's just a very small amount of provider-specific code in {one
|
25
|
-
file}[https://github.com/ronen/defog/blob/master/lib/defog/fog_wrapper.rb],
|
26
|
-
plus spec examples.)
|
27
|
-
|
28
25
|
== Usage Summary
|
29
26
|
|
30
27
|
Full Rdoc is available at http://rubydoc.info/gems/defog
|
@@ -216,8 +213,23 @@ Gemfile:
|
|
216
213
|
|
217
214
|
== Compatibility
|
218
215
|
|
219
|
-
Defog
|
220
|
-
|
216
|
+
Defog is currently known to work on:
|
217
|
+
|
218
|
+
* Ruby: MRI 1.9.2, MRI 1.9.3
|
219
|
+
* Fog Storage: :local, :AWS
|
220
|
+
|
221
|
+
The above storage providers are what the author uses. Please fork and add
|
222
|
+
others! (There's just a very small amount of provider-specific code in {one
|
223
|
+
file}[https://github.com/ronen/defog/blob/master/lib/defog/fog_wrapper.rb],
|
224
|
+
plus spec examples.)
|
225
|
+
|
226
|
+
== History
|
227
|
+
|
228
|
+
Release Notes:
|
229
|
+
|
230
|
+
* 0.7.0 - Add :query option to Handle#url
|
231
|
+
* 0.6.1 - Bug fix (caching)
|
232
|
+
* 0.6.0 - Add logging
|
221
233
|
|
222
234
|
== Copyright
|
223
235
|
|
data/Rakefile
CHANGED
data/lib/defog/fog_wrapper.rb
CHANGED
@@ -89,7 +89,7 @@ module Defog #:nodoc: all
|
|
89
89
|
Digest::MD5.hexdigest(fog_head(key).body)
|
90
90
|
end
|
91
91
|
|
92
|
-
def url(key,
|
92
|
+
def url(key, options={})
|
93
93
|
localpath = Pathname.new("#{@local_root}/#{@prefix}#{key}").expand_path
|
94
94
|
if defined?(Rails)
|
95
95
|
relative = localpath.relative_path_from Rails.root + "public" rescue nil
|
@@ -116,8 +116,10 @@ module Defog #:nodoc: all
|
|
116
116
|
fog_head(key).etag
|
117
117
|
end
|
118
118
|
|
119
|
-
def url(key,
|
120
|
-
|
119
|
+
def url(key, options={})
|
120
|
+
options = options.keyword_args(:expiry => :required, :query => :optional)
|
121
|
+
expiry = options.delete(:expiry)
|
122
|
+
fog_head(key).url(expiry, options)
|
121
123
|
end
|
122
124
|
|
123
125
|
end
|
data/lib/defog/handle.rb
CHANGED
@@ -60,19 +60,25 @@ module Defog
|
|
60
60
|
fog_model.andand.last_modified
|
61
61
|
end
|
62
62
|
|
63
|
-
# Returns a URL to access the remote cloud file.
|
63
|
+
# Returns a URL to access the remote cloud file. The options are
|
64
|
+
# storage-specific.
|
64
65
|
#
|
65
|
-
#
|
66
|
+
# For :AWS files, the option
|
66
67
|
# :expiry => time
|
67
|
-
#
|
68
|
-
# <code>Time.now + 10.minutes</code>.
|
68
|
+
# is required and specifies the expiration of time-limited URLS when
|
69
|
+
# using :AWS. The default is <code>Time.now + 10.minutes</code>.
|
70
|
+
# The option
|
71
|
+
# :query => { ... }
|
72
|
+
# is optional and is passed directly to fog. Example usage might be
|
73
|
+
# :query => {'response-content-disposition' => 'attachment'}
|
69
74
|
#
|
70
|
-
# For :local cloud files,
|
71
|
-
# Rails app's public directory, returns a
|
72
|
-
# the public directory. Otherwise returns a
|
75
|
+
# For :local cloud files, all options are ignored. If Rails is defined
|
76
|
+
# and the file is in Rails app's public directory, returns a path
|
77
|
+
# relative to the public directory. Otherwise returns a
|
78
|
+
# <code>"file://"</code> URL
|
73
79
|
def url(opts={})
|
74
|
-
opts = opts.keyword_args(:expiry => Time.now + 10*60)
|
75
|
-
@proxy.fog_wrapper.url(@key, opts
|
80
|
+
opts = opts.keyword_args(:expiry => Time.now + 10*60, :query => :optional)
|
81
|
+
@proxy.fog_wrapper.url(@key, opts)
|
76
82
|
end
|
77
83
|
|
78
84
|
# Returns the underlying Fog::Model, should you need it for something.
|
data/lib/defog/version.rb
CHANGED
data/spec/file_spec.rb
CHANGED
@@ -51,9 +51,9 @@ shared_examples "read" do
|
|
51
51
|
|
52
52
|
it "should pass encodings through" do
|
53
53
|
create_remote("encode me")
|
54
|
-
@proxy.file(key, "#{@mode}:EUC-JP:UTF-
|
54
|
+
@proxy.file(key, "#{@mode}:EUC-JP:UTF-8") do |file|
|
55
55
|
file.external_encoding.name.should == "EUC-JP"
|
56
|
-
file.internal_encoding.name.should == "UTF-
|
56
|
+
file.internal_encoding.name.should == "UTF-8"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
data/spec/handle_spec.rb
CHANGED
@@ -116,6 +116,18 @@ describe Defog::Handle do
|
|
116
116
|
args = {:provider => :AWS, :aws_access_key_id => "dummyid", :aws_secret_access_key => "dummysecret", :region => "eu-west-1", :bucket => "tester"}
|
117
117
|
it_should_behave_like "a handle", args
|
118
118
|
|
119
|
+
it "should pass url query options to fog" do
|
120
|
+
@proxy = Defog::Proxy.new(args)
|
121
|
+
|
122
|
+
create_remote("reach out to me")
|
123
|
+
t = Time.now + 10*60
|
124
|
+
#Fog::Storage::AWS::File.any_instance.should_receive(:url).with(t, "response-content-disposition" => "attachment")
|
125
|
+
url = @proxy.file(key).url(:expiry => t, :query => {"response-content-disposition" => "attachment"})
|
126
|
+
puts url
|
127
|
+
url.should include "response-content-disposition=attachment"
|
128
|
+
end
|
129
|
+
|
130
|
+
|
119
131
|
end
|
120
132
|
|
121
133
|
end
|
data/spec/proxy_spec.rb
CHANGED
@@ -218,8 +218,8 @@ shared_examples "a proxy" do |args|
|
|
218
218
|
proxy_path.should_not be_exist
|
219
219
|
other_proxy_path("a").should be_exist
|
220
220
|
other_proxy_path("b").should be_exist
|
221
|
-
other_proxy_path("
|
222
|
-
other_proxy_path("
|
221
|
+
other_proxy_path("R").should be_exist
|
222
|
+
other_proxy_path("S").should be_exist
|
223
223
|
end
|
224
224
|
end
|
225
225
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
16
|
-
requirement: &
|
16
|
+
requirement: &70218300244080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70218300244080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hash_keyword_args
|
27
|
-
requirement: &
|
27
|
+
requirement: &70218300243200 !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: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70218300243200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fastandand
|
38
|
-
requirement: &
|
38
|
+
requirement: &70218300242260 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70218300242260
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70218300241500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70218300241500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70218300240880 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70218300240880
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
|
-
requirement: &
|
71
|
+
requirement: &70218300240200 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70218300240200
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: simplecov-gem-adapter
|
82
|
-
requirement: &
|
82
|
+
requirement: &70218300239480 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70218300239480
|
91
91
|
description: Wrapper to fog gem, proxying access to cloud files as local files.
|
92
92
|
email:
|
93
93
|
- ronen@barzel.org
|
@@ -96,6 +96,7 @@ extensions: []
|
|
96
96
|
extra_rdoc_files: []
|
97
97
|
files:
|
98
98
|
- .gitignore
|
99
|
+
- .travis.yml
|
99
100
|
- Gemfile
|
100
101
|
- LICENSE
|
101
102
|
- README.rdoc
|