Skip to content

Commit

Permalink
Very scratchy data store
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwynne committed Jun 15, 2009
1 parent 3422d80 commit dc758e3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cucover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,4 @@ def store

After do
Cucover.stop_recording
end
end
12 changes: 12 additions & 0 deletions lib/cucover/recording.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
module Cucover
class Recording
class Data < Struct.new(:file_colon_line, :covered_files)
end

def initialize(scenario_or_table_row)
@scenario_or_table_row = scenario_or_table_row
@analyzer = Rcov::CodeCoverageAnalyzer.new
@covered_files = []
end

def file_colon_line
@scenario_or_table_row.file_colon_line
end

def record_file(source_file)
@covered_files << source_file unless @covered_files.include?(source_file)
end
Expand All @@ -17,5 +25,9 @@ def stop
@analyzer.remove_hook
@covered_files.concat @analyzer.analyzed_files
end

def to_data
Data.new(file_colon_line, @covered_files)
end
end
end
25 changes: 24 additions & 1 deletion lib/cucover/store.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
module Cucover
class Store
def initialize
if File.exists?(data_file)
puts "reading #{data_file}"
File.open(data_file) do |f|
@recordings = Marshal.load(f)
end
else
puts "no data - starting with a blank slate"
@recordings = {}
end
at_exit do
File.open(data_file, 'w') do |file|
file.puts Marshal.dump(@recordings)
end
end
end

def keep(recording)

@recordings[recording.file_colon_line] = recording.to_data
end

def fetch_recordings_covering(source_file)
[ FakeRecording.new ]
end

private

def data_file
Dir.pwd + '/cucover.data'
end

class FakeRecording
def feature_filename
"features/call_foo.feature"
Expand Down

0 comments on commit dc758e3

Please sign in to comment.