opsicle 0.13.0 → 0.13.1

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: c70b5f91d3917104411e5e0b6cc183406b1b8016
4
- data.tar.gz: 61418c77bb81f7adccd36dfed093ea482e59077c
3
+ metadata.gz: 0baf2ced70ed7f2d668ef04fd18e666c3c1e0b52
4
+ data.tar.gz: 74431df218528ff5e3e3a75cc4106537149ca150
5
5
  SHA512:
6
- metadata.gz: 39ceb8570c356e6a74411a4f5307771ee7cfc1bddb9ddb958d26209a3a8366225c8f5e8d695b075be0b2744a472acd35cb74eade46841f29bd5cd65b98d8a5b4
7
- data.tar.gz: d1322f7a77cfb0c3e5e416fe9a7d3632a13908704f9a0e1d32adcdb8969705d4c50c04de01653f19c6aedb0bfcda659ec1c1b1be0db89f4034c545979996b869
6
+ metadata.gz: d88d1230288fb6adcb4c18a0a6d23742043bf8561955af051ada5fc33d35181633b8e714d3ab8d2bb5e1272f91cc0d96a572e71752564b6a6c2fa99e288980fc
7
+ data.tar.gz: 9054a81eb6a19777f1424c9f961604b464c9aa64d65d5cd888d090fa22174177269f29032a1a870d5461cde5b6629547225373b8f23770a054301eccd9846b36
@@ -29,25 +29,33 @@ module Opsicle
29
29
 
30
30
  # Make client with correct configuration available to monitor spies
31
31
  App.client = Client.new(environment)
32
- @deploy = Opsicle::Deployment.new(@deployment_id, App.client) if @deployment_id
32
+ if @deployment_id
33
+ # `deploy`, `chef-update`, `execute-recipes` command, which is no-tty compatible so these can be automated via cron, etc.
34
+ @deploy = Opsicle::Deployment.new(@deployment_id, App.client)
35
+ else
36
+ # `monitor` command, which requires a TTY.
37
+ raise "Monitor requires a TTY." unless $stdout.tty?
38
+ end
33
39
  end
34
40
 
35
41
  def start
36
42
  begin
37
43
  @running = true
38
44
 
39
- setup
45
+ if $stdout.tty?
46
+ setup
40
47
 
41
- @threads[:command] ||= Thread.new do
42
- command_loop # listen for commands
43
- end
48
+ @threads[:command] ||= Thread.new do
49
+ command_loop # listen for commands
50
+ end
44
51
 
45
- @threads[:refresh_screen] ||= Thread.new do
46
- refresh_screen_loop # refresh frequently
47
- end
52
+ @threads[:refresh_screen] ||= Thread.new do
53
+ refresh_screen_loop # refresh frequently
54
+ end
48
55
 
49
- @threads[:refresh_data] ||= Thread.new do
50
- refresh_data_loop # refresh not so frequently
56
+ @threads[:refresh_data] ||= Thread.new do
57
+ refresh_data_loop # refresh not so frequently
58
+ end
51
59
  end
52
60
 
53
61
  if @deploy
@@ -67,7 +75,7 @@ module Opsicle
67
75
 
68
76
  @running = false
69
77
  wakey_wakey
70
- @screen.close
78
+ @screen.close unless @screen.nil?
71
79
  @screen = nil # Ruby curses lib doesn't have closed?(), so we set to nil, just in case
72
80
 
73
81
  options[:error] ? raise(options[:error]) : raise(QuitMonitor, options[:message])
@@ -159,7 +167,7 @@ module Opsicle
159
167
  # to the spies would get ugly.
160
168
  def refresh_deploy_status_loop
161
169
  while @running do
162
- next unless @screen # HACK: only certain test scenarios?
170
+ next unless @screen || !$stdout.tty?# HACK: only certain test scenarios?
163
171
 
164
172
  check_deploy_status
165
173
 
@@ -168,7 +176,9 @@ module Opsicle
168
176
  end
169
177
 
170
178
  def check_deploy_status
171
- unless deploy.running?
179
+ if deploy.running?
180
+ Output.say(". ") unless $stdout.tty?
181
+ else
172
182
  if deploy.failed?
173
183
  stop(error: Opsicle::Errors::DeployFailed.new(deploy.command))
174
184
  elsif deploy.successful?
@@ -1,3 +1,3 @@
1
1
  module Opsicle
2
- VERSION = "0.13.0"
2
+ VERSION = "0.13.1"
3
3
  end
@@ -49,7 +49,8 @@ module Opsicle
49
49
  it "should print changes with table" do
50
50
  allow(HashDiff).to receive(:diff) { [%w[- nyan 1], %w[+ cat 2],%w[~ taco 3 4]] }
51
51
  expect(Output).to receive(:say).with("Changes: 3") { nil }
52
- expect(Output).to receive_message_chain("terminal.say")
52
+ allow(Output).to receive_message_chain("terminal.say")
53
+ allow(Output).to receive_message_chain("terminal.color")
53
54
  subject.print(nil, nil)
54
55
  end
55
56
  end
@@ -30,6 +30,11 @@ describe Opsicle::Monitor::App do
30
30
  expect(@app.restarting).to equal(false)
31
31
  end
32
32
 
33
+ it "raises error without a tty" do
34
+ expect($stdout).to receive(:tty?) { false }
35
+ expect { Opsicle::Monitor::App.new("staging", {}) }.to raise_error(RuntimeError, "Monitor requires a TTY.")
36
+ end
37
+
33
38
  context "when the app is montoring a deploy" do
34
39
  before do
35
40
  @app = Opsicle::Monitor::App.new("staging", {:deployment_id => 123})
@@ -42,6 +47,11 @@ describe Opsicle::Monitor::App do
42
47
  it "assigns a deploy" do
43
48
  expect(@app.deploy).to be_an_instance_of(Opsicle::Deployment)
44
49
  end
50
+
51
+ it "works without a tty for a deployment" do
52
+ allow($stdout).to receive(:tty?) { false }
53
+ Opsicle::Monitor::App.new("staging", {:deployment_id => 123})
54
+ end
45
55
  end
46
56
 
47
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opsicle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Fleener
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-30 00:00:00.000000000 Z
12
+ date: 2015-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk