attic-cleanup 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +19 -1
- data/lib/attic-cleanup/initialize/init.rb +17 -2
- data/lib/attic-cleanup/path/custom.rb +21 -2
- data/lib/attic-cleanup/storage/store_files.rb +3 -1
- data/lib/attic-cleanup/utility.rb +6 -2
- data/lib/attic-cleanup.rb +2 -0
- metadata +5 -5
data/README.md
CHANGED
@@ -96,4 +96,22 @@ attic-cleanup new --name projects --path ~/MyProjects/CurrentProject
|
|
96
96
|
|
97
97
|
This will generate a new shortcut. The shortcut name will be @projects and the path will be ~/MyProjects/CurrentProject
|
98
98
|
|
99
|
-
You can always adjust shortcuts and default location in MyAttic folder.
|
99
|
+
You can always adjust shortcuts and default location in MyAttic folder.
|
100
|
+
|
101
|
+
Setting default with the 'default' command
|
102
|
+
==========================================
|
103
|
+
attic-cleanup default ~/MyProject
|
104
|
+
|
105
|
+
|
106
|
+
This will adjust the default location for the store command to ~/MyProject instead of Desktop
|
107
|
+
|
108
|
+
|
109
|
+
Adding files to ignore
|
110
|
+
========================
|
111
|
+
attic-cleanup ignore ~/Desktop/MyProject
|
112
|
+
|
113
|
+
This will add the path to MyProject to the ignore_files.txt file.
|
114
|
+
Every path in this file will be ignored if you try to store it (or all).
|
115
|
+
So let's say you want to store all the files that are on your desktop except the MyProject folder.
|
116
|
+
You just add it to the ignore_files.txt file or use the ignore command.
|
117
|
+
Once you try to store all the files on your Desktop, it will skip MyProjects folder.
|
@@ -4,6 +4,7 @@ module AtticCleanup
|
|
4
4
|
# Default text for the custom_paths.txt file
|
5
5
|
CUSTOM_FILE = "#Write all your custom paths here.
|
6
6
|
#Or generate them with the 'attic-cleanup new' command
|
7
|
+
#Write all your custom paths like the examples, no extra spaces.
|
7
8
|
doc #{File.join(ENV['HOME'], 'Documents')}
|
8
9
|
pic #{File.join(ENV['HOME'], 'Pictures')}
|
9
10
|
mus #{File.join(ENV['HOME'], 'Music')}
|
@@ -14,6 +15,18 @@ dow #{File.join(ENV['HOME'], 'Downloads')}"
|
|
14
15
|
DEFAULT_FILE = "#Write your default location here.
|
15
16
|
#{File.join(ENV['HOME'], 'Desktop')}"
|
16
17
|
|
18
|
+
# Default text for the ignore_files.txt file
|
19
|
+
IGNORE_FILE = "#Write all the files/folders you want to ignore here.
|
20
|
+
#Don't write any spaces before or after the paths, just write it like the examples.
|
21
|
+
#{File.join(ENV['HOME'], 'Desktop')}
|
22
|
+
#{File.join(ENV['HOME'], 'Documents')}
|
23
|
+
#{File.join(ENV['HOME'], 'Pictures')}
|
24
|
+
#{File.join(ENV['HOME'], 'Music')}
|
25
|
+
#{File.join(ENV['HOME'], 'Movies')}
|
26
|
+
#{File.join(ENV['HOME'], 'Downloads')}
|
27
|
+
#{File.join(ENV['HOME'], 'Dropbox')}
|
28
|
+
#{File.join(ENV['HOME'], 'MyAttic')}"
|
29
|
+
|
17
30
|
# Checks if folder exists, if it doesn't it will be created
|
18
31
|
def self.check_folder(value)
|
19
32
|
if !File.directory? value
|
@@ -31,6 +44,8 @@ dow #{File.join(ENV['HOME'], 'Downloads')}"
|
|
31
44
|
text = CUSTOM_FILE
|
32
45
|
elsif value == MyAttic::DEFAULT
|
33
46
|
text = DEFAULT_FILE
|
47
|
+
elsif value == MyAttic::IGNORE
|
48
|
+
text = IGNORE_FILE
|
34
49
|
end
|
35
50
|
w.write(text)
|
36
51
|
end
|
@@ -41,11 +56,11 @@ dow #{File.join(ENV['HOME'], 'Downloads')}"
|
|
41
56
|
def self.clear
|
42
57
|
attic_folders = Dir.glob(File.join(MyAttic::ATTIC, "*"));
|
43
58
|
attic_folders.each do |f|
|
44
|
-
if f == MyAttic::CUSTOM || f == MyAttic::LOG || f == MyAttic::TODAY || f == MyAttic::DEFAULT
|
59
|
+
if f == MyAttic::CUSTOM || f == MyAttic::LOG || f == MyAttic::TODAY || f == MyAttic::DEFAULT || f == MyAttic::IGNORE
|
45
60
|
elsif Dir[File.join(f, "/*")].empty?
|
46
61
|
FileUtils.rm_rf(f)
|
47
62
|
end
|
48
63
|
end
|
49
64
|
end
|
50
65
|
end
|
51
|
-
end
|
66
|
+
end
|
@@ -2,7 +2,7 @@ module AtticCleanup
|
|
2
2
|
module Path
|
3
3
|
class Custom
|
4
4
|
attr_accessor :name, :path, :file, :line_nr
|
5
|
-
|
5
|
+
|
6
6
|
# Gets the last line in the default_path.txt file,
|
7
7
|
# which is the path to the default route
|
8
8
|
def self.default
|
@@ -76,6 +76,19 @@ module AtticCleanup
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
def self.check_ignore(file)
|
80
|
+
is_file = false
|
81
|
+
lines = []
|
82
|
+
File.open(MyAttic::IGNORE, 'r') do |r|
|
83
|
+
while line = r.gets do
|
84
|
+
if line == file || line == file+"\n"
|
85
|
+
is_file = true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
is_file
|
90
|
+
end
|
91
|
+
|
79
92
|
# Write to the custom_paths.txt file
|
80
93
|
def write
|
81
94
|
File.open(@file, 'a') do |w|
|
@@ -83,7 +96,13 @@ module AtticCleanup
|
|
83
96
|
end
|
84
97
|
end
|
85
98
|
|
86
|
-
def self.
|
99
|
+
def self.set_ignore(value)
|
100
|
+
File.open(MyAttic::IGNORE, 'a') do |w|
|
101
|
+
w.write("\n"+value)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.set_default(value)
|
87
106
|
File.open(MyAttic::DEFAULT, 'w') do |w|
|
88
107
|
w.write("#Write your default location here.\n#{value}")
|
89
108
|
end
|
@@ -124,12 +124,14 @@ module AtticCleanup
|
|
124
124
|
|
125
125
|
# Moves each file to the MyAttic folder
|
126
126
|
@bundle_items.each do |b|
|
127
|
+
selected_file = File.join( location, AtticCleanup::Storage::FolderFiles.find(folder_files.all_files, b) )
|
127
128
|
# If the file wasn't found, print error
|
128
129
|
if AtticCleanup::Storage::FolderFiles.find(folder_files.all_files, b) == nil
|
129
130
|
puts "File ID " + b.to_s + " was not found"
|
131
|
+
elsif AtticCleanup::Path::Custom.check_ignore(selected_file) == true
|
132
|
+
puts "Ignored #{selected_file}"
|
130
133
|
else
|
131
134
|
# If file was found move it, print it and record it in the log
|
132
|
-
selected_file = File.join( location, AtticCleanup::Storage::FolderFiles.find(folder_files.all_files, b) )
|
133
135
|
puts "Moving " + selected_file + " to your attic.."
|
134
136
|
AtticCleanup::Log.save(selected_file, MyAttic::TODAY)
|
135
137
|
FileUtils.mv(selected_file, MyAttic::TODAY)
|
@@ -56,9 +56,13 @@ module AtticCleanup
|
|
56
56
|
|
57
57
|
desc "default", "Set a default path for store."
|
58
58
|
def default(input)
|
59
|
-
AtticCleanup::Path::Custom.
|
59
|
+
AtticCleanup::Path::Custom.set_default(input)
|
60
60
|
end
|
61
61
|
|
62
|
+
desc "ignore", "Add a file or folder you want to ignore."
|
63
|
+
def ignore(input)
|
64
|
+
AtticCleanup::Path::Custom.set_ignore(input)
|
65
|
+
end
|
62
66
|
desc "shortcuts", "View all available shortcuts"
|
63
67
|
# Show all the availible shortcuts from the custom_paths.txt file
|
64
68
|
def shortcuts
|
@@ -67,4 +71,4 @@ module AtticCleanup
|
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
70
|
-
end
|
74
|
+
end
|
data/lib/attic-cleanup.rb
CHANGED
@@ -25,6 +25,7 @@ module MyAttic
|
|
25
25
|
TODAY = File.join(ENV["HOME"], "MyAttic", Date.today.to_s)
|
26
26
|
CUSTOM = File.join(ENV["HOME"], "MyAttic/custom_paths.txt")
|
27
27
|
DEFAULT = File.join(ENV["HOME"], "MyAttic/default_path.txt")
|
28
|
+
IGNORE = File.join(ENV["HOME"], "MyAttic/ignore_files.txt")
|
28
29
|
LOG = File.join(ENV["HOME"], "MyAttic/log.txt")
|
29
30
|
|
30
31
|
# Checks if all the folders and files exist, also deletes any empty folders
|
@@ -32,6 +33,7 @@ module MyAttic
|
|
32
33
|
AtticCleanup::Init.check_folder(MyAttic::TODAY)
|
33
34
|
AtticCleanup::Init.check_file(MyAttic::DEFAULT)
|
34
35
|
AtticCleanup::Init.check_file(MyAttic::CUSTOM)
|
36
|
+
AtticCleanup::Init.check_file(MyAttic::IGNORE)
|
35
37
|
AtticCleanup::Init.clear
|
36
38
|
|
37
39
|
# This constant is set after the initializers because it reads
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attic-cleanup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &74494500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *74494500
|
25
25
|
description:
|
26
26
|
email: kevin.van.rooijen@gmail.com
|
27
27
|
executables:
|
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.8.
|
62
|
+
rubygems_version: 1.8.10
|
63
63
|
signing_key:
|
64
64
|
specification_version: 3
|
65
65
|
summary: attic-cleanup is a gem to easily store your files when you need to get them
|