@@ -7,31 +7,16 @@ SUPPORT = File.join(ROOT, 'support')
7
7
TEST = File.join(ROOT, 'test')
8
8
JQUERY_DIR = File.join(ROOT, 'jquery')
9
9
10
- unless defined? OSX then
11
- OSX = PLATFORM =~ /darwin/
12
- WIN = PLATFORM =~ /win32/
13
- NIX = !(OSX || WIN)
14
- end
15
-
10
+ require 'rubygems'
16
11
begin
17
- require 'term/ansicolor'
18
- include Term::ANSIColor
12
+ require 'colored'
19
13
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'
30
15
end
31
16
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
35
20
36
21
#
37
22
# you can use FileUtils: http://corelib.rubyonrails.org/classes/FileUtils.html
@@ -87,19 +72,19 @@ def parse_version()
87
72
f = File.new(File.join(FIREFOX, 'install.rdf'))
88
73
text = f.read
89
74
unless text=~/<em:version>([^<]*)<\/em:version>/
90
- puts "#{red( 'Version not found') }"
75
+ puts "#{'Version not found'.red }"
91
76
exit
92
77
end
93
78
$1
94
79
end
95
80
96
81
def die(s)
97
- puts(red(s) )
82
+ puts(s.red )
98
83
exit(1)
99
84
end
100
85
101
86
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 }"
103
88
applied = false
104
89
lines = []
105
90
File.open(filepath, 'r') do |f|
@@ -119,7 +104,7 @@ def check_if_addon_exists()
119
104
end
120
105
121
106
def sys(cmd)
122
- puts blue ("> "+cmd)
107
+ puts ("> "+cmd).blue
123
108
system(cmd)
124
109
end
125
110
@@ -146,11 +131,11 @@ task :default do
146
131
File.unlink(res) if File.exists?(res)
147
132
puts "#{cmd_color('zipping')} #{file_color(res)}"
148
133
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}\" *");
150
135
end
151
136
remove_dir(TMP) if File.exist?(TMP) # recursive!
152
137
153
- puts "\ninstaller is in #{yellow( res) }, enjoy!"
138
+ puts "\ninstaller is in #{res.yellow }, enjoy!"
154
139
end
155
140
156
141
desc "Resets version in all relevant sources"
@@ -159,11 +144,11 @@ task :version do
159
144
version = ARGV[1] or die("Please specify a version as first parameter")
160
145
firequery_js_path = File.join(FIREFOX, 'chrome', 'content', 'firequery.js')
161
146
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 }"
163
148
end
164
149
install_rdf_path = File.join(FIREFOX, 'install.rdf')
165
150
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 }"
167
152
end
168
153
exit(0)
169
154
end
0 commit comments