maid 0.6.0.alpha.5 → 0.6.0.alpha.6

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS.md CHANGED
@@ -5,6 +5,7 @@ In alphabetical order:
5
5
  * Graham Siener (@gsiener)
6
6
  * Jayson Rhynas (@jayrhynas)
7
7
  * John Colvin (@JohnColvin)
8
+ * Jurriaan Pruis (@jurriaan)
8
9
  * Justin Hileman (@bobthecow)
9
10
  * Larry Lv (@larrylv)
10
11
  * Lewis O'Driscoll (@loddy1234)
@@ -12,6 +13,7 @@ In alphabetical order:
12
13
  * Mark Jaquith (@markjaquith)
13
14
  * Mikael Hultgren (@blomma)
14
15
  * Mu Ye (@yemutex)
16
+ * Nico Ritschel (@nicosuave)
15
17
  * Pedro Lambert (@p-lambert)
16
18
  * Shiro Hazuki (@HazukiShiro)
17
19
  * Vladimir Agafonkin (@mourner)
data/ChangeLog CHANGED
@@ -5,6 +5,7 @@ maid (0.6.0) unstable; urgency=low
5
5
  * Pedro Lambert: Add support for Rake tasks defined by Maid (Closes: #68, #123)
6
6
  * Jurriaan Pruis: Add daemon mode and repeat support (Closes: #126, #131)
7
7
  * Jurriaan Pruis: Add "ignore" option support for "watch" (Closes: #132)
8
+ * Nico Ritschel: Add "copy" tool (Closes: #72, #133)
8
9
 
9
10
  -- Benjamin Oakes <hello@benjaminoakes.com> TODO
10
11
 
data/lib/maid/tools.rb CHANGED
@@ -643,6 +643,35 @@ module Maid::Tools
643
643
  Array(paths).select { |p| !(filter_types & content_types(p)).empty? }
644
644
  end
645
645
 
646
+ # Copy from `sources` to `destination`
647
+ #
648
+ # The path is not copied if a file already exists at the destination with the same name. A warning is logged instead.
649
+ # Note: Similar functionality is provided by the sync tool, but this requires installation of the `rsync` binary
650
+ # ## Examples
651
+ #
652
+ # Single path:
653
+ #
654
+ # copy('~/Downloads/foo.zip', '~/Archive/Software/Mac OS X/')
655
+ #
656
+ # Multiple paths:
657
+ #
658
+ # copy(['~/Downloads/foo.zip', '~/Downloads/bar.zip'], '~/Archive/Software/Mac OS X/')
659
+ # copy(dir('~/Downloads/*.zip'), '~/Archive/Software/Mac OS X/')
660
+ def copy(sources, destination, options = {})
661
+ destination = expand(destination)
662
+
663
+ expand_all(sources).each do |source|
664
+ target = File.join(destination, File.basename(source))
665
+
666
+ unless File.exist?(target)
667
+ log("cp #{ source.inspect } #{ destination.inspect }")
668
+ FileUtils.cp(source, destination )
669
+ else
670
+ warn("skipping #{ source.inspect } because #{ target.inspect } already exists")
671
+ end
672
+ end
673
+ end
674
+
646
675
  private
647
676
 
648
677
  def firefox_downloading?(path)
data/lib/maid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Maid
2
- VERSION = '0.6.0.alpha.5'
2
+ VERSION = '0.6.0.alpha.6'
3
3
  end
@@ -545,6 +545,43 @@ module Maid
545
545
  @maid.sync(@src_dir, @dst_dir)
546
546
  end
547
547
  end
548
+
549
+ describe '#copy' do
550
+ before do
551
+ @src_file = (@src_dir = '~/Source/') + (@file_name = 'foo.zip')
552
+ FileUtils.mkdir_p(@src_dir)
553
+ FileUtils.touch(@src_file)
554
+ FileUtils.mkdir_p(@dst_dir = '~/Destination/')
555
+ end
556
+
557
+ it 'should move expanded paths, passing file_options' do
558
+ @maid.copy(@src_file, @dst_dir)
559
+ File.exists?(@dst_dir + @file_name).should be_true
560
+ end
561
+
562
+ it 'should log the move' do
563
+ @logger.should_receive(:info)
564
+ @maid.copy(@src_file, @dst_dir)
565
+ end
566
+
567
+ it 'should not move if the target already exists' do
568
+ FileUtils.touch(@dst_dir + @file_name)
569
+ @logger.should_receive(:warn)
570
+
571
+ @maid.copy(@src_file, @dst_dir)
572
+ end
573
+
574
+ it 'should handle multiple from paths' do
575
+ second_src_file = @src_dir + (second_file_name = 'bar.zip')
576
+ FileUtils.touch(second_src_file)
577
+ src_files = [@src_file, second_src_file]
578
+
579
+ @maid.copy(src_files, @dst_dir)
580
+ p "Source files: #{src_files}, dst_dir: #{@dst_dir}"
581
+ File.exist?(@dst_dir + @file_name).should be_true
582
+ File.exist?(@dst_dir + second_file_name).should be_true
583
+ end
584
+ end
548
585
  end
549
586
 
550
587
  describe Tools, :fakefs => false do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.alpha.5
4
+ version: 0.6.0.alpha.6
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2014-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: escape
16
- requirement: &9484660 !ruby/object:Gem::Requirement
16
+ requirement: &7178700 !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: *9484660
27
+ version_requirements: *7178700
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: thor
30
- requirement: &9480520 !ruby/object:Gem::Requirement
30
+ requirement: &7174560 !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: *9480520
41
+ version_requirements: *7174560
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: deprecated
44
- requirement: &9456100 !ruby/object:Gem::Requirement
44
+ requirement: &7150080 !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: *9456100
52
+ version_requirements: *7150080
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: mime-types
55
- requirement: &9455100 !ruby/object:Gem::Requirement
55
+ requirement: &7149140 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
@@ -60,10 +60,10 @@ dependencies:
60
60
  version: '2.0'
61
61
  type: :runtime
62
62
  prerelease: false
63
- version_requirements: *9455100
63
+ version_requirements: *7149140
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: rubyzip
66
- requirement: &9454180 !ruby/object:Gem::Requirement
66
+ requirement: &7148160 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
69
  - - ~>
@@ -71,10 +71,10 @@ dependencies:
71
71
  version: 1.1.0
72
72
  type: :runtime
73
73
  prerelease: false
74
- version_requirements: *9454180
74
+ version_requirements: *7148160
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: xdg
77
- requirement: &9453500 !ruby/object:Gem::Requirement
77
+ requirement: &7147500 !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: *9453500
85
+ version_requirements: *7147500
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: listen
88
- requirement: &9452900 !ruby/object:Gem::Requirement
88
+ requirement: &7146880 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ~>
@@ -93,10 +93,10 @@ dependencies:
93
93
  version: 2.8.0
94
94
  type: :runtime
95
95
  prerelease: false
96
- version_requirements: *9452900
96
+ version_requirements: *7146880
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rufus-scheduler
99
- requirement: &9452200 !ruby/object:Gem::Requirement
99
+ requirement: &7146200 !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements:
102
102
  - - ~>
@@ -104,10 +104,10 @@ dependencies:
104
104
  version: 3.0.6
105
105
  type: :runtime
106
106
  prerelease: false
107
- version_requirements: *9452200
107
+ version_requirements: *7146200
108
108
  - !ruby/object:Gem::Dependency
109
109
  name: fakefs
110
- requirement: &9451640 !ruby/object:Gem::Requirement
110
+ requirement: &7145620 !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements:
113
113
  - - ~>
@@ -115,10 +115,10 @@ dependencies:
115
115
  version: 0.4.2
116
116
  type: :development
117
117
  prerelease: false
118
- version_requirements: *9451640
118
+ version_requirements: *7145620
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: guard
121
- requirement: &9451060 !ruby/object:Gem::Requirement
121
+ requirement: &7145080 !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
124
124
  - - ~>
@@ -126,10 +126,10 @@ dependencies:
126
126
  version: 2.10.4
127
127
  type: :development
128
128
  prerelease: false
129
- version_requirements: *9451060
129
+ version_requirements: *7145080
130
130
  - !ruby/object:Gem::Dependency
131
131
  name: guard-rspec
132
- requirement: &9450300 !ruby/object:Gem::Requirement
132
+ requirement: &7144320 !ruby/object:Gem::Requirement
133
133
  none: false
134
134
  requirements:
135
135
  - - ~>
@@ -137,10 +137,10 @@ dependencies:
137
137
  version: 4.5.0
138
138
  type: :development
139
139
  prerelease: false
140
- version_requirements: *9450300
140
+ version_requirements: *7144320
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: rake
143
- requirement: &9449720 !ruby/object:Gem::Requirement
143
+ requirement: &7143720 !ruby/object:Gem::Requirement
144
144
  none: false
145
145
  requirements:
146
146
  - - ~>
@@ -148,10 +148,10 @@ dependencies:
148
148
  version: 10.4.2
149
149
  type: :development
150
150
  prerelease: false
151
- version_requirements: *9449720
151
+ version_requirements: *7143720
152
152
  - !ruby/object:Gem::Dependency
153
153
  name: redcarpet
154
- requirement: &9449100 !ruby/object:Gem::Requirement
154
+ requirement: &7143080 !ruby/object:Gem::Requirement
155
155
  none: false
156
156
  requirements:
157
157
  - - ~>
@@ -159,10 +159,10 @@ dependencies:
159
159
  version: 3.2.2
160
160
  type: :development
161
161
  prerelease: false
162
- version_requirements: *9449100
162
+ version_requirements: *7143080
163
163
  - !ruby/object:Gem::Dependency
164
164
  name: rspec
165
- requirement: &9448460 !ruby/object:Gem::Requirement
165
+ requirement: &7142480 !ruby/object:Gem::Requirement
166
166
  none: false
167
167
  requirements:
168
168
  - - ~>
@@ -170,10 +170,10 @@ dependencies:
170
170
  version: 3.1.0
171
171
  type: :development
172
172
  prerelease: false
173
- version_requirements: *9448460
173
+ version_requirements: *7142480
174
174
  - !ruby/object:Gem::Dependency
175
175
  name: timecop
176
- requirement: &9404220 !ruby/object:Gem::Requirement
176
+ requirement: &7098200 !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
179
179
  - - ~>
@@ -181,10 +181,10 @@ dependencies:
181
181
  version: 0.7.0
182
182
  type: :development
183
183
  prerelease: false
184
- version_requirements: *9404220
184
+ version_requirements: *7098200
185
185
  - !ruby/object:Gem::Dependency
186
186
  name: yard
187
- requirement: &9403340 !ruby/object:Gem::Requirement
187
+ requirement: &7097280 !ruby/object:Gem::Requirement
188
188
  none: false
189
189
  requirements:
190
190
  - - ~>
@@ -192,10 +192,10 @@ dependencies:
192
192
  version: 0.8.4
193
193
  type: :development
194
194
  prerelease: false
195
- version_requirements: *9403340
195
+ version_requirements: *7097280
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: rb-inotify
198
- requirement: &9402600 !ruby/object:Gem::Requirement
198
+ requirement: &7096540 !ruby/object:Gem::Requirement
199
199
  none: false
200
200
  requirements:
201
201
  - - ~>
@@ -203,10 +203,10 @@ dependencies:
203
203
  version: 0.9.0
204
204
  type: :development
205
205
  prerelease: false
206
- version_requirements: *9402600
206
+ version_requirements: *7096540
207
207
  - !ruby/object:Gem::Dependency
208
208
  name: rb-fsevent
209
- requirement: &9401380 !ruby/object:Gem::Requirement
209
+ requirement: &7095320 !ruby/object:Gem::Requirement
210
210
  none: false
211
211
  requirements:
212
212
  - - ~>
@@ -214,7 +214,7 @@ dependencies:
214
214
  version: 0.9.2
215
215
  type: :development
216
216
  prerelease: false
217
- version_requirements: *9401380
217
+ version_requirements: *7095320
218
218
  description: ! 'Be lazy: let Maid clean up after you. Think of it as "Hazel for hackers".'
219
219
  email:
220
220
  - hello@benjaminoakes.com