lib/format.rb in old_style-1.4.1 vs lib/format.rb in old_style-1.4.2

- old
+ new

@@ -1,27 +1,34 @@ module Format + PATH = Dir.pwd BASE = File.expand_path('../../base.css', __FILE__) + CSS_PATH = PATH + "/old_style/index.css" def new_or_open_index unless File.directory?(PATH + "/old_style") Dir.mkdir(PATH + "/old_style") end File.open(PATH + "/old_style/index.html", 'w+') end - def create_css_file? - write_css + def base_css_count + File.readlines(BASE).count == File.readlines(CSS_PATH).count end - def css_path - PATH + "/old_style/index.css" + def create_css_file? + unless File.exists?(CSS_PATH) && base_css_count + write_css + true + else + false + end end def write_css - file = File.new(css_path, 'w+') + file = File.new(CSS_PATH, 'w+') File.readlines(BASE).each do |line| file.write line end file.close end @@ -33,11 +40,11 @@ file.write "<li id='main-heading'> #{self.directories.count} Controller evaluated </li>" file.write "</div>" file.write "<body>" file.write "<head>" - file.write "<link rel='stylesheet' type='text/css' href=#{css_path}>" + file.write "<link rel='stylesheet' type='text/css' href=#{CSS_PATH}>" file.write "</head>" file.write "<div id='content'>" file.write "<div id='directories'>" file.write "<h2 id='dir-heading'>#{self.directories.sort_by{|x| x.downcase}}</h2>" file.write "</div>" @@ -89,9 +96,10 @@ file.write "<li id='footer-caption'>If you find any issues please let me know at </li>" file.write "<a id ='issues-link' href = 'https://github.com/hayduke19us/old_style/issues?state=open'>old_style's issues page on github<a>" file.write "</div>" file.write "</div>" + file.close true end def good_percent x = self.found.keys.count/(self.found.keys.count + self.empty.keys.count).to_f