fakefs 0.11.3 → 0.12.0

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: e5ae273cfc5ad5edc3ecd07fc069e7901c52b1d8
4
- data.tar.gz: 149a6003e19ce19a6dec5d34f88f7c2db2bf6be8
3
+ metadata.gz: f09643c4a4c819c9be5e231605189c97ef45cb91
4
+ data.tar.gz: 284b16d9e2b824ded282f59e5063572eb7138434
5
5
  SHA512:
6
- metadata.gz: 5079a8e369598d3292d60f1ce11be1dcff5ac2c3ef5a47f00c2a8c03612783b6ce1bb04bf7a08eaf3a4177f608d9d8785bdb5cbce867de60a6cc761574cf3268
7
- data.tar.gz: 92c9ab47a85ac8f4bf2510963b9713b8701f3146952f23ef16d0fc087ef9e8b1865da6927abd63ae91a6870d5fa0b5f23c34a499d1e0f444f44b97f930b116b9
6
+ metadata.gz: 97da5905b26ec724ec3be99ff03f11a4ab535c98b687e1a5ec1dc53eb9a0780127ede82c8c9920eef215d50b94e333da8907805b8dac0dfdc386a7193cbf62a7
7
+ data.tar.gz: aa27617f51c8fb48be3a460c2c931fd32aa083ab5dbd2f96c24bdfc687b56345019950c5bcf70356cd3456086edac48702a097d9f4e35478438bdd354d655862
data/lib/fakefs/dir.rb CHANGED
@@ -90,6 +90,17 @@ module FakeFS
90
90
  Dir.new(dirname).map { |file| File.basename(file) }
91
91
  end
92
92
 
93
+ if RUBY_VERSION >= '2.4'
94
+ def self.empty?(dirname)
95
+ _check_for_valid_file(dirname)
96
+ if File.directory?(dirname)
97
+ Dir.new(dirname).count <= 2
98
+ else
99
+ false
100
+ end
101
+ end
102
+ end
103
+
93
104
  def self.foreach(dirname, &_block)
94
105
  Dir.open(dirname) { |file| yield file }
95
106
  end
data/lib/fakefs/file.rb CHANGED
@@ -110,6 +110,12 @@ module FakeFS
110
110
  exists?(path) && size(path) == 0
111
111
  end
112
112
 
113
+ if RUBY_VERSION >= '2.4'
114
+ class << self
115
+ alias_method :empty?, :zero?
116
+ end
117
+ end
118
+
113
119
  def self.const_missing(name)
114
120
  RealFile.const_get(name)
115
121
  end
@@ -26,5 +26,15 @@ module FakeFS
26
26
  def writable?(file_name)
27
27
  File.writable?(file_name)
28
28
  end
29
+
30
+ def zero?(file_name)
31
+ File.zero?(file_name)
32
+ end
33
+
34
+ if RUBY_VERSION > '2.4'
35
+ class << self
36
+ alias empty? zero?
37
+ end
38
+ end
29
39
  end
30
40
  end
@@ -1019,6 +1019,18 @@ module FakeFS
1019
1019
  end
1020
1020
 
1021
1021
  alias_method :delete, :unlink
1022
+
1023
+ if RUBY_VERSION > '2.4'
1024
+ # Checks if a file or directory is empty, using
1025
+ # <tt>FileTest.empty?</tt> or <tt>Dir.empty?</tt> as necessary.
1026
+ def empty?
1027
+ if File.directory? @path
1028
+ Dir.empty? @path
1029
+ else
1030
+ FileTest.empty? @path
1031
+ end
1032
+ end
1033
+ end
1022
1034
  end
1023
1035
 
1024
1036
  # Pathname class
@@ -1,7 +1,7 @@
1
1
  module FakeFS
2
2
  # Version module
3
3
  module Version
4
- VERSION = '0.11.3'.freeze
4
+ VERSION = '0.12.0'.freeze
5
5
 
6
6
  def self.to_s
7
7
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakefs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-10-05 00:00:00.000000000 Z
15
+ date: 2018-01-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.5.1
160
+ rubygems_version: 2.6.14
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: A fake filesystem. Use it in your tests.