defog 0.1.0 → 0.1.1
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/README.rdoc +9 -6
- data/defog.gemspec +1 -0
- data/lib/defog/handle.rb +22 -5
- data/lib/defog/proxy.rb +1 -1
- data/lib/defog/version.rb +1 -1
- data/spec/handle_spec.rb +18 -2
- data/spec/proxy_spec.rb +1 -1
- metadata +25 -14
data/README.rdoc
CHANGED
@@ -82,18 +82,21 @@ closing (e.g. via <code>File.unlink(file.path)</code>) or pass
|
|
82
82
|
|
83
83
|
=== Proxy handle
|
84
84
|
|
85
|
-
Calling Defog::Proxy#file without a mode returns a Defog::Handle object that supports
|
85
|
+
Calling Defog::Proxy#file without a mode returns a Defog::Handle object that supports cloud file query and manipulation:
|
86
86
|
|
87
|
-
|
88
|
-
|
87
|
+
handle = defog.file("key")
|
88
|
+
handle.exist? # => true if the cloud file exists
|
89
|
+
handle.delete # deletes the cloud file
|
90
|
+
handle.size # => size of the cloud file
|
91
|
+
handle.last_modified # => modification date of the cloud file
|
89
92
|
|
90
|
-
In fact, <code>
|
93
|
+
In fact, <code>defog.file("key", mode, options, &block)</code> is really just shorthand for
|
91
94
|
|
92
|
-
|
95
|
+
defog.file("key").open(mode, options, &block)
|
93
96
|
|
94
97
|
In addition, the handle allows you to look up the path where the local proxy file will be if/when you open the proxy (but without actually doing the proxying).
|
95
98
|
|
96
|
-
|
99
|
+
defog.file("key").proxy_path # => Pathname where proxy file is, was, or will be
|
97
100
|
|
98
101
|
=== Persistence
|
99
102
|
|
data/defog.gemspec
CHANGED
data/lib/defog/handle.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "fastandand"
|
2
|
+
|
1
3
|
module Defog
|
2
4
|
# Create a Defog::Handle proxy instance via Defog::Proxy#file, such as
|
3
5
|
#
|
@@ -14,13 +16,17 @@ module Defog
|
|
14
16
|
# The #proxy_path attribute method returns a <code>Pathname</code>
|
15
17
|
# giving the local proxy file location. Querying the attribute does
|
16
18
|
# <i>not</i> upload, download, synchronize, or otherwise interact with
|
17
|
-
# the cloud or local proxy file in any way -- just returns a constructed
|
18
|
-
# a
|
19
|
+
# the cloud or local proxy file in any way -- it just returns a constructed
|
20
|
+
# Pathname. The <code>proxy_path</code> is a deterministic function of the
|
21
|
+
# cloud key and Defog::Proxy#proxy_root, so you can rely on it not
|
22
|
+
# changing between independent accesses to a cloud file.
|
19
23
|
#
|
20
24
|
class Handle
|
21
25
|
|
22
26
|
attr_reader :key
|
23
27
|
attr_reader :proxy #:nodoc:
|
28
|
+
|
29
|
+
# Pathname where proxy file is, was, or will be located.
|
24
30
|
attr_reader :proxy_path
|
25
31
|
|
26
32
|
def initialize(proxy, key) #:nodoc:
|
@@ -31,12 +37,23 @@ module Defog
|
|
31
37
|
|
32
38
|
# Returns true if the remote cloud file exists
|
33
39
|
def exist?
|
34
|
-
|
40
|
+
!!fog_model
|
35
41
|
end
|
36
42
|
|
37
|
-
# Deletes the remote cloud file
|
43
|
+
# Deletes the remote cloud file if it exists
|
38
44
|
def delete
|
39
|
-
|
45
|
+
fog_model.andand.destroy
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns the size of the remote cloud file, or nil if it doesn't exist
|
49
|
+
def size
|
50
|
+
fog_model.andand.content_length
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns the modification date of the remote cloud file, or nil if it
|
54
|
+
# doesn't exist
|
55
|
+
def last_modified
|
56
|
+
fog_model.andand.last_modified
|
40
57
|
end
|
41
58
|
|
42
59
|
# Returns a URL to access the remote cloud file.
|
data/lib/defog/proxy.rb
CHANGED
data/lib/defog/version.rb
CHANGED
data/spec/handle_spec.rb
CHANGED
@@ -10,15 +10,31 @@ shared_examples "a handle" do |proxyargs|
|
|
10
10
|
@handle = @proxy.file(key)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "should report exist? true if
|
13
|
+
it "should report exist? true if remote cloud file exists" do
|
14
14
|
create_remote("i exist")
|
15
15
|
@handle.should be_exist
|
16
16
|
end
|
17
17
|
|
18
|
-
it "should report exist? false if
|
18
|
+
it "should report exist? false if remote cloud file does not exist" do
|
19
19
|
@handle.should_not be_exist
|
20
20
|
end
|
21
21
|
|
22
|
+
{ :size => :content_length,
|
23
|
+
:last_modified => :last_modified,
|
24
|
+
:delete => :destroy }.each do |method, fog_method|
|
25
|
+
|
26
|
+
it "should delegate #{method.inspect} to the fog model #{fog_method.inspect}if the remote file exists" do
|
27
|
+
create_remote("delegate me")
|
28
|
+
@handle.fog_model.class.any_instance.should_receive(fog_method).and_return { "dummy" }
|
29
|
+
@handle.send(method).should == "dummy"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return nil from #{method} if the remote file does not exist" do
|
33
|
+
@handle.send(method).should be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
22
38
|
it "should delete a remote cloud file" do
|
23
39
|
create_remote("delete me")
|
24
40
|
remote_exist?.should be_true
|
data/spec/proxy_spec.rb
CHANGED
@@ -10,7 +10,7 @@ shared_examples "a proxy" do |args|
|
|
10
10
|
it "should default proxy root to Rails.root" do
|
11
11
|
with_rails_defined do
|
12
12
|
proxy = Defog::Proxy.new(args)
|
13
|
-
proxy.proxy_root.should == Rails.root + "defog" + proxy.provider.to_s + proxy.location
|
13
|
+
proxy.proxy_root.should == Rails.root + "tmp/defog" + proxy.provider.to_s + proxy.location
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
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.1.
|
4
|
+
version: 0.1.1
|
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-04-
|
12
|
+
date: 2012-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
16
|
-
requirement: &
|
16
|
+
requirement: &70159750978980 !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: *70159750978980
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hash_keyword_args
|
27
|
-
requirement: &
|
27
|
+
requirement: &70159750978560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70159750978560
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: fastandand
|
38
|
+
requirement: &70159750978140 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70159750978140
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rake
|
38
|
-
requirement: &
|
49
|
+
requirement: &70159750977700 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: '0'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70159750977700
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: rspec
|
49
|
-
requirement: &
|
60
|
+
requirement: &70159750977280 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70159750977280
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: simplecov
|
60
|
-
requirement: &
|
71
|
+
requirement: &70159750976820 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,10 +76,10 @@ dependencies:
|
|
65
76
|
version: '0'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70159750976820
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: simplecov-gem-adapter
|
71
|
-
requirement: &
|
82
|
+
requirement: &70159750976360 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,7 +87,7 @@ dependencies:
|
|
76
87
|
version: '0'
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70159750976360
|
80
91
|
description: Wrapper to fog gem, proxying access to cloud files as local files.
|
81
92
|
email:
|
82
93
|
- ronen@barzel.org
|