require 'parser/parse' require 'parser/protections_table' require 'database/dir_tree' require 'configuration/config' require 'optimiser/transformer' require 'optimiser/outputter' require 'rubygems' require 'P4' require 'tree' require 'json/ext' require 'pry' include Config p "Requires Loaded" ft = Dir_Tree.new p4 = P4.new prot = Protections_Table.new(p4, ft) cp = Parse.new(Config::CHECKPOINT, ft, prot) unless File.exist?("json_xpost_parse") p "reading checkpoint" cp.read_in p "checkpoint processed" ft.remove_client_trees prot.apply_protections_to_tree p "protections have been applied to to the file tree" File.open('json_post_parse', 'w') do |file| file.write(ft.root.to_json(:max_nesting => 200)) end File.open('prot_table', 'w') do |file| file.write(prot.table) end p 'parsed data jsonified' else p "Checkpoint already parsed - loading that data" p "If this is incorrect, delete the file 'json_post_parse'" ft = File.open('json_post_parse', 'r') do |file| JSON.parse(file.gets, :max_nesting => 200) end prot.table = File.open('prot_table', 'r') do |file| JSON.parse(file.gets) end prot.ft = ft p 'json data has been read in' end trans = Transformer.new(ft.root, prot) trans.calculate_protections p "protections have been calculated" out = Outputter.new(trans.calculated_ft) p_table = out.output_tree(prot, ft) p "process finished" # "now performing test" #met = Metrics.new(p4, ft, prot.find_users_and_groups(), out) # #p 'pre-commencing' #met.before_opt #p 'post-commencing' #met.after_opt(prot) p p_table