backup-aliyun2 0.1.5

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: 36b24144189b5517933064695c80197f3bad0235
4
+ data.tar.gz: 540fbe15331f0d7c1f59077c28014c6f1f20f964
5
+ SHA512:
6
+ metadata.gz: bebac5e0ce76cf92e74248d6eee34ff1217c90cb75dac242c3a94ae88b43dc8198c91198f895396355cccf3cb1d7b8f5be00a8285dae6d3e04c73deb3f67b4f7
7
+ data.tar.gz: ed10179f097111c25cf99d9fa45c95dd324645c73a1d99c56aa93ec24400887e257dc46f2e93805686c70f0efe2b77f13d73a4d5db65715cdc6ef44ab4ddebc6
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+
8
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'rspec'
5
+ gem 'mocha'
data/Gemfile.lock ADDED
@@ -0,0 +1,287 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ backup-aliyun2 (0.1.4)
5
+ backup (~> 4.2.0)
6
+ carrierwave-aliyun (~> 0.4.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ CFPropertyList (2.3.1)
12
+ activemodel (4.1.15)
13
+ activesupport (= 4.1.15)
14
+ builder (~> 3.1)
15
+ activesupport (4.1.15)
16
+ i18n (~> 0.6, >= 0.6.9)
17
+ json (~> 1.7, >= 1.7.7)
18
+ minitest (~> 5.1)
19
+ thread_safe (~> 0.1)
20
+ tzinfo (~> 1.1)
21
+ addressable (2.3.5)
22
+ aliyun-oss-sdk (0.1.6)
23
+ addressable
24
+ gyoku
25
+ httparty
26
+ atomic (1.1.14)
27
+ aws-ses (0.5.0)
28
+ builder
29
+ mail (> 2.2.5)
30
+ mime-types
31
+ xml-simple
32
+ backup (4.2.3)
33
+ CFPropertyList (= 2.3.1)
34
+ addressable (= 2.3.5)
35
+ atomic (= 1.1.14)
36
+ aws-ses (= 0.5.0)
37
+ buftok (= 0.2.0)
38
+ builder (= 3.2.2)
39
+ descendants_tracker (= 0.0.3)
40
+ dogapi (= 1.11.0)
41
+ dropbox-sdk (= 1.5.1)
42
+ equalizer (= 0.0.9)
43
+ excon (= 0.44.4)
44
+ faraday (= 0.8.8)
45
+ fission (= 0.5.0)
46
+ flowdock (= 0.4.0)
47
+ fog (= 1.28.0)
48
+ fog-atmos (= 0.1.0)
49
+ fog-aws (= 0.1.1)
50
+ fog-brightbox (= 0.7.1)
51
+ fog-core (= 1.29.0)
52
+ fog-ecloud (= 0.0.2)
53
+ fog-json (= 1.0.0)
54
+ fog-profitbricks (= 0.0.2)
55
+ fog-radosgw (= 0.0.3)
56
+ fog-riakcs (= 0.1.0)
57
+ fog-sakuracloud (= 1.0.0)
58
+ fog-serverlove (= 0.1.1)
59
+ fog-softlayer (= 0.4.1)
60
+ fog-storm_on_demand (= 0.1.0)
61
+ fog-terremark (= 0.0.4)
62
+ fog-vmfusion (= 0.0.1)
63
+ fog-voxel (= 0.0.2)
64
+ fog-xml (= 0.1.1)
65
+ formatador (= 0.2.5)
66
+ hipchat (= 1.0.1)
67
+ http (= 0.5.0)
68
+ http_parser.rb (= 0.6.0)
69
+ httparty (= 0.12.0)
70
+ inflecto (= 0.0.2)
71
+ ipaddress (= 0.8.0)
72
+ json (= 1.8.2)
73
+ mail (= 2.5.4)
74
+ memoizable (= 0.4.0)
75
+ mime-types (= 1.25.1)
76
+ mini_portile (= 0.6.2)
77
+ multi_json (= 1.10.1)
78
+ multi_xml (= 0.5.5)
79
+ multipart-post (= 1.2.0)
80
+ net-scp (= 1.2.1)
81
+ net-sftp (= 2.1.2)
82
+ net-ssh (= 2.9.2)
83
+ nokogiri (= 1.6.6.2)
84
+ open4 (= 1.3.0)
85
+ pagerduty (= 2.0.0)
86
+ polyglot (= 0.3.3)
87
+ simple_oauth (= 0.2.0)
88
+ thor (= 0.18.1)
89
+ thread_safe (= 0.1.3)
90
+ treetop (= 1.4.15)
91
+ twitter (= 5.5.0)
92
+ unf (= 0.1.3)
93
+ unf_ext (= 0.0.6)
94
+ xml-simple (= 1.1.4)
95
+ buftok (0.2.0)
96
+ builder (3.2.2)
97
+ carrierwave (0.11.0)
98
+ activemodel (>= 3.2.0)
99
+ activesupport (>= 3.2.0)
100
+ json (>= 1.7)
101
+ mime-types (>= 1.16)
102
+ carrierwave-aliyun (0.4.3)
103
+ aliyun-oss-sdk (>= 0.1.6)
104
+ carrierwave (>= 0.5.7)
105
+ descendants_tracker (0.0.3)
106
+ diff-lcs (1.2.5)
107
+ dogapi (1.11.0)
108
+ json (>= 1.5.1)
109
+ dropbox-sdk (1.5.1)
110
+ json
111
+ equalizer (0.0.9)
112
+ excon (0.44.4)
113
+ faraday (0.8.8)
114
+ multipart-post (~> 1.2.0)
115
+ fission (0.5.0)
116
+ CFPropertyList (~> 2.2)
117
+ flowdock (0.4.0)
118
+ httparty (~> 0.7)
119
+ multi_json
120
+ fog (1.28.0)
121
+ fog-atmos
122
+ fog-aws (~> 0.0)
123
+ fog-brightbox (~> 0.4)
124
+ fog-core (~> 1.27, >= 1.27.3)
125
+ fog-ecloud
126
+ fog-json
127
+ fog-profitbricks
128
+ fog-radosgw (>= 0.0.2)
129
+ fog-riakcs
130
+ fog-sakuracloud (>= 0.0.4)
131
+ fog-serverlove
132
+ fog-softlayer
133
+ fog-storm_on_demand
134
+ fog-terremark
135
+ fog-vmfusion
136
+ fog-voxel
137
+ fog-xml (~> 0.1.1)
138
+ ipaddress (~> 0.5)
139
+ nokogiri (~> 1.5, >= 1.5.11)
140
+ fog-atmos (0.1.0)
141
+ fog-core
142
+ fog-xml
143
+ fog-aws (0.1.1)
144
+ fog-core (~> 1.27)
145
+ fog-json (~> 1.0)
146
+ fog-xml (~> 0.1)
147
+ ipaddress (~> 0.8)
148
+ fog-brightbox (0.7.1)
149
+ fog-core (~> 1.22)
150
+ fog-json
151
+ inflecto (~> 0.0.2)
152
+ fog-core (1.29.0)
153
+ builder
154
+ excon (~> 0.38)
155
+ formatador (~> 0.2)
156
+ mime-types
157
+ net-scp (~> 1.1)
158
+ net-ssh (>= 2.1.3)
159
+ fog-ecloud (0.0.2)
160
+ fog-core
161
+ fog-xml
162
+ fog-json (1.0.0)
163
+ multi_json (~> 1.0)
164
+ fog-profitbricks (0.0.2)
165
+ fog-core
166
+ fog-xml
167
+ nokogiri
168
+ fog-radosgw (0.0.3)
169
+ fog-core (>= 1.21.0)
170
+ fog-json
171
+ fog-xml (>= 0.0.1)
172
+ fog-riakcs (0.1.0)
173
+ fog-core
174
+ fog-json
175
+ fog-xml
176
+ fog-sakuracloud (1.0.0)
177
+ fog-core
178
+ fog-json
179
+ fog-serverlove (0.1.1)
180
+ fog-core
181
+ fog-json
182
+ fog-softlayer (0.4.1)
183
+ fog-core
184
+ fog-json
185
+ fog-storm_on_demand (0.1.0)
186
+ fog-core
187
+ fog-json
188
+ fog-terremark (0.0.4)
189
+ fog-core
190
+ fog-xml
191
+ fog-vmfusion (0.0.1)
192
+ fission
193
+ fog-core
194
+ fog-voxel (0.0.2)
195
+ fog-core
196
+ fog-xml
197
+ fog-xml (0.1.1)
198
+ fog-core
199
+ nokogiri (~> 1.5, >= 1.5.11)
200
+ formatador (0.2.5)
201
+ gyoku (1.3.1)
202
+ builder (>= 2.1.2)
203
+ hipchat (1.0.1)
204
+ httparty
205
+ http (0.5.0)
206
+ http_parser.rb
207
+ http_parser.rb (0.6.0)
208
+ httparty (0.12.0)
209
+ json (~> 1.8)
210
+ multi_xml (>= 0.5.2)
211
+ i18n (0.7.0)
212
+ inflecto (0.0.2)
213
+ ipaddress (0.8.0)
214
+ json (1.8.2)
215
+ mail (2.5.4)
216
+ mime-types (~> 1.16)
217
+ treetop (~> 1.4.8)
218
+ memoizable (0.4.0)
219
+ thread_safe (~> 0.1.3)
220
+ metaclass (0.0.4)
221
+ mime-types (1.25.1)
222
+ mini_portile (0.6.2)
223
+ minitest (5.8.4)
224
+ mocha (1.1.0)
225
+ metaclass (~> 0.0.1)
226
+ multi_json (1.10.1)
227
+ multi_xml (0.5.5)
228
+ multipart-post (1.2.0)
229
+ net-scp (1.2.1)
230
+ net-ssh (>= 2.6.5)
231
+ net-sftp (2.1.2)
232
+ net-ssh (>= 2.6.5)
233
+ net-ssh (2.9.2)
234
+ nokogiri (1.6.6.2)
235
+ mini_portile (~> 0.6.0)
236
+ open4 (1.3.0)
237
+ pagerduty (2.0.0)
238
+ json (>= 1.7.7)
239
+ polyglot (0.3.3)
240
+ rspec (3.4.0)
241
+ rspec-core (~> 3.4.0)
242
+ rspec-expectations (~> 3.4.0)
243
+ rspec-mocks (~> 3.4.0)
244
+ rspec-core (3.4.4)
245
+ rspec-support (~> 3.4.0)
246
+ rspec-expectations (3.4.0)
247
+ diff-lcs (>= 1.2.0, < 2.0)
248
+ rspec-support (~> 3.4.0)
249
+ rspec-mocks (3.4.1)
250
+ diff-lcs (>= 1.2.0, < 2.0)
251
+ rspec-support (~> 3.4.0)
252
+ rspec-support (3.4.1)
253
+ simple_oauth (0.2.0)
254
+ thor (0.18.1)
255
+ thread_safe (0.1.3)
256
+ atomic
257
+ treetop (1.4.15)
258
+ polyglot
259
+ polyglot (>= 0.3.1)
260
+ twitter (5.5.0)
261
+ addressable (~> 2.3)
262
+ buftok (~> 0.2.0)
263
+ descendants_tracker (~> 0.0.3)
264
+ equalizer (~> 0.0.9)
265
+ faraday (>= 0.8, < 0.10)
266
+ http (~> 0.5.0)
267
+ http_parser.rb (~> 0.6.0)
268
+ json (~> 1.8)
269
+ memoizable (~> 0.4.0)
270
+ simple_oauth (~> 0.2.0)
271
+ tzinfo (1.2.2)
272
+ thread_safe (~> 0.1)
273
+ unf (0.1.3)
274
+ unf_ext
275
+ unf_ext (0.0.6)
276
+ xml-simple (1.1.4)
277
+
278
+ PLATFORMS
279
+ ruby
280
+
281
+ DEPENDENCIES
282
+ backup-aliyun2!
283
+ mocha
284
+ rspec
285
+
286
+ BUNDLED WITH
287
+ 1.11.2
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Jason Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ ## Backup to Aliyun OSS
2
+
3
+ 此 Gem 是 [Backup](https://github.com/meskyanichi/backup) 的辅助插件,目的是让 Backup 支持存储到 [Aliyun OSS](http://oss.aliyun.com)。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ $ gem install backup-aliyun
9
+ ```
10
+ ## 配置
11
+
12
+ 你需要在你的 Backup models 文件里面单独引用 `backup-aliyun`,比如:
13
+
14
+ ~/Backup/models/foo.rb
15
+
16
+ ```ruby
17
+ require "backup-aliyun" # 引用 backup-aliyun
18
+
19
+ Backup::Model.new(:foo, 'Description for foo') do
20
+
21
+ # 配置阿里云 OSS 作为备份存储方式, 注意,Aliyun 这个地方一定要打引号
22
+ store_with "Aliyun" do |aliyun|
23
+ aliyun.access_key_id = 'my_access_id'
24
+ aliyun.access_key_secret = 'my_access_key'
25
+ aliyun.bucket = 'bucket-name'
26
+ aliyun.path = '/path/to/my/backups'
27
+ aliyun.keep = 10
28
+ end
29
+ end
30
+ ```
31
+
32
+ 然后你就可以用 Backup 把你的备份文件存储到 Aliyun OSS 上面了。
33
+
34
+ 至于 Backup 的使用方法请参见 [Backup](https://github.com/meskyanichi/backup) 的文档。
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "backup-aliyun2"
6
+ s.version = "0.1.5"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Godwin Ken"]
9
+ s.email = ["gurulancer@gmail.com"]
10
+ s.homepage = "https://github.com/stockcode/backup-aliyun"
11
+ s.summary = %q{Aliyun OSS Storage support for new Backup}
12
+ s.description = %q{Aliyun OSS Storage support for new Backup}
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+ s.license = 'MIT'
18
+
19
+ s.add_dependency "backup", "~> 4.2.0"
20
+ s.add_dependency "carrierwave-aliyun", ["~> 0.4.0"]
21
+ end
@@ -0,0 +1,3 @@
1
+ require "backup"
2
+
3
+ Backup::Storage.send(:autoload, :Aliyun, File.join(File.dirname(__FILE__),"backup/storage/aliyun"))
Binary file
@@ -0,0 +1,53 @@
1
+ require "carrierwave-aliyun"
2
+ require "base64"
3
+
4
+ module Backup
5
+ module Storage
6
+ class Aliyun < Base
7
+ attr_accessor :bucket,:access_key_id,:access_key_secret,:aliyun_internal, :area, :path
8
+
9
+ def initialize(model, storage_id = nil, &block)
10
+ super(model, storage_id)
11
+
12
+ @path ||= 'backups'
13
+
14
+ instance_eval(&block) if block_given?
15
+ end
16
+
17
+ private
18
+
19
+ def connection
20
+ return @connection if @connection
21
+
22
+ CarrierWave.configure do |config|
23
+ config.storage = :aliyun
24
+ config.aliyun_access_id = self.access_key_id
25
+ config.aliyun_access_key = self.access_key_secret
26
+ config.aliyun_bucket = self.bucket
27
+ config.aliyun_area = self.area || "cn-hangzhou"
28
+ config.aliyun_internal = self.aliyun_internal || false
29
+ end
30
+
31
+ @uploader = CarrierWave::Uploader::Base.new
32
+ @connection = CarrierWave::Storage::Aliyun::Connection.new(@uploader)
33
+ end
34
+
35
+ def transfer!
36
+ remote_path = remote_path_for(@package)
37
+
38
+ @package.filenames.each do |filename|
39
+ src = File.join(Config.tmp_path, filename)
40
+ dest = File.join(remote_path, filename)
41
+ Logger.info "#{storage_name} uploading '#{ dest }'..."
42
+ connection.put(dest, File.open(src))
43
+ end
44
+ end
45
+
46
+ def remove!(package)
47
+ remote_path = remote_path_for(package)
48
+ Logger.info "#{storage_name} removing '#{remote_path}'..."
49
+ connection.delete(remote_path)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,172 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Storage::Aliyun do
6
+ let(:model) { Backup::Model.new(:test_trigger, 'test label') }
7
+ let(:storage) do
8
+ Backup::Storage::Aliyun.new(model) do |db|
9
+ db.access_key_id = 'my_access_id'
10
+ db.access_key_secret = 'my_access_key'
11
+ db.bucket = 'foo'
12
+ db.keep = 5
13
+ end
14
+ end
15
+
16
+ it 'should be a subclass of Storage::Base' do
17
+ Backup::Storage::Aliyun.
18
+ superclass.should == Backup::Storage::Base
19
+ end
20
+
21
+ describe '#initialize' do
22
+ after { Backup::Storage::Aliyun.clear_defaults! }
23
+
24
+ it 'should load pre-configured defaults through Base' do
25
+ Backup::Storage::Aliyun.any_instance.expects(:load_defaults!)
26
+ storage
27
+ end
28
+
29
+ it 'should pass the model reference to Base' do
30
+ storage.instance_variable_get(:@model).should == model
31
+ end
32
+
33
+ it 'should pass the storage_id to Base' do
34
+ storage = Backup::Storage::Aliyun.new(model, 'my_storage_id')
35
+ storage.storage_id.should == 'my_storage_id'
36
+ end
37
+
38
+ context 'when no pre-configured defaults have been set' do
39
+ it 'should use the values given' do
40
+ storage.access_key_id.should == 'my_access_id'
41
+ storage.access_key_secret.should == 'my_access_key'
42
+ storage.bucket.should == "foo"
43
+ storage.path.should == 'backups'
44
+
45
+ storage.storage_id.should be_nil
46
+ storage.keep.should == 5
47
+ end
48
+
49
+ it 'should use default values if none are given' do
50
+ storage = Backup::Storage::Aliyun.new(model)
51
+ storage.access_key_id.should be_nil
52
+ storage.access_key_secret.should be_nil
53
+ storage.bucket.should be_nil
54
+ storage.path.should == 'backups'
55
+
56
+ storage.storage_id.should be_nil
57
+ storage.keep.should be_nil
58
+ end
59
+ end # context 'when no pre-configured defaults have been set'
60
+
61
+ context 'when pre-configured defaults have been set' do
62
+ before do
63
+ Backup::Storage::Aliyun.defaults do |s|
64
+ s.access_key_id = 'some_api_key'
65
+ s.access_key_secret = 'some_api_secret'
66
+ s.bucket = 'some_bucket'
67
+ s.path = 'some_path'
68
+ s.keep = 15
69
+ end
70
+ end
71
+
72
+ it 'should use pre-configured defaults' do
73
+ storage = Backup::Storage::Aliyun.new(model)
74
+
75
+ storage.access_key_id.should == 'some_api_key'
76
+ storage.access_key_secret.should == 'some_api_secret'
77
+ storage.bucket.should == 'some_bucket'
78
+ storage.path.should == 'some_path'
79
+
80
+ storage.storage_id.should be_nil
81
+ storage.keep.should == 15
82
+ end
83
+
84
+ it 'should override pre-configured defaults' do
85
+ storage = Backup::Storage::Aliyun.new(model) do |s|
86
+ s.access_key_id = 'new_api_key'
87
+ s.access_key_secret = 'new_api_secret'
88
+ s.bucket = 'new_bucket'
89
+ s.path = 'new_path'
90
+ s.keep = 10
91
+ end
92
+
93
+ storage.access_key_id.should == 'new_api_key'
94
+ storage.access_key_secret.should == 'new_api_secret'
95
+ storage.bucket.should == 'new_bucket'
96
+ storage.path.should == 'new_path'
97
+
98
+ storage.storage_id.should be_nil
99
+ storage.keep.should == 10
100
+ end
101
+ end # context 'when pre-configured defaults have been set'
102
+ end # describe '#initialize'
103
+
104
+ describe '#transfer!' do
105
+ let(:connection) { mock }
106
+ let(:package) { mock }
107
+ let(:file) { mock }
108
+ let(:s) { sequence '' }
109
+
110
+ before do
111
+ storage.instance_variable_set(:@package, package)
112
+ storage.stubs(:storage_name).returns('Storage::Aliyun')
113
+ Backup::Config.stubs(:tmp_path).returns('/local/path')
114
+ storage.stubs(:connection).returns(connection)
115
+ file.stubs(:read).returns("foo")
116
+ end
117
+
118
+ it 'should transfer the package files' do
119
+
120
+ storage.expects(:remote_path_for).in_sequence(s).with(package).
121
+ returns('remote/path')
122
+ package.stubs(:filenames).returns(["backup.tar.enc-aa","backup.tar.enc-ab"])
123
+ # first yield
124
+ Backup::Logger.expects(:info).in_sequence(s).with(
125
+ "Storage::Aliyun uploading 'remote/path/backup.tar.enc-aa'..."
126
+ )
127
+ File.expects(:open).in_sequence(s).with(
128
+ File.join('/local/path', 'backup.tar.enc-aa'), 'r'
129
+ ).yields(file)
130
+ connection.expects(:put).in_sequence(s).with(
131
+ File.join('remote/path', 'backup.tar.enc-aa'), file
132
+ )
133
+ # second yield
134
+ Backup::Logger.expects(:info).in_sequence(s).with(
135
+ "Storage::Aliyun uploading 'remote/path/backup.tar.enc-ab'..."
136
+ )
137
+ File.expects(:open).in_sequence(s).with(
138
+ File.join('/local/path', 'backup.tar.enc-ab'), 'r'
139
+ ).yields(file)
140
+ connection.expects(:put).in_sequence(s).with(
141
+ File.join('remote/path', 'backup.tar.enc-ab'), file
142
+ )
143
+
144
+ storage.send(:transfer!)
145
+ end
146
+ end # describe '#transfer!'
147
+
148
+ describe '#remove!' do
149
+ let(:package) { mock }
150
+ let(:connection) { mock }
151
+ let(:s) { sequence '' }
152
+
153
+ before do
154
+ storage.stubs(:storage_name).returns('Storage::Aliyun')
155
+ storage.stubs(:connection).returns(connection)
156
+ end
157
+
158
+ it 'should remove the package files' do
159
+ storage.expects(:remote_path_for).in_sequence(s).with(package).
160
+ returns('remote/path')
161
+ # after both yields
162
+ Backup::Logger.expects(:info).in_sequence(s).with(
163
+ "Storage::Aliyun removing 'remote/path'..."
164
+ )
165
+ connection.expects(:delete).in_sequence(s).with('remote/path')
166
+
167
+ storage.send(:remove!, package)
168
+ end
169
+ end # describe '#remove!'
170
+
171
+
172
+ end
@@ -0,0 +1,37 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'bundler/setup'
3
+ require 'backup'
4
+ require 'backup-aliyun'
5
+
6
+
7
+ require 'rspec/autorun'
8
+ RSpec.configure do |config|
9
+ ##
10
+ # Use Mocha to mock with RSpec
11
+ config.mock_with :mocha
12
+
13
+ ##
14
+ # Example Helpers
15
+ # config.include Backup::ExampleHelpers
16
+
17
+ config.filter_run :focus => true
18
+ config.run_all_when_everything_filtered = true
19
+ config.treat_symbols_as_metadata_keys_with_true_values = true
20
+
21
+
22
+ config.before(:each) do
23
+ # ::FileUtils will always be either SandboxFileUtils or FileUtils::NoWrite.
24
+ # SandboxFileUtils.deactivate!(:noop)
25
+
26
+ # prevent system calls
27
+ Backup::Utilities.stubs(:gnu_tar?).returns(true)
28
+ Backup::Utilities.stubs(:utility)
29
+ Backup::Utilities.stubs(:run)
30
+ Backup::Pipeline.any_instance.stubs(:run)
31
+
32
+ Backup::Utilities.send(:reset!)
33
+ Backup::Config.send(:reset!)
34
+ # Logger only queues messages received until Logger.start! is called.
35
+ Backup::Logger.send(:reset!)
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backup-aliyun2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Godwin Ken
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: backup
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: carrierwave-aliyun
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.0
41
+ description: Aliyun OSS Storage support for new Backup
42
+ email:
43
+ - gurulancer@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE
53
+ - README.md
54
+ - backup-aliyun.gemspec
55
+ - lib/backup-aliyun.rb
56
+ - lib/backup/.DS_Store
57
+ - lib/backup/storage/aliyun.rb
58
+ - spec/aliyun_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: https://github.com/stockcode/backup-aliyun
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.6.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Aliyun OSS Storage support for new Backup
84
+ test_files:
85
+ - spec/aliyun_spec.rb
86
+ - spec/spec_helper.rb
87
+ has_rdoc: