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: 1681d174d7e3443b945cfba8e3400c7c5a48b891
4
- data.tar.gz: cd0d194648f0ed2b631610597c4ca742bea4be60
3
+ metadata.gz: ab78d952715ccd097239e67bccdd4e0e1a6c7635
4
+ data.tar.gz: f7a994bd5aee7df2ada620b1641e769946abfb8e
5
5
  SHA512:
6
- metadata.gz: 3f8c6164de81843f7f769971df63a3d373afa79fb547e33295725cb77550dd41b93c79bda3c790cea54e64660862824b5f05af891f82b1402c3a142951a4c0f6
7
- data.tar.gz: b364e24a139bdabe12c2ab47cc19f032d80412b6a9bce473b7e1fc89997a35413b308c5ba21f79fa163eb6b3d360af66afede0a25c9ce333c67fe0fc528405dc
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) && (Dir.entries(d) - ['.','..']).empty?
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)
@@ -1,3 +1,3 @@
1
1
  module BranchableCDNAssets
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -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
- expect( files ).to receive(:remove_empty_directories)
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.2
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-02-26 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake