-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest_planet.rb
52 lines (37 loc) · 1.09 KB
/
test_planet.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
###
# to run use
# ruby -I ./lib script/test_planet.rb
require 'html/template'
## check templates from original planet.py distribution
## see https://people.gnome.org/~jdub/bzr/planet/devel/trunk/examples/
files = [
'basic/index.html.tmpl',
'fancy/index.html.tmpl',
'atom.xml.tmpl',
'foafroll.xml.tmpl',
'opml.xml.tmpl',
'rss10.xml.tmpl',
'rss20.xml.tmpl'
].each do |name|
text = File.open( "./test/templates/planet/#{name}", "r:utf-8" ).read
puts "--- #{name}:"
puts text
puts "---"
t = HtmlTemplate.new( text )
pp t.names
puts "--- #{name} - erb:"
puts t.text
puts
puts
out_path = "tmp/#{File.dirname(name)}/#{File.basename(name,File.extname(name))}.erb"
puts "out_path: #{out_path}"
FileUtils.mkdir_p( File.dirname(out_path) )
File.open( out_path, 'w:utf-8') {|f| f.write(t.text) }
=begin
if t.errors.size > 0
puts "!! ERROR - #{t.errors.size} conversion / syntax error(s):"
pp t.errors
raise ## todo - find a good Error - StandardError - why? why not?
end
=end
end