Sha256: ec19beac7a34bb16d6ea0bf93429b59859277f4e01fae44d08da1862e9835205
Contents?: true
Size: 1.14 KB
Versions: 5
Compression:
Stored size: 1.14 KB
Contents
module Churn # responsible for storing the churn history to json, # and for loading old churn history data from json. class ChurnHistory #takes current revision and its hash_data and stores it def self.store_revision_history(revision, hash_data, data_directory) FileUtils.mkdir_p data_directory File.open("#{data_directory}/#{revision}.json", 'w') {|file| file.write(hash_data.to_json) } end #given a previous project revision find and load the churn data from a json file def self.load_revision_data(revision, data_directory) #load revision data from scratch folder if it exists filename = "#{data_directory}/#{revision}.json" if File.exist?(filename) begin json_data = File.read(filename) data = JSON.parse(json_data) changed_files = data['churn']['changed_files'] changed_classes = data['churn']['changed_classes'] changed_methods = data['churn']['changed_methods'] rescue JSON::ParserError #leave all of the objects nil end end [changed_files, changed_classes, changed_methods] end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
churn-1.0.8 | lib/churn/history.rb |
churn-1.0.7 | lib/churn/history.rb |
churn-1.0.6 | lib/churn/history.rb |
churn-1.0.5 | lib/churn/history.rb |
churn-1.0.4 | lib/churn/history.rb |