2012-06-13 02:47:45 +00:00
|
|
|
require 'rainbow'
|
|
|
|
|
2011-12-05 23:49:52 +00:00
|
|
|
module Jasmine::Headless::FileChecker
|
2012-01-11 13:44:28 +00:00
|
|
|
def excluded_formats
|
|
|
|
::Jasmine::Headless::EXCLUDED_FORMATS
|
|
|
|
end
|
|
|
|
|
2011-12-05 23:49:52 +00:00
|
|
|
def bad_format?(file)
|
|
|
|
return if file.nil?
|
2011-12-06 14:31:23 +00:00
|
|
|
|
2012-01-11 13:44:28 +00:00
|
|
|
excluded_formats.any? do |format|
|
2011-12-06 14:31:23 +00:00
|
|
|
file[%r{\.#{format}(\.|$)}]
|
|
|
|
end
|
2011-12-05 23:49:52 +00:00
|
|
|
end
|
2012-01-11 13:44:28 +00:00
|
|
|
|
2011-12-05 23:49:52 +00:00
|
|
|
def alert_bad_format(file)
|
2012-01-11 13:44:28 +00:00
|
|
|
Jasmine::Headless.warn("[%s] %s: %s" % [ 'Skipping File'.color(:red), file.color(:yellow), "unsupported format".color(:white) ])
|
2011-12-05 23:49:52 +00:00
|
|
|
end
|
2011-12-06 14:31:23 +00:00
|
|
|
|
|
|
|
def alert_if_bad_format?(file)
|
|
|
|
if result = bad_format?(file)
|
|
|
|
alert_bad_format(file)
|
|
|
|
end
|
|
|
|
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|