backup-aliyun 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +204 -56
- data/README.md +12 -8
- data/Rakefile +7 -0
- data/backup-aliyun.gemspec +3 -3
- data/lib/backup-aliyun.rb +1 -1
- data/lib/backup/storage/aliyun.rb +16 -17
- data/spec/aliyun_spec.rb +21 -18
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 856cfedea421e4401f3d6e588e25d493269519ce
|
4
|
+
data.tar.gz: 30af243dc8e02df522a7a86fecc0597ab9c8064f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e43fa18b48c01d212b35a4f3529f0057df25b3c5497414957fb6f52c6228c473b1de9edc09e43312a049f3137cb0c0862f583b93701698ea1d96f30b48c0645b
|
7
|
+
data.tar.gz: 0248ce8597f9b211c08fa717b865f9bebcac921e306651dbb87051c4c0d0f1be5062e5fcaa077ae22bffca5b3a6fe5844182dd9aa9808cd09d08581608cf7f03
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
## Backup 4.x
|
2
|
+
|
3
|
+
0.2.0
|
4
|
+
-----
|
5
|
+
|
6
|
+
- Use aliyun-oss-sdk instead of carrierwave-aliyun.
|
7
|
+
- Add `config.area`, default is 'cn-hangzhou';
|
8
|
+
- Work for Backup 4.x;
|
9
|
+
|
10
|
+
## Backup 3.x
|
11
|
+
|
12
|
+
0.1.1
|
13
|
+
-----
|
14
|
+
|
15
|
+
> for Backup 3.x
|
16
|
+
|
17
|
+
- First release.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,92 +1,224 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
backup-aliyun (0.
|
4
|
+
backup-aliyun (0.2.0)
|
5
|
+
aliyun-oss-sdk (>= 0.1.6)
|
5
6
|
backup (>= 3.7.0)
|
6
|
-
carrierwave-aliyun (~> 0.2.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
CFPropertyList (2.3.1)
|
12
|
+
addressable (2.3.5)
|
13
|
+
aliyun-oss-sdk (0.1.6)
|
14
|
+
addressable
|
15
|
+
gyoku
|
16
|
+
httparty
|
17
|
+
atomic (1.1.14)
|
18
|
+
aws-ses (0.5.0)
|
19
|
+
builder
|
20
|
+
mail (> 2.2.5)
|
21
|
+
mime-types
|
22
|
+
xml-simple
|
23
|
+
backup (4.2.3)
|
24
|
+
CFPropertyList (= 2.3.1)
|
25
|
+
addressable (= 2.3.5)
|
26
|
+
atomic (= 1.1.14)
|
27
|
+
aws-ses (= 0.5.0)
|
28
|
+
buftok (= 0.2.0)
|
15
29
|
builder (= 3.2.2)
|
30
|
+
descendants_tracker (= 0.0.3)
|
31
|
+
dogapi (= 1.11.0)
|
16
32
|
dropbox-sdk (= 1.5.1)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
33
|
+
equalizer (= 0.0.9)
|
34
|
+
excon (= 0.44.4)
|
35
|
+
faraday (= 0.8.8)
|
36
|
+
fission (= 0.5.0)
|
37
|
+
flowdock (= 0.4.0)
|
38
|
+
fog (= 1.28.0)
|
39
|
+
fog-atmos (= 0.1.0)
|
40
|
+
fog-aws (= 0.1.1)
|
41
|
+
fog-brightbox (= 0.7.1)
|
42
|
+
fog-core (= 1.29.0)
|
43
|
+
fog-ecloud (= 0.0.2)
|
44
|
+
fog-json (= 1.0.0)
|
45
|
+
fog-profitbricks (= 0.0.2)
|
46
|
+
fog-radosgw (= 0.0.3)
|
47
|
+
fog-riakcs (= 0.1.0)
|
48
|
+
fog-sakuracloud (= 1.0.0)
|
49
|
+
fog-serverlove (= 0.1.1)
|
50
|
+
fog-softlayer (= 0.4.1)
|
51
|
+
fog-storm_on_demand (= 0.1.0)
|
52
|
+
fog-terremark (= 0.0.4)
|
53
|
+
fog-vmfusion (= 0.0.1)
|
54
|
+
fog-voxel (= 0.0.2)
|
55
|
+
fog-xml (= 0.1.1)
|
56
|
+
formatador (= 0.2.5)
|
57
|
+
hipchat (= 1.0.1)
|
58
|
+
http (= 0.5.0)
|
59
|
+
http_parser.rb (= 0.6.0)
|
60
|
+
httparty (= 0.12.0)
|
61
|
+
inflecto (= 0.0.2)
|
62
|
+
ipaddress (= 0.8.0)
|
63
|
+
json (= 1.8.2)
|
24
64
|
mail (= 2.5.4)
|
25
|
-
|
26
|
-
|
27
|
-
|
65
|
+
memoizable (= 0.4.0)
|
66
|
+
mime-types (= 1.25.1)
|
67
|
+
mini_portile (= 0.6.2)
|
68
|
+
multi_json (= 1.10.1)
|
69
|
+
multi_xml (= 0.5.5)
|
28
70
|
multipart-post (= 1.2.0)
|
29
|
-
net-scp (= 1.1
|
71
|
+
net-scp (= 1.2.1)
|
30
72
|
net-sftp (= 2.1.2)
|
31
|
-
net-ssh (= 2.
|
32
|
-
nokogiri (= 1.
|
73
|
+
net-ssh (= 2.9.2)
|
74
|
+
nokogiri (= 1.6.6.2)
|
33
75
|
open4 (= 1.3.0)
|
76
|
+
pagerduty (= 2.0.0)
|
34
77
|
polyglot (= 0.3.3)
|
35
|
-
ruby-hmac (= 0.4.0)
|
36
78
|
simple_oauth (= 0.2.0)
|
37
79
|
thor (= 0.18.1)
|
38
|
-
|
39
|
-
|
80
|
+
thread_safe (= 0.1.3)
|
81
|
+
treetop (= 1.4.15)
|
82
|
+
twitter (= 5.5.0)
|
83
|
+
unf (= 0.1.3)
|
84
|
+
unf_ext (= 0.0.6)
|
85
|
+
xml-simple (= 1.1.4)
|
86
|
+
buftok (0.2.0)
|
40
87
|
builder (3.2.2)
|
41
|
-
|
42
|
-
activesupport (~> 3.0)
|
43
|
-
carrierwave-aliyun (0.2.1)
|
44
|
-
carrierwave (>= 0.5.7)
|
45
|
-
rest-client (>= 1.6.7)
|
88
|
+
descendants_tracker (0.0.3)
|
46
89
|
diff-lcs (1.2.4)
|
90
|
+
dogapi (1.11.0)
|
91
|
+
json (>= 1.5.1)
|
47
92
|
dropbox-sdk (1.5.1)
|
48
93
|
json
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
94
|
+
equalizer (0.0.9)
|
95
|
+
excon (0.44.4)
|
96
|
+
faraday (0.8.8)
|
97
|
+
multipart-post (~> 1.2.0)
|
98
|
+
fission (0.5.0)
|
99
|
+
CFPropertyList (~> 2.2)
|
100
|
+
flowdock (0.4.0)
|
101
|
+
httparty (~> 0.7)
|
102
|
+
multi_json
|
103
|
+
fog (1.28.0)
|
104
|
+
fog-atmos
|
105
|
+
fog-aws (~> 0.0)
|
106
|
+
fog-brightbox (~> 0.4)
|
107
|
+
fog-core (~> 1.27, >= 1.27.3)
|
108
|
+
fog-ecloud
|
109
|
+
fog-json
|
110
|
+
fog-profitbricks
|
111
|
+
fog-radosgw (>= 0.0.2)
|
112
|
+
fog-riakcs
|
113
|
+
fog-sakuracloud (>= 0.0.4)
|
114
|
+
fog-serverlove
|
115
|
+
fog-softlayer
|
116
|
+
fog-storm_on_demand
|
117
|
+
fog-terremark
|
118
|
+
fog-vmfusion
|
119
|
+
fog-voxel
|
120
|
+
fog-xml (~> 0.1.1)
|
121
|
+
ipaddress (~> 0.5)
|
122
|
+
nokogiri (~> 1.5, >= 1.5.11)
|
123
|
+
fog-atmos (0.1.0)
|
124
|
+
fog-core
|
125
|
+
fog-xml
|
126
|
+
fog-aws (0.1.1)
|
127
|
+
fog-core (~> 1.27)
|
128
|
+
fog-json (~> 1.0)
|
129
|
+
fog-xml (~> 0.1)
|
130
|
+
ipaddress (~> 0.8)
|
131
|
+
fog-brightbox (0.7.1)
|
132
|
+
fog-core (~> 1.22)
|
133
|
+
fog-json
|
134
|
+
inflecto (~> 0.0.2)
|
135
|
+
fog-core (1.29.0)
|
53
136
|
builder
|
54
|
-
excon (~> 0.
|
55
|
-
formatador (~> 0.2
|
137
|
+
excon (~> 0.38)
|
138
|
+
formatador (~> 0.2)
|
56
139
|
mime-types
|
57
|
-
multi_json (~> 1.0)
|
58
140
|
net-scp (~> 1.1)
|
59
141
|
net-ssh (>= 2.1.3)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
httparty
|
65
|
-
httparty (0.11.0)
|
142
|
+
fog-ecloud (0.0.2)
|
143
|
+
fog-core
|
144
|
+
fog-xml
|
145
|
+
fog-json (1.0.0)
|
66
146
|
multi_json (~> 1.0)
|
147
|
+
fog-profitbricks (0.0.2)
|
148
|
+
fog-core
|
149
|
+
fog-xml
|
150
|
+
nokogiri
|
151
|
+
fog-radosgw (0.0.3)
|
152
|
+
fog-core (>= 1.21.0)
|
153
|
+
fog-json
|
154
|
+
fog-xml (>= 0.0.1)
|
155
|
+
fog-riakcs (0.1.0)
|
156
|
+
fog-core
|
157
|
+
fog-json
|
158
|
+
fog-xml
|
159
|
+
fog-sakuracloud (1.0.0)
|
160
|
+
fog-core
|
161
|
+
fog-json
|
162
|
+
fog-serverlove (0.1.1)
|
163
|
+
fog-core
|
164
|
+
fog-json
|
165
|
+
fog-softlayer (0.4.1)
|
166
|
+
fog-core
|
167
|
+
fog-json
|
168
|
+
fog-storm_on_demand (0.1.0)
|
169
|
+
fog-core
|
170
|
+
fog-json
|
171
|
+
fog-terremark (0.0.4)
|
172
|
+
fog-core
|
173
|
+
fog-xml
|
174
|
+
fog-vmfusion (0.0.1)
|
175
|
+
fission
|
176
|
+
fog-core
|
177
|
+
fog-voxel (0.0.2)
|
178
|
+
fog-core
|
179
|
+
fog-xml
|
180
|
+
fog-xml (0.1.1)
|
181
|
+
fog-core
|
182
|
+
nokogiri (~> 1.5, >= 1.5.11)
|
183
|
+
formatador (0.2.5)
|
184
|
+
gyoku (1.3.1)
|
185
|
+
builder (>= 2.1.2)
|
186
|
+
hipchat (1.0.1)
|
187
|
+
httparty
|
188
|
+
http (0.5.0)
|
189
|
+
http_parser.rb
|
190
|
+
http_parser.rb (0.6.0)
|
191
|
+
httparty (0.12.0)
|
192
|
+
json (~> 1.8)
|
67
193
|
multi_xml (>= 0.5.2)
|
68
|
-
|
69
|
-
|
194
|
+
inflecto (0.0.2)
|
195
|
+
ipaddress (0.8.0)
|
196
|
+
json (1.8.2)
|
70
197
|
mail (2.5.4)
|
71
198
|
mime-types (~> 1.16)
|
72
199
|
treetop (~> 1.4.8)
|
200
|
+
memoizable (0.4.0)
|
201
|
+
thread_safe (~> 0.1.3)
|
73
202
|
metaclass (0.0.1)
|
74
|
-
mime-types (1.
|
203
|
+
mime-types (1.25.1)
|
204
|
+
mini_portile (0.6.2)
|
75
205
|
mocha (0.14.0)
|
76
206
|
metaclass (~> 0.0.1)
|
77
|
-
multi_json (1.
|
78
|
-
multi_xml (0.5.
|
207
|
+
multi_json (1.10.1)
|
208
|
+
multi_xml (0.5.5)
|
79
209
|
multipart-post (1.2.0)
|
80
|
-
net-scp (1.1
|
210
|
+
net-scp (1.2.1)
|
81
211
|
net-ssh (>= 2.6.5)
|
82
212
|
net-sftp (2.1.2)
|
83
213
|
net-ssh (>= 2.6.5)
|
84
|
-
net-ssh (2.
|
85
|
-
nokogiri (1.
|
214
|
+
net-ssh (2.9.2)
|
215
|
+
nokogiri (1.6.6.2)
|
216
|
+
mini_portile (~> 0.6.0)
|
86
217
|
open4 (1.3.0)
|
218
|
+
pagerduty (2.0.0)
|
219
|
+
json (>= 1.7.7)
|
87
220
|
polyglot (0.3.3)
|
88
|
-
|
89
|
-
mime-types (>= 1.16)
|
221
|
+
rake (11.1.2)
|
90
222
|
rspec (2.14.1)
|
91
223
|
rspec-core (~> 2.14.0)
|
92
224
|
rspec-expectations (~> 2.14.0)
|
@@ -95,16 +227,28 @@ GEM
|
|
95
227
|
rspec-expectations (2.14.2)
|
96
228
|
diff-lcs (>= 1.1.3, < 2.0)
|
97
229
|
rspec-mocks (2.14.3)
|
98
|
-
ruby-hmac (0.4.0)
|
99
230
|
simple_oauth (0.2.0)
|
100
231
|
thor (0.18.1)
|
101
|
-
|
232
|
+
thread_safe (0.1.3)
|
233
|
+
atomic
|
234
|
+
treetop (1.4.15)
|
102
235
|
polyglot
|
103
236
|
polyglot (>= 0.3.1)
|
104
|
-
twitter (
|
105
|
-
|
106
|
-
|
107
|
-
|
237
|
+
twitter (5.5.0)
|
238
|
+
addressable (~> 2.3)
|
239
|
+
buftok (~> 0.2.0)
|
240
|
+
descendants_tracker (~> 0.0.3)
|
241
|
+
equalizer (~> 0.0.9)
|
242
|
+
faraday (>= 0.8, < 0.10)
|
243
|
+
http (~> 0.5.0)
|
244
|
+
http_parser.rb (~> 0.6.0)
|
245
|
+
json (~> 1.8)
|
246
|
+
memoizable (~> 0.4.0)
|
247
|
+
simple_oauth (~> 0.2.0)
|
248
|
+
unf (0.1.3)
|
249
|
+
unf_ext
|
250
|
+
unf_ext (0.0.6)
|
251
|
+
xml-simple (1.1.4)
|
108
252
|
|
109
253
|
PLATFORMS
|
110
254
|
ruby
|
@@ -112,4 +256,8 @@ PLATFORMS
|
|
112
256
|
DEPENDENCIES
|
113
257
|
backup-aliyun!
|
114
258
|
mocha
|
259
|
+
rake
|
115
260
|
rspec
|
261
|
+
|
262
|
+
BUNDLED WITH
|
263
|
+
1.11.2
|
data/README.md
CHANGED
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
此 Gem 是 [Backup](https://github.com/meskyanichi/backup) 的辅助插件,目的是让 Backup 支持存储到 [Aliyun OSS](http://oss.aliyun.com)。
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/huacnlee/backup-aliyun.svg?branch=master)](https://travis-ci.org/huacnlee/backup-aliyun)
|
6
|
+
|
5
7
|
## 安装
|
6
8
|
|
7
9
|
```bash
|
8
10
|
$ gem install backup-aliyun
|
9
11
|
```
|
12
|
+
|
10
13
|
## 配置
|
11
14
|
|
12
15
|
你需要在你的 Backup models 文件里面单独引用 `backup-aliyun`,比如:
|
@@ -16,15 +19,16 @@ $ gem install backup-aliyun
|
|
16
19
|
```ruby
|
17
20
|
require "backup-aliyun" # 引用 backup-aliyun
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
aliyun.access_key_id = 'my_access_id'
|
22
|
+
Model.new(:foo, 'Description for foo') do
|
23
|
+
# 配置阿里云 OSS 作为备份存储方式, 注意,Aliyun 这个地方一定要打引号
|
24
|
+
store_with "Aliyun" do |aliyun|
|
25
|
+
aliyun.access_key_id = 'my_access_id'
|
24
26
|
aliyun.access_key_secret = 'my_access_key'
|
25
|
-
aliyun.bucket
|
26
|
-
|
27
|
-
aliyun.
|
27
|
+
aliyun.bucket = 'bucket-name'
|
28
|
+
# 修改对应的 OSS 所在区域,默认 cn-hangzhou
|
29
|
+
aliyun.area = 'cn-hangzhou'
|
30
|
+
aliyun.path = '/path/to/my/backups'
|
31
|
+
aliyun.keep = 10
|
28
32
|
end
|
29
33
|
end
|
30
34
|
```
|
data/Rakefile
ADDED
data/backup-aliyun.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "backup-aliyun"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.0"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Jason Lee"]
|
9
9
|
s.email = ["huacnlee@gmail.com"]
|
@@ -17,5 +17,5 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.license = 'MIT'
|
18
18
|
|
19
19
|
s.add_dependency "backup", ">= 3.7.0"
|
20
|
-
s.add_dependency "
|
21
|
-
end
|
20
|
+
s.add_dependency "aliyun-oss-sdk", [">= 0.1.6"]
|
21
|
+
end
|
data/lib/backup-aliyun.rb
CHANGED
@@ -1,32 +1,31 @@
|
|
1
|
-
require
|
2
|
-
require "base64"
|
1
|
+
require 'aliyun/oss'
|
3
2
|
|
4
3
|
module Backup
|
5
4
|
module Storage
|
6
5
|
class Aliyun < Base
|
7
|
-
attr_accessor :bucket
|
8
|
-
|
6
|
+
attr_accessor :bucket, :area, :access_key_id, :access_key_secret, :path
|
7
|
+
|
9
8
|
def initialize(model, storage_id = nil, &block)
|
10
9
|
super(model, storage_id)
|
11
10
|
|
12
11
|
@path ||= 'backups'
|
12
|
+
@area ||= 'cn-hangzhou'
|
13
13
|
|
14
14
|
instance_eval(&block) if block_given?
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
private
|
18
|
-
|
19
|
-
def
|
20
|
-
return @
|
18
|
+
|
19
|
+
def client
|
20
|
+
return @client if defined? @client
|
21
21
|
opts = {
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:aliyun_bucket => self.bucket,
|
25
|
-
:aliyun_internal => self.aliyun_internal || false
|
22
|
+
host: "oss-#{self.area}.aliyuncs.com",
|
23
|
+
bucket: self.bucket
|
26
24
|
}
|
27
|
-
@
|
25
|
+
@client = ::Aliyun::Oss::Client.new(self.access_key_id, self.access_key_secret, opts)
|
26
|
+
@client
|
28
27
|
end
|
29
|
-
|
28
|
+
|
30
29
|
def transfer!
|
31
30
|
remote_path = remote_path_for(@package)
|
32
31
|
|
@@ -35,15 +34,15 @@ module Backup
|
|
35
34
|
dest = File.join(remote_path, filename)
|
36
35
|
Logger.info "#{storage_name} uploading '#{ dest }'..."
|
37
36
|
File.open(src, 'r') do |file|
|
38
|
-
|
37
|
+
client.bucket_create_object(dest, file, {})
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
42
|
-
|
41
|
+
|
43
42
|
def remove!(package)
|
44
43
|
remote_path = remote_path_for(package)
|
45
44
|
Logger.info "#{storage_name} removing '#{remote_path}'..."
|
46
|
-
|
45
|
+
client.bucket_delete_object(remote_path)
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
data/spec/aliyun_spec.rb
CHANGED
@@ -6,10 +6,11 @@ describe Backup::Storage::Aliyun do
|
|
6
6
|
let(:model) { Backup::Model.new(:test_trigger, 'test label') }
|
7
7
|
let(:storage) do
|
8
8
|
Backup::Storage::Aliyun.new(model) do |db|
|
9
|
-
db.access_key_id
|
10
|
-
db.access_key_secret = '
|
11
|
-
db.bucket
|
12
|
-
db.
|
9
|
+
db.access_key_id = ENV['ALIYUN_ACCESS_ID'] || 'my_access_id'
|
10
|
+
db.access_key_secret = ENV['ALIYUN_ACCESS_KEY'] || '123456'
|
11
|
+
db.bucket = ENV['ALIYUN_BUCKET'] || 'carrierwave-aliyun-test'
|
12
|
+
db.area = ENV['ALIYUN_AREA'] || 'cn-hangzhou'
|
13
|
+
db.keep = 5
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -37,9 +38,10 @@ describe Backup::Storage::Aliyun do
|
|
37
38
|
|
38
39
|
context 'when no pre-configured defaults have been set' do
|
39
40
|
it 'should use the values given' do
|
40
|
-
storage.access_key_id.should == 'my_access_id'
|
41
|
-
storage.access_key_secret.should == '
|
42
|
-
storage.bucket.should ==
|
41
|
+
storage.access_key_id.should == ENV['ALIYUN_ACCESS_ID'] || 'my_access_id'
|
42
|
+
storage.access_key_secret.should == ENV['ALIYUN_ACCESS_KEY'] || '123456'
|
43
|
+
storage.bucket.should == ENV['ALIYUN_BUCKET'] || 'carrierwave-aliyun-test'
|
44
|
+
storage.area.should == ENV['ALIYUN_AREA'] || 'cn-hangzhou'
|
43
45
|
storage.path.should == 'backups'
|
44
46
|
|
45
47
|
storage.storage_id.should be_nil
|
@@ -51,7 +53,8 @@ describe Backup::Storage::Aliyun do
|
|
51
53
|
storage.access_key_id.should be_nil
|
52
54
|
storage.access_key_secret.should be_nil
|
53
55
|
storage.bucket.should be_nil
|
54
|
-
storage.
|
56
|
+
storage.area.should == 'cn-hangzhou'
|
57
|
+
storage.path.should == 'backups'
|
55
58
|
|
56
59
|
storage.storage_id.should be_nil
|
57
60
|
storage.keep.should be_nil
|
@@ -102,7 +105,7 @@ describe Backup::Storage::Aliyun do
|
|
102
105
|
end # describe '#initialize'
|
103
106
|
|
104
107
|
describe '#transfer!' do
|
105
|
-
let(:
|
108
|
+
let(:client) { mock }
|
106
109
|
let(:package) { mock }
|
107
110
|
let(:file) { mock }
|
108
111
|
let(:s) { sequence '' }
|
@@ -111,12 +114,12 @@ describe Backup::Storage::Aliyun do
|
|
111
114
|
storage.instance_variable_set(:@package, package)
|
112
115
|
storage.stubs(:storage_name).returns('Storage::Aliyun')
|
113
116
|
Backup::Config.stubs(:tmp_path).returns('/local/path')
|
114
|
-
storage.stubs(:
|
117
|
+
storage.stubs(:client).returns(client)
|
115
118
|
file.stubs(:read).returns("foo")
|
116
119
|
end
|
117
120
|
|
118
121
|
it 'should transfer the package files' do
|
119
|
-
|
122
|
+
|
120
123
|
storage.expects(:remote_path_for).in_sequence(s).with(package).
|
121
124
|
returns('remote/path')
|
122
125
|
package.stubs(:filenames).returns(["backup.tar.enc-aa","backup.tar.enc-ab"])
|
@@ -127,8 +130,8 @@ describe Backup::Storage::Aliyun do
|
|
127
130
|
File.expects(:open).in_sequence(s).with(
|
128
131
|
File.join('/local/path', 'backup.tar.enc-aa'), 'r'
|
129
132
|
).yields(file)
|
130
|
-
|
131
|
-
File.join('remote/path', 'backup.tar.enc-aa'), file
|
133
|
+
client.expects(:bucket_create_object).in_sequence(s).with(
|
134
|
+
File.join('remote/path', 'backup.tar.enc-aa'), file, {}
|
132
135
|
)
|
133
136
|
# second yield
|
134
137
|
Backup::Logger.expects(:info).in_sequence(s).with(
|
@@ -137,8 +140,8 @@ describe Backup::Storage::Aliyun do
|
|
137
140
|
File.expects(:open).in_sequence(s).with(
|
138
141
|
File.join('/local/path', 'backup.tar.enc-ab'), 'r'
|
139
142
|
).yields(file)
|
140
|
-
|
141
|
-
File.join('remote/path', 'backup.tar.enc-ab'), file
|
143
|
+
client.expects(:bucket_create_object).in_sequence(s).with(
|
144
|
+
File.join('remote/path', 'backup.tar.enc-ab'), file, {}
|
142
145
|
)
|
143
146
|
|
144
147
|
storage.send(:transfer!)
|
@@ -147,12 +150,12 @@ describe Backup::Storage::Aliyun do
|
|
147
150
|
|
148
151
|
describe '#remove!' do
|
149
152
|
let(:package) { mock }
|
150
|
-
let(:
|
153
|
+
let(:client) { mock }
|
151
154
|
let(:s) { sequence '' }
|
152
155
|
|
153
156
|
before do
|
154
157
|
storage.stubs(:storage_name).returns('Storage::Aliyun')
|
155
|
-
storage.stubs(:
|
158
|
+
storage.stubs(:client).returns(client)
|
156
159
|
end
|
157
160
|
|
158
161
|
it 'should remove the package files' do
|
@@ -162,7 +165,7 @@ describe Backup::Storage::Aliyun do
|
|
162
165
|
Backup::Logger.expects(:info).in_sequence(s).with(
|
163
166
|
"Storage::Aliyun removing 'remote/path'..."
|
164
167
|
)
|
165
|
-
|
168
|
+
client.expects(:bucket_delete_object).in_sequence(s).with('remote/path')
|
166
169
|
|
167
170
|
storage.send(:remove!, package)
|
168
171
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backup-aliyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backup
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.7.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: aliyun-oss-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.1.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.1.6
|
41
41
|
description: Aliyun OSS Storage support for Backup
|
42
42
|
email:
|
43
43
|
- huacnlee@gmail.com
|
@@ -45,12 +45,14 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- CHANGELOG.md
|
50
51
|
- Gemfile
|
51
52
|
- Gemfile.lock
|
52
53
|
- LICENSE
|
53
54
|
- README.md
|
55
|
+
- Rakefile
|
54
56
|
- backup-aliyun.gemspec
|
55
57
|
- lib/backup-aliyun.rb
|
56
58
|
- lib/backup/.DS_Store
|
@@ -67,21 +69,20 @@ require_paths:
|
|
67
69
|
- lib
|
68
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
71
|
requirements:
|
70
|
-
- -
|
72
|
+
- - ">="
|
71
73
|
- !ruby/object:Gem::Version
|
72
74
|
version: '0'
|
73
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
76
|
requirements:
|
75
|
-
- -
|
77
|
+
- - ">="
|
76
78
|
- !ruby/object:Gem::Version
|
77
79
|
version: '0'
|
78
80
|
requirements: []
|
79
81
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.5.1
|
81
83
|
signing_key:
|
82
84
|
specification_version: 4
|
83
85
|
summary: Aliyun OSS Storage support for Backup
|
84
86
|
test_files:
|
85
87
|
- spec/aliyun_spec.rb
|
86
88
|
- spec/spec_helper.rb
|
87
|
-
has_rdoc:
|