Class: Wraith::FolderManager
- Inherits:
-
Object
- Object
- Wraith::FolderManager
- Defined in:
- lib/wraith/folder.rb
Instance Attribute Summary collapse
-
#wraith ⇒ Object
readonly
Returns the value of attribute wraith.
Instance Method Summary collapse
- #clear_shots_folder ⇒ Object
- #create_folders ⇒ Object
- #dir ⇒ Object
-
#initialize(config) ⇒ FolderManager
constructor
A new instance of FolderManager.
- #paths ⇒ Object
- #spider_paths ⇒ Object
-
#tidy_shots_folder(dirs) ⇒ Object
Tidy up the shots folder, removing uncessary files.
Constructor Details
#initialize(config) ⇒ FolderManager
Returns a new instance of FolderManager.
6 7 8 |
# File 'lib/wraith/folder.rb', line 6 def initialize(config) @wraith = Wraith::Wraith.new(config) end |
Instance Attribute Details
#wraith ⇒ Object (readonly)
Returns the value of attribute wraith.
4 5 6 |
# File 'lib/wraith/folder.rb', line 4 def wraith @wraith end |
Instance Method Details
#clear_shots_folder ⇒ Object
27 28 29 30 |
# File 'lib/wraith/folder.rb', line 27 def clear_shots_folder FileUtils.rm_rf("./#{dir}") FileUtils.mkdir_p("#{dir}") end |
#create_folders ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wraith/folder.rb', line 32 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 puts 'Creating Folders' end |
#dir ⇒ Object
10 11 12 |
# File 'lib/wraith/folder.rb', line 10 def dir wraith.directory end |
#paths ⇒ Object
14 15 16 |
# File 'lib/wraith/folder.rb', line 14 def paths wraith.paths end |
#spider_paths ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/wraith/folder.rb', line 18 def spider_paths if !paths paths = File.read(wraith.spider_file) eval(paths) else wraith.paths end end |
#tidy_shots_folder(dirs) ⇒ Object
Tidy up the shots folder, removing uncessary files
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/wraith/folder.rb', line 47 def tidy_shots_folder(dirs) if wraith.mode == 'diffs_only' dirs.each do |a, b| # If we are running in "diffs_only mode, and none of the variants show a difference # we remove the file from the shots folder if b.none? { |_k, v| v[:data] > 0 } FileUtils.rm_rf("#{wraith.directory}/#{a}") dirs.delete(a) end end end end |