checkson 0.1 → 0.2

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
  SHA256:
3
- metadata.gz: 7ab2f87748c7e3e77a1039fd9b7fff153687069c01edfb7ac94e8594cab6f04f
4
- data.tar.gz: 022660ab8a3dc7b6c324bf109e8a598793702f29fad90b426a7e7afc432d4fb3
3
+ metadata.gz: 2222386bd03c3421453df6fc47a6d91343a68a4e10f2eb33a5ca3108c9f39147
4
+ data.tar.gz: d234523870e13a2bdd163b101a0f82e270205e80929c013adda59d4d9a51b388
5
5
  SHA512:
6
- metadata.gz: 86a5f89b4cd75ee3302a40decd676c8f9b0b38fc4963fcecb92055fddae5a4b1a0d5fcdf59a5fab7ce92066cd3afdfe6533897a97b8c5aad3ecc580cd49d5ceb
7
- data.tar.gz: 7adaf87b8b50bb79a28900eae335f35930bc0413f9c8e5ac61fb826356296adcd6ea9df0cb541ff79f78300dc55ebeca7b455eb4aaa00163796334c840b458a6
6
+ metadata.gz: 1255ff0bc3a4e7393c82a0a404b17090397fe5956a7e389d0069d66790bfe262418baf197871f667e69e47843d10fc3c1fae0b514d49a7f91547b8688ce074b5
7
+ data.tar.gz: b52e63e8fc994b9d5310c12c315830ec58e0bf2537d8fbd0d3f45a2881ce41a35f9284e1e7b46baeb25257cf6fb581c13d59f991ac12c914c88f67cc4193c15e
data/lib/checkson.rb CHANGED
@@ -3,5 +3,4 @@
3
3
  require_relative 'checkson/ui'
4
4
  require_relative 'checkson/context'
5
5
  require_relative 'checkson/config'
6
- require_relative 'checkson/checks/base'
7
- require_relative 'checkson/checks/shell'
6
+ require_relative 'checkson/check'
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'checks/base'
4
+ require_relative 'checks/shell'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Base
4
- attr_reader :messages
4
+ attr_reader :status
5
5
 
6
6
  def initialize(_opts = {})
7
7
  @status = :ok
@@ -18,7 +18,8 @@ module Checkson
18
18
  @checks << OpenStruct.new(
19
19
  klass: context.klass,
20
20
  description: description,
21
- params: context.params
21
+ params: context.params,
22
+ help: context.help
22
23
  )
23
24
  end
24
25
  end
@@ -6,6 +6,7 @@ module Checkson
6
6
  def initialize(&block)
7
7
  @kass = nil
8
8
  @params = {}
9
+ @help = []
9
10
  instance_eval(&block)
10
11
  end
11
12
 
@@ -16,5 +17,10 @@ module Checkson
16
17
  def set(key, value)
17
18
  @params[key.to_sym] = value
18
19
  end
20
+
21
+ def help(message = nil)
22
+ @help << message if message
23
+ @help
24
+ end
19
25
  end
20
26
  end
data/lib/checkson/ui.rb CHANGED
@@ -8,17 +8,22 @@ module Checkson
8
8
  def initialize
9
9
  set_default_options
10
10
  parse_options
11
- start_cfgd
11
+ start_checks
12
12
  end
13
13
 
14
14
  protected
15
15
 
16
- def start_cfgd
16
+ def winsize
17
+ require 'io/console'
18
+ IO.console.winsize
19
+ end
20
+
21
+ def start_checks
17
22
  @config = Checkson::Config.new(@opts[:config])
18
23
  @config.checks.each do |check|
19
24
  c = check.klass.new(check.params)
20
25
  c.check
21
- puts c.ok?
26
+ output c, check
22
27
  end
23
28
  end
24
29
 
@@ -41,6 +46,22 @@ module Checkson
41
46
  end.parse!
42
47
  end
43
48
 
49
+ def output(sym, check)
50
+ status_column = winsize[1] / 3 * 2
51
+ print check.description
52
+ case sym.status
53
+ when :ok
54
+ puts "\033[#{status_column}G\033[1;32mOK\033[0m"
55
+ when :failed
56
+ puts "\033[#{status_column}G\033[1;31mFAILED\033[0m"
57
+ unless check.help.empty?
58
+ check.help.each do |message|
59
+ puts "--> #{message}"
60
+ end
61
+ end
62
+ end
63
+ end
64
+
44
65
  def die(msg)
45
66
  warn(msg)
46
67
  exit 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkson
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2020-03-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple framework for checking node facts
14
14
  email: florian@fsrv.xyz
@@ -20,6 +20,7 @@ files:
20
20
  - README.md
21
21
  - bin/checkson
22
22
  - lib/checkson.rb
23
+ - lib/checkson/check.rb
23
24
  - lib/checkson/checks/base.rb
24
25
  - lib/checkson/checks/shell.rb
25
26
  - lib/checkson/config.rb