defog 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 024349bd2d3f5def5bf676cd93b7a222500003ab
4
+ data.tar.gz: 1636cbfc52043124967d8cd0dd5538ae80b42e0e
5
+ SHA512:
6
+ metadata.gz: 282ade57688944a3d6b0203faece002aab973f92ddb93c702548ba3de50ae1252932b45a38f608c6acc56d2a0ce8ab83ac3dfb6f8d2d6c48ae4567acbdf131ca
7
+ data.tar.gz: f4d0323c3ef34a697f7f7bf667f46dd1fb5fd57ec948ce33fa90199cedbe20c8e212bb91c3cc5b1a97cdb89d9ac46a8d6f15fee8d91f699d1b595e006c0f3660
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
+ - 2.0.0
4
5
  notifications:
5
6
  recipients:
6
7
  - ronen@barzel.org
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # defog
2
2
 
3
- [<img
4
- src="https://secure.travis-ci.org/ronen/defog.png"/>](http://travis-ci.org/ronen/defog) [<img src="https://gemnasium.com/ronen/defog.png" alt="Dependency
5
- Status" />](https://gemnasium.com/ronen/defog)
3
+ [![Gem Version](https://badge.fury.io/rb/defog.png)](http://badge.fury.io/rb/defog)
4
+ [![Build Status](https://secure.travis-ci.org/ronen/defog.png)](http://travis-ci.org/ronen/defog)
5
+ [![Dependency Status](https://gemnasium.com/ronen/defog.png)](https://gemnasium.com/ronen/defog)
6
6
 
7
7
  Defog wraps the [fog](https://rubygems.org/gems/fog) gem (specifically,
8
- [Fog::Storage](http://fog.io/1.3.1/storage/)), providing access to files
8
+ [Fog::Storage](http://fog.io/storage/)), providing access to files
9
9
  stored in the cloud via proxy files on the local file system. A proxy file can
10
10
  be
11
11
  * Read-only: A local cached copy of a cloud file.
@@ -24,9 +24,11 @@ Defog also provides a few simple remote-file management methods to minimize
24
24
  the need to dig down into the Fog layer; but full access to the underlying fog
25
25
  objects is available should it be needed.
26
26
 
27
+ Full Rdoc is available at [http://rubydoc.info/gems/defog](Full Rdoc is available at http://rubydoc.info/gems/defog)
28
+
27
29
  ## Usage Summary
28
30
 
29
- Full Rdoc is available at http://rubydoc.info/gems/defog
31
+
30
32
 
31
33
  ### Create proxy connection
32
34
 
@@ -42,7 +44,7 @@ proxies files in a specific remote location, e.g.:
42
44
  defog = Defog::Proxy.new(:provider => :Local,
43
45
  :local_root => "/path/to/directory")
44
46
 
45
- For complete options, see Defog::Proxy.new RDOC
47
+ For complete options, see [Defog::Proxy.new RDOC](http://rubydoc.info/gems/defog/Defog/Proxy)
46
48
 
47
49
  ### Proxy a file
48
50
 
@@ -99,6 +101,7 @@ supports cloud file query and manipulation:
99
101
  handle.delete # deletes the cloud file
100
102
  handle.size # => size of the cloud file
101
103
  handle.last_modified # => modification date of the cloud file
104
+ handle.md5_hash # => MD5 hash digest of the cloud file
102
105
 
103
106
  In fact, `defog.file("key", mode, options, &block)` is really just shorthand
104
107
  for
@@ -238,19 +241,20 @@ Gemfile:
238
241
 
239
242
  Defog is currently known to work on:
240
243
 
241
- * Ruby: MRI 1.9.2, MRI 1.9.3
244
+ * Ruby: MRI 1.9.2, MRI 1.9.3, MRI 2.0.0
242
245
  * Fog Storage: :local, :AWS
243
246
 
244
247
 
245
248
  The above storage providers are what the author uses. Please fork and add
246
- others! (There's just a very small amount of provider-specific code in one
247
- file, https://github.com/ronen/defog/blob/master/lib/defog/fog_wrapper.rb,
249
+ others! (There's just a very small amount of provider-specific code in [one
250
+ file](https://github.com/ronen/defog/blob/master/lib/defog/fog_wrapper.rb]),
248
251
  plus appropriate rspec examples.)
249
252
 
250
253
  ## History
251
254
 
252
255
  Release Notes:
253
256
 
257
+ * 0.9.0 - Expose Handle#md5_hash
254
258
  * 0.8.0 - Include prefix in proxy_path (thus allowing cache sharing)
255
259
  * 0.7.2 - Bug fix: don't fail when clearing cache if another process clears it first
256
260
  * 0.7.1 - Add key info to message if there's an exception when getting file
data/lib/defog/handle.rb CHANGED
@@ -14,19 +14,19 @@ module Defog
14
14
  # end
15
15
  #
16
16
  # The #proxy_path attribute method returns a <code>Pathname</code>
17
- # giving the local proxy file location. Querying the attribute does
17
+ # giving the local proxy file location. Querying the attribute does
18
18
  # <i>not</i> upload, download, synchronize, or otherwise interact with
19
19
  # the cloud or local proxy file in any way -- it just returns a constructed
20
20
  # Pathname. The <code>proxy_path</code> is a deterministic function of the
21
21
  # cloud key and Defog::Proxy#proxy_root, so you can rely on it not
22
22
  # changing between independent accesses to a cloud file.
23
- #
23
+ #
24
24
  class Handle
25
25
 
26
26
  attr_reader :key
27
27
  attr_reader :proxy #:nodoc:
28
28
 
29
- # Pathname where proxy file is, was, or will be located.
29
+ # Pathname where proxy file is, was, or will be located.
30
30
  attr_reader :proxy_path
31
31
 
32
32
  def initialize(proxy, key) #:nodoc:
@@ -39,7 +39,7 @@ module Defog
39
39
  "<#{self.class}: key=#{key}>"
40
40
  end
41
41
 
42
- # Returns true if the remote cloud file exists
42
+ # Returns true if the remote cloud file exists
43
43
  def exist?
44
44
  !!fog_model
45
45
  end
@@ -53,13 +53,20 @@ module Defog
53
53
  def size
54
54
  fog_model.andand.content_length
55
55
  end
56
-
56
+
57
57
  # Returns the modification date of the remote cloud file, or nil if it
58
58
  # doesn't exist
59
59
  def last_modified
60
60
  fog_model.andand.last_modified
61
61
  end
62
62
 
63
+ # Returns the MD5 hash digest of the remote cloud file, or nil if it
64
+ # doesn't exist
65
+ #
66
+ def md5_hash
67
+ return @proxy.fog_wrapper.get_md5(@key) if exist?
68
+ end
69
+
63
70
  # Returns a URL to access the remote cloud file. The options are
64
71
  # storage-specific.
65
72
  #
@@ -75,7 +82,7 @@ module Defog
75
82
  # For :local cloud files, all options are ignored. If Rails is defined
76
83
  # and the file is in Rails app's public directory, returns a path
77
84
  # relative to the public directory. Otherwise returns a
78
- # <code>"file://"</code> URL
85
+ # <code>"file://"</code> URL
79
86
  def url(opts={})
80
87
  opts = opts.keyword_args(:expiry => Time.now + 10*60, :query => :optional)
81
88
  @proxy.fog_wrapper.url(@key, opts)
@@ -91,7 +98,7 @@ module Defog
91
98
  @proxy.fog_wrapper.fog_head(@key)
92
99
  end
93
100
 
94
- # Returns a Defog::File object, which is a specialization of ::File.
101
+ # Returns a Defog::File object, which is a specialization of ::File.
95
102
  #
96
103
  # <code>mode</code> can be the usual "r", "r+", "w", "w+", "a", or "a+" with the
97
104
  # usual semantics. When opened in a readable mode ("r", "r+", "w+",
data/lib/defog/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Defog
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
data/spec/handle_spec.rb CHANGED
@@ -29,13 +29,29 @@ shared_examples "a handle" do |proxyargs|
29
29
  end
30
30
  end
31
31
 
32
- it "should report exist? true if remote cloud file exists" do
33
- create_remote("i exist")
34
- @handle.should be_exist
32
+ context "if remote cloud file exists" do
33
+
34
+ before(:each) do
35
+ create_remote("i exist")
36
+ end
37
+
38
+ it "should report exist? true" do
39
+ @handle.should be_exist
40
+ end
41
+
42
+ it "should return md5 hash" do
43
+ @handle.md5_hash.should == Digest::MD5.hexdigest("i exist")
44
+ end
35
45
  end
36
46
 
37
- it "should report exist? false if remote cloud file does not exist" do
38
- @handle.should_not be_exist
47
+ context "if remote cloud file does not exist" do
48
+ it "should report exist? false" do
49
+ @handle.should_not be_exist
50
+ end
51
+
52
+ it "should return nil md5 hash" do
53
+ @handle.md5_hash.should be_nil
54
+ end
39
55
  end
40
56
 
41
57
  { :size => :content_length,
metadata CHANGED
@@ -1,142 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
5
- prerelease:
4
+ version: 0.9.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - ronen barzel
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
11
+ date: 2013-06-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fog
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: hash_keyword_args
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: fastandand
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rdoc
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: simplecov
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: simplecov-gem-adapter
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  description: Wrapper to fog gem, proxying access to cloud files as local files.
@@ -168,27 +151,26 @@ files:
168
151
  - spec/support/helpers.rb
169
152
  homepage: http://github.com/ronen/defog
170
153
  licenses: []
154
+ metadata: {}
171
155
  post_install_message:
172
156
  rdoc_options: []
173
157
  require_paths:
174
158
  - lib
175
159
  required_ruby_version: !ruby/object:Gem::Requirement
176
- none: false
177
160
  requirements:
178
- - - ! '>='
161
+ - - '>='
179
162
  - !ruby/object:Gem::Version
180
163
  version: '0'
181
164
  required_rubygems_version: !ruby/object:Gem::Requirement
182
- none: false
183
165
  requirements:
184
- - - ! '>='
166
+ - - '>='
185
167
  - !ruby/object:Gem::Version
186
168
  version: '0'
187
169
  requirements: []
188
170
  rubyforge_project:
189
- rubygems_version: 1.8.25
171
+ rubygems_version: 2.0.3
190
172
  signing_key:
191
- specification_version: 3
173
+ specification_version: 4
192
174
  summary: Wrapper to fog gem, proxying access to cloud files as local files. Access
193
175
  can be read-only (local cache), write-only (upload), or read-write (mirror)
194
176
  test_files: