filestorage 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33971b80bef4ca70e5a2a8a3038f689648e5169b
4
- data.tar.gz: eea31006f29bc16888dbf20ec866454d39b5a2c4
3
+ metadata.gz: 2abf484dfc5af8e0ef647937ed42157988a2e0d7
4
+ data.tar.gz: 29de042d162e5d27dbd487db7d3f6f7c13cdd424
5
5
  SHA512:
6
- metadata.gz: 0d4b6ef232ff99f8bd15e38e7ad71506cd20f5df7741889718b1959cf774fd76ba9f4d45ec05a0efe06dfa92deae130b43416c5c84fb024127a6561d396fed31
7
- data.tar.gz: 4fe54d1057385cdb61aa9508351b282fe47cafc334899a6b070b19e077ec3a7b83443fa91250d4b0405025256885b8a7a1d43f749aa7cc1b051eb4f11b4bed03
6
+ metadata.gz: 4cd06b97c672d866c85052ae557de92aac191afd8589f55edb0e0fa5c128d26c1c289e4536974b4c33d1edf08830e8925be8388fffcbac8b10b744f8e5713ae8
7
+ data.tar.gz: 1e48f071b52fe5f0ab184ae21a7e448b17f9bafb8febb4409fd6f69dac9d7b35fe50e4469b418e62e7577ddb4bc85e43c6253e96a7cae0f310170fe98005a430
@@ -37,10 +37,11 @@ module Filestorage
37
37
  File.open(fullpath, "rb")
38
38
  end
39
39
 
40
- def delete(path)
40
+ def delete(path, delete_dir: false)
41
41
  fullpath = @base_dir + path
42
42
  raise NotExist.new("Not exist #{path}") unless File.exist?(fullpath)
43
43
  FileUtils.rm(fullpath)
44
+ sweep(fullpath.parent) if delete_dir
44
45
  path
45
46
  end
46
47
 
@@ -58,6 +59,23 @@ module Filestorage
58
59
  files
59
60
  end
60
61
 
62
+ private
63
+
64
+ def sweep(path)
65
+ paths(path).reverse.each do |p|
66
+ FileUtils.rmdir(p) if p.children.empty?
67
+ end
68
+ end
69
+
70
+ def paths(path)
71
+ p = []
72
+ until path.to_s == @base_dir.to_s
73
+ p << path
74
+ path = path.parent
75
+ end
76
+ p.reverse
77
+ end
78
+
61
79
  end # of class Local
62
80
 
63
81
  end # of module LocalFilestorage
@@ -1,3 +1,3 @@
1
1
  module Filestorage
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - takatoh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2014-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk