7 require(File.join(File.dirname(__FILE__), '..', 'lib', 'twitter'))
11 # Reads in local file from current directory.
13 self.read(self.join(self.dirname(__FILE__), file))
18 # Follows <tt>Strategy</tt> design pattern
19 class RCov::OutputMorpher
20 # transforms given list of <tt>files</tt> based on new template.
21 def transform(files, output_dir = '../web/rcov/', template = 'templates/rcov.rhtml')
23 data = File.read(file)
24 fname = File.basename(file)
25 xml = Tidy.open(:show_warnings => true) do |tidy|
26 tidy.options.output_xml = true
30 rhtml = ERB.new(File.read_local(template), 0)
31 parser = Hpricot.parse(xml)
32 legend_content = parser.find_element('pre')
33 table_content = parser.find_element('table')
34 code_content = table_content.next_sibling
35 index = (fname == 'index.html')
36 version = Twitter::Version.to_version
37 File.delete(fname) if File.exists?(fname)
38 File.open("#{output_dir}/#{fname}", 'w') do |f|
39 f.puts(rhtml.result(binding))
47 # returns html files to morph based on tidy configuration file
48 def configure_morpher(tidy_conf = 'tidy.yml')
49 overrides = YAML.load(File.read_local('tidy.yml'))
50 Tidy.path = overrides['path'] || '/usr/lib/libtidy-0.99.so.0'
51 Dir.glob(overrides['html_glob'] || 'doc/rcov/**/*.html')
57 RCov::OutputMorpher.new.transform(RCov.configure_morpher)