class Wraith::FolderManager
Attributes
wraith[R]
Public Class Methods
new(config)
click to toggle source
# File lib/wraith/folder.rb, line 8 def initialize(config) @wraith = Wraith::Wraith.new(config) end
Public Instance Methods
clear_shots_folder()
click to toggle source
# File lib/wraith/folder.rb, line 33 def clear_shots_folder FileUtils.rm_rf("./#{dir}") FileUtils.mkdir_p("#{dir}") end
copy_base_images()
click to toggle source
# File lib/wraith/folder.rb, line 53 def copy_base_images logger.info "COPYING BASE IMAGES" wraith.paths.each do |path| path = path[0] logger.info "Copying #{history_dir}/#{path} to #{dir}" FileUtils.cp_r(Dir.glob("#{history_dir}/#{path}"), dir) end end
copy_old_shots()
click to toggle source
# File lib/wraith/folder.rb, line 38 def copy_old_shots if history_dir.nil? logger.error "no `history_dir` attribute found in config. Cannot copy files." else FileUtils.mkdir_p("#{history_dir}") FileUtils.cp_r("#{dir}/.", "#{history_dir}/") FileUtils.rm_rf("#{history_dir}/thumbnails") # thumbnails aren't generated until the gallery stage anyway FileUtils.rm_rf("#{dir}") # get rid of the live folder Dir["#{history_dir}/**/*.png"].each do |filepath| new_name = filepath.gsub("latest.png", "base.png") File.rename(filepath, new_name) end end end
create_folders()
click to toggle source
# File lib/wraith/folder.rb, line 62 def create_folders spider_paths.each do |folder_label, path| unless path path = folder_label folder_label = path.gsub("/", "__") end FileUtils.mkdir_p("#{dir}/thumbnails/#{folder_label}") FileUtils.mkdir_p("#{dir}/#{folder_label}") end logger.info "Creating Folders" end
dir()
click to toggle source
# File lib/wraith/folder.rb, line 12 def dir wraith.directory end
history_dir()
click to toggle source
# File lib/wraith/folder.rb, line 16 def history_dir wraith.history_dir end
paths()
click to toggle source
# File lib/wraith/folder.rb, line 20 def paths wraith.paths end
spider_paths()
click to toggle source
# File lib/wraith/folder.rb, line 24 def spider_paths if !paths paths = File.read(wraith.spider_file) eval(paths) else wraith.paths end end
threshold_rate(dirs)
click to toggle source
# File lib/wraith/folder.rb, line 86 def threshold_rate(dirs) dirs.each do |_folder_name, shot_info| shot_info.each do |_k, v| begin return false unless v.include?(:diff) return false if v[:data] > wraith.threshold rescue return true end end end end
tidy_shots_folder(dirs)
click to toggle source
# File lib/wraith/folder.rb, line 75 def tidy_shots_folder(dirs) if wraith.mode == "diffs_only" dirs.each do |folder_name, shot_info| if shot_info.none? { |_k, v| v[:data] > 0 } FileUtils.rm_rf("#{wraith.directory}/#{folder_name}") dirs.delete(folder_name) end end end end