do_snapshot 0.0.10 → 0.0.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3d032d3f0b49ab4934028b7cdf53afe136cb31d
4
- data.tar.gz: 0a65ff53e0105584a803c22814837a43b30f231f
3
+ metadata.gz: 8803902d64a76db013fb9c2866ef0e04c79ef2de
4
+ data.tar.gz: 22589c3aa8c1eef2af78aefd89f6cf04b959340b
5
5
  SHA512:
6
- metadata.gz: cb714515796586f65b5d3d25a19a5aa54c281297eb7a00b6b1a259711eb577265ea73194728393d15602f149eecc6300a32a1372dcd86ecd98a0026025074979
7
- data.tar.gz: 42939c0a5ef8789584e6f8b6afd80c23993c07378053fded1c80effdbfbcca8038421f46e870891c4003616733ba36b7790087b1abbb851ef205a77025b4a6ef
6
+ metadata.gz: bcb151a013ef7ec0d78dd35132c5f9e6c9cfdce35e55ec0d918331247f63d616f330b8713d0b11101d7d503fff80d39677f1873a7d044961b0c15425726a3cc8
7
+ data.tar.gz: 1b300fb97331704010d0167949345fcb238296d82321e907fa62d13808816227ed2d30476d6ace14db77b7b437300dacb2a76558273927c4e92106c8dbe37f1d
data/README.md CHANGED
@@ -27,7 +27,7 @@ Here some features:
27
27
 
28
28
  Ruby versions: 1.9.3 and higher. JRuby in 1.9 mode is also supported.
29
29
 
30
- ![DoSnaphot example](https://raw.githubusercontent.com/merqlove/do_snapshot/master/assets/example.png)
30
+ <img src="https://raw.githubusercontent.com/merqlove/do_snapshot/master/assets/example.png" style="max-width:100%" alt="DoSnaphot example">
31
31
 
32
32
  ### You can ask me, "Why you made this tool?"
33
33
 
@@ -45,7 +45,7 @@ Install it yourself as:
45
45
 
46
46
  $ gem install do_snapshot
47
47
 
48
- For **OSX** users ([Homebrew Tap](http://github.com/merqlove/do_snapshot/tap)):
48
+ For **OSX** users ([Homebrew Tap](http://github.com/merqlove/homebrew-do-snapshot)):
49
49
 
50
50
  $ brew tap merqlove/do-snapshot && brew install do_snapshot
51
51
 
@@ -97,7 +97,7 @@ Keep latest 5 snapshots, send mail notification instead of creating new one:
97
97
 
98
98
  $ do_snapshot --keep 10 --stop --mail to:yourmail@example.com
99
99
 
100
- ![DoSnapshot Safe Mode Example](https://raw.githubusercontent.com/merqlove/do_snapshot/master/assets/safe_mode.png)
100
+ <img src="https://raw.githubusercontent.com/merqlove/do_snapshot/master/assets/safe_mode.png" style="max-width:100%" alt="DoSnapshot Safe Mode Example">
101
101
 
102
102
  E-mail notifications disabled out of the box.
103
103
  For working mailer you need to set e-mail settings via run options.
@@ -117,7 +117,7 @@ module DoSnapshot
117
117
  # Before snapshot we to know that machine has powered off.
118
118
  #
119
119
  def get_event_status(id, time)
120
- return true if (Time.now.to_f - time.to_f) > timeout
120
+ return true if (Time.now - time) > timeout
121
121
  event = Digitalocean::Event.find(id)
122
122
  fail event.message unless event.status.include?('OK')
123
123
  # noinspection RubyResolve,RubyResolve
@@ -31,9 +31,9 @@ module DoSnapshot
31
31
  protected
32
32
 
33
33
  attr_accessor :droplets, :exclude, :only
34
- attr_accessor :keep, :quiet, :stop, :clean
34
+ attr_accessor :keep, :quiet, :stop, :clean, :timeout, :delay
35
35
 
36
- attr_writer :notify, :delay, :timeout, :threads, :api
36
+ attr_writer :notify, :threads, :api
37
37
 
38
38
  def api
39
39
  @api ||= API.new(delay: delay, timeout: timeout)
@@ -47,14 +47,6 @@ module DoSnapshot
47
47
  @threads ||= []
48
48
  end
49
49
 
50
- def timeout
51
- @timeout ||= 600
52
- end
53
-
54
- def delay
55
- @delay ||= 10
56
- end
57
-
58
50
  # Working with list of droplets.
59
51
  #
60
52
  def work_with_droplets
@@ -80,6 +72,7 @@ module DoSnapshot
80
72
  next if exclude.include? id
81
73
  next if !only.empty? && !only.include?(id)
82
74
 
75
+ Log.debug "Droplet id: #{id} name: #{droplet.name} "
83
76
  instance = api.droplet id
84
77
 
85
78
  prepare_instance instance.droplet
@@ -35,7 +35,11 @@ module DoSnapshot
35
35
  buffer << message
36
36
  logger.send(type, message) if logger
37
37
 
38
- say message, color(type) unless (type == :debug && !verbose) || quiet
38
+ say message, color(type) unless print?(type)
39
+ end
40
+
41
+ def print?(type)
42
+ (type == :debug && !verbose) || quiet
39
43
  end
40
44
 
41
45
  def say(message, color)
@@ -2,5 +2,5 @@
2
2
  # Current version
3
3
  #
4
4
  module DoSnapshot
5
- VERSION = '0.0.10'
5
+ VERSION = '0.0.11'
6
6
  end
@@ -210,10 +210,6 @@ describe DoSnapshot::API do
210
210
  .to have_been_made
211
211
  end
212
212
  end
213
-
214
- after(:all) do
215
- WebMock.reset!
216
- end
217
213
  end
218
214
 
219
215
  before(:each) do
@@ -46,30 +46,23 @@ describe DoSnapshot::Command do
46
46
  end
47
47
  end
48
48
 
49
- # TODO: MUST HAVE! Now when this two works others can fail...
50
- # I think it's threading problem with RSpec
51
- # context 'when droplet failed for shutdown' do
52
- # it 'raised with error' do
53
- # fail = stub_droplet_stop_fail(droplet_id)
54
- #
55
- # expect { snap_runner }
56
- # .to raise_error(DoSnapshot::DropletShutdownError)
57
- #
58
- # remove_request_stub(fail)
59
- # end
60
- # end
61
-
62
- # context 'when no snapshot created' do
63
- # it 'raised with error' do
64
- # # no_snapshot =
65
- # stub_droplet_snapshot_fail(droplet_id, snapshot_name)
66
- #
67
- # expect { snap_runner }
68
- # .to raise_error(DoSnapshot::SnapshotCreateError)
69
- #
70
- # # remove_request_stub(no_snapshot)
71
- # end
72
- # end
49
+ context 'when droplet failed for shutdown' do
50
+ it 'raised with error' do
51
+ stub_droplet_stop_fail(droplet_id)
52
+
53
+ expect { snap_runner }
54
+ .to raise_error(DoSnapshot::DropletShutdownError)
55
+ end
56
+ end
57
+
58
+ context 'when no snapshot created' do
59
+ it 'raised with error' do
60
+ stub_droplet_snapshot_fail(droplet_id, snapshot_name)
61
+
62
+ expect { snap_runner }
63
+ .to raise_error(DoSnapshot::SnapshotCreateError)
64
+ end
65
+ end
73
66
  end
74
67
 
75
68
  describe '.fail_power_off' do
@@ -106,7 +99,6 @@ describe DoSnapshot::Command do
106
99
  end
107
100
 
108
101
  before(:each) do
109
- # @cmd = DoSnapshot::Command
110
102
  stub_all_api(nil, true)
111
103
  log.buffer = %w()
112
104
  log.verbose = false
@@ -115,6 +107,7 @@ describe DoSnapshot::Command do
115
107
 
116
108
  def snap_runner(options = nil)
117
109
  options ||= default_options
110
+ cmd.send('api=', nil)
118
111
  cmd.snap(options, [:log, :mail, :smtp, :trace, :digital_ocean_client_id, :digital_ocean_api_key])
119
112
  end
120
113
  end
@@ -12,7 +12,7 @@ shared_context 'spec' do
12
12
  let(:image_id2) { '5019903' }
13
13
  let(:cli_keys) { Thor::CoreExt::HashWithIndifferentAccess.new(digital_ocean_client_id: 'NOTFOO', digital_ocean_client_bar: 'NOTBAR') }
14
14
  let(:snapshot_name) { "foo_#{DateTime.now.strftime('%Y_%m_%d')}" }
15
- let(:default_options) { Hash[only: %w( 100823 ), exclude: %w(), keep: 3, trace: true, clean: true, delay: 0, timeout: 600, droplets: nil, threads: []] }
15
+ let(:default_options) { Hash[only: %w( 100823 ), exclude: %w(), keep: 3, stop: false, trace: true, clean: true, delay: 0, timeout: 600, droplets: nil, threads: []] }
16
16
  let(:no_exclude) { [] }
17
17
  let(:exclude) { %w( 100824 100825 ) }
18
18
  let(:no_only) { [] }
@@ -88,12 +88,7 @@ shared_context 'spec' do
88
88
  WebMock.reset!
89
89
  end
90
90
 
91
- after(:all) do
92
- # sleep(1)
93
- end
94
-
95
91
  before(:each) do
96
- # stub_cleanup
97
92
  ENV['DIGITAL_OCEAN_API_KEY'] = api_key
98
93
  ENV['DIGITAL_OCEAN_CLIENT_ID'] = client_key
99
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Merkulov