forked from premailer/premailer
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
63 lines (47 loc) · 1.55 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require 'bundler/setup'
require 'rake/testtask'
require "bundler/gem_tasks"
require 'yard'
GEM_ROOT = File.dirname(__FILE__).freeze unless defined?(GEM_ROOT)
lib_path = File.expand_path('lib', GEM_ROOT)
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include? lib_path
require 'premailer/version'
desc 'Parse a URL and write out the output.'
task :inline do
require 'premailer'
url = ENV['url']
output = ENV['output']
if !url or url.empty? or !output or output.empty?
puts 'Usage: rake inline url=http://example.com/ output=output.html'
exit
end
premailer = Premailer.new(url, :warn_level => Premailer::Warnings::SAFE, :verbose => true, :adapter => :nokogiri)
File.open(output, "w") do |fout|
fout.puts premailer.to_inline_css
end
puts "Succesfully parsed '#{url}' into '#{output}'"
puts premailer.warnings.length.to_s + ' CSS warnings were found'
end
task :text do
require 'premailer'
url = ENV['url']
output = ENV['output']
if !url or url.empty? or !output or output.empty?
puts 'Usage: rake text url=http://example.com/ output=output.txt'
exit
end
premailer = Premailer.new(url, :warn_level => Premailer::Warnings::SAFE)
File.open(output, "w") do |fout|
fout.puts premailer.to_plain_text
end
puts "Succesfully parsed '#{url}' into '#{output}'"
end
Rake::TestTask.new do |t|
t.test_files = FileList['test/test_*.rb']
t.verbose = false
t.warning = false
end
YARD::Rake::YardocTask.new do |yard|
yard.options << "--title='Premailer #{Premailer::VERSION} Documentation'"
end
task :default => [:test]