maid 0.4.2 → 0.5.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS.md CHANGED
@@ -11,4 +11,5 @@ In alphabetical order:
11
11
  * Mark Jaquith (@markjaquith)
12
12
  * Mikael Hultgren (@blomma)
13
13
  * Mu Ye (@yemutex)
14
+ * Shiro Hazuki (@HazukiShiro)
14
15
  * Vladimir Agafonkin (@mourner)
data/ChangeLog CHANGED
@@ -1,8 +1,10 @@
1
- maid (0.4.2) stable; urgency=low
1
+ maid (0.5.0) unstable; urgency=low
2
2
 
3
- * Updated dependencies: "rubyzip"
3
+ * New utility methods: "dir_safe", "downloading?"
4
+ * Shiro Hazuki: Implementations of "dir_safe" and "downloading?" released
5
+ into the public domain (Closes: #107)
4
6
 
5
- -- Benjamin Oakes <hello@benjaminoakes.com> Fri, 1 Nov 2013 00:00:00 +0000
7
+ -- Benjamin Oakes <hello@benjaminoakes.com> TODO
6
8
 
7
9
  maid (0.4.1) stable; urgency=low
8
10
 
data/lib/maid/tools.rb CHANGED
@@ -212,6 +212,20 @@ module Maid::Tools
212
212
  sort
213
213
  end
214
214
 
215
+ # Same as `dir`, but excludes files that are (possibly) being
216
+ # downloaded.
217
+ #
218
+ # ## Example
219
+ #
220
+ # Move Debian/Ubuntu packages that are finished downloading into a software directory.
221
+ #
222
+ # move dir_safe('~/Downloads/*.deb'), '~/Archive/Software'
223
+ #
224
+ def dir_safe(globs)
225
+ dir(globs).
226
+ reject { |path| downloading?(path) }
227
+ end
228
+
215
229
  # Give only files matching the given glob.
216
230
  #
217
231
  # This is the same as `dir` but only includes actual files (no directories or symlinks).
@@ -312,6 +326,13 @@ module Maid::Tools
312
326
  mdls_to_array(path, 'kMDItemWhereFroms')
313
327
  end
314
328
 
329
+ # Detect whether the path is currently being downloaded in Chrome or Firefox.
330
+ #
331
+ # See also: `dir_safe`
332
+ def downloading?(path)
333
+ chrome_downloading?(path) || firefox_downloading?(path)
334
+ end
335
+
315
336
  # Find all duplicate files in the given globs.
316
337
  #
317
338
  # More often than not, you'll want to use `newest_dupes_in` or
@@ -626,6 +647,15 @@ module Maid::Tools
626
647
 
627
648
  private
628
649
 
650
+ def firefox_downloading?(path)
651
+ path =~ /\.part$/ ||
652
+ File.exist?("#{path}.part")
653
+ end
654
+
655
+ def chrome_downloading?(path)
656
+ path =~ /\.crdownload$/
657
+ end
658
+
629
659
  def sh_escape(array)
630
660
  Escape.shell_command(Array(array))
631
661
  end
data/lib/maid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Maid
2
- VERSION = '0.4.2'
2
+ VERSION = '0.5.0.alpha.1'
3
3
  end
data/maid.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency('thor', '>= 0.14.0', '< 0.19.0')
23
23
  s.add_dependency('deprecated', '~> 3.0.0')
24
24
  s.add_dependency('mime-types', '~> 2.0')
25
- s.add_dependency('rubyzip', '~> 1.1.0')
25
+ s.add_dependency('rubyzip', '~> 1.0.0')
26
26
  s.add_dependency('xdg', '~> 2.2.3') # previous versions had bugs
27
27
  # TODO: use one of these two gems instead of `mdfind`. **But** They have to work on Linux as well.
28
28
  #
@@ -368,6 +368,20 @@ module Maid
368
368
  end
369
369
  end
370
370
 
371
+ describe '#downloading?' do
372
+ it 'detects a normal file as not being downloaded' do
373
+ @maid.downloading?('foo.zip').should be_false
374
+ end
375
+
376
+ it 'detects when downloading in Firefox' do
377
+ @maid.downloading?('foo.zip.part').should be_true
378
+ end
379
+
380
+ it 'detects when downloading in Chrome' do
381
+ @maid.downloading?('foo.zip.crdownload').should be_true
382
+ end
383
+ end
384
+
371
385
  describe '#duration_s' do
372
386
  it 'should determine audio length' do
373
387
  @maid.should_receive(:cmd).and_return('235.705')
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
5
- prerelease:
4
+ version: 0.5.0.alpha.1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Benjamin Oakes
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-01 00:00:00.000000000 Z
12
+ date: 2013-10-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: escape
16
- requirement: &15219540 !ruby/object:Gem::Requirement
16
+ requirement: &9483740 !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: *15219540
27
+ version_requirements: *9483740
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: thor
30
- requirement: &15218100 !ruby/object:Gem::Requirement
30
+ requirement: &9482840 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -38,10 +38,10 @@ dependencies:
38
38
  version: 0.19.0
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *15218100
41
+ version_requirements: *9482840
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: deprecated
44
- requirement: &15217260 !ruby/object:Gem::Requirement
44
+ requirement: &9482000 !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: *15217260
52
+ version_requirements: *9482000
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: mime-types
55
- requirement: &15216700 !ruby/object:Gem::Requirement
55
+ requirement: &9481480 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
@@ -60,21 +60,21 @@ dependencies:
60
60
  version: '2.0'
61
61
  type: :runtime
62
62
  prerelease: false
63
- version_requirements: *15216700
63
+ version_requirements: *9481480
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: rubyzip
66
- requirement: &15216040 !ruby/object:Gem::Requirement
66
+ requirement: &9480860 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
69
  - - ~>
70
70
  - !ruby/object:Gem::Version
71
- version: 1.1.0
71
+ version: 1.0.0
72
72
  type: :runtime
73
73
  prerelease: false
74
- version_requirements: *15216040
74
+ version_requirements: *9480860
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: xdg
77
- requirement: &15215420 !ruby/object:Gem::Requirement
77
+ requirement: &9480280 !ruby/object:Gem::Requirement
78
78
  none: false
79
79
  requirements:
80
80
  - - ~>
@@ -82,10 +82,10 @@ dependencies:
82
82
  version: 2.2.3
83
83
  type: :runtime
84
84
  prerelease: false
85
- version_requirements: *15215420
85
+ version_requirements: *9480280
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: fakefs
88
- requirement: &15214860 !ruby/object:Gem::Requirement
88
+ requirement: &9479380 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ~>
@@ -93,10 +93,10 @@ dependencies:
93
93
  version: 0.4.2
94
94
  type: :development
95
95
  prerelease: false
96
- version_requirements: *15214860
96
+ version_requirements: *9479380
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: guard
99
- requirement: &15214320 !ruby/object:Gem::Requirement
99
+ requirement: &9478580 !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements:
102
102
  - - ~>
@@ -104,10 +104,10 @@ dependencies:
104
104
  version: 2.2.2
105
105
  type: :development
106
106
  prerelease: false
107
- version_requirements: *15214320
107
+ version_requirements: *9478580
108
108
  - !ruby/object:Gem::Dependency
109
109
  name: guard-rspec
110
- requirement: &15213640 !ruby/object:Gem::Requirement
110
+ requirement: &9477600 !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements:
113
113
  - - ~>
@@ -115,10 +115,10 @@ dependencies:
115
115
  version: 4.0.3
116
116
  type: :development
117
117
  prerelease: false
118
- version_requirements: *15213640
118
+ version_requirements: *9477600
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: rake
121
- requirement: &15213140 !ruby/object:Gem::Requirement
121
+ requirement: &9476380 !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
124
124
  - - ~>
@@ -126,10 +126,10 @@ dependencies:
126
126
  version: 10.1.0
127
127
  type: :development
128
128
  prerelease: false
129
- version_requirements: *15213140
129
+ version_requirements: *9476380
130
130
  - !ruby/object:Gem::Dependency
131
131
  name: redcarpet
132
- requirement: &15212340 !ruby/object:Gem::Requirement
132
+ requirement: &9474760 !ruby/object:Gem::Requirement
133
133
  none: false
134
134
  requirements:
135
135
  - - ~>
@@ -137,10 +137,10 @@ dependencies:
137
137
  version: 3.0.0
138
138
  type: :development
139
139
  prerelease: false
140
- version_requirements: *15212340
140
+ version_requirements: *9474760
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: rspec
143
- requirement: &15211680 !ruby/object:Gem::Requirement
143
+ requirement: &9471940 !ruby/object:Gem::Requirement
144
144
  none: false
145
145
  requirements:
146
146
  - - ~>
@@ -148,10 +148,10 @@ dependencies:
148
148
  version: 2.14.1
149
149
  type: :development
150
150
  prerelease: false
151
- version_requirements: *15211680
151
+ version_requirements: *9471940
152
152
  - !ruby/object:Gem::Dependency
153
153
  name: timecop
154
- requirement: &15211100 !ruby/object:Gem::Requirement
154
+ requirement: &9471120 !ruby/object:Gem::Requirement
155
155
  none: false
156
156
  requirements:
157
157
  - - ~>
@@ -159,10 +159,10 @@ dependencies:
159
159
  version: 0.6.3
160
160
  type: :development
161
161
  prerelease: false
162
- version_requirements: *15211100
162
+ version_requirements: *9471120
163
163
  - !ruby/object:Gem::Dependency
164
164
  name: yard
165
- requirement: &15210480 !ruby/object:Gem::Requirement
165
+ requirement: &9470440 !ruby/object:Gem::Requirement
166
166
  none: false
167
167
  requirements:
168
168
  - - ~>
@@ -170,10 +170,10 @@ dependencies:
170
170
  version: 0.8.4
171
171
  type: :development
172
172
  prerelease: false
173
- version_requirements: *15210480
173
+ version_requirements: *9470440
174
174
  - !ruby/object:Gem::Dependency
175
175
  name: rb-inotify
176
- requirement: &15208780 !ruby/object:Gem::Requirement
176
+ requirement: &9469460 !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
179
179
  - - ~>
@@ -181,10 +181,10 @@ dependencies:
181
181
  version: 0.9.0
182
182
  type: :development
183
183
  prerelease: false
184
- version_requirements: *15208780
184
+ version_requirements: *9469460
185
185
  - !ruby/object:Gem::Dependency
186
186
  name: rb-fsevent
187
- requirement: &15208220 !ruby/object:Gem::Requirement
187
+ requirement: &9468360 !ruby/object:Gem::Requirement
188
188
  none: false
189
189
  requirements:
190
190
  - - ~>
@@ -192,7 +192,7 @@ dependencies:
192
192
  version: 0.9.2
193
193
  type: :development
194
194
  prerelease: false
195
- version_requirements: *15208220
195
+ version_requirements: *9468360
196
196
  description: ! 'Be lazy: let Maid clean up after you. Think of it as "Hazel for hackers".'
197
197
  email:
198
198
  - hello@benjaminoakes.com
@@ -270,9 +270,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
270
270
  required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  none: false
272
272
  requirements:
273
- - - ! '>='
273
+ - - ! '>'
274
274
  - !ruby/object:Gem::Version
275
- version: '0'
275
+ version: 1.3.1
276
276
  requirements: []
277
277
  rubyforge_project: maid
278
278
  rubygems_version: 1.8.11