maid 0.2.0.beta.1 → 0.2.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS.md ADDED
@@ -0,0 +1,7 @@
1
+ In alphabetical order:
2
+
3
+ * Benjamin Oakes (@benjaminoakes)
4
+ * Larry Lv (@larrylv)
5
+ * Lewis O'Driscoll (@loddy1234)
6
+ * Lloyd Philbrook (@phoolish)
7
+ * Mark Jaquith (@markjaquith)
data/ChangeLog CHANGED
@@ -1,6 +1,15 @@
1
+ maid (0.2.0.beta.2) unstable; urgency=low
2
+
3
+ * Add more documentation to "find" and "remove" (Closes: #74)
4
+ * Add logging to `mkdir` (Closes: #75, #77)
5
+ * Updated README to include Hacker News post
6
+ * Updated AUTHORS to include new contributors
7
+ * Various development improvements
8
+
9
+ -- Benjamin Oakes <hello@benjaminoakes.com> Sun, 16 Dec 2012 00:00:00 +0000
10
+
1
11
  maid (0.2.0.beta.1) unstable; urgency=low
2
12
 
3
- * (Development in progress)
4
13
  * Change "dir" to allow multiple paths (Closes: #64)
5
14
  * Change "mkdir" to return the path of the created directory (Closes: #69)
6
15
  * Various development improvements
data/README.md CHANGED
@@ -2,21 +2,38 @@
2
2
 
3
3
  Be lazy! Let Maid clean up after you, based on rules you define.
4
4
 
5
- [Installation](https://github.com/benjaminoakes/maid#installation) | [Tutorial](https://github.com/benjaminoakes/maid#tutorial) | [Example](https://github.com/benjaminoakes/maid-example) | [Documentation](http://rubydoc.info/gems/maid/Maid/Tools) | [Change Log](https://github.com/benjaminoakes/maid/blob/master/ChangeLog)
5
+ [Installation](https://github.com/benjaminoakes/maid#installation)
6
+ | [Tutorial](https://github.com/benjaminoakes/maid#tutorial)
7
+ | [Example](https://github.com/benjaminoakes/maid-example)
8
+ | [Documentation][]
9
+ | [Change Log](https://github.com/benjaminoakes/maid/blob/master/ChangeLog)
6
10
 
7
- Maid keeps files from sitting around too long, untouched. Many of the downloads and other files you collect can easily be categorized and handled appropriately by rules you define. Let the maid in your computer take care of the easy stuff, so you can spend more of your time on what matters.
11
+ Maid keeps files from sitting around too long, untouched. Many of the downloads and temporary files you collect can
12
+ easily be categorized and handled appropriately by rules you define. Let the `maid` in your computer take care of the
13
+ easy stuff, so you can spend more of your time on what matters.
8
14
 
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.
15
+ Think of it like the email filters you might already have, but for files. Worried about things happening that you don't
16
+ expect? Maid doesn't overwrite files and actions are logged so you can tell what happened.
10
17
 
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.)
18
+ Maid is inspired by the Mac OS X shareware program [Hazel](http://www.noodlesoft.com/hazel.php). Think of Maid as
19
+ **"Hazel for hackers"**.
12
20
 
13
- Your rules are defined in Ruby, so easy rules are easy and difficult rules are possible. This also makes Maid a great general-purpose **advanced file renaming tool**.
21
+ Your rules are defined in Ruby, so simple rules are easy and difficult rules are possible. This also makes Maid a great
22
+ general-purpose **advanced file renaming tool**.
14
23
 
15
24
  ## Want to help?
16
25
 
26
+ This project wouldn't be where it is today without its users and contributors. Thank you! See [AUTHORS][] and the
27
+ [contributors graph][] for more info.
28
+
29
+ [authors]: https://github.com/benjaminoakes/maid/blob/master/AUTHORS.md
30
+ [contributors graph]: https://github.com/benjaminoakes/maid/graphs/contributors
31
+
17
32
  ### For Users
18
33
 
19
- [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=benjaminoakes&url=https://github.com/benjaminoakes/maid&title=maid&language=en_GB&tags=github&category=software)
34
+ [
35
+ [Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)
36
+ ](https://flattr.com/submit/auto?user_id=benjaminoakes&url=https://github.com/benjaminoakes/maid&title=maid&language=en_GB&tags=github&category=software)
20
37
 
21
38
  * Participate in [beta testing](https://github.com/benjaminoakes/maid/issues/10)
22
39
  * [Report an issue](https://github.com/benjaminoakes/maid/issues) (bug or feature request)
@@ -29,13 +46,22 @@ Your rules are defined in Ruby, so easy rules are easy and difficult rules are p
29
46
  [![Build Status](https://secure.travis-ci.org/benjaminoakes/maid.png)](http://travis-ci.org/benjaminoakes/maid)
30
47
  [![Dependency Status](https://gemnasium.com/benjaminoakes/maid.png)](https://gemnasium.com/benjaminoakes/maid)
31
48
 
49
+ * Address a `TODO` or `FIXME` in the code.
32
50
  * Complete an issue (easy ones [are labelled](https://github.com/benjaminoakes/maid/issues?labels=difficulty-1&page=1&state=open), and issues for future releases are [grouped by milestone](https://github.com/benjaminoakes/maid/issues/milestones)).
33
51
  * **Working on an issue?** Please leave a comment so others know.
34
52
  * See the [Contributing guide](https://github.com/benjaminoakes/maid/wiki/Contributing)
35
53
 
36
54
  ## Buzz
37
55
 
38
- [![OneThingWell Logo](https://raw.github.com/benjaminoakes/maid/master/resources/OneThingWell.png)](http://onethingwell.org/)
56
+ [
57
+ ![Hacker News Logo](https://raw.github.com/benjaminoakes/maid/master/resources/hacker-news.png)
58
+ ](http://news.ycombinator.com/)
59
+
60
+ [Hazel for hackers](http://news.ycombinator.com/item?id=4928605) - December 16th, 2012 (peaked at #2)
61
+
62
+ [
63
+ ![OneThingWell Logo](https://raw.github.com/benjaminoakes/maid/master/resources/OneThingWell.png)
64
+ ](http://onethingwell.org/)
39
65
 
40
66
  [Maid](http://onethingwell.org/post/30455088809/maid) - August 29th, 2012
41
67
 
@@ -47,21 +73,25 @@ Your rules are defined in Ruby, so easy rules are easy and difficult rules are p
47
73
 
48
74
  ## Installation
49
75
 
50
- [![Download for Ubuntu](https://github.com/benjaminoakes/maid/raw/master/resources/download-for-ubuntu.png)](https://github.com/benjaminoakes/maid/issues/3)
76
+ [
77
+ ![Download for Ubuntu](https://github.com/benjaminoakes/maid/raw/master/resources/download-for-ubuntu.png)
78
+ ](https://github.com/benjaminoakes/maid/issues/3)
51
79
 
52
80
  #### Offically supported:
53
81
 
54
82
  * **OS:** Mac OS X, Ubuntu
55
83
  * **Ruby:** 1.8.7, 1.9.3 (preferred)
56
84
 
57
- (Other Ruby versions and OSes may work, but are not officially supported. Contributions are welcome, however.)
85
+ Some features require OS X. See the [documentation][] for more details. Other Ruby versions and Linux distributions
86
+ may work, but are not officially supported. (Contributions are welcome, however.)
58
87
 
59
88
  ### Manual Installation
60
89
 
61
90
  First, you need Ruby:
62
91
 
63
92
  * **Mac OS X:** Ruby 1.8.7 comes preinstalled.
64
- * **Ubuntu:** Ruby is not preinstalled. To install Ruby 1.9.3: `sudo apt-get install ruby1.9.1 # (sic)` ([Interested in a package?](https://github.com/benjaminoakes/maid/issues/3))
93
+ * **Ubuntu:** Ruby is not preinstalled. To install Ruby 1.9.3: `sudo apt-get install ruby1.9.1 # (sic)`
94
+ ([Interested in a package?](https://github.com/benjaminoakes/maid/issues/3))
65
95
 
66
96
  Then, you can install via RubyGems. Open a terminal and run:
67
97
 
@@ -79,12 +109,15 @@ If you decide you don't want Maid installed anymore, remove it:
79
109
 
80
110
  ### Troubleshooting
81
111
 
82
- * Having multiple Ruby versions installed can confuse things. If you're a Ruby developer, you may prefer to just `gem install maid` with your preferred setup. Ruby 1.9.3 is recommended.
83
- * Older packages of Ruby for Ubuntu may not automatically add the RubyGems `bin` directory to your `$PATH`. Double check your settings.
112
+ * Having multiple Ruby versions installed can confuse things. If you're a Ruby developer, you may prefer to just
113
+ `gem install maid` with your preferred setup. Ruby 1.9.3 is recommended.
114
+ * Older packages of Ruby for Ubuntu may not automatically add the RubyGems `bin` directory to your `$PATH`. Double
115
+ check your settings.
84
116
 
85
117
  ## Tutorial
86
118
 
87
- In a nutshell, Maid uses "rules" to define how files are handled. Once you have rules defined, you can either test what cleaning would do (`maid clean -n`) or actually clean (`maid clean`).
119
+ In a nutshell, Maid uses "rules" to define how files are handled. Once you have rules defined, you can either test what
120
+ cleaning would do (`maid clean -n`) or actually clean (`maid clean`).
88
121
 
89
122
  To generate a [sample rules file](https://github.com/benjaminoakes/maid/blob/master/lib/maid/rules.sample.rb), run:
90
123
 
@@ -152,29 +185,38 @@ Then, this is the command to test, as well as some sample output:
152
185
  mv "/Users/ben/Downloads/issue12.pdf" "/Users/ben/Books/"
153
186
  mv "/Users/ben/Downloads/spring2011newsletter.pdf" "/Users/ben/Books/"
154
187
 
155
- For help with command line usage, run `maid help`. For more DSL helper methods, please see the documentation of [Maid::Tools](http://rubydoc.info/gems/maid/Maid/Tools).
188
+ For help with command line usage, run `maid help`. For more help, please see the links at the top of this README.
156
189
 
157
190
  ### Automation
158
191
 
159
- 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.
192
+ Once you get a hang for what you can do with Maid, let it do its stuff automatically throughout the day. You'll find
193
+ your computer stays a little tidier with as you teach it how to handle your common files.
160
194
 
161
195
  To do this, edit your crontab in your tool of choice:
162
196
 
163
197
  crontab -e
164
198
 
165
- ...and have it invoke the `maid clean` 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`.
199
+ ...and have it invoke the `maid clean` command. The `--silent` option is provided to keep this from emailing you, if
200
+ desired. A log of the actions taken is kept at `~/.maid/maid.log`.
166
201
 
167
202
  Example for every day at 1am:
168
203
 
169
204
  # minute hour day_of_month month day_of_week command_to_execute
170
205
  0 1 * * * /bin/bash -li -c "maid clean --silent"
171
206
 
172
- Both Mac OS X and Ubuntu 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.
207
+ Both Mac OS X and Ubuntu support callbacks when folders are changed, and that may be a forthcoming feature in Maid.
208
+ That said, I find `cron` to take care of most of my needs.
173
209
 
174
210
  ## Warranty
175
211
 
176
- 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.
212
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING
213
+ THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
214
+ IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
215
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
216
+ ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
177
217
 
178
218
  ## License
179
219
 
180
220
  GPLv2. See LICENSE for a copy.
221
+
222
+ [documentation]: http://rubydoc.info/gems/maid/Maid/Tools
data/Vagrantfile CHANGED
@@ -4,6 +4,7 @@
4
4
  Vagrant::Config.run do |config|
5
5
  # See also: `script/vagrant-test`, `script/vagrant-test-all`
6
6
  config.vm.box = ENV['MAID_TARGET_BOX'] || 'precise64'
7
+ config.vm.box_url = 'http://files.vagrantup.com/precise64.box' if 'precise64' == config.vm.box
7
8
 
8
9
  config.vm.provision(:shell, :path => 'script/vagrant-provision', :args => ENV['MAID_TARGET_RUBY'] || '1.9.3')
9
10
  end
data/lib/maid/maid.rb CHANGED
@@ -4,6 +4,9 @@ require 'logger'
4
4
  require 'xdg'
5
5
 
6
6
  # Maid cleans up according to the given rules, logging what it does.
7
+ #
8
+ # TODO: Rename to something less ambiguous, e.g. "cleaning agent", "cleaner", "vacuum", etc. Having this class within
9
+ # the `Maid` module makes things confusing.
7
10
  class Maid::Maid
8
11
  DEFAULTS = {
9
12
  :progname => 'Maid',
@@ -1,5 +1,6 @@
1
1
  module Maid::NumericExtensions
2
- # From https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/numeric/time.rb, with some modifications since active_support ruins Logger by overriding its functionality.
2
+ # From https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/numeric/time.rb, with some
3
+ # modifications since `active_support` ruins `Logger` by overriding its functionality.
3
4
  module Time
4
5
  # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
5
6
  #
@@ -4,7 +4,8 @@
4
4
  #
5
5
  # maid clean -n
6
6
  #
7
- # **NOTE:** It's recommended you just use this as a template; if you run these rules on your machine without knowing what they do, you might run into unwanted results!
7
+ # **NOTE:** It's recommended you just use this as a template; if you run these rules on your machine without knowing
8
+ # what they do, you might run into unwanted results!
8
9
  #
9
10
  # Don't forget, it's just Ruby! You can define custom methods and use them below:
10
11
  #
@@ -21,7 +22,8 @@
21
22
  # * Ask me a question over email (hello@benjaminoakes.com) or Twitter (@benjaminoakes)
22
23
 
23
24
  Maid.rules do
24
- # **NOTE:** It's recommended you just use this as a template; if you run these rules on your machine without knowing what they do, you might run into unwanted results!
25
+ # **NOTE:** It's recommended you just use this as a template; if you run these rules on your machine without knowing
26
+ # what they do, you might run into unwanted results!
25
27
 
26
28
  rule 'Linux ISOs, etc' do
27
29
  trash(dir('~/Downloads/*.iso'))
@@ -63,7 +65,8 @@ Maid.rules do
63
65
  # NOTE: Currently, only Mac OS X supports `downloaded_from`.
64
66
  rule 'Old files downloaded while developing/testing' do
65
67
  dir('~/Downloads/*').each do |path|
66
- if downloaded_from(path).any? { |u| u.match('http://localhost') || u.match('http://staging.yourcompany.com') } && 1.week.since?(accessed_at(path))
68
+ if downloaded_from(path).any? { |u| u.match('http://localhost') || u.match('http://staging.yourcompany.com') } &&
69
+ 1.week.since?(accessed_at(path))
67
70
  trash(path)
68
71
  end
69
72
  end
data/lib/maid/tools.rb CHANGED
@@ -9,7 +9,8 @@ require 'time'
9
9
  # * Automatically expand paths (that is, `'~/Downloads/foo.zip'` becomes `'/home/username/Downloads/foo.zip'`)
10
10
  # * Respect the `noop` (`dry-run`) option if it is set
11
11
  #
12
- # Some methods are not available on all platforms. An `ArgumentError` is raised when a command is not available. See tags such as: [Mac OS X]
12
+ # Some methods are not available on all platforms. An `ArgumentError` is raised when a command is not available. See
13
+ # tags such as: [Mac OS X]
13
14
  module Maid::Tools
14
15
  include Deprecated
15
16
 
@@ -34,19 +35,22 @@ module Maid::Tools
34
35
  target = File.join(destination, File.basename(source))
35
36
 
36
37
  unless File.exist?(target)
37
- @logger.info("mv #{ source.inspect } #{ destination.inspect }")
38
+ log("mv #{ source.inspect } #{ destination.inspect }")
38
39
  FileUtils.mv(source, destination, @file_options)
39
40
  else
40
- @logger.warn("skipping #{ source.inspect } because #{ target.inspect } already exists")
41
+ warn("skipping #{ source.inspect } because #{ target.inspect } already exists")
41
42
  end
42
43
  end
43
44
  end
44
45
 
45
46
  # Move the given paths to the user's trash.
46
47
  #
47
- # The path is still moved if a file already exists in the trash with the same name. However, the current date and time is appended to the filename.
48
+ # The path is still moved if a file already exists in the trash with the same name. However, the current date and
49
+ # time is appended to the filename.
48
50
  #
49
- # **Note:** the OS-native "restore" or "put back" functionality for trashed files is not currently supported. (See [issue #63](https://github.com/benjaminoakes/maid/issues/63).) However, they can be restored manually, and the Maid log can help assist with this.
51
+ # **Note:** the OS-native "restore" or "put back" functionality for trashed files is not currently supported. (See
52
+ # [issue #63](https://github.com/benjaminoakes/maid/issues/63).) However, they can be restored manually, and the Maid
53
+ # log can help assist with this.
50
54
  #
51
55
  # ## Options
52
56
  #
@@ -69,13 +73,18 @@ module Maid::Tools
69
73
  def trash(paths, options = {})
70
74
  # ## Implementation Notes
71
75
  #
72
- # Trashing files correctly is surprisingly hard. What Maid ends up doing is one the easiest, most foolproof solutions: moving the file.
76
+ # Trashing files correctly is surprisingly hard. What Maid ends up doing is one the easiest, most foolproof
77
+ # solutions: moving the file.
73
78
  #
74
- # Unfortunately, that means it's not possile to restore files automatically in OSX or Ubuntu. The previous location of the file is lost.
79
+ # Unfortunately, that means it's not possile to restore files automatically in OSX or Ubuntu. The previous location
80
+ # of the file is lost.
75
81
  #
76
- # OSX support depends on AppleScript or would require a not-yet-written C extension to interface with the OS. The AppleScript solution is less than ideal: the user has to be logged in, Finder has to be running, and it makes the "trash can sound" every time a file is moved.
82
+ # OSX support depends on AppleScript or would require a not-yet-written C extension to interface with the OS. The
83
+ # AppleScript solution is less than ideal: the user has to be logged in, Finder has to be running, and it makes the
84
+ # "trash can sound" every time a file is moved.
77
85
  #
78
- # Ubuntu makes it easy to implement, and there's a Python library for doing so (see `trash-cli`). However, there's not a Ruby equivalent yet.
86
+ # Ubuntu makes it easy to implement, and there's a Python library for doing so (see `trash-cli`). However, there's
87
+ # not a Ruby equivalent yet.
79
88
 
80
89
  expand_all(paths).each do |path|
81
90
  target = File.join(@trash_path, File.basename(path))
@@ -98,6 +107,8 @@ module Maid::Tools
98
107
  end
99
108
 
100
109
  # Delete the files at the given path recursively.
110
+ #
111
+ # **NOTE**: In most cases, `trash` is a safer choice, since the files will be recoverable by retreiving them from the trash. Once you delete a file using `remove`, it's gone! Please use `trash` whenever possible and only use `remove` when necessary.
101
112
  #
102
113
  # ## Options
103
114
  #
@@ -107,7 +118,7 @@ module Maid::Tools
107
118
  #
108
119
  # `:secure => boolean`
109
120
  #
110
- # Infrequently needed. See [`FileUtils.remove_entry_secure`](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure)
121
+ # Infrequently needed. See [`FileUtils.remove_entry_secure`][fures]
111
122
  #
112
123
  # ## Examples
113
124
  #
@@ -119,18 +130,21 @@ module Maid::Tools
119
130
  #
120
131
  # remove(['~/Downloads/foo.zip', '~/Downloads/bar.zip'])
121
132
  # remove(dir('~/Downloads/*.zip'))
133
+ #
134
+ # [fures]: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure
122
135
  def remove(paths, options = {})
123
136
  expand_all(paths).each do |path|
124
137
  options = @file_options.merge(options)
125
138
 
126
- @logger.info("Removing #{ path.inspect }")
139
+ log("Removing #{ path.inspect }")
127
140
  FileUtils.rm_r(path, options)
128
141
  end
129
142
  end
130
143
 
131
144
  # Give all files matching the given glob.
132
145
  #
133
- # Note that the globs are *not* regexps (they're closer to shell globs). However, some regexp-like notation can be used, e.g. `?`, `[a-z]`, `{tgz,zip}`. For more details, see Ruby's documentation on `Dir.glob`.
146
+ # Note that the globs are *not* regexps (they're closer to shell globs). However, some regexp-like notation can be
147
+ # used, e.g. `?`, `[a-z]`, `{tgz,zip}`. For more details, see Ruby's documentation on `Dir.glob`.
134
148
  #
135
149
  # The matches are sorted lexically to aid in readability when using `--dry-run`.
136
150
  #
@@ -177,7 +191,8 @@ module Maid::Tools
177
191
  # move('~/Downloads/Pink Floyd*.mp3', mkdir('~/Music/Pink Floyd/'))
178
192
  def mkdir(path, options = {})
179
193
  path = expand(path)
180
- FileUtils.mkdir_p(path, options)
194
+ log("mkdir -p #{ path.inspect }")
195
+ FileUtils.mkdir_p(path, options) # @file_options.merge(options))
181
196
  path
182
197
  end
183
198
 
@@ -191,6 +206,12 @@ module Maid::Tools
191
206
  #
192
207
  # find('~/Downloads/') # => [...]
193
208
  #
209
+ # Recursing and filtering using a regular expression:
210
+ #
211
+ # find('~/Downloads/').grep(/\.pdf$/)
212
+ #
213
+ # (**Note:** It's just Ruby, so any methods in `Array` and `Enumerable` can be used.)
214
+ #
194
215
  # Recursing with a block:
195
216
  #
196
217
  # find('~/Downloads/') do |path|
@@ -315,7 +336,8 @@ module Maid::Tools
315
336
  #
316
337
  # Pull and push the `git` repository at the given path.
317
338
  #
318
- # Since this is deprecated, you might also be interested in [SparkleShare](http://sparkleshare.org/), a great `git`-based file syncronization project.
339
+ # Since this is deprecated, you might also be interested in [SparkleShare](http://sparkleshare.org/), a great
340
+ # `git`-based file syncronization project.
319
341
  #
320
342
  # ## Examples
321
343
  #
@@ -323,7 +345,7 @@ module Maid::Tools
323
345
  def git_piston(path)
324
346
  full_path = expand(path)
325
347
  stdout = cmd("cd #{full_path.inspect} && git pull && git push 2>&1")
326
- @logger.info "Fired git piston on #{full_path.inspect}. STDOUT:\n\n#{stdout}"
348
+ log("Fired git piston on #{full_path.inspect}. STDOUT:\n\n#{stdout}")
327
349
  end
328
350
 
329
351
  deprecated :git_piston, 'SparkleShare (http://sparkleshare.org/)'
@@ -376,11 +398,19 @@ module Maid::Tools
376
398
 
377
399
  ops << '--delete' if options[:delete]
378
400
  stdout = cmd("rsync #{ ops.join(' ') } #{ from.inspect } #{ to.inspect } 2>&1")
379
- @logger.info("Fired sync from #{ from.inspect } to #{ to.inspect }. STDOUT:\n\n#{ stdout }")
401
+ log("Fired sync from #{ from.inspect } to #{ to.inspect }. STDOUT:\n\n#{ stdout }")
380
402
  end
381
403
 
382
404
  private
383
405
 
406
+ def log(message)
407
+ @logger.info(message)
408
+ end
409
+
410
+ def warn(message)
411
+ @logger.warn(message)
412
+ end
413
+
384
414
  def expand(path)
385
415
  File.expand_path(path)
386
416
  end
@@ -1,6 +1,7 @@
1
1
  # Migrate trash to correct directory on Linux due to a configuration bug in previous releases.
2
2
  #
3
- # It used to be that the default trash path was the same on every platform, so everything used to go to `~/.Trash` regardless of OS. (For what it's worth, that used to be the correct trash path on older releases of Ubuntu.)
3
+ # It used to be that the default trash path was the same on every platform, so everything used to go to `~/.Trash`
4
+ # regardless of OS. (For what it's worth, that used to be the correct trash path on older releases of Ubuntu.)
4
5
  module Maid
5
6
  module TrashMigration
6
7
  class << self
@@ -2,7 +2,8 @@ require 'ohai'
2
2
 
3
3
  # Version information for the host system, kind of like a browser's user agent string.
4
4
  #
5
- # This could potentially be a part of `Platform` or `VERSION` but both of those are used when building the gemspec, which can't depend on other gems.
5
+ # This could potentially be a part of `Platform` or `VERSION` but both of those are used when building the gemspec,
6
+ # which can't depend on other gems. FIXME: That's no longer accurate, so this could be `Platform.user_agent` instead.
6
7
  module Maid::UserAgent
7
8
  class << self
8
9
  # This used to be called `#to_s`, but that made things difficult when testing.
data/lib/maid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Maid
2
- VERSION = '0.2.0.beta.1'
2
+ VERSION = '0.2.0.beta.2'
3
3
  end
Binary file
@@ -1,12 +1,27 @@
1
+ require 'logger'
1
2
  require 'ohai'
3
+ require 'rbconfig'
4
+ require 'stringio'
2
5
  require 'xdg'
3
6
 
4
7
  # > What is Dependency Testing?
5
8
  # >
6
- # > Examines an application's requirements for pre-existing software, initial states and configuration in order to maintain proper functionality.
9
+ # > Examines an application's requirements for pre-existing software, initial states and configuration in order to
10
+ # > maintain proper functionality.
7
11
  # >
8
12
  # > -- http://sqa.fyicenter.com/FAQ/Software-QA-Testing/What_is_Dependency_Testing_.html
9
13
  describe 'Dependency expectations' do
14
+ describe Logger do
15
+ # Depending on the situation, `Logger` might have been overwritten to have a different interface. (I'm looking at you, Rails.)
16
+ it 'logs with the expected interface' do
17
+ io = StringIO.new
18
+ logger = Logger.new(io)
19
+ logger.info('my message')
20
+ logger.formatter = lambda { |_, _, _, msg| msg }
21
+ io.string.should match(/my message/)
22
+ end
23
+ end
24
+
10
25
  describe Ohai do
11
26
  before do
12
27
  @ohai = Ohai::System.new
@@ -27,11 +42,20 @@ describe 'Dependency expectations' do
27
42
  end
28
43
  end
29
44
 
45
+ describe RbConfig do
46
+ it 'identifies the host operating system' do
47
+ RbConfig::CONFIG['host_os'].should match(/[a-z]+/)
48
+ end
49
+ end
50
+
30
51
  describe XDG do
31
52
  it 'has DATA_HOME' do
32
- # FIXME: This test could be cleaner. We can't depend on the directory to already exist, even on systems that use the XDG standard. This seems safe enough for now.
53
+ # FIXME: This test could be cleaner. We can't depend on the directory to already exist, even on systems that use
54
+ # the XDG standard. This seems safe enough for now.
55
+ #
56
+ # More info:
33
57
  #
34
- # More info: [XDG Base Directory Specification](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
58
+ # * [XDG Base Directory Specification](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
35
59
  XDG['DATA_HOME'].to_s.should match(%r{^/.*?/\.local/share$})
36
60
  end
37
61
  end
@@ -163,7 +163,8 @@ module Maid
163
163
  end
164
164
 
165
165
  it 'lists multiple files in alphabetical order' do
166
- # It doesn't occur with `FakeFS` as far as I can tell, but Ubuntu (and possibly OS X) can give the results out of lexical order. That makes using the `dry-run` output difficult to use.
166
+ # It doesn't occur with `FakeFS` as far as I can tell, but Ubuntu (and possibly OS X) can give the results out
167
+ # of lexical order. That makes using the `dry-run` output difficult to use.
167
168
  Dir.stub(:glob) { %w(/home/foo/b.zip /home/foo/a.zip /home/foo/c.zip) }
168
169
  @maid.dir('~/Downloads/*.zip').should == %w(/home/foo/a.zip /home/foo/b.zip /home/foo/c.zip)
169
170
  end
@@ -191,6 +192,11 @@ module Maid
191
192
  File.exist?("#@home/Downloads/Music/Pink.Floyd").should be_true
192
193
  end
193
194
 
195
+ it 'should log the creation of the directory' do
196
+ @logger.should_receive(:info)
197
+ @maid.mkdir('~/Downlaods/Music/Pink.Floyd')
198
+ end
199
+
194
200
  it 'returns the path of the created directory' do
195
201
  @maid.mkdir('~/Reference/Foo').should == "#@home/Reference/Foo"
196
202
  end
@@ -341,7 +347,9 @@ module Maid
341
347
  end
342
348
 
343
349
  it 'should add multiple exlcude options' do
344
- @maid.should_receive(:cmd).with(%(rsync -a -u --exclude=".git" --exclude=".rvmrc" "#@home/Downloads/" "#@home/Reference" 2>&1))
350
+ @maid.
351
+ should_receive(:cmd).
352
+ with(%(rsync -a -u --exclude=".git" --exclude=".rvmrc" "#@home/Downloads/" "#@home/Reference" 2>&1))
345
353
  @maid.sync(@src_dir, @dst_dir, :exclude => ['.git', '.rvmrc'])
346
354
  end
347
355
 
@@ -4,7 +4,7 @@ module Maid
4
4
  describe UserAgent do
5
5
  describe 'the user agent string' do
6
6
  it 'is formatted with the Maid version, platform version, and Ruby version' do
7
- system = {
7
+ system = {
8
8
  'platform' => 'Unix',
9
9
  'platform_version' => '1.0',
10
10
  'languages' => {
@@ -13,14 +13,14 @@ module Maid
13
13
  'platform' => 'pdp7',
14
14
  }
15
15
  }
16
- }
16
+ }
17
17
 
18
- system.stub(:all_plugins)
18
+ system.stub(:all_plugins)
19
19
 
20
- Ohai::System.stub(:new) { system }
20
+ Ohai::System.stub(:new) { system }
21
21
  ::Maid.stub(:const_get).with(:VERSION) { '0.0.1' }
22
22
 
23
- UserAgent.value.should == 'Maid/0.0.1 (Unix/1.0; Ruby/1.8.8 pdp7)'
23
+ UserAgent.value.should == 'Maid/0.0.1 (Unix/1.0; Ruby/1.8.8 pdp7)'
24
24
  end
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,280 +1,194 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: maid
3
- version: !ruby/object:Gem::Version
4
- hash: 62196353
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0.beta.2
5
5
  prerelease: 6
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- - beta
11
- - 1
12
- version: 0.2.0.beta.1
13
6
  platform: ruby
14
- authors:
7
+ authors:
15
8
  - Benjamin Oakes
16
9
  autorequire:
17
10
  bindir: bin
18
11
  cert_chain: []
19
-
20
- date: 2012-12-02 00:00:00 -05:00
21
- default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
24
15
  name: thor
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &18495240 !ruby/object:Gem::Requirement
27
17
  none: false
28
- requirements:
18
+ requirements:
29
19
  - - ~>
30
- - !ruby/object:Gem::Version
31
- hash: 95
32
- segments:
33
- - 0
34
- - 16
35
- - 0
20
+ - !ruby/object:Gem::Version
36
21
  version: 0.16.0
37
22
  type: :runtime
38
- version_requirements: *id001
39
- - !ruby/object:Gem::Dependency
40
- name: deprecated
41
23
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *18495240
25
+ - !ruby/object:Gem::Dependency
26
+ name: deprecated
27
+ requirement: &18494620 !ruby/object:Gem::Requirement
43
28
  none: false
44
- requirements:
29
+ requirements:
45
30
  - - ~>
46
- - !ruby/object:Gem::Version
47
- hash: 5
48
- segments:
49
- - 3
50
- - 0
51
- - 1
31
+ - !ruby/object:Gem::Version
52
32
  version: 3.0.1
53
33
  type: :runtime
54
- version_requirements: *id002
55
- - !ruby/object:Gem::Dependency
56
- name: maid-xdg
57
34
  prerelease: false
58
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *18494620
36
+ - !ruby/object:Gem::Dependency
37
+ name: maid-xdg
38
+ requirement: &18493960 !ruby/object:Gem::Requirement
59
39
  none: false
60
- requirements:
61
- - - "="
62
- - !ruby/object:Gem::Version
63
- hash: 127
64
- segments:
65
- - 2
66
- - 2
67
- - 1
68
- - 2
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
69
43
  version: 2.2.1.2
70
44
  type: :runtime
71
- version_requirements: *id003
72
- - !ruby/object:Gem::Dependency
73
- name: ohai
74
45
  prerelease: false
75
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *18493960
47
+ - !ruby/object:Gem::Dependency
48
+ name: ohai
49
+ requirement: &18493180 !ruby/object:Gem::Requirement
76
50
  none: false
77
- requirements:
51
+ requirements:
78
52
  - - ~>
79
- - !ruby/object:Gem::Version
80
- hash: 23
81
- segments:
82
- - 6
83
- - 14
84
- - 0
53
+ - !ruby/object:Gem::Version
85
54
  version: 6.14.0
86
55
  type: :runtime
87
- version_requirements: *id004
88
- - !ruby/object:Gem::Dependency
89
- name: fakefs
90
56
  prerelease: false
91
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *18493180
58
+ - !ruby/object:Gem::Dependency
59
+ name: fakefs
60
+ requirement: &18492320 !ruby/object:Gem::Requirement
92
61
  none: false
93
- requirements:
62
+ requirements:
94
63
  - - ~>
95
- - !ruby/object:Gem::Version
96
- hash: 13
97
- segments:
98
- - 0
99
- - 4
100
- - 1
64
+ - !ruby/object:Gem::Version
101
65
  version: 0.4.1
102
66
  type: :development
103
- version_requirements: *id005
104
- - !ruby/object:Gem::Dependency
105
- name: guard
106
67
  prerelease: false
107
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *18492320
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: &18490420 !ruby/object:Gem::Requirement
108
72
  none: false
109
- requirements:
73
+ requirements:
110
74
  - - ~>
111
- - !ruby/object:Gem::Version
112
- hash: 11
113
- segments:
114
- - 1
115
- - 5
116
- - 4
75
+ - !ruby/object:Gem::Version
117
76
  version: 1.5.4
118
77
  type: :development
119
- version_requirements: *id006
120
- - !ruby/object:Gem::Dependency
121
- name: guard-rspec
122
78
  prerelease: false
123
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *18490420
80
+ - !ruby/object:Gem::Dependency
81
+ name: guard-rspec
82
+ requirement: &18475800 !ruby/object:Gem::Requirement
124
83
  none: false
125
- requirements:
84
+ requirements:
126
85
  - - ~>
127
- - !ruby/object:Gem::Version
128
- hash: 3
129
- segments:
130
- - 2
131
- - 3
132
- - 0
86
+ - !ruby/object:Gem::Version
133
87
  version: 2.3.0
134
88
  type: :development
135
- version_requirements: *id007
136
- - !ruby/object:Gem::Dependency
137
- name: rb-readline
138
89
  prerelease: false
139
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *18475800
91
+ - !ruby/object:Gem::Dependency
92
+ name: rb-readline
93
+ requirement: &18474560 !ruby/object:Gem::Requirement
140
94
  none: false
141
- requirements:
95
+ requirements:
142
96
  - - ~>
143
- - !ruby/object:Gem::Version
144
- hash: 11
145
- segments:
146
- - 0
147
- - 4
148
- - 2
97
+ - !ruby/object:Gem::Version
149
98
  version: 0.4.2
150
99
  type: :development
151
- version_requirements: *id008
152
- - !ruby/object:Gem::Dependency
153
- name: rake
154
100
  prerelease: false
155
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *18474560
102
+ - !ruby/object:Gem::Dependency
103
+ name: rake
104
+ requirement: &18473600 !ruby/object:Gem::Requirement
156
105
  none: false
157
- requirements:
106
+ requirements:
158
107
  - - ~>
159
- - !ruby/object:Gem::Version
160
- hash: 75
161
- segments:
162
- - 10
163
- - 0
164
- - 2
108
+ - !ruby/object:Gem::Version
165
109
  version: 10.0.2
166
110
  type: :development
167
- version_requirements: *id009
168
- - !ruby/object:Gem::Dependency
169
- name: redcarpet
170
111
  prerelease: false
171
- requirement: &id010 !ruby/object:Gem::Requirement
112
+ version_requirements: *18473600
113
+ - !ruby/object:Gem::Dependency
114
+ name: redcarpet
115
+ requirement: &18470360 !ruby/object:Gem::Requirement
172
116
  none: false
173
- requirements:
117
+ requirements:
174
118
  - - ~>
175
- - !ruby/object:Gem::Version
176
- hash: 3
177
- segments:
178
- - 2
179
- - 2
180
- - 2
119
+ - !ruby/object:Gem::Version
181
120
  version: 2.2.2
182
121
  type: :development
183
- version_requirements: *id010
184
- - !ruby/object:Gem::Dependency
185
- name: rspec
186
122
  prerelease: false
187
- requirement: &id011 !ruby/object:Gem::Requirement
123
+ version_requirements: *18470360
124
+ - !ruby/object:Gem::Dependency
125
+ name: rspec
126
+ requirement: &18469780 !ruby/object:Gem::Requirement
188
127
  none: false
189
- requirements:
128
+ requirements:
190
129
  - - ~>
191
- - !ruby/object:Gem::Version
192
- hash: 63
193
- segments:
194
- - 2
195
- - 12
196
- - 0
130
+ - !ruby/object:Gem::Version
197
131
  version: 2.12.0
198
132
  type: :development
199
- version_requirements: *id011
200
- - !ruby/object:Gem::Dependency
201
- name: timecop
202
133
  prerelease: false
203
- requirement: &id012 !ruby/object:Gem::Requirement
134
+ version_requirements: *18469780
135
+ - !ruby/object:Gem::Dependency
136
+ name: timecop
137
+ requirement: &18468940 !ruby/object:Gem::Requirement
204
138
  none: false
205
- requirements:
139
+ requirements:
206
140
  - - ~>
207
- - !ruby/object:Gem::Version
208
- hash: 13
209
- segments:
210
- - 0
211
- - 5
212
- - 3
141
+ - !ruby/object:Gem::Version
213
142
  version: 0.5.3
214
143
  type: :development
215
- version_requirements: *id012
216
- - !ruby/object:Gem::Dependency
217
- name: yard
218
144
  prerelease: false
219
- requirement: &id013 !ruby/object:Gem::Requirement
145
+ version_requirements: *18468940
146
+ - !ruby/object:Gem::Dependency
147
+ name: yard
148
+ requirement: &18468260 !ruby/object:Gem::Requirement
220
149
  none: false
221
- requirements:
150
+ requirements:
222
151
  - - ~>
223
- - !ruby/object:Gem::Version
224
- hash: 57
225
- segments:
226
- - 0
227
- - 8
228
- - 3
152
+ - !ruby/object:Gem::Version
229
153
  version: 0.8.3
230
154
  type: :development
231
- version_requirements: *id013
232
- - !ruby/object:Gem::Dependency
233
- name: rb-inotify
234
155
  prerelease: false
235
- requirement: &id014 !ruby/object:Gem::Requirement
156
+ version_requirements: *18468260
157
+ - !ruby/object:Gem::Dependency
158
+ name: rb-inotify
159
+ requirement: &18466100 !ruby/object:Gem::Requirement
236
160
  none: false
237
- requirements:
161
+ requirements:
238
162
  - - ~>
239
- - !ruby/object:Gem::Version
240
- hash: 47
241
- segments:
242
- - 0
243
- - 8
244
- - 8
163
+ - !ruby/object:Gem::Version
245
164
  version: 0.8.8
246
165
  type: :development
247
- version_requirements: *id014
248
- - !ruby/object:Gem::Dependency
249
- name: rb-fsevent
250
166
  prerelease: false
251
- requirement: &id015 !ruby/object:Gem::Requirement
167
+ version_requirements: *18466100
168
+ - !ruby/object:Gem::Dependency
169
+ name: rb-fsevent
170
+ requirement: &18465080 !ruby/object:Gem::Requirement
252
171
  none: false
253
- requirements:
172
+ requirements:
254
173
  - - ~>
255
- - !ruby/object:Gem::Version
256
- hash: 63
257
- segments:
258
- - 0
259
- - 9
260
- - 2
174
+ - !ruby/object:Gem::Version
261
175
  version: 0.9.2
262
176
  type: :development
263
- version_requirements: *id015
177
+ prerelease: false
178
+ version_requirements: *18465080
264
179
  description: Be lazy. Let Maid clean up after you, based on rules you define.
265
- email:
180
+ email:
266
181
  - hello@benjaminoakes.com
267
- executables:
182
+ executables:
268
183
  - maid
269
184
  extensions: []
270
-
271
185
  extra_rdoc_files: []
272
-
273
- files:
186
+ files:
274
187
  - .gitignore
275
188
  - .rspec
276
189
  - .rvmrc
277
190
  - .travis.yml
191
+ - AUTHORS.md
278
192
  - CONTRIBUTING.md
279
193
  - ChangeLog
280
194
  - Gemfile
@@ -298,6 +212,7 @@ files:
298
212
  - maid.gemspec
299
213
  - resources/OneThingWell.png
300
214
  - resources/download-for-ubuntu.png
215
+ - resources/hacker-news.png
301
216
  - resources/ruby5.gif
302
217
  - script/smoke-test
303
218
  - script/vagrant-provision
@@ -314,51 +229,30 @@ files:
314
229
  - spec/lib/maid/user_agent_spec.rb
315
230
  - spec/lib/maid_spec.rb
316
231
  - spec/spec_helper.rb
317
- has_rdoc: true
318
232
  homepage: http://github.com/benjaminoakes/maid
319
- licenses:
233
+ licenses:
320
234
  - GPLv2
321
235
  post_install_message:
322
236
  rdoc_options: []
323
-
324
- require_paths:
237
+ require_paths:
325
238
  - lib
326
- required_ruby_version: !ruby/object:Gem::Requirement
239
+ required_ruby_version: !ruby/object:Gem::Requirement
327
240
  none: false
328
- requirements:
329
- - - ">="
330
- - !ruby/object:Gem::Version
331
- hash: 3
332
- segments:
333
- - 0
334
- version: "0"
335
- required_rubygems_version: !ruby/object:Gem::Requirement
241
+ requirements:
242
+ - - ! '>='
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
245
+ required_rubygems_version: !ruby/object:Gem::Requirement
336
246
  none: false
337
- requirements:
338
- - - ">"
339
- - !ruby/object:Gem::Version
340
- hash: 25
341
- segments:
342
- - 1
343
- - 3
344
- - 1
247
+ requirements:
248
+ - - ! '>'
249
+ - !ruby/object:Gem::Version
345
250
  version: 1.3.1
346
251
  requirements: []
347
-
348
252
  rubyforge_project: maid
349
- rubygems_version: 1.6.2
253
+ rubygems_version: 1.8.11
350
254
  signing_key:
351
255
  specification_version: 3
352
256
  summary: Be lazy. Let Maid clean up after you, based on rules you define.
353
- test_files:
354
- - spec/dependency_spec.rb
355
- - spec/lib/maid/app_spec.rb
356
- - spec/lib/maid/maid_spec.rb
357
- - spec/lib/maid/numeric_extensions_spec.rb
358
- - spec/lib/maid/platform_spec.rb
359
- - spec/lib/maid/rule_spec.rb
360
- - spec/lib/maid/tools_spec.rb
361
- - spec/lib/maid/trash_migration_spec.rb
362
- - spec/lib/maid/user_agent_spec.rb
363
- - spec/lib/maid_spec.rb
364
- - spec/spec_helper.rb
257
+ test_files: []
258
+ has_rdoc: