Skip to content

Commit b8502bd

Browse files
committed
replace ansicolors with colored gem
1 parent 52efb98 commit b8502bd

File tree

1 file changed

+14
-29
lines changed

1 file changed

+14
-29
lines changed

rakefile

+14-29
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,16 @@ SUPPORT = File.join(ROOT, 'support')
77
TEST = File.join(ROOT, 'test')
88
JQUERY_DIR = File.join(ROOT, 'jquery')
99

10-
unless defined? OSX then
11-
OSX = PLATFORM =~ /darwin/
12-
WIN = PLATFORM =~ /win32/
13-
NIX = !(OSX || WIN)
14-
end
15-
10+
require 'rubygems'
1611
begin
17-
require 'term/ansicolor'
18-
include Term::ANSIColor
12+
require 'colored'
1913
rescue LoadError
20-
raise 'Run "gem install term-ansicolor"'
21-
end
22-
# http://kpumuk.info/ruby-on-rails/colorizing-console-ruby-script-output/
23-
if WIN then
24-
begin
25-
require 'win32console'
26-
include Win32::Console::ANSI
27-
rescue LoadError
28-
raise 'Run "gem install win32console" to use terminal colors on Windows'
29-
end
14+
raise 'You must "gem install colored" to use terminal colors'
3015
end
3116

32-
def file_color(text); yellow(text); end
33-
def dir_color(text); blue(text); end
34-
def cmd_color(text); green(text); end
17+
def file_color(text); text.yellow; end
18+
def dir_color(text); text.blue; end
19+
def cmd_color(text); text.magenta; end
3520

3621
#
3722
# you can use FileUtils: http://corelib.rubyonrails.org/classes/FileUtils.html
@@ -87,19 +72,19 @@ def parse_version()
8772
f = File.new(File.join(FIREFOX, 'install.rdf'))
8873
text = f.read
8974
unless text=~/<em:version>([^<]*)<\/em:version>/
90-
puts "#{red('Version not found')}"
75+
puts "#{'Version not found'.red}"
9176
exit
9277
end
9378
$1
9479
end
9580

9681
def die(s)
97-
puts(red(s))
82+
puts(s.red)
9883
exit(1)
9984
end
10085

10186
def patch(filepath, matcher, replacer)
102-
puts "Patching #{blue(filepath[ROOT.size+1..-1])} with #{yellow(replacer.to_s)}"
87+
puts "Patching #{filepath[ROOT.size+1..-1].blue} with #{replacer.to_s.yellow}"
10388
applied = false
10489
lines = []
10590
File.open(filepath, 'r') do |f|
@@ -119,7 +104,7 @@ def check_if_addon_exists()
119104
end
120105

121106
def sys(cmd)
122-
puts blue("> "+cmd)
107+
puts ("> "+cmd).blue
123108
system(cmd)
124109
end
125110

@@ -146,11 +131,11 @@ task :default do
146131
File.unlink(res) if File.exists?(res)
147132
puts "#{cmd_color('zipping')} #{file_color(res)}"
148133
Dir.chdir(TMP) do
149-
puts red('need zip on command line (download http://www.info-zip.org/Zip.html)') unless system("zip -r \"#{res}\" *");
134+
puts ('need zip on command line (download http://www.info-zip.org/Zip.html)').red unless system("zip -r \"#{res}\" *");
150135
end
151136
remove_dir(TMP) if File.exist?(TMP) # recursive!
152137

153-
puts "\ninstaller is in #{yellow(res)}, enjoy!"
138+
puts "\ninstaller is in #{res.yellow}, enjoy!"
154139
end
155140

156141
desc "Resets version in all relevant sources"
@@ -159,11 +144,11 @@ task :version do
159144
version = ARGV[1] or die("Please specify a version as first parameter")
160145
firequery_js_path = File.join(FIREFOX, 'chrome', 'content', 'firequery.js')
161146
if not patch(firequery_js_path, /version: '([0-9\.])+'/, "version: '#{version}'")
162-
puts " #{red("patching had no effect")}"
147+
puts " #{"patching had no effect".red}"
163148
end
164149
install_rdf_path = File.join(FIREFOX, 'install.rdf')
165150
if not patch(install_rdf_path, /<em:version>([0-9\.])+<\/em:version>/, "<em:version>#{version}</em:version>")
166-
puts " #{red("patching had no effect")}"
151+
puts " #{"patching had no effect".red}"
167152
end
168153
exit(0)
169154
end

0 commit comments

Comments
 (0)