maid 0.1.0 → 0.1.1
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/.gitignore +2 -17
- data/.rvmrc +1 -0
- data/CONTRIBUTING.rdoc +1 -0
- data/Gemfile.lock +1 -1
- data/{README.rdoc → README.md} +50 -27
- data/TODO.rdoc +12 -0
- data/configure +7 -0
- data/lib/maid/rules.sample.rb +5 -3
- data/lib/maid/tools.rb +2 -0
- data/lib/maid/version.rb +1 -1
- metadata +25 -29
data/.gitignore
CHANGED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.8.7@maid --create
|
data/CONTRIBUTING.rdoc
CHANGED
@@ -9,6 +9,7 @@ To make things easier on you, I've compiled some Notes and Guidelines.
|
|
9
9
|
* This is a Ruby Gem, built using Bundler. For a walkthrough of how that works, see http://railscasts.com/episodes/245-new-gem-with-bundler.
|
10
10
|
* `rake install` builds and installs the gem, but you'll probably need to do `sudo rake install`. This lets you test the `maid` command.
|
11
11
|
* Keep in mind that the gemspec only looks at files in the VCS (git).
|
12
|
+
* Developing using Ruby 1.9.2? Use "irb -I lib -r maid" to have access to Maid in irb.
|
12
13
|
|
13
14
|
== Guidelines
|
14
15
|
|
data/Gemfile.lock
CHANGED
data/{README.rdoc → README.md}
RENAMED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# Maid
|
2
|
+
|
3
|
+
[](https://flattr.com/submit/auto?user_id=benjaminoakes&url=https://github.com/benjaminoakes/maid&title=maid&language=en_GB&tags=github&category=software)
|
2
4
|
|
3
5
|
Be lazy! Let Maid clean up after you, based on rules you define.
|
4
6
|
|
@@ -6,48 +8,69 @@ Maid keeps files from sitting around too long, untouched. Many of the downloads
|
|
6
8
|
|
7
9
|
Think of it like the email filters you might already have, but for files. Worried about things happening that you don't expect? Maid doesn't overwrite files and actions are logged so you can tell what happened.
|
8
10
|
|
9
|
-
Maid is inspired by the Mac OS X shareware program Hazel
|
11
|
+
Maid is inspired by the Mac OS X shareware program [Hazel](http://www.noodlesoft.com/hazel.php). This tool was created on Mac OS X 10.6, but should be generally portable to other systems. (Some of the more advanced features such as `downloaded_from` require OS X, however.)
|
10
12
|
|
11
13
|
Your rules are defined in Ruby, so easy rules are easy and difficult rules are possible.
|
12
14
|
|
13
|
-
http://
|
15
|
+

|
16
|
+
[](http://travis-ci.org/benjaminoakes/maid)
|
17
|
+
|
18
|
+
## Buzz
|
19
|
+
|
20
|
+
* [OneThingWell: Maid](http://onethingwell.org/post/30455088809/maid) (August 29th, 2012)
|
21
|
+
|
22
|
+
## Is it any good?
|
23
|
+
|
24
|
+
Yes.
|
25
|
+
|
26
|
+
## Installation
|
14
27
|
|
15
|
-
|
28
|
+
Maid supports OS X and Ubuntu. Other Unix-like operating systems may work, but are not officially supported. (Contributions are welcome, however.)
|
16
29
|
|
17
|
-
|
30
|
+
### OS X
|
18
31
|
|
19
|
-
|
32
|
+
Open a terminal and run:
|
20
33
|
|
21
|
-
gem install maid
|
34
|
+
gem install maid
|
22
35
|
|
23
36
|
If you want to install the executable for all users, you may need to give root access:
|
24
37
|
|
25
|
-
sudo gem install maid
|
38
|
+
sudo gem install maid
|
26
39
|
|
27
|
-
|
40
|
+
### Ubuntu
|
28
41
|
|
29
|
-
|
42
|
+
**Want easier installation?** Please make your voice heard in [issue #3](https://github.com/benjaminoakes/maid/issues/3).
|
43
|
+
|
44
|
+
You'll need Ruby and RubyGems installed. Open a terminal and run:
|
30
45
|
|
31
46
|
sudo apt-get install ruby
|
32
47
|
sudo apt-get install rubygems
|
33
48
|
|
34
|
-
You might also need to add the RubyGems
|
49
|
+
You might also need to add the RubyGems `bin` directory to your `$PATH`. For example, you might need to add something like this to your `~/.bashrc`:
|
35
50
|
|
36
51
|
export PATH="/var/lib/gems/1.8/bin:$PATH"
|
52
|
+
|
53
|
+
Then install Maid itself:
|
54
|
+
|
55
|
+
gem install maid
|
56
|
+
|
57
|
+
If you want to install the executable for all users, you may need to give root access:
|
37
58
|
|
38
|
-
|
59
|
+
sudo gem install maid
|
60
|
+
|
61
|
+
## Tutorial
|
39
62
|
|
40
63
|
Maid rules are defined using Ruby, with some common operations made easier with a small DSL (Domain Specific Language). Here's a sample:
|
41
64
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
65
|
+
Maid.rules do
|
66
|
+
rule 'Old files downloaded while developing/testing' do
|
67
|
+
dir('~/Downloads/*').each do |path|
|
68
|
+
if downloaded_from(path).any? {|u| u.match 'http://localhost'} && 1.week.since?(last_accessed(path))
|
69
|
+
trash(path)
|
70
|
+
end
|
47
71
|
end
|
48
72
|
end
|
49
73
|
end
|
50
|
-
end
|
51
74
|
|
52
75
|
Before you start running your rules, you'll likely want to be able to test them. Here's how:
|
53
76
|
|
@@ -56,12 +79,12 @@ Before you start running your rules, you'll likely want to be able to test them.
|
|
56
79
|
maid --noop
|
57
80
|
maid -n
|
58
81
|
|
59
|
-
To run your rules on demand, you can run
|
82
|
+
To run your rules on demand, you can run `maid` manually:
|
60
83
|
|
61
84
|
maid # Run the rules at ~/.maid/rules.rb, logging to ~/.maid/maid.log
|
62
85
|
maid -r some_rules.rb # Run the rules in the file 'some_rules.rb', logging to ~/.maid/maid.log
|
63
86
|
|
64
|
-
So, for example, if this is
|
87
|
+
So, for example, if this is `some_rules.rb`:
|
65
88
|
|
66
89
|
Maid.rules do
|
67
90
|
rule 'downloaded PDF books' do
|
@@ -79,31 +102,31 @@ This is the command to test, as well as some sample output:
|
|
79
102
|
mv "/Users/ben/Downloads/issue12.pdf" "/Users/ben/Books/"
|
80
103
|
mv "/Users/ben/Downloads/spring2011newsletter.pdf" "/Users/ben/Books/"
|
81
104
|
|
82
|
-
For more DSL helper methods, please see the documentation of Maid::Tools.
|
105
|
+
For more DSL helper methods, please see the documentation of [Maid::Tools](http://rubydoc.info/gems/maid/0.1.0/Maid/Tools).
|
83
106
|
|
84
|
-
|
107
|
+
### Automation
|
85
108
|
|
86
109
|
Once you get a hang for what you can do with Maid, let it do its stuff automatically throughout the day. You'll find your computer stays a little tidier with as you teach it how to handle your common files.
|
87
110
|
|
88
|
-
To do this, edit your crontab in your tool of choice and have it invoke the
|
111
|
+
To do this, edit your crontab in your tool of choice and have it invoke the `maid` command. The `--silent` option is provided to keep this from emailing you, if desired. A log of the actions taken is kept at `~/.maid/maid.log`.
|
89
112
|
|
90
113
|
Example for every day at 1am:
|
91
114
|
|
92
115
|
# minute hour day_of_month month day_of_week command_to_execute
|
93
116
|
0 1 * * * /bin/bash -li -c "maid --silent"
|
94
117
|
|
95
|
-
Both Mac OS X and Linux support callbacks when folders are changed, and that may be a forthcoming feature in Maid. That said, I find cron to take care of most of my needs.
|
118
|
+
Both Mac OS X and Linux support callbacks when folders are changed, and that may be a forthcoming feature in Maid. That said, I find `cron` to take care of most of my needs.
|
96
119
|
|
97
|
-
|
120
|
+
## Sample
|
98
121
|
|
99
122
|
For a sample rules file, run:
|
100
123
|
|
101
124
|
maid sample
|
102
125
|
|
103
|
-
|
126
|
+
## Warranty
|
104
127
|
|
105
128
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
106
129
|
|
107
|
-
|
130
|
+
## License
|
108
131
|
|
109
132
|
GPLv2. See LICENSE for a copy.
|
data/TODO.rdoc
CHANGED
@@ -4,6 +4,18 @@
|
|
4
4
|
|
5
5
|
Some of these might not happen, but they're being thought about. Feel free to add your own.
|
6
6
|
|
7
|
+
* "Push to S3" method (for backing up, etc)
|
8
|
+
* Classifiers and file-content based rules. Example:
|
9
|
+
* Take bills and bank statements, classify them as the type of document they are, and then rename them based on their content:
|
10
|
+
* ["eStatement.pdf", "eStatement (1).pdf", "eStatement (2).pdf", "statement-1c3f34d.pdf", "statement-2c53ad1.pdf", "document-34d1c3f.pdf", "document-3ad12c5.pdf"] => ['ING', 'ING', 'ING', 'Citi', 'Citi', 'UI', 'UI']
|
11
|
+
* For example, ING statements have a date found with the pattern /Your Savings Summary as of\s+(.*?)$/i, Citi statements have the pattern /Statement Closing Date.*?(\d\d\/\d\d\/\d\d\d\d)/im, etc. Map using the patterns and rules.
|
12
|
+
|
13
|
+
# (Define classification rules in some format here, naming one 'bank_statements' with the extraction rule 'date')
|
14
|
+
|
15
|
+
dir('~/Downloads/*.pdf').classify(as: 'bank_statements', extract: 'date').each do |original_path, classification, date|
|
16
|
+
move(original_path, "~/Bills/#{classification}/#{date.strftime(...)}.pdf")
|
17
|
+
end
|
18
|
+
|
7
19
|
* Daemon mode
|
8
20
|
* Menubar/system tray icon
|
9
21
|
* Import of rules from other programs
|
data/configure
ADDED
data/lib/maid/rules.sample.rb
CHANGED
@@ -8,11 +8,12 @@
|
|
8
8
|
#
|
9
9
|
# * Run `maid help`
|
10
10
|
# * Read the README at http://github.com/benjaminoakes/maid
|
11
|
-
# * For more DSL helper methods, please see the documentation of Maid::Tools.
|
11
|
+
# * For more DSL helper methods, please see the documentation of Maid::Tools at http://rubydoc.info/gems/maid/0.1.0/Maid/Tools
|
12
12
|
# * Come up with some cool tools of your own? Fork, make your changes, and send me a pull request on GitHub!
|
13
|
-
# * Ask me a question over email (hello@benjaminoakes.com) or
|
13
|
+
# * Ask me a question over email (hello@benjaminoakes.com) or Twitter (@benjaminoakes)
|
14
14
|
#
|
15
15
|
Maid.rules do
|
16
|
+
# NOTE: Currently, only Mac OS X supports `duration_s`.
|
16
17
|
rule 'MP3s likely to be music' do
|
17
18
|
dir('~/Downloads/*.mp3').each do |path|
|
18
19
|
if duration_s(path) > 30.0
|
@@ -20,7 +21,8 @@ Maid.rules do
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|
24
|
+
|
25
|
+
# NOTE: Currently, only Mac OS X supports `downloaded_from`.
|
24
26
|
rule 'Old files downloaded while developing/testing' do
|
25
27
|
dir('~/Downloads/*').each do |path|
|
26
28
|
if downloaded_from(path).any? {|u| u.match 'http://localhost' || u.match('http://staging.yourcompany.com') } && 1.week.since?(last_accessed(path))
|
data/lib/maid/tools.rb
CHANGED
@@ -114,6 +114,8 @@ module Maid::Tools
|
|
114
114
|
|
115
115
|
# Pulls and pushes the given git repository.
|
116
116
|
#
|
117
|
+
# You might also be interested in SparkleShare (http://sparkleshare.org/), a great git-based file syncronization project.
|
118
|
+
#
|
117
119
|
# git_piston('~/code/projectname')
|
118
120
|
def git_piston(path)
|
119
121
|
full_path = File.expand_path(path)
|
data/lib/maid/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Oakes
|
@@ -15,12 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-08-31 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name: thor
|
22
21
|
prerelease: false
|
23
|
-
|
22
|
+
name: thor
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
@@ -31,12 +31,12 @@ dependencies:
|
|
31
31
|
- 14
|
32
32
|
- 6
|
33
33
|
version: 0.14.6
|
34
|
+
requirement: *id001
|
34
35
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name: rake
|
38
37
|
prerelease: false
|
39
|
-
|
38
|
+
name: rake
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -47,12 +47,12 @@ dependencies:
|
|
47
47
|
- 8
|
48
48
|
- 7
|
49
49
|
version: 0.8.7
|
50
|
+
requirement: *id002
|
50
51
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
|
-
name: rspec
|
54
53
|
prerelease: false
|
55
|
-
|
54
|
+
name: rspec
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
58
|
- - ~>
|
@@ -63,12 +63,12 @@ dependencies:
|
|
63
63
|
- 5
|
64
64
|
- 0
|
65
65
|
version: 2.5.0
|
66
|
+
requirement: *id003
|
66
67
|
type: :development
|
67
|
-
version_requirements: *id003
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
|
-
name: timecop
|
70
69
|
prerelease: false
|
71
|
-
|
70
|
+
name: timecop
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -79,12 +79,12 @@ dependencies:
|
|
79
79
|
- 3
|
80
80
|
- 5
|
81
81
|
version: 0.3.5
|
82
|
+
requirement: *id004
|
82
83
|
type: :development
|
83
|
-
version_requirements: *id004
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name: ZenTest
|
86
85
|
prerelease: false
|
87
|
-
|
86
|
+
name: ZenTest
|
87
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
90
|
- - ~>
|
@@ -95,8 +95,8 @@ dependencies:
|
|
95
95
|
- 4
|
96
96
|
- 2
|
97
97
|
version: 4.4.2
|
98
|
+
requirement: *id005
|
98
99
|
type: :development
|
99
|
-
version_requirements: *id005
|
100
100
|
description: Be lazy. Let Maid clean up after you, based on rules you define.
|
101
101
|
email:
|
102
102
|
- hello@benjaminoakes.com
|
@@ -109,16 +109,18 @@ extra_rdoc_files: []
|
|
109
109
|
files:
|
110
110
|
- .gitignore
|
111
111
|
- .rspec
|
112
|
+
- .rvmrc
|
112
113
|
- .travis.yml
|
113
114
|
- CONTRIBUTING.rdoc
|
114
115
|
- Gemfile
|
115
116
|
- Gemfile.lock
|
116
117
|
- LICENSE
|
117
118
|
- Maidfile
|
118
|
-
- README.
|
119
|
+
- README.md
|
119
120
|
- Rakefile
|
120
121
|
- TODO.rdoc
|
121
122
|
- bin/maid
|
123
|
+
- configure
|
122
124
|
- lib/maid.rb
|
123
125
|
- lib/maid/app.rb
|
124
126
|
- lib/maid/maid.rb
|
@@ -165,15 +167,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
167
|
requirements: []
|
166
168
|
|
167
169
|
rubyforge_project: maid
|
168
|
-
rubygems_version: 1.
|
170
|
+
rubygems_version: 1.8.24
|
169
171
|
signing_key:
|
170
172
|
specification_version: 3
|
171
173
|
summary: Be lazy. Let Maid clean up after you, based on rules you define.
|
172
|
-
test_files:
|
173
|
-
|
174
|
-
- spec/lib/maid/maid_spec.rb
|
175
|
-
- spec/lib/maid/numeric_extensions_spec.rb
|
176
|
-
- spec/lib/maid/rule_spec.rb
|
177
|
-
- spec/lib/maid/tools_spec.rb
|
178
|
-
- spec/lib/maid_spec.rb
|
179
|
-
- spec/spec_helper.rb
|
174
|
+
test_files: []
|
175
|
+
|