forked from premailer/premailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile.rb
71 lines (54 loc) · 1.58 KB
/
rakefile.rb
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
64
65
66
67
68
69
70
$:.unshift File.expand_path('../lib', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rubygems/package_task'
require 'fileutils'
require 'premailer'
def gemspec
@gemspec ||= begin
file = File.expand_path('../premailer.gemspec', __FILE__)
eval(File.read(file), binding, file)
end
end
Gem::PackageTask.new(gemspec) do |pkg|
pkg.need_tar = true
end
task :default => [:test]
desc 'Parse a URL and write out the output.'
task :inline do
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)
fout = File.open(output, "w")
fout.puts premailer.to_inline_css
fout.close
puts "Succesfully parsed '#{url}' into '#{output}'"
puts premailer.warnings.length.to_s + ' CSS warnings were found'
end
task :text do
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)
fout = File.open(output, "w")
fout.puts premailer.to_plain_text
fout.close
puts "Succesfully parsed '#{url}' into '#{output}'"
end
Rake::TestTask.new do |t|
t.test_files = FileList['test/test_*.rb']
t.verbose = false
end
begin
require 'yard'
YARD::Rake::YardocTask.new
rescue LoadError
$stderr.puts "Please install YARD with: gem install yard"
end