kennel 1.22.0 → 1.23.0

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
  SHA256:
3
- metadata.gz: 99fe288f8c067c9b928cad757037bb771a7eb6da1c80e135fd5ebd64aa9df418
4
- data.tar.gz: dd92d7dcf71f2ae12a5205dc91b2d0fd1672ea3b5faa9a55813c2555cc0324df
3
+ metadata.gz: 54f57edb8166bf98aad7e8e687623f601806795e76c02406ac33954c26a7f7c9
4
+ data.tar.gz: 3aec9e32679df1ef1d1623be7fd8f329bf05acfd2e73c741e574669a530694cd
5
5
  SHA512:
6
- metadata.gz: fb9091c738a012f8328f9094a13af3a78d33cc00a8884edd04705169796dc081dad80fd7ab088427235f03aadb27035ae8a47fe8c3b2d18356b1ea03d4c80346
7
- data.tar.gz: cf8facf8bfed794a4f452959463cc2537056221993c19b261a4154d5a928e97770cac6a6161c9be2d6f9f0f2e08d8989a1b56e347df9c958a17f26febd9a1806
6
+ metadata.gz: ff156400117553d230a0a25045ede871e29411ad74f744a0d81260fd45bfac8446d68b687615a58f8ed0e788b99e34ff8c5f961ea9b30455adbdf7b3aeee3166
7
+ data.tar.gz: 2fd54886196b1308830e2717bac2e53b6265fb0dcc510bc4f633940961768a429413122f3358ea1d69d8a599d38792d31b67fba67315636b34dbf4da6989d47b
data/lib/kennel.rb CHANGED
@@ -27,7 +27,12 @@ require "kennel/models/project"
27
27
  require "kennel/models/team"
28
28
 
29
29
  module Kennel
30
+ @out = $stdout
31
+ @err = $stderr
32
+
30
33
  class << self
34
+ attr_accessor :out, :err
35
+
31
36
  def generate
32
37
  FileUtils.rm_rf("generated")
33
38
  generated.each do |part|
@@ -157,7 +157,7 @@ module Kennel
157
157
  monitor_path = (id_path.empty? ? widget : widget.dig(*id_path))
158
158
  monitor_path[id_key] =
159
159
  id_map[id] ||
160
- warn("Unable to find #{id} in existing monitors (they need to be created first to link them)")
160
+ Kennel.err.puts("Unable to find #{id} in existing monitors (they need to be created first to link them)")
161
161
  end
162
162
 
163
163
  def tracking_id?(id)
@@ -5,7 +5,7 @@ module Kennel
5
5
  class Progress
6
6
  # print what we are doing and a spinner until it is done ... then show how long it took
7
7
  def self.progress(name)
8
- $stderr.print "#{name} ... "
8
+ Kennel.err.print "#{name} ... "
9
9
 
10
10
  animation = "-\\|/"
11
11
  count = 0
@@ -15,9 +15,9 @@ module Kennel
15
15
  spinner = Thread.new do
16
16
  loop do
17
17
  break if stop
18
- $stderr.print animation[count % animation.size]
18
+ Kennel.err.print animation[count % animation.size]
19
19
  sleep 0.2
20
- $stderr.print "\b"
20
+ Kennel.err.print "\b"
21
21
  count += 1
22
22
  end
23
23
  end
@@ -26,7 +26,7 @@ module Kennel
26
26
 
27
27
  stop = true
28
28
  spinner.join
29
- $stderr.print "#{time.round(2)}s\n"
29
+ Kennel.err.print "#{time.round(2)}s\n"
30
30
 
31
31
  result
32
32
  end
data/lib/kennel/syncer.rb CHANGED
@@ -14,9 +14,9 @@ module Kennel
14
14
  end
15
15
 
16
16
  def plan
17
- puts "Plan:"
17
+ Kennel.out.puts "Plan:"
18
18
  if noop?
19
- puts Utils.color(:green, "Nothing to do")
19
+ Kennel.out.puts Utils.color(:green, "Nothing to do")
20
20
  else
21
21
  print_plan "Create", @create, :green
22
22
  print_plan "Update", @update, :yellow
@@ -32,18 +32,18 @@ module Kennel
32
32
  @create.each do |_, e|
33
33
  reply = @api.create e.class.api_resource, e.as_json
34
34
  reply = unnest(e.class.api_resource, reply)
35
- puts "Created #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.url(reply.fetch(:id))}"
35
+ Kennel.out.puts "Created #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.url(reply.fetch(:id))}"
36
36
  end
37
37
 
38
38
  block_irreversible_partial_updates
39
39
  @update.each do |id, e|
40
40
  @api.update e.class.api_resource, id, e.as_json
41
- puts "Updated #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.url(id)}"
41
+ Kennel.out.puts "Updated #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.url(id)}"
42
42
  end
43
43
 
44
44
  @delete.each do |id, _, a|
45
45
  @api.delete a.fetch(:api_resource), id
46
- puts "Deleted #{a.fetch(:api_resource)} #{tracking_id(a)} #{id}"
46
+ Kennel.out.puts "Deleted #{a.fetch(:api_resource)} #{tracking_id(a)} #{id}"
47
47
  end
48
48
  end
49
49
 
@@ -145,7 +145,7 @@ module Kennel
145
145
  def print_plan(step, list, color)
146
146
  return if list.empty?
147
147
  list.each do |_, e, a, diff|
148
- puts Utils.color(color, "#{step} #{tracking_id(e&.as_json || a)}")
148
+ Kennel.out.puts Utils.color(color, "#{step} #{tracking_id(e&.as_json || a)}")
149
149
  print_diff(diff) if diff # only for update
150
150
  end
151
151
  end
@@ -162,11 +162,11 @@ module Kennel
162
162
  end
163
163
 
164
164
  if (old + new).size > 100
165
- puts " #{type}#{field}"
166
- puts " #{old} ->"
167
- puts " #{new}"
165
+ Kennel.out.puts " #{type}#{field}"
166
+ Kennel.out.puts " #{old} ->"
167
+ Kennel.out.puts " #{new}"
168
168
  else
169
- puts " #{type}#{field} #{old} -> #{new}"
169
+ Kennel.out.puts " #{type}#{field} #{old} -> #{new}"
170
170
  end
171
171
  end
172
172
  end
@@ -14,17 +14,17 @@ module Kennel
14
14
  def print(api, tag)
15
15
  monitors = filtered_monitors(api, tag)
16
16
  if monitors.empty?
17
- puts "No unmuted alerts found"
17
+ Kennel.out.puts "No unmuted alerts found"
18
18
  else
19
19
  monitors.each do |m|
20
- puts m[:name]
21
- puts Utils.path_to_url("/monitors/#{m[:id]}")
20
+ Kennel.out.puts m[:name]
21
+ Kennel.out.puts Utils.path_to_url("/monitors/#{m[:id]}")
22
22
  m[:state][:groups].each do |g|
23
23
  color = COLORS[g[:status]] || :default
24
24
  since = "\t#{time_since(g[:last_triggered_ts])}"
25
- puts "#{Kennel::Utils.color(color, g[:status])}\t#{g[:name]}#{since}"
25
+ Kennel.out.puts "#{Kennel::Utils.color(color, g[:status])}\t#{g[:name]}#{since}"
26
26
  end
27
- puts
27
+ Kennel.out.puts
28
28
  end
29
29
  end
30
30
  end
data/lib/kennel/utils.rb CHANGED
@@ -26,11 +26,11 @@ module Kennel
26
26
  end
27
27
 
28
28
  def ask(question)
29
- $stderr.printf color(:red, "#{question} - press 'y' to continue: ")
29
+ Kennel.err.printf color(:red, "#{question} - press 'y' to continue: ")
30
30
  begin
31
31
  STDIN.gets.chomp == "y"
32
32
  rescue Interrupt # do not show a backtrace if user decides to Ctrl+C here
33
- $stderr.print "\n"
33
+ Kennel.err.print "\n"
34
34
  exit 1
35
35
  end
36
36
  end
@@ -44,34 +44,34 @@ module Kennel
44
44
  end
45
45
 
46
46
  def capture_stdout
47
- old = $stdout
48
- $stdout = StringIO.new
47
+ old = Kennel.out
48
+ Kennel.out = StringIO.new
49
49
  yield
50
- $stdout.string
50
+ Kennel.out.string
51
51
  ensure
52
- $stdout = old
52
+ Kennel.out = old
53
53
  end
54
54
 
55
55
  def capture_stderr
56
- old = $stderr
57
- $stderr = StringIO.new
56
+ old = Kennel.err
57
+ Kennel.err = StringIO.new
58
58
  yield
59
- $stderr.string
59
+ Kennel.err.string
60
60
  ensure
61
- $stderr = old
61
+ Kennel.err = old
62
62
  end
63
63
 
64
64
  def tee_output
65
- old_stdout = $stdout
66
- old_stderr = $stderr
65
+ old_stdout = Kennel.out
66
+ old_stderr = Kennel.err
67
67
  capture = StringIO.new
68
- $stdout = TeeIO.new([capture, $stdout])
69
- $stderr = TeeIO.new([capture, $stderr])
68
+ Kennel.out = TeeIO.new([capture, Kennel.out])
69
+ Kennel.err = TeeIO.new([capture, Kennel.err])
70
70
  yield
71
71
  capture.string
72
72
  ensure
73
- $stderr = old_stderr
74
- $stdout = old_stdout
73
+ Kennel.out = old_stdout
74
+ Kennel.err = old_stderr
75
75
  end
76
76
 
77
77
  def capture_sh(command)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.22.0"
3
+ VERSION = "1.23.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.0
4
+ version: 1.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday