<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>LICENSE</filename>
    </added>
    <added>
      <filename>spec/builder_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,59 +4,86 @@ module StaticMatic
     
     def initialize(staticmatic)
       @staticmatic = staticmatic
-      
+      determine_last_build
       build_pages
+      log_version
+    end
+    
+    def determine_last_build
+      versions_file = @staticmatic.root_dir + &quot;/builds&quot;
+      
+      if File.exists?(versions_file)
+        @last_build = File.read(versions_file).split(/\n/)[0]
+      else
+        @last_build = &quot;&quot;
+      end
+    end
+    
+    def log_version
+      timestamp = Time.now.strftime(&quot;%Y%m%d%H%M%S&quot;)
+      versions_file = @staticmatic.root_dir + &quot;/builds&quot;
+      
+      if File.exists?(versions_file)
+        current_versions = File.read(versions_file)
+        
+        File.open(versions_file, &quot;w&quot;) do |file|
+          file.puts timestamp
+          file.puts current_versions
+        end
+      else
+        File.open(versions_file, &quot;w&quot;) do |file|
+          file.puts timestamp
+        end
+      end
+      
     end
     
     def build_pages
       [&quot;pages&quot;, &quot;stylesheets&quot;].each do |template_path|
         Dir[&quot;#{@staticmatic.src_dir}/#{template_path}/**/*&quot;].each do |path|
+
           if File.directory? path
             if !File.exists? build_path_for(path)
-              puts &quot;Creating: #{build_path_for(path)}&quot;
+              @staticmatic.logger.info(&quot;Creating: #{build_path_for(path)}&quot;)
+              
               FileUtils.mkdir(build_path_for(path))
             end
           else
 
             format = @staticmatic.determine_format_for(path).to_s
-            path = base_template_name_for(path)
+            base_template_name = base_template_name_for(path)
+
             @staticmatic.template.template_format = format
-            if should_overwrite?(path, format)
+            build_file_path = &quot;#{build_path_for(path)}.#{format}&quot;
+
+            if should_overwrite?(path, build_file_path)
               if format == &quot;html&quot;
-                output = @staticmatic.render_with_layout(path)
+                output = @staticmatic.render_with_layout(base_template_name)
               else
-                output = @staticmatic.render(path)
+                output = @staticmatic.render(base_template_name)
               end
                           
               output_prefix = &quot;#{template_path}/&quot; if template_path != &quot;pages&quot;
-              save_built_file(path, output, format)
+              save_built_file(build_file_path, output)
             end
           end
         end
       end
     end
     
-    def should_overwrite?(path, format)
-      return true
-
-      build_file = &quot;#{build_path_for(path)}.#{format}&quot;
+    def should_overwrite?(template_file, build_file)
 
-      path = @staticmatic.full_template_path(path)
-      
       if File.exists? build_file
-
-        template_path = @staticmatic.template.full_template_path(path, @staticmatic.template.finder.pick_template_extension(path))
-        #file_changed? template_path, build_file
-        true
+        file_changed? template_file
       else
         true
       end
     end
     
-    def file_changed?(src_file, build_file)
-      build_modification_time = File.stat(build_file).mtime.strftime(&quot;%Y%m%d%H%M%s&quot;)
-      template_modification_time = File.stat(src_file).mtime.strftime(&quot;%Y%m%d%H%M%s&quot;)
-      if template_modification_time &gt; build_modification_time
+    def file_changed?(src_file)
+      template_modification_time = File.stat(src_file).mtime.strftime(&quot;%Y%m%d%H%M%S&quot;)
+      puts &quot;#{template_modification_time.to_i} &gt; #{@last_build.to_i}&quot;
+      if template_modification_time.to_i &gt; @last_build.to_i
         true
       else
         false
@@ -65,9 +92,11 @@ module StaticMatic
     
     # Strip off src file path and extension
     def base_template_name_for(path)
-      path.gsub!(/^\.\/src\//, '')
-      path.gsub!(/^pages\//, '') if path.match(/^pages/)
-      path.gsub(/\.[a-z]+$/, '')
+      
+      path.gsub(&quot;#{@staticmatic.root_dir}/&quot;, &quot;&quot;).
+           gsub(/^src\//, '').
+           gsub(/^pages\//, '').
+           gsub(/\.[a-z]+$/, '')
     end
     
     # Return an output filename
@@ -76,9 +105,9 @@ module StaticMatic
     end
     
     # Save contents to the specified file with the given extension to the build directory
-    def save_built_file(path, contents, extension)
-      path = &quot;#{build_path_for(path)}.#{extension}&quot;
-      puts &quot;Generating #{path}&quot;
+    def save_built_file(path, contents)
+
+      @staticmatic.logger.info(&quot;Generating #{path}&quot;)
       File.open(path, 'w+') do |f|
         f &lt;&lt; contents
       end</diff>
      <filename>lib/staticmatic/builder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -0,0 +1,3 @@
+require 'rake'
+require 'rubygems'
+require 'tasks/staticmatic'
\ No newline at end of file</diff>
      <filename>lib/staticmatic/templates/default/Rakefile</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1ebd4d20e7b8a264cb62844420f112d9db9be4ca</id>
    </parent>
  </parents>
  <author>
    <name>Stephen Bartholomew</name>
    <email>steve@curve21.com</email>
  </author>
  <url>http://github.com/stevebartholomew/staticmatic/commit/cc9dc9bbc95609cb4eb77bdf1b187d5bc3bd2b52</url>
  <id>cc9dc9bbc95609cb4eb77bdf1b187d5bc3bd2b52</id>
  <committed-date>2008-07-03T12:57:42-07:00</committed-date>
  <authored-date>2008-07-03T12:57:42-07:00</authored-date>
  <message>Added build tracking - only builds when templates have been altered, added license</message>
  <tree>ba9e5fe29f1d82ddd33a30ad4ecb1b5412aa1d97</tree>
  <committer>
    <name>Stephen Bartholomew</name>
    <email>steve@curve21.com</email>
  </committer>
</commit>
