nice-chef-formatter 0.0.2 → 0.0.3
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.
- data/lib/nice-chef-formatter.rb +3 -5
- data/nice-chef-formatter.gemspec +1 -1
- metadata +2 -3
- data/lib/chef/formatters/coloredputter.rb +0 -76
data/lib/nice-chef-formatter.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'chef/formatters/minimal'
|
2
|
-
require 'chef/formatters/coloredputter'
|
3
2
|
|
4
3
|
class Chef
|
5
4
|
module Formatters
|
@@ -10,7 +9,6 @@ class Chef
|
|
10
9
|
# Override parent class
|
11
10
|
def initialize(out, err)
|
12
11
|
super
|
13
|
-
@output = Coloredputter.new(out, err)
|
14
12
|
livedrive_title = "
|
15
13
|
=====================================================================
|
16
14
|
=====================================================================
|
@@ -95,21 +93,21 @@ class Chef
|
|
95
93
|
def resource_skipped(resource, action, conditional)
|
96
94
|
# Output should be blue (Skipped)
|
97
95
|
resource_exec_time = Time.now.to_f - @resource_start_time
|
98
|
-
puts(" * #{resource} action #{action} (#{resource_exec_time.round(3)} secs)",
|
96
|
+
puts(" * #{resource} action #{action} (#{resource_exec_time.round(3)} secs)", :blue)
|
99
97
|
end
|
100
98
|
|
101
99
|
# Called when a resource has no converge actions, e.g., it was already correct.
|
102
100
|
def resource_up_to_date(resource, action)
|
103
101
|
# Output should be green
|
104
102
|
resource_exec_time = Time.now.to_f - @resource_start_time
|
105
|
-
puts(" * #{resource} action #{action} (#{resource_exec_time.round(3)} secs)",
|
103
|
+
puts(" * #{resource} action #{action} (#{resource_exec_time.round(3)} secs)", :green)
|
106
104
|
end
|
107
105
|
|
108
106
|
# Called after a resource has been completely converged.
|
109
107
|
def resource_updated(resource, action)
|
110
108
|
# Output should be yellow (changes are applied)
|
111
109
|
resource_exec_time = Time.now.to_f - @resource_start_time
|
112
|
-
puts(" * #{resource} action #{action} (#{resource_exec_time.round(3)} secs)",
|
110
|
+
puts(" * #{resource} action #{action} (#{resource_exec_time.round(3)} secs)", :yellow)
|
113
111
|
end
|
114
112
|
end
|
115
113
|
end
|
data/nice-chef-formatter.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "nice-chef-formatter"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.3"
|
6
6
|
s.authors = ["Nadir Lloret"]
|
7
7
|
s.email = ["nadir.lloret@livedrive.com"]
|
8
8
|
s.homepage = "https://github.com/nadirollo/nice-chef-formatter"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nice-chef-formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -36,7 +36,6 @@ extensions: []
|
|
36
36
|
extra_rdoc_files: []
|
37
37
|
files:
|
38
38
|
- README.md
|
39
|
-
- lib/chef/formatters/coloredputter.rb
|
40
39
|
- lib/nice-chef-formatter.rb
|
41
40
|
- nice-chef-formatter.gemspec
|
42
41
|
homepage: https://github.com/nadirollo/nice-chef-formatter
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'chef/formatters/base'
|
2
|
-
|
3
|
-
|
4
|
-
class Chef
|
5
|
-
module Formatters
|
6
|
-
class Coloredputter < Outputter
|
7
|
-
def initialize(out, err)
|
8
|
-
super(out, err)
|
9
|
-
if OS.windows?
|
10
|
-
require 'Win32API'
|
11
|
-
get_std_handle = Win32API.new("kernel32", "GetStdHandle", ['L'], 'L')
|
12
|
-
@stdout = get_std_handle.call(-11)
|
13
|
-
@set_console_txt_attrb = Win32API.new("kernel32", "SetConsoleTextAttribute", ['L','N'], 'I')
|
14
|
-
elsif OS.linux?
|
15
|
-
require 'rainbow'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def puts(string, *color)
|
20
|
-
if OS.linux?
|
21
|
-
case color[0]
|
22
|
-
when 'green'
|
23
|
-
@out.puts Rainbow(string).color(:green)
|
24
|
-
when 'yellow'
|
25
|
-
@out.puts Rainbow(string).color(:yellow)
|
26
|
-
when 'red'
|
27
|
-
@out.puts Rainbow(string).color(:red)
|
28
|
-
when 'blue'
|
29
|
-
@out.puts Rainbow(string).color(:blue)
|
30
|
-
else
|
31
|
-
@out.puts string
|
32
|
-
end
|
33
|
-
elsif OS.windows?
|
34
|
-
case color[0]
|
35
|
-
when 'green'
|
36
|
-
@set_console_txt_attrb.call(@stdout, 90)
|
37
|
-
@out.puts string
|
38
|
-
when 'yellow'
|
39
|
-
@set_console_txt_attrb.call(@stdout, 94)
|
40
|
-
@out.puts string
|
41
|
-
when 'red'
|
42
|
-
@set_console_txt_attrb.call(@stdout, 92)
|
43
|
-
@out.puts string
|
44
|
-
when 'blue'
|
45
|
-
@set_console_txt_attrb.call(@stdout, 91)
|
46
|
-
@out.puts string
|
47
|
-
else
|
48
|
-
@set_console_txt_attrb.call(@stdout, 95)
|
49
|
-
@out.puts string
|
50
|
-
end
|
51
|
-
@set_console_txt_attrb.call(@stdout, 95)
|
52
|
-
else
|
53
|
-
@out.puts string
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
module OS
|
60
|
-
def OS.windows?
|
61
|
-
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
62
|
-
end
|
63
|
-
|
64
|
-
def OS.mac?
|
65
|
-
(/darwin/ =~ RUBY_PLATFORM) != nil
|
66
|
-
end
|
67
|
-
|
68
|
-
def OS.unix?
|
69
|
-
!OS.windows?
|
70
|
-
end
|
71
|
-
|
72
|
-
def OS.linux?
|
73
|
-
OS.unix? and not OS.mac?
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|