defog 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,12 +37,19 @@ module Defog #:nodoc: all
37
37
  path.open("r#{encoding}") do |file|
38
38
  fog_directory.files.create(:key => @prefix.to_s + key, :body => file)
39
39
  end
40
+ @heads.delete(key)
40
41
  end
41
42
 
42
43
  def fog_head(key)
43
44
  @heads[key] ||= fog_directory.files.head(@prefix.to_s + key)
44
45
  end
45
46
 
47
+ def fog_delete(key)
48
+ fog_head(key).destroy.tap {
49
+ @heads.delete(key)
50
+ }
51
+ end
52
+
46
53
  def each
47
54
  prefix = @prefix.to_s
48
55
  off = prefix.size
data/lib/defog/handle.rb CHANGED
@@ -46,7 +46,7 @@ module Defog
46
46
 
47
47
  # Deletes the remote cloud file if it exists
48
48
  def delete
49
- fog_model.andand.destroy
49
+ fog_model and @proxy.fog_wrapper.fog_delete(@key)
50
50
  end
51
51
 
52
52
  # Returns the size of the remote cloud file, or nil if it doesn't exist
data/lib/defog/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Defog
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/spec/file_spec.rb CHANGED
@@ -4,7 +4,7 @@ shared_examples "get proxy" do
4
4
 
5
5
  it "should create proxy if remote exists" do
6
6
  create_remote("hello")
7
- should_log /download/
7
+ should_log /Download/
8
8
  file = @proxy.file(key, @mode)
9
9
  File.exist?(file.path).should be_true
10
10
  file.close
@@ -18,7 +18,7 @@ shared_examples "get proxy" do
18
18
  create_remote("hello")
19
19
  create_proxy("goodbye")
20
20
  proxy_path.read.should == "goodbye"
21
- should_log /download/
21
+ should_log /Download/
22
22
  @proxy.file(key, @mode)
23
23
  proxy_path.read.should == "hello"
24
24
  end
@@ -28,7 +28,7 @@ shared_examples "get proxy" do
28
28
  create_proxy("hello")
29
29
  handle = @proxy.file(key)
30
30
  handle.proxy_path.should_not_receive(:open).with(/^w/)
31
- should_not_log /download/
31
+ should_not_log /Download/
32
32
  handle.open(@mode)
33
33
  end
34
34
  end
@@ -84,7 +84,7 @@ shared_examples "append" do
84
84
  create_remote("hello")
85
85
  @proxy.file(key, @mode, :persist => true) do |file|
86
86
  file.write "goodbye"
87
- should_log /upload/
87
+ should_log /Upload/
88
88
  end
89
89
  proxy_path.read.should == "hellogoodbye"
90
90
  end
@@ -93,7 +93,7 @@ end
93
93
  shared_examples "create" do
94
94
 
95
95
  it "should create remote" do
96
- should_log /upload/
96
+ should_log /Upload/
97
97
  file = @proxy.file(key, @mode)
98
98
  create_proxy("upload me")
99
99
  file.close
@@ -101,7 +101,7 @@ shared_examples "create" do
101
101
  end
102
102
 
103
103
  it "should not create remote if proxy is deleted" do
104
- should_not_log /upload/
104
+ should_not_log /Upload/
105
105
  @proxy.file(key, @mode) do |file|
106
106
  file.write("ignore me")
107
107
  proxy_path.unlink
@@ -110,7 +110,7 @@ shared_examples "create" do
110
110
  end
111
111
 
112
112
  it "should not create remote if :synchronize => false" do
113
- should_not_log /upload/
113
+ should_not_log /Upload/
114
114
  file = @proxy.file(key, @mode)
115
115
  create_proxy("ignore me")
116
116
  file.close(:synchronize => false)
@@ -118,7 +118,7 @@ shared_examples "create" do
118
118
  end
119
119
 
120
120
  it "should create remote asynchronously if :synchronize => async" do
121
- should_log /upload/
121
+ should_log /Upload/
122
122
  file = @proxy.file(key, @mode)
123
123
  create_proxy("upload me in thread")
124
124
  Thread.should_receive(:new) { |&block|
@@ -138,7 +138,7 @@ shared_examples "update" do
138
138
  remote_body.should == "overwrite me"
139
139
  file = @proxy.file(key, @mode)
140
140
  create_proxy("upload me")
141
- should_log /upload/
141
+ should_log /Upload/
142
142
  file.close
143
143
  remote_body.should == "upload me"
144
144
  end
@@ -151,13 +151,13 @@ shared_examples "update" do
151
151
  remote_body.should == "overwrite me"
152
152
  block.call
153
153
  }
154
- should_log /upload/
154
+ should_log /Upload/
155
155
  file.close(:synchronize => :async)
156
156
  remote_body.should == "upload me"
157
157
  end
158
158
 
159
159
  it "should not overwrite remote if proxy is deleted" do
160
- should_not_log /upload/
160
+ should_not_log /Upload/
161
161
  create_remote("keep me")
162
162
  @proxy.file(key, @mode) do |file|
163
163
  file.write("ignore me")
@@ -167,7 +167,7 @@ shared_examples "update" do
167
167
  end
168
168
 
169
169
  it "should not overwrite remote if :synchronize => false" do
170
- should_not_log /upload/
170
+ should_not_log /Upload/
171
171
  create_remote("keep me")
172
172
  file = @proxy.file(key, @mode)
173
173
  create_proxy("ignore me")
data/spec/handle_spec.rb CHANGED
@@ -27,7 +27,7 @@ shared_examples "a handle" do |proxyargs|
27
27
  :last_modified => :last_modified,
28
28
  :delete => :destroy }.each do |method, fog_method|
29
29
 
30
- it "should delegate #{method.inspect} to the fog model #{fog_method.inspect}if the remote file exists" do
30
+ it "should delegate #{method.inspect} to the fog model #{fog_method.inspect} if the remote file exists" do
31
31
  create_remote("delegate me")
32
32
  @handle.fog_model.class.any_instance.should_receive(fog_method).and_return { "dummy" }
33
33
  @handle.send(method).should == "dummy"
@@ -61,6 +61,15 @@ shared_examples "a handle" do |proxyargs|
61
61
  @handle.fog_model.body.should == "foggy"
62
62
  end
63
63
 
64
+ it "should update when file changes" do
65
+ create_remote("abc")
66
+ @proxy.file(key).size.should == 3
67
+ @proxy.file(key).open("w") do |f|
68
+ f.write("defghij")
69
+ end
70
+ @proxy.file(key).size.should == 7
71
+ end
72
+
64
73
 
65
74
  end
66
75
 
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.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
16
- requirement: &70349591699120 !ruby/object:Gem::Requirement
16
+ requirement: &70295900380220 !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: *70349591699120
24
+ version_requirements: *70295900380220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hash_keyword_args
27
- requirement: &70349591698520 !ruby/object:Gem::Requirement
27
+ requirement: &70295900379640 !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: *70349591698520
35
+ version_requirements: *70295900379640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fastandand
38
- requirement: &70349591698100 !ruby/object:Gem::Requirement
38
+ requirement: &70295900379020 !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: *70349591698100
46
+ version_requirements: *70295900379020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70349591697640 !ruby/object:Gem::Requirement
49
+ requirement: &70295900378340 !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: *70349591697640
57
+ version_requirements: *70295900378340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70349591697160 !ruby/object:Gem::Requirement
60
+ requirement: &70295900377800 !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: *70349591697160
68
+ version_requirements: *70295900377800
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &70349591696700 !ruby/object:Gem::Requirement
71
+ requirement: &70295900376820 !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: *70349591696700
79
+ version_requirements: *70295900376820
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov-gem-adapter
82
- requirement: &70349591696200 !ruby/object:Gem::Requirement
82
+ requirement: &70295900362380 !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: *70349591696200
90
+ version_requirements: *70295900362380
91
91
  description: Wrapper to fog gem, proxying access to cloud files as local files.
92
92
  email:
93
93
  - ronen@barzel.org