<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/cucover/recorder.rb</filename>
    </added>
    <added>
      <filename>lib/cucover/store.rb</filename>
    </added>
    <added>
      <filename>spec/cucover/store_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,19 +1,60 @@
 $:.unshift(File.dirname(__FILE__)) 
 require 'dependencies'
+require 'cucover/logging_config'
 require 'cucover/cli_commands/coverage_of'
 require 'cucover/cli_commands/cucumber'
 require 'cucover/cli_commands/show_recordings'
-require 'cucover/logging_config'
+require 'cucover/controller'
+require 'cucover/cli'
 require 'cucover/monkey'
 require 'cucover/rails'
 require 'cucover/recording'
-require 'cucover/controller'
-require 'cucover/cli'
+require 'cucover/recorder'
+require 'cucover/store'
 
 module Cucover
   class &lt;&lt; self
     def logger
       Logging::Logger['Cucover']
-    end        
+    end
+    
+    def should_execute?(scenario_or_table_row)
+      controller(scenario_or_table_row).should_execute?
+    end
+    
+    def start_recording!(scenario_or_table_row)
+      raise(&quot;Already recording. Please call stop first.&quot;) if recording?
+
+      @current_recorder = Recorder.new(scenario_or_table_row)
+      @current_recorder.start!
+      record_file(scenario_or_table_row.file_colon_line.split(':').first) # TODO: clean this by extending the feature element
+    end
+
+    def stop_recording!
+      return unless recording?
+
+      @current_recorder.stop!
+      store.keep!(@current_recorder.recording)
+      @current_recorder = nil
+    end
+    
+    def record_file(source_file)
+      Cucover.logger.debug(&quot;Recording extra source file #{source_file}&quot;)
+      @current_recorder.record_file!(source_file)
+    end
+  
+    private
+    
+    def controller(scenario_or_table_row)
+      Controller.new(scenario_or_table_row.file_colon_line, store)
+    end
+    
+    def recording?
+      !!@current_recorder
+    end
+  
+    def store
+      @store ||= Store.new
+    end
   end  
 end</diff>
      <filename>lib/cucover.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module Cucover
       
       def initialize(cli_args)
         @filespec = cli_args[1]
-        @store = ::Cucover::Recording::Store.new
+        @store = Store.new
       end
       
       def execute</diff>
      <filename>lib/cucover/cli_commands/coverage_of.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ module Cucover
   module CliCommands
     class ShowRecordings
       def initialize(cli_args)
-        @store = Cucover::Recording::Store.new
+        @store = Store.new
       end
       
       def execute</diff>
      <filename>lib/cucover/cli_commands/show_recordings.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,8 @@
 module Cucover
   class Controller
-    class &lt;&lt; self
-      def [](scenario_or_table_row)
-        new(scenario_or_table_row.file_colon_line)
-      end
-    end
-    
-    def initialize(file_colon_line)
+    def initialize(file_colon_line, store)
       @file_colon_line = file_colon_line
-      @store = Recording::Store.new
+      @store = store
     end
     
     def should_execute?</diff>
      <filename>lib/cucover/controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,8 +16,8 @@ Before do |scenario_or_table_row|
   Cucover.logger.info(&quot;Starting #{scenario_or_table_row.class} #{scenario_or_table_row.file_colon_line}&quot;)
   Cucover::Rails.patch_if_necessary
   
-  if Cucover::Controller[scenario_or_table_row].should_execute?    
-    Cucover::Recording.start(scenario_or_table_row)
+  if Cucover.should_execute?(scenario_or_table_row)
+    Cucover.start_recording!(scenario_or_table_row)
   else
     announce &quot;[ Cucover - Skipping clean scenario ]&quot;
     scenario_or_table_row.skip_invoke!
@@ -25,5 +25,5 @@ Before do |scenario_or_table_row|
 end
 
 After do
-  Cucover::Recording.stop
+  Cucover.stop_recording!
 end</diff>
      <filename>lib/cucover/cucumber_hooks.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,15 +5,14 @@ module Cucover
         return if @patched
         return unless defined?(ActionView)
       
-        Monkey.extend_every ActionView::Template =&gt; Cucover::Rails::RecordsRenders
-      
+        Monkey.extend_every ActionView::Template =&gt; Cucover::Rails::RecordsRenders      
         @patched = true
       end
     end
   
     module RecordsRenders
       def render
-        Cucover::Recording.record_file(@filename)
+        Cucover.record_file(@filename)
         super
       end
     end</diff>
      <filename>lib/cucover/rails.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,44 +1,64 @@
-require 'cucover/recording/recorder'
-require 'cucover/recording/data'
-require 'cucover/recording/covered_file'
-require 'cucover/recording/store'
-
 module Cucover
-  module Recording
-    class &lt;&lt; self
-      def start(scenario_or_table_row)
-        raise(&quot;Already recording. Please call stop first.&quot;) if recording?
-      
-        @current_recorder = Recording::Recorder.new(scenario_or_table_row)
-        @current_recorder.start
-        record_file(scenario_or_table_row.file_colon_line.split(':').first) # TODO: clean this by extending the feature element
-      end
+  class Recording &lt; Struct.new(
+      :file_colon_line, 
+      :exception, 
+      :additional_covered_files, 
+      :analyzer, 
+      :start_time, :end_time)
     
-      def stop
-        return unless recording?
-        @current_recorder.stop
-        store.keep(@current_recorder.to_data)
-        @current_recorder = nil
-      end
-      
-      def record_file(source_file)
-        Cucover.logger.debug(&quot;Recording extra source file #{source_file}&quot;)
-        @current_recorder.record_file(source_file)
-      end
+    def feature_filename
+      file_colon_line.split(':').first
+    end
+    
+    def covers_file?(source_file)
+      covered_files.include?(source_file)
+    end
+    
+    def covers_line?(source_file, line_number)
+      covered_files.detect{ |f| f.file == source_file }.covers_line?(line_number)
+    end
+    
+    def covered_files
+      @covered_files ||= analyzed_covered_files + additional_covered_files
+    end
     
-      def record_exception(exception)
-        @current_recorder.fail!(exception)
+    def failed?
+      !!exception
+    end
+    
+    private
+    
+    def additional_covered_files
+      super.map do |filename|
+        CoveredFile.new(filename, nil, self)
       end
-
-      private
+    end
     
-      def recording?
-        !!@current_recorder
+    def analyzed_covered_files
+      filtered_analyzed_files.map do |filename| 
+        lines, marked_info, count_info = analyzer.data(filename)
+        CoveredFile.new(filename, marked_info, self)
       end
+    end
     
-      def store
-        store ||= Recording::Store.new
+    def boring?(file)
+      [
+        /gem/,
+        /vendor/,
+        /lib\/ruby/,
+        /cucover/
+      ].any? do |expression|
+        file.match expression
       end
     end
+    
+    def filtered_analyzed_files
+      analyzer.analyzed_files.reject{ |f| boring?(f) }
+    end
+
+    def normalized_files
+      cleaned_analyzed_files + additional_covered_files
+    end
   end
-end
\ No newline at end of file
+end
+require 'cucover/recording/covered_file'
\ No newline at end of file</diff>
      <filename>lib/cucover/recording.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,56 +1,53 @@
 module Cucover
-  module Recording
-    class CoveredFile
-
-      module HasLineNumberDetail
-        def covered_lines
-          return @covered_lines if @covered_lines
-          @covered_lines = []
-          @marked_info.each_with_index do |covered, index|
-            line_number = index + 1
-            @covered_lines &lt;&lt; line_number if covered
-          end
-          @covered_lines
-        end
-      end
-      
-      attr_reader :file
-      
-      def initialize(full_filename, marked_info, recording)
-        @recording      = recording
-        @full_filename  = full_filename
-        @marked_info    = marked_info
-        @file = File.expand_path(full_filename).gsub(/^#{Dir.pwd}\//, '')
-        
-        extend HasLineNumberDetail if @marked_info
-      end
-      
-      def dirty?
-        Cucover.logger.debug(&quot;#{file}     last modified at #{File.mtime(@full_filename)}&quot;)
-        Cucover.logger.debug(&quot;#{file} recording started at #{@recording.start_time}&quot;)
-        result = File.mtime(@full_filename).to_i &gt;= @recording.start_time.to_i
-        Cucover.logger.debug(result ? &quot;dirty&quot; : &quot;not dirty&quot;)
-        result
-      end
-      
-      def covers_line?(line_number)
-        covered_lines.include?(line_number)
-      end
-      
-      def ==(other)
-        other == file
-      end
-      
-      def to_s
-        &quot;#{file}:#{covered_lines.join(':')}&quot;
-      end
-      
-      private
-      
+  class Recording::CoveredFile
+    attr_reader :file
+    
+    def initialize(full_filename, rcov_marked_info, recording)
+      @full_filename    = full_filename
+      @rcov_marked_info = rcov_marked_info
+      @recording        = recording
+      @file = File.expand_path(full_filename).gsub(/^#{Dir.pwd}\//, '')
+      
+      extend HasLineNumberDetail if @rcov_marked_info
+    end
+    
+    def dirty?
+      Cucover.logger.debug(&quot;#{file}     last modified at #{File.mtime(@full_filename)}&quot;)
+      Cucover.logger.debug(&quot;#{file} recording started at #{@recording.start_time}&quot;)
+      result = File.mtime(@full_filename).to_i &gt;= @recording.start_time.to_i
+      Cucover.logger.debug(&quot;verdict: #{(result ? &quot;dirty&quot; : &quot;not dirty&quot;)}&quot;)
+      result
+    end
+    
+    def covers_line?(line_number)
+      covered_lines.include?(line_number)
+    end
+    
+    def ==(other)
+      other == file
+    end
+    
+    def to_s
+      &quot;#{file}:#{covered_lines.join(':')}&quot;
+    end
+    
+    private
+    
+    def covered_lines
+      ['&lt;unknown lines&gt;']
+    end
+    
+    module HasLineNumberDetail
       def covered_lines
-        ['&lt;unknown lines&gt;']
+        return @covered_lines if @covered_lines
+        
+        @covered_lines = []
+        @rcov_marked_info.each_with_index do |covered, index|
+          line_number = index + 1
+          @covered_lines &lt;&lt; line_number if covered
+        end
+        @covered_lines
       end
-      
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/cucover/recording/covered_file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,16 @@
 require File.dirname(__FILE__) + '/../spec_helper'
 
-describe Cucover::Controller do
-  describe &quot;#should_execute?&quot; do
-    before(:each) do
-      @store = mock(Cucover::Recording::Store)
-      Cucover::Recording::Store.stub!(:new).and_return(@store)
-      @example = mock('Example', :file_colon_line =&gt; 'foo.feature:123')
-    end
-    it &quot;when no previous recording exists, it should always return true&quot; do
-      @store.should_receive(:latest_recording).with(@example.file_colon_line).and_return(nil)
-      Cucover::Controller[@example].should_execute?.should be_true
+module Cucover
+  describe Controller do
+    describe &quot;#should_execute?&quot; do
+      before(:each) do
+        @store = mock(Store)
+        @example_id = 'foo.feature:123'
+      end
+      it &quot;when no previous recording exists, it should always return true&quot; do
+        @store.should_receive(:latest_recording).with(@example_id).and_return(nil)
+        Controller.new(@example_id, @store).should_execute?.should be_true
+      end
     end
   end
-end
+end
\ No newline at end of file</diff>
      <filename>spec/cucover/controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-module Cucover::Recording
+class Cucover::Recording
   describe CoveredFile do
     describe &quot;with a marked info&quot; do
       before(:each) do</diff>
      <filename>spec/cucover/recording/covered_file_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/cucover/recording/data.rb</filename>
    </removed>
    <removed>
      <filename>lib/cucover/recording/recorder.rb</filename>
    </removed>
    <removed>
      <filename>lib/cucover/recording/store.rb</filename>
    </removed>
    <removed>
      <filename>spec/cucover/recording/store_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>aa144ba680057bdb8ba82954c6bd93700160c4f6</id>
    </parent>
  </parents>
  <author>
    <name>Matt Wynne</name>
    <email>matt@mattwynne.net</email>
  </author>
  <url>http://github.com/mattwynne/cucover/commit/d1cf385ec6fa8c2498a0a04980b0f9a2dbe4d31d</url>
  <id>d1cf385ec6fa8c2498a0a04980b0f9a2dbe4d31d</id>
  <committed-date>2009-06-21T14:21:35-07:00</committed-date>
  <authored-date>2009-06-21T14:21:35-07:00</authored-date>
  <message>Refactoring and cleaning up</message>
  <tree>fd9140feef1cee53b1a97108e98b2179fe9e6de9</tree>
  <committer>
    <name>Matt Wynne</name>
    <email>matt@mattwynne.net</email>
  </committer>
</commit>
