lib/test_diff/storage.rb in test_diff-0.1.1 vs lib/test_diff/storage.rb in test_diff-0.1.2

- old
+ new

@@ -29,14 +29,16 @@ end coverage_data end end - def find_for(file) + def find_for(files, sub_folder = nil) results = [] - Dir["#{@folder}/**/*.yml"].each do |storage_file| - find_for_storage_file(results, storage_file, file) + root_folder = @folder + root_folder += "/#{sub_folder}" if sub_folder + Dir["#{root_folder}/**/*.yml"].each do |storage_file| + find_for_storage_file(results, storage_file, files) end results end def clear @@ -45,15 +47,22 @@ end end private - def find_for_storage_file(results, storage_file, file) + def find_for_storage_file(results, storage_file, files) YAML::Store.new(storage_file).transaction(true) do |store| - unless store[file].to_s.split(',').delete_if { |s| s == '' || s == '0' }.empty? - results << storage_file.gsub('.yml', '').gsub("#{@folder}/", '') + found_files = files & store.roots + found_files.each do |file| + if _active_file?(store[file]) + results << storage_file.gsub('.yml', '').gsub("#{@folder}/", '') + end end end + end + + def _active_file?(file) + !file.to_s.split(',').delete_if { |s| s == '' || s == '0' }.empty? end def get_store(file) dir = File.dirname("#{@folder}/#{file}") filename = File.basename(file) + '.yml'