Module: AtticCleanup::Init
- Defined in:
- lib/attic-cleanup/initialize/init.rb
Constant Summary collapse
- CUSTOM_FILE =
Default text for the custom_paths.txt file
"#Write all your custom paths here. #Or generate them with the 'attic-cleanup new' command #Write all your custom paths like the examples, no extra spaces. des #{File.join(ENV['HOME'], 'Desktop')} doc #{File.join(ENV['HOME'], 'Documents')} pic #{File.join(ENV['HOME'], 'Pictures')} mus #{File.join(ENV['HOME'], 'Music')} mov #{File.join(ENV['HOME'], 'Movies')} dow #{File.join(ENV['HOME'], 'Downloads')} dro #{File.join(ENV['HOME'], 'Dropbox')}"
- DEFAULT_FILE =
Default text for the default_path.txt file
"#Write your default location here. #{File.join(ENV['HOME'], 'Desktop')}"
- IGNORE_FILE =
Default text for the ignore_files.txt file
"#Write all the files/folders you want to ignore here. #Don't write any spaces before or after the paths, just write it like the examples. #{File.join(ENV['HOME'], 'Desktop')} #{File.join(ENV['HOME'], 'Documents')} #{File.join(ENV['HOME'], 'Pictures')} #{File.join(ENV['HOME'], 'Music')} #{File.join(ENV['HOME'], 'Movies')} #{File.join(ENV['HOME'], 'Downloads')} #{File.join(ENV['HOME'], 'Dropbox')}\n#{File.join(ENV['HOME'], 'MyAttic')}"
Class Method Summary collapse
-
.check_file(value) ⇒ Object
Checks if file exists, if it doesn’t it will be created and depending on which file, the default text will be set.
-
.check_folder(value) ⇒ Object
Checks if folder exists, if it doesn’t it will be created.
-
.clear ⇒ Object
Delete all folders in MyAttic that are empty.
Class Method Details
.check_file(value) ⇒ Object
Checks if file exists, if it doesn’t it will be created and depending on which file, the default text will be set
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/attic-cleanup/initialize/init.rb', line 41 def self.check_file(value) if !File.exist?(value) File.open(value, 'w') do |w| if value == MyAttic::CUSTOM text = CUSTOM_FILE elsif value == MyAttic::DEFAULT text = DEFAULT_FILE elsif value == MyAttic::IGNORE text = IGNORE_FILE end w.write(text) end end end |
.check_folder(value) ⇒ Object
Checks if folder exists, if it doesn’t it will be created
32 33 34 35 36 37 |
# File 'lib/attic-cleanup/initialize/init.rb', line 32 def self.check_folder(value) if !File.directory? value FileUtils.mkdir(value) puts "#{value} doesn't exist yet.\nCreating #{value}.." end end |
.clear ⇒ Object
Delete all folders in MyAttic that are empty
57 58 59 60 61 62 63 64 65 |
# File 'lib/attic-cleanup/initialize/init.rb', line 57 def self.clear attic_folders = Dir.glob(File.join(MyAttic::ATTIC, "*")); attic_folders.each do |f| if f == MyAttic::TODAY elsif Dir[File.join(f, "/*")].empty? FileUtils.rm_rf(f) end end end |