branchable_cdn_assets 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab78d952715ccd097239e67bccdd4e0e1a6c7635
|
4
|
+
data.tar.gz: f7a994bd5aee7df2ada620b1641e769946abfb8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f80a5a192ced43ab482fa31e870e7baf429e6e5f33a6e71be4419c0dc4b5de7bcb26105d6a5b47c04056b1324b4ca08ad7ddef6204868ef6ebef39283d30c68
|
7
|
+
data.tar.gz: 8765796e5a26a58cd1519e0a707889d26d9ea26dea1448cfc53f46e1cc7e394f089a6e106487fd9210da50a3af9d0447f7e698dcfabcb83e7bf5eac9b5ff1a3d
|
@@ -121,9 +121,19 @@ module BranchableCDNAssets
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def empty_directories
|
124
|
-
Dir[ File.join( Dir.pwd, root, '**/*' ) ].select do |d|
|
125
|
-
File.directory?(d)
|
124
|
+
directories = Dir[ File.join( Dir.pwd, root, '**/*' ) ].select do |d|
|
125
|
+
File.directory?(d)
|
126
126
|
end
|
127
|
+
|
128
|
+
empty_directories = directories.select do |d|
|
129
|
+
# a directory is empty if it only includes other empty directories
|
130
|
+
(( Dir.entries(d) - ['.','..'] ).map { |entry| File.join(d, entry) } - directories ).empty?
|
131
|
+
end
|
132
|
+
|
133
|
+
# reversing to ensure that nested directories are listed first
|
134
|
+
# so on removal we don't try and remove upper directories *then*
|
135
|
+
# the nested directories that aren't there anymore
|
136
|
+
empty_directories.sort_by { |i| i.length }.reverse
|
127
137
|
end
|
128
138
|
|
129
139
|
# @return [Array] the pushed files (only those updated on remote)
|
@@ -224,6 +224,10 @@ describe BranchableCDNAssets::FileManager do
|
|
224
224
|
end
|
225
225
|
|
226
226
|
context "when confirm removal" do
|
227
|
+
after :each do
|
228
|
+
`rm -rf cdn`
|
229
|
+
end
|
230
|
+
|
227
231
|
it "removes files that are local and on remote" do
|
228
232
|
expect( BranchableCDNAssets::Shell ).to receive(:run_local).with("rm cdn/filename_one")
|
229
233
|
release_stdin 'y' do
|
@@ -233,10 +237,19 @@ describe BranchableCDNAssets::FileManager do
|
|
233
237
|
|
234
238
|
it "removes empty directories" do
|
235
239
|
files = described_class.new(@config)
|
236
|
-
|
240
|
+
allow( Dir).to receive(:[]).with( "#{Dir.pwd}/cdn/**/*" ).and_call_original
|
241
|
+
|
242
|
+
`mkdir -p cdn/empty_dir`
|
243
|
+
`mkdir -p cdn/dir/empty_dir`
|
244
|
+
`mkdir -p cdn/foo`
|
245
|
+
`touch cdn/bar`
|
246
|
+
`touch cdn/foo/baz`
|
247
|
+
|
237
248
|
release_stdin 'y' do
|
238
249
|
files.prune!
|
239
250
|
end
|
251
|
+
|
252
|
+
expect( HereOrThere::Local.new.run("ls cdn").stdout ).to eq "bar\nfoo\n"
|
240
253
|
end
|
241
254
|
end
|
242
255
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: branchable_cdn_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|