attic-cleanup 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -0
- data/lib/attic-cleanup.rb +8 -6
- data/lib/attic-cleanup/initialize/init.rb +6 -5
- data/lib/attic-cleanup/path/custom.rb +12 -1
- data/lib/attic-cleanup/storage/store_files.rb +16 -9
- data/lib/attic-cleanup/utility.rb +22 -13
- metadata +4 -4
data/README.md
CHANGED
@@ -81,6 +81,15 @@ Type y to continue or type n to exit.
|
|
81
81
|
Once you press y all the file will be moved to the MyAttic folder and every file will be printed in the log.txt file.
|
82
82
|
|
83
83
|
|
84
|
+
Last Example: I want to send certain files in a folder to a different folder, but not the MyAttic folder
|
85
|
+
========================================================================================================
|
86
|
+
attic-cleanup store @doc @projects
|
87
|
+
|
88
|
+
|
89
|
+
This line will give you the option to send files / folders from @doc to @projects.
|
90
|
+
|
91
|
+
This works exactly the same way as storing files to the MyAttic folder, except you're storing your files to a different location
|
92
|
+
|
84
93
|
Checking which shortcuts are available
|
85
94
|
======================================
|
86
95
|
attic-cleanup shortcuts
|
data/lib/attic-cleanup.rb
CHANGED
@@ -22,15 +22,17 @@ require File.expand_path("../../lib/attic-cleanup/initialize/init", __FILE__)
|
|
22
22
|
# All the constants and initializers
|
23
23
|
module MyAttic
|
24
24
|
ATTIC = File.join(ENV["HOME"], "MyAttic")
|
25
|
-
TODAY = File.join(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
TODAY = File.join(MyAttic::ATTIC, Date.today.to_s)
|
26
|
+
CONFIG = File.join(MyAttic::ATTIC, "config")
|
27
|
+
CUSTOM = File.join(MyAttic::CONFIG, "custom_paths.txt")
|
28
|
+
DEFAULT = File.join(MyAttic::CONFIG, "default_path.txt")
|
29
|
+
IGNORE = File.join(MyAttic::CONFIG, "ignore_files.txt")
|
30
|
+
LOG = File.join(MyAttic::CONFIG, "log.txt")
|
30
31
|
|
31
32
|
# Checks if all the folders and files exist, also deletes any empty folders
|
32
33
|
AtticCleanup::Init.check_folder(MyAttic::ATTIC)
|
33
34
|
AtticCleanup::Init.check_folder(MyAttic::TODAY)
|
35
|
+
AtticCleanup::Init.check_folder(MyAttic::CONFIG)
|
34
36
|
AtticCleanup::Init.check_file(MyAttic::DEFAULT)
|
35
37
|
AtticCleanup::Init.check_file(MyAttic::CUSTOM)
|
36
38
|
AtticCleanup::Init.check_file(MyAttic::IGNORE)
|
@@ -39,4 +41,4 @@ module MyAttic
|
|
39
41
|
# This constant is set after the initializers because it reads
|
40
42
|
# the custom_paths.txt file. And it needs to be created first.
|
41
43
|
SHORTCUTS = AtticCleanup::Path::Custom.all(MyAttic::CUSTOM)
|
42
|
-
end
|
44
|
+
end
|
@@ -5,11 +5,13 @@ module AtticCleanup
|
|
5
5
|
CUSTOM_FILE = "#Write all your custom paths here.
|
6
6
|
#Or generate them with the 'attic-cleanup new' command
|
7
7
|
#Write all your custom paths like the examples, no extra spaces.
|
8
|
+
des #{File.join(ENV['HOME'], 'Desktop')}
|
8
9
|
doc #{File.join(ENV['HOME'], 'Documents')}
|
9
10
|
pic #{File.join(ENV['HOME'], 'Pictures')}
|
10
11
|
mus #{File.join(ENV['HOME'], 'Music')}
|
11
12
|
mov #{File.join(ENV['HOME'], 'Movies')}
|
12
|
-
dow #{File.join(ENV['HOME'], 'Downloads')}
|
13
|
+
dow #{File.join(ENV['HOME'], 'Downloads')}
|
14
|
+
dro #{File.join(ENV['HOME'], 'Dropbox')}"
|
13
15
|
|
14
16
|
# Default text for the default_path.txt file
|
15
17
|
DEFAULT_FILE = "#Write your default location here.
|
@@ -24,8 +26,7 @@ dow #{File.join(ENV['HOME'], 'Downloads')}"
|
|
24
26
|
#{File.join(ENV['HOME'], 'Music')}
|
25
27
|
#{File.join(ENV['HOME'], 'Movies')}
|
26
28
|
#{File.join(ENV['HOME'], 'Downloads')}
|
27
|
-
#{File.join(ENV['HOME'], 'Dropbox')}
|
28
|
-
#{File.join(ENV['HOME'], 'MyAttic')}"
|
29
|
+
#{File.join(ENV['HOME'], 'Dropbox')}\n#{File.join(ENV['HOME'], 'MyAttic')}"
|
29
30
|
|
30
31
|
# Checks if folder exists, if it doesn't it will be created
|
31
32
|
def self.check_folder(value)
|
@@ -56,11 +57,11 @@ dow #{File.join(ENV['HOME'], 'Downloads')}"
|
|
56
57
|
def self.clear
|
57
58
|
attic_folders = Dir.glob(File.join(MyAttic::ATTIC, "*"));
|
58
59
|
attic_folders.each do |f|
|
59
|
-
if f == MyAttic::
|
60
|
+
if f == MyAttic::TODAY
|
60
61
|
elsif Dir[File.join(f, "/*")].empty?
|
61
62
|
FileUtils.rm_rf(f)
|
62
63
|
end
|
63
64
|
end
|
64
|
-
end
|
65
|
+
end
|
65
66
|
end
|
66
67
|
end
|
@@ -15,6 +15,17 @@ module AtticCleanup
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def check_shortcut(input)
|
19
|
+
if input[0..0] == "@"
|
20
|
+
c = AtticCleanup::Path::Custom.new
|
21
|
+
# The input without the first character (the @ sign)
|
22
|
+
c.name = input[1..-1]
|
23
|
+
c.file = MyAttic::CUSTOM
|
24
|
+
input = c.find_custom
|
25
|
+
end
|
26
|
+
input
|
27
|
+
end
|
28
|
+
|
18
29
|
# Selects every line from the selected file
|
19
30
|
# but ignores lines where the first character is '#'
|
20
31
|
def self.all(file)
|
@@ -66,7 +77,7 @@ module AtticCleanup
|
|
66
77
|
end
|
67
78
|
end
|
68
79
|
if selected_line == nil
|
69
|
-
puts "Shortcut not found"
|
80
|
+
puts "Shortcut not found '@#{@name}'"
|
70
81
|
exit 1
|
71
82
|
else
|
72
83
|
the_name_count = the_name.count("A-z, \s")
|
@@ -3,6 +3,8 @@ module AtticCleanup
|
|
3
3
|
module Storage
|
4
4
|
class StoreFiles
|
5
5
|
|
6
|
+
attr_accessor :destination
|
7
|
+
|
6
8
|
# Easy method for input
|
7
9
|
def input
|
8
10
|
STDOUT.flush
|
@@ -17,7 +19,7 @@ module AtticCleanup
|
|
17
19
|
# If the location wasn't set, the default
|
18
20
|
# location will be used from the default_path.txt file
|
19
21
|
def location= ( value )
|
20
|
-
if value == ""
|
22
|
+
if value == "" || value == nil
|
21
23
|
value = AtticCleanup::Path::Custom.default
|
22
24
|
elsif value == "."
|
23
25
|
Dir.chdir(".")
|
@@ -26,11 +28,15 @@ module AtticCleanup
|
|
26
28
|
end
|
27
29
|
@location = value
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
# Checks if the selected path exists
|
31
33
|
def check
|
32
|
-
|
33
|
-
|
34
|
+
@check
|
35
|
+
end
|
36
|
+
|
37
|
+
def check=(value)
|
38
|
+
if !File.directory? value
|
39
|
+
puts "Invalid path " + value
|
34
40
|
exit 1
|
35
41
|
end
|
36
42
|
end
|
@@ -69,7 +75,8 @@ module AtticCleanup
|
|
69
75
|
i = 1
|
70
76
|
while i == 1
|
71
77
|
# Message with the current location and simple instructions
|
72
|
-
puts "\
|
78
|
+
puts "\nFrom: #{location}"
|
79
|
+
puts "To: #{destination}"
|
73
80
|
puts "Which files do you want to store in your attic?"
|
74
81
|
puts "Type ls for the list of items"
|
75
82
|
puts "Select the items by id. Example: 1,3,5"
|
@@ -133,12 +140,12 @@ module AtticCleanup
|
|
133
140
|
else
|
134
141
|
# If file was found move it, print it and record it in the log
|
135
142
|
puts "Moving " + selected_file + " to your attic.."
|
136
|
-
AtticCleanup::Log.save(selected_file,
|
137
|
-
FileUtils.mv(selected_file,
|
143
|
+
AtticCleanup::Log.save(selected_file, @destination)
|
144
|
+
FileUtils.mv(selected_file, @destination)
|
138
145
|
end
|
139
146
|
end
|
140
|
-
puts "The files have been moved to " +
|
147
|
+
puts "The files have been moved to " + @destination
|
141
148
|
end
|
142
149
|
end
|
143
150
|
end
|
144
|
-
end
|
151
|
+
end
|
@@ -6,11 +6,14 @@ module AtticCleanup
|
|
6
6
|
"Choose a path or shortcut to store the contents of the given folder.
|
7
7
|
custom paths are called by placing an '@' sign in front of it.
|
8
8
|
example: @mypath
|
9
|
+
You can also store from one place to another, example:
|
10
|
+
attic-cleanup store @doc @myproject
|
11
|
+
Now you can choose files / folders from the @doc path and send them to the @myproject folder.
|
9
12
|
|
10
13
|
-a => 'all'
|
11
14
|
-f => 'force'\n\n"
|
12
15
|
method_options :a => :boolean, :f => :boolean
|
13
|
-
def store(
|
16
|
+
def store(location="", destination="")
|
14
17
|
|
15
18
|
# Checks if the options are set
|
16
19
|
if options[:a]
|
@@ -19,21 +22,24 @@ module AtticCleanup
|
|
19
22
|
if options[:f]
|
20
23
|
f = true
|
21
24
|
end
|
22
|
-
|
23
|
-
# If the input for store has an "@" at the beginning
|
24
|
-
# it's a shortcut.
|
25
|
-
if input[0..0] == "@"
|
26
|
-
c = AtticCleanup::Path::Custom.new
|
27
|
-
# The input without the first character (the @ sign)
|
28
|
-
c.name = input[1..-1]
|
29
|
-
c.file = MyAttic::CUSTOM
|
30
|
-
input = c.find_custom
|
31
|
-
end
|
25
|
+
|
32
26
|
# The input is the location, if the input had an @ sign
|
33
27
|
# at the beginning, the custom path will be stored in input variable
|
28
|
+
c = AtticCleanup::Path::Custom.new
|
34
29
|
s = AtticCleanup::Storage::StoreFiles.new
|
35
|
-
|
36
|
-
|
30
|
+
if destination != nil && destination != ""
|
31
|
+
destination = c.check_shortcut(destination)
|
32
|
+
s.destination = destination
|
33
|
+
s.check = destination
|
34
|
+
else
|
35
|
+
destination = MyAttic::TODAY
|
36
|
+
s.destination = destination
|
37
|
+
s.check = s.destination
|
38
|
+
end
|
39
|
+
location = c.check_shortcut(location)
|
40
|
+
s.location = location
|
41
|
+
location = s.location
|
42
|
+
s.check = location
|
37
43
|
s.store(a, f)
|
38
44
|
end
|
39
45
|
|
@@ -56,6 +62,8 @@ module AtticCleanup
|
|
56
62
|
|
57
63
|
desc "default", "Set a default path for store."
|
58
64
|
def default(input)
|
65
|
+
c = AtticCleanup::Path::Custom.new
|
66
|
+
input = c.check_shortcut(input)
|
59
67
|
AtticCleanup::Path::Custom.set_default(input)
|
60
68
|
end
|
61
69
|
|
@@ -63,6 +71,7 @@ module AtticCleanup
|
|
63
71
|
def ignore(input)
|
64
72
|
AtticCleanup::Path::Custom.set_ignore(input)
|
65
73
|
end
|
74
|
+
|
66
75
|
desc "shortcuts", "View all available shortcuts"
|
67
76
|
# Show all the availible shortcuts from the custom_paths.txt file
|
68
77
|
def shortcuts
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ 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: &70362726577020 !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: *70362726577020
|
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.11
|
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
|