omnistore 0.0.17 → 0.0.18
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.
@@ -69,7 +69,13 @@ module OmniStore
|
|
69
69
|
FileUtils.mv(src_path, dest_path, options)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
def copy(src, dest, other = self, options = {})
|
73
|
+
src_path = expand(src)
|
74
|
+
dest_path = expand(dest, other.dir)
|
75
|
+
FileUtils.copy(src_path, dest_path, options)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
73
79
|
|
74
80
|
def expand(path, dir = @dir)
|
75
81
|
File.expand_path(path, dir)
|
@@ -47,6 +47,11 @@ module OmniStore
|
|
47
47
|
options[:bucket_name] = other.bucket.name
|
48
48
|
bucket.objects[src].move_to(dest, options)
|
49
49
|
end
|
50
|
+
|
51
|
+
def copy(src, dest, other = self, options = {})
|
52
|
+
options[:bucket] = other.bucket
|
53
|
+
bucket.objects[src].copy_to(dest, options)
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
52
57
|
end
|
data/lib/omnistore/version.rb
CHANGED
@@ -59,4 +59,31 @@ describe OmniStore::Storage::Local::Mountpoint do
|
|
59
59
|
it { should_not raise_error }
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
describe '#copy' do
|
64
|
+
let(:src) { t = Tempfile.new(TEST_FILENAME, MOUNTPOINT); File.basename(t.path) }
|
65
|
+
let(:dst) { TEST_FILENAME + Time.new.to_i.to_s }
|
66
|
+
let(:other) { OmniStore::Storage::Local.mountpoint(:a) }
|
67
|
+
subject { lambda { OmniStore::Storage::Local.mountpoint.copy(src, dst, other) } }
|
68
|
+
|
69
|
+
before do
|
70
|
+
OmniStore::Config.mountpoint = { :a => MOUNTPOINT, :b => TMPDIR }
|
71
|
+
OmniStore::Storage.remount!
|
72
|
+
end
|
73
|
+
after { other.delete(dst) rescue nil }
|
74
|
+
|
75
|
+
context 'when specified a file path that does not exist' do
|
76
|
+
let(:src) { TEST_FILENAME + Time.new.to_i.to_s }
|
77
|
+
it { should raise_error }
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when specified a file path that exist' do
|
81
|
+
it { should_not raise_error }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when copy to another mountpoint' do
|
85
|
+
let(:other) { OmniStore::Storage::Local.mountpoint(:b) }
|
86
|
+
it { should_not raise_error }
|
87
|
+
end
|
88
|
+
end
|
62
89
|
end
|
@@ -116,4 +116,38 @@ describe 'OmniStore::Storage::S3::Mountpoint' do
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
describe '#copy' do
|
120
|
+
let(:src) { TEST_FILENAME }
|
121
|
+
let(:dst) { TEST_FILENAME + Time.new.to_i.to_s }
|
122
|
+
let(:other) { OmniStore::Storage::S3.mountpoint(:a) }
|
123
|
+
subject { lambda { OmniStore::Storage::S3.mountpoint.copy(src, dst, other) } }
|
124
|
+
|
125
|
+
before do
|
126
|
+
OmniStore::Config.mountpoint = { :a => AWS_BUCKET, :b => AWS_BUCKET + 'b' }
|
127
|
+
OmniStore::Storage.remount!
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'when copy to same mountpoint' do
|
131
|
+
before do
|
132
|
+
AWS::S3::S3Object.any_instance.stub(:copy_to).with do |*args|
|
133
|
+
args[0].should eq dst
|
134
|
+
args[1][:bucket].name.should eq AWS_BUCKET
|
135
|
+
true
|
136
|
+
end
|
137
|
+
end
|
138
|
+
it { should_not raise_error }
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'when copy to another mountpoint' do
|
142
|
+
before do
|
143
|
+
AWS::S3::S3Object.any_instance.stub(:copy_to).with do |*args|
|
144
|
+
args[0].should eq dst
|
145
|
+
args[1][:bucket].name.should eq other.bucket.name
|
146
|
+
true
|
147
|
+
end
|
148
|
+
end
|
149
|
+
let(:other) { OmniStore::Storage::S3.mountpoint(:b) }
|
150
|
+
it { should_not raise_error }
|
151
|
+
end
|
152
|
+
end
|
119
153
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omnistore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
segments:
|
125
125
|
- 0
|
126
|
-
hash: -
|
126
|
+
hash: -527908049
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
segments:
|
134
134
|
- 0
|
135
|
-
hash: -
|
135
|
+
hash: -527908049
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
138
|
rubygems_version: 1.8.24
|