maid 0.6.0.beta.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +16 -1
  2. data/lib/maid/tools.rb +31 -29
  3. data/lib/maid/version.rb +1 -1
  4. metadata +42 -42
data/README.md CHANGED
@@ -235,7 +235,22 @@ Maid.rules do
235
235
  end
236
236
  ```
237
237
 
238
- To run the daemon run `maid daemon`. Starting the daemon on login depends on the platform.
238
+ Here's a simple "watch" rule that organizes images by dimensions as soon as they're added to `~/Pictures`:
239
+
240
+ ```ruby
241
+ Maid.rules do
242
+ watch '~/Pictures' do
243
+ rule 'organize images by dimensions' do
244
+ where_content_type(dir('~/Pictures/*'), 'image').each do |image|
245
+ width, height = dimensions_px(image)
246
+ move(image, mkdir("~/Pictures/#{width}x#{height}"))
247
+ end
248
+ end
249
+ end
250
+ end
251
+ ```
252
+
253
+ The command to run the daemon is `maid daemon`. Starting the daemon on login depends on the platform. On Ubuntu for example, you can run `maid daemon` as a normal startup application (Power/Gear Menu -> Startup Applications... -> Add).
239
254
 
240
255
  ### Rake Tasks
241
256
 
@@ -144,6 +144,35 @@ module Maid::Tools
144
144
  end
145
145
  end
146
146
 
147
+ # Copy from `sources` to `destination`
148
+ #
149
+ # The path is not copied if a file already exists at the destination with the same name. A warning is logged instead.
150
+ # Note: Similar functionality is provided by the sync tool, but this requires installation of the `rsync` binary
151
+ # ## Examples
152
+ #
153
+ # Single path:
154
+ #
155
+ # copy('~/Downloads/foo.zip', '~/Archive/Software/Mac OS X/')
156
+ #
157
+ # Multiple paths:
158
+ #
159
+ # copy(['~/Downloads/foo.zip', '~/Downloads/bar.zip'], '~/Archive/Software/Mac OS X/')
160
+ # copy(dir('~/Downloads/*.zip'), '~/Archive/Software/Mac OS X/')
161
+ def copy(sources, destination, options = {})
162
+ destination = expand(destination)
163
+
164
+ expand_all(sources).each do |source|
165
+ target = File.join(destination, File.basename(source))
166
+
167
+ unless File.exist?(target)
168
+ log("cp #{ source.inspect } #{ destination.inspect }")
169
+ FileUtils.cp(source, destination )
170
+ else
171
+ warn("skipping #{ source.inspect } because #{ target.inspect } already exists")
172
+ end
173
+ end
174
+ end
175
+
147
176
  # Delete the files at the given path recursively.
148
177
  #
149
178
  # **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.
@@ -406,6 +435,8 @@ module Maid::Tools
406
435
  # ## Examples
407
436
  #
408
437
  # dimensions_px('image.jpg') # => [1024, 768]
438
+ # width, height = dimensions_px('image.jpg')
439
+ # dimensions_px('image.jpg').join('x') # => "1024x768"
409
440
  def dimensions_px(path)
410
441
  Dimensions.dimensions(path)
411
442
  end
@@ -655,35 +686,6 @@ module Maid::Tools
655
686
  Array(paths).select { |p| !(filter_types & content_types(p)).empty? }
656
687
  end
657
688
 
658
- # Copy from `sources` to `destination`
659
- #
660
- # The path is not copied if a file already exists at the destination with the same name. A warning is logged instead.
661
- # Note: Similar functionality is provided by the sync tool, but this requires installation of the `rsync` binary
662
- # ## Examples
663
- #
664
- # Single path:
665
- #
666
- # copy('~/Downloads/foo.zip', '~/Archive/Software/Mac OS X/')
667
- #
668
- # Multiple paths:
669
- #
670
- # copy(['~/Downloads/foo.zip', '~/Downloads/bar.zip'], '~/Archive/Software/Mac OS X/')
671
- # copy(dir('~/Downloads/*.zip'), '~/Archive/Software/Mac OS X/')
672
- def copy(sources, destination, options = {})
673
- destination = expand(destination)
674
-
675
- expand_all(sources).each do |source|
676
- target = File.join(destination, File.basename(source))
677
-
678
- unless File.exist?(target)
679
- log("cp #{ source.inspect } #{ destination.inspect }")
680
- FileUtils.cp(source, destination )
681
- else
682
- warn("skipping #{ source.inspect } because #{ target.inspect } already exists")
683
- end
684
- end
685
- end
686
-
687
689
  private
688
690
 
689
691
  def firefox_downloading?(path)
@@ -1,4 +1,4 @@
1
1
  module Maid
2
- VERSION = '0.6.0.beta.2'
2
+ VERSION = '0.6.0'
3
3
  SUMMARY = 'Be lazy. Let Maid clean up after you, based on rules you define. Think of it as "Hazel for hackers".'
4
4
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.beta.2
5
- prerelease: 6
4
+ version: 0.6.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Benjamin Oakes
@@ -13,7 +13,7 @@ date: 2014-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: escape
16
- requirement: &12511240 !ruby/object:Gem::Requirement
16
+ requirement: &14894940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 0.1.0
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *12511240
27
+ version_requirements: *14894940
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: thor
30
- requirement: &12508320 !ruby/object:Gem::Requirement
30
+ requirement: &14891580 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -38,10 +38,10 @@ dependencies:
38
38
  version: 1.0.0
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *12508320
41
+ version_requirements: *14891580
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: deprecated
44
- requirement: &12506260 !ruby/object:Gem::Requirement
44
+ requirement: &14888740 !ruby/object:Gem::Requirement
45
45
  none: false
46
46
  requirements:
47
47
  - - ~>
@@ -49,10 +49,10 @@ dependencies:
49
49
  version: 3.0.0
50
50
  type: :runtime
51
51
  prerelease: false
52
- version_requirements: *12506260
52
+ version_requirements: *14888740
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: dimensions
55
- requirement: &12503140 !ruby/object:Gem::Requirement
55
+ requirement: &14887880 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ! '>='
@@ -63,10 +63,10 @@ dependencies:
63
63
  version: '2.0'
64
64
  type: :runtime
65
65
  prerelease: false
66
- version_requirements: *12503140
66
+ version_requirements: *14887880
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: mime-types
69
- requirement: &12501680 !ruby/object:Gem::Requirement
69
+ requirement: &14884180 !ruby/object:Gem::Requirement
70
70
  none: false
71
71
  requirements:
72
72
  - - ~>
@@ -74,10 +74,10 @@ dependencies:
74
74
  version: '2.0'
75
75
  type: :runtime
76
76
  prerelease: false
77
- version_requirements: *12501680
77
+ version_requirements: *14884180
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: rubyzip
80
- requirement: &12499880 !ruby/object:Gem::Requirement
80
+ requirement: &14883280 !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
83
  - - ~>
@@ -85,10 +85,10 @@ dependencies:
85
85
  version: 1.1.0
86
86
  type: :runtime
87
87
  prerelease: false
88
- version_requirements: *12499880
88
+ version_requirements: *14883280
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: xdg
91
- requirement: &12496640 !ruby/object:Gem::Requirement
91
+ requirement: &14880920 !ruby/object:Gem::Requirement
92
92
  none: false
93
93
  requirements:
94
94
  - - ~>
@@ -96,10 +96,10 @@ dependencies:
96
96
  version: 2.2.3
97
97
  type: :runtime
98
98
  prerelease: false
99
- version_requirements: *12496640
99
+ version_requirements: *14880920
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: listen
102
- requirement: &12495320 !ruby/object:Gem::Requirement
102
+ requirement: &14878280 !ruby/object:Gem::Requirement
103
103
  none: false
104
104
  requirements:
105
105
  - - ~>
@@ -107,10 +107,10 @@ dependencies:
107
107
  version: 2.8.0
108
108
  type: :runtime
109
109
  prerelease: false
110
- version_requirements: *12495320
110
+ version_requirements: *14878280
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rufus-scheduler
113
- requirement: &12493620 !ruby/object:Gem::Requirement
113
+ requirement: &14876960 !ruby/object:Gem::Requirement
114
114
  none: false
115
115
  requirements:
116
116
  - - ~>
@@ -118,10 +118,10 @@ dependencies:
118
118
  version: 3.0.6
119
119
  type: :runtime
120
120
  prerelease: false
121
- version_requirements: *12493620
121
+ version_requirements: *14876960
122
122
  - !ruby/object:Gem::Dependency
123
123
  name: fakefs
124
- requirement: &12492700 !ruby/object:Gem::Requirement
124
+ requirement: &14875200 !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements:
127
127
  - - ~>
@@ -129,10 +129,10 @@ dependencies:
129
129
  version: 0.4.2
130
130
  type: :development
131
131
  prerelease: false
132
- version_requirements: *12492700
132
+ version_requirements: *14875200
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: guard
135
- requirement: &12491920 !ruby/object:Gem::Requirement
135
+ requirement: &14874200 !ruby/object:Gem::Requirement
136
136
  none: false
137
137
  requirements:
138
138
  - - ~>
@@ -140,10 +140,10 @@ dependencies:
140
140
  version: 2.10.4
141
141
  type: :development
142
142
  prerelease: false
143
- version_requirements: *12491920
143
+ version_requirements: *14874200
144
144
  - !ruby/object:Gem::Dependency
145
145
  name: guard-rspec
146
- requirement: &12490940 !ruby/object:Gem::Requirement
146
+ requirement: &14873520 !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements:
149
149
  - - ~>
@@ -151,10 +151,10 @@ dependencies:
151
151
  version: 4.5.0
152
152
  type: :development
153
153
  prerelease: false
154
- version_requirements: *12490940
154
+ version_requirements: *14873520
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: rake
157
- requirement: &12489340 !ruby/object:Gem::Requirement
157
+ requirement: &14872440 !ruby/object:Gem::Requirement
158
158
  none: false
159
159
  requirements:
160
160
  - - ~>
@@ -162,10 +162,10 @@ dependencies:
162
162
  version: 10.4.2
163
163
  type: :development
164
164
  prerelease: false
165
- version_requirements: *12489340
165
+ version_requirements: *14872440
166
166
  - !ruby/object:Gem::Dependency
167
167
  name: redcarpet
168
- requirement: &12488580 !ruby/object:Gem::Requirement
168
+ requirement: &14870960 !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements:
171
171
  - - ~>
@@ -173,10 +173,10 @@ dependencies:
173
173
  version: 3.2.2
174
174
  type: :development
175
175
  prerelease: false
176
- version_requirements: *12488580
176
+ version_requirements: *14870960
177
177
  - !ruby/object:Gem::Dependency
178
178
  name: rspec
179
- requirement: &12487780 !ruby/object:Gem::Requirement
179
+ requirement: &14870180 !ruby/object:Gem::Requirement
180
180
  none: false
181
181
  requirements:
182
182
  - - ~>
@@ -184,10 +184,10 @@ dependencies:
184
184
  version: 3.1.0
185
185
  type: :development
186
186
  prerelease: false
187
- version_requirements: *12487780
187
+ version_requirements: *14870180
188
188
  - !ruby/object:Gem::Dependency
189
189
  name: timecop
190
- requirement: &12483760 !ruby/object:Gem::Requirement
190
+ requirement: &14869320 !ruby/object:Gem::Requirement
191
191
  none: false
192
192
  requirements:
193
193
  - - ~>
@@ -195,10 +195,10 @@ dependencies:
195
195
  version: 0.7.0
196
196
  type: :development
197
197
  prerelease: false
198
- version_requirements: *12483760
198
+ version_requirements: *14869320
199
199
  - !ruby/object:Gem::Dependency
200
200
  name: yard
201
- requirement: &12456320 !ruby/object:Gem::Requirement
201
+ requirement: &14863120 !ruby/object:Gem::Requirement
202
202
  none: false
203
203
  requirements:
204
204
  - - ~>
@@ -206,10 +206,10 @@ dependencies:
206
206
  version: 0.8.4
207
207
  type: :development
208
208
  prerelease: false
209
- version_requirements: *12456320
209
+ version_requirements: *14863120
210
210
  - !ruby/object:Gem::Dependency
211
211
  name: rb-inotify
212
- requirement: &12454800 !ruby/object:Gem::Requirement
212
+ requirement: &14837760 !ruby/object:Gem::Requirement
213
213
  none: false
214
214
  requirements:
215
215
  - - ~>
@@ -217,10 +217,10 @@ dependencies:
217
217
  version: 0.9.0
218
218
  type: :development
219
219
  prerelease: false
220
- version_requirements: *12454800
220
+ version_requirements: *14837760
221
221
  - !ruby/object:Gem::Dependency
222
222
  name: rb-fsevent
223
- requirement: &12452460 !ruby/object:Gem::Requirement
223
+ requirement: &14836080 !ruby/object:Gem::Requirement
224
224
  none: false
225
225
  requirements:
226
226
  - - ~>
@@ -228,7 +228,7 @@ dependencies:
228
228
  version: 0.9.2
229
229
  type: :development
230
230
  prerelease: false
231
- version_requirements: *12452460
231
+ version_requirements: *14836080
232
232
  description: Be lazy. Let Maid clean up after you, based on rules you define. Think
233
233
  of it as "Hazel for hackers".
234
234
  email:
@@ -315,9 +315,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
315
315
  required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  none: false
317
317
  requirements:
318
- - - ! '>'
318
+ - - ! '>='
319
319
  - !ruby/object:Gem::Version
320
- version: 1.3.1
320
+ version: '0'
321
321
  requirements: []
322
322
  rubyforge_project: maid
323
323
  rubygems_version: 1.8.11