Skip to content

Commit 8a1f8b5

Browse files
committed
Merge branch 'colorize'
2 parents adc7428 + 7a7b3af commit 8a1f8b5

File tree

4 files changed

+111
-7
lines changed

4 files changed

+111
-7
lines changed

lib/java_buildpack/buildpack.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
require 'java_buildpack/component/mutable_java_home'
2626
require 'java_buildpack/component/security_providers'
2727
require 'java_buildpack/logging/logger_factory'
28+
require 'java_buildpack/util/colorize'
2829
require 'java_buildpack/util/configuration_utils'
2930
require 'java_buildpack/util/constantize'
3031
require 'java_buildpack/util/snake_case'
@@ -100,7 +101,7 @@ def release
100101

101102
private
102103

103-
BUILDPACK_MESSAGE = '-----> Java Buildpack Version: %s'.freeze
104+
BUILDPACK_MESSAGE = "#{'----->'.red.bold} #{'Java Buildpack'.blue.bold} %s".freeze
104105

105106
LOAD_ROOT = (Pathname.new(__FILE__).dirname + '..').freeze
106107

lib/java_buildpack/buildpack_version.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ def to_hash
8383
# @return [String] a +String+ representation of the version
8484
def to_s(human_readable = true)
8585
s = []
86-
s << @version if @version
87-
s << (human_readable ? '(offline)' : 'offline') if @offline
86+
s << @version.blue if @version
87+
s << (human_readable ? '(offline)'.blue : 'offline') if @offline
8888

8989
if remote_string
9090
s << '|' if @version && human_readable
9191
s << remote_string
9292
end
9393

94-
s << 'unknown' if s.empty?
94+
s << 'unknown'.yellow if s.empty?
9595
s.join(human_readable ? ' ' : '-')
9696
end
9797

lib/java_buildpack/component/base_component.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
require 'fileutils'
1717
require 'java_buildpack/component'
1818
require 'java_buildpack/util/cache/application_cache'
19+
require 'java_buildpack/util/colorize'
1920
require 'java_buildpack/util/format_duration'
2021
require 'java_buildpack/util/shell'
2122
require 'java_buildpack/util/space_case'
@@ -86,10 +87,10 @@ def release
8687
# @return [Void]
8788
def download(version, uri, name = @component_name)
8889
download_start_time = Time.now
89-
print "-----> Downloading #{name} #{version} from #{uri.sanitize_uri} "
90+
print "#{'----->'.red.bold} Downloading #{name.blue.bold} #{version.to_s.blue} from #{uri.sanitize_uri} "
9091

9192
JavaBuildpack::Util::Cache::ApplicationCache.new.get(uri) do |file, downloaded|
92-
puts downloaded ? "(#{(Time.now - download_start_time).duration})" : '(found in cache)'
93+
puts downloaded ? "(#{(Time.now - download_start_time).duration})".green.italic : '(found in cache)'.green.italic
9394
yield file
9495
end
9596
end
@@ -167,7 +168,7 @@ def with_timing(caption)
167168

168169
yield
169170

170-
puts "(#{(Time.now - start_time).duration})"
171+
puts "(#{(Time.now - start_time).duration})".green.italic
171172
end
172173

173174
private
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Cloud Foundry Java Buildpack
2+
# Copyright 2013-2017 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
class String
17+
18+
def bg_black
19+
"\e[40m#{self}\e[0m"
20+
end
21+
22+
def bg_blue
23+
"\e[44m#{self}\e[0m"
24+
end
25+
26+
def bg_brown
27+
"\e[43m#{self}\e[0m"
28+
end
29+
30+
def bg_cyan
31+
"\e[46m#{self}\e[0m"
32+
end
33+
34+
def bg_gray
35+
"\e[47m#{self}\e[0m"
36+
end
37+
38+
def bg_green
39+
"\e[42m#{self}\e[0m"
40+
end
41+
42+
def bg_magenta
43+
"\e[45m#{self}\e[0m"
44+
end
45+
46+
def bg_red
47+
"\e[41m#{self}\e[0m"
48+
end
49+
50+
def black
51+
"\e[30m#{self}\e[0m"
52+
end
53+
54+
def blink
55+
"\e[5m#{self}\e[25m"
56+
end
57+
58+
def blue
59+
"\e[34m#{self}\e[0m"
60+
end
61+
62+
def bold
63+
"\e[1m#{self}\e[22m"
64+
end
65+
66+
def brown
67+
"\e[33m#{self}\e[0m"
68+
end
69+
70+
def cyan
71+
"\e[36m#{self}\e[0m"
72+
end
73+
74+
def gray
75+
"\e[37m#{self}\e[0m"
76+
end
77+
78+
def green
79+
"\e[32m#{self}\e[0m"
80+
end
81+
82+
def italic
83+
"\e[3m#{self}\e[23m"
84+
end
85+
86+
def magenta
87+
"\e[35m#{self}\e[0m"
88+
end
89+
90+
def red
91+
"\e[31m#{self}\e[0m"
92+
end
93+
94+
def reverse_color
95+
"\e[7m#{self}\e[27m"
96+
end
97+
98+
def underline
99+
"\e[4m#{self}\e[24m"
100+
end
101+
102+
end

0 commit comments

Comments
 (0)