sacback 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83bc1c9dd28613bc0b8d1cea52f5b184dcb3f973
4
- data.tar.gz: 46b2464c5306818f8b6652c2e4bd7ac3ea31196c
3
+ metadata.gz: b29b43b3754e3d2c1152aa1884368451e811fac6
4
+ data.tar.gz: f61ef765666d5896aaad258dae43c252f3410f37
5
5
  SHA512:
6
- metadata.gz: a4b0938d093e2eef1fa4d06d8e771285d5f59c4919f7ee94cd0bda09bcc786fa8e8e73ff32b506a0c9f59b1fffcaad74556808bc8fe7484d64180912b62efb42
7
- data.tar.gz: c109d33c5978ec2398b36604cf5f4eac339ffd2934aeeb13375872856bbadd0d4b1a219cb1552d3c3df4dc503430c90f95e58a485d84e47bac2ba202407d5c1d
6
+ metadata.gz: 1b8bc5f02f49fd94b2bfbec9e4f29bf7d0d20520c1f4ed2437430969037fe05ca2e32fd7a0e50352c0fab2572e427d8f20bc59b2718ca93d4fc7e134c65d58a3
7
+ data.tar.gz: 7da585361326a37f87c0911601c803ac2690af1ce7f360d9f1a6ec42d66430a06e59799701e258da4c3b3da04257870f81da763026154ddb7cf01af0fd1933bc
data/README.md CHANGED
@@ -12,12 +12,8 @@ Sacbackはさくらのクラウドのディスクをローカルホストにバ
12
12
 
13
13
  ## セットアップ
14
14
 
15
- まだgem化していないため、プロジェクトをクローンしてください。
16
-
17
15
  ```
18
- $ git clone https://github.com/shimotori/sacback.git
19
- $ cd sacback
20
- $ bundle install
16
+ $ gem install sacback
21
17
  ```
22
18
 
23
19
  さくらのクラウドの認証情報とゾーン名を以下の環境変数にセットします。
@@ -33,7 +29,7 @@ $ bundle install
33
29
  ## 使い方
34
30
 
35
31
  ```
36
- $ bundle exec bin/sacback
32
+ $ sacback
37
33
  Commands:
38
34
  sacback a DISK_NAME [LOCAL_DIR_PATH] # Run all through with the disk (def...
39
35
  sacback c DISK_NAME # Create an archive from the disk
@@ -49,17 +45,13 @@ Options:
49
45
  # Default: 512
50
46
  ```
51
47
 
52
- まだgem化していないため、直接 `sacback` コマンドを使うことはできません。
53
-
54
- 実行する時にはプロジェクトディレクトリーに移動して、`bundle exec bin/sacback` で実行してください。
55
-
56
48
 
57
49
 
58
50
  #### コマンド
59
51
 
60
52
  * a: すべての処理を一気に実行します。(以降のc, g, r, z)
61
53
 
62
- 例: `bundle exec bin/sacback a disk1 /backup`
54
+ 例: `sacback a disk1 /backup`
63
55
 
64
56
  * c: さくらのクラウド上でディスクからアーカイブを作成します。
65
57
 
@@ -6,7 +6,6 @@ require 'zlib'
6
6
  require 'double_bag_ftps'
7
7
  require 'saklient/cloud/api'
8
8
  require 'sacback'
9
- require 'sacback/sacloud_request'
10
9
 
11
10
 
12
11
  module Sacback
@@ -79,9 +78,10 @@ module Sacback
79
78
  desc "r ARCHIVE_ID", "Remove the archive"
80
79
  def r(archive_id)
81
80
  log "r: Remove the archive: archive id=#{archive_id}"
82
- request = create_rest_api_request
83
- result = request.send :delete, "/archive/#{archive_id}"
84
- if result['Success'] && result['is_ok']
81
+ @api = authorize
82
+ archive = @api.archive.get_by_id archive_id
83
+ result = archive.destroy
84
+ if result[:Success] && result[:is_ok]
85
85
  log "The archive #{archive_id} was removed."
86
86
  else
87
87
  abort "Error: removing the archive #{archive_id} failed"
@@ -152,11 +152,6 @@ module Sacback
152
152
  end
153
153
 
154
154
 
155
- def create_rest_api_request
156
- Sacback::SacloudRequest.new(ENV['SACLOUD_TOKEN'], ENV['SACLOUD_SECRET'], ENV['SACLOUD_ZONE'], SACLOUD_API_VERSION)
157
- end
158
-
159
-
160
155
  def download_with_doublebugftps(ftp_info, local_file)
161
156
  BasicSocket.do_not_reverse_lookup = true
162
157
  ftps = DoubleBagFTPS.new
@@ -1,3 +1,3 @@
1
1
  module Sacback
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sacback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eiichi Shimotori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-28 00:00:00.000000000 Z
11
+ date: 2014-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,6 @@ files:
96
96
  - bin/sacback
97
97
  - lib/sacback.rb
98
98
  - lib/sacback/cli.rb
99
- - lib/sacback/sacloud_request.rb
100
99
  - lib/sacback/version.rb
101
100
  - sacback.gemspec
102
101
  homepage: https://github.com/shimotori/sacback
@@ -119,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
118
  version: '0'
120
119
  requirements: []
121
120
  rubyforge_project:
122
- rubygems_version: 2.2.2
121
+ rubygems_version: 2.4.4
123
122
  signing_key:
124
123
  specification_version: 4
125
124
  summary: Sakura Cloud disk backup tool
@@ -1,53 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'net/https'
4
- require 'uri'
5
-
6
-
7
- module Sacback
8
- class SacloudRequest
9
-
10
- def initialize(token, secret, zone, api_version = '1.1')
11
- @token = token
12
- @secret = secret
13
- @base_url = "https://secure.sakura.ad.jp/cloud/zone/#{zone}/api/cloud/#{api_version}"
14
- end
15
-
16
-
17
- # Send a request
18
- def send(method, path, params = {})
19
- uri = URI.parse(@base_url + path)
20
-
21
- # HTTPS setting
22
- https = Net::HTTP.new(uri.host, uri.port)
23
- https.use_ssl = true
24
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
25
-
26
- # Set the request class
27
- request_class = case method
28
- when :get then Net::HTTP::Get
29
- when :post then Net::HTTP::Post
30
- when :delete then Net::HTTP::Delete
31
- when :put then Net::HTTP::Put
32
- else
33
- raise ArgumentError, 'invalid method'
34
- end
35
-
36
- # Basic Auth setting
37
- request = request_class.new(uri.path)
38
- request.basic_auth @token, @secret
39
-
40
- # Parameter setting
41
- request.body = JSON.generate(params) if (method == :post) || (method == :put)
42
-
43
- # Send the request
44
- response = https.start do |x|
45
- x.request request
46
- end
47
-
48
- # Return the body as JSON
49
- JSON.parse response.body
50
- end
51
-
52
- end
53
- end