fakefs 1.2.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -10
- data/lib/fakefs/dir.rb +11 -7
- data/lib/fakefs/file.rb +5 -3
- data/lib/fakefs/fileutils.rb +2 -2
- data/lib/fakefs/globber.rb +12 -11
- data/lib/fakefs/pathname.rb +4 -4
- data/lib/fakefs/version.rb +1 -1
- metadata +9 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05aa1f68c0f9298802a4171ba6b109e53cb2e020b9b6f2973872ce4cc4de6ce1
|
4
|
+
data.tar.gz: 566bdaeab08f35a081857a4a76170c6b94f29bf928735f81470a19e4280297e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25dd82ac5d99560aee6642ee5faea80ee35cf0b70610d6b1f7b3e4cd7369c78f9acf9fce6567ad4ae0409c82e388917a220f4acc2637875768df486127491cf9
|
7
|
+
data.tar.gz: 8d087e11e9c7ba065bf07b4cff4ff51011ecf903fd830aa5ec51d8dcb2c18ded53c3cfbf38cc8226f7d4f46590bc3868fa902bfcc2011c1e19c1586868a920eb
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FakeFS [![build status](https://
|
1
|
+
FakeFS [![build status](https://github.com/fakefs/fakefs/workflows/CI/badge.svg)](https://github.com/fakefs/fakefs/actions?query=branch%3Amaster)
|
2
2
|
======
|
3
3
|
|
4
4
|
Mocking calls to FileUtils or File means tightly coupling tests with the implementation.
|
@@ -159,14 +159,6 @@ FakeFS::File.class_eval do
|
|
159
159
|
end
|
160
160
|
```
|
161
161
|
|
162
|
-
[MockFS](http://mockfs.rubyforge.org/) comparison
|
163
|
-
----------------------------------
|
164
|
-
|
165
|
-
FakeFS provides a test suite and works with symlinks. It's also strictly a
|
166
|
-
test-time dependency: your actual library does not need to use or know about
|
167
|
-
FakeFS.
|
168
|
-
|
169
|
-
|
170
162
|
Caveats
|
171
163
|
-------
|
172
164
|
|
@@ -210,7 +202,7 @@ Meta
|
|
210
202
|
* Code: `git clone git://github.com/fakefs/fakefs.git`
|
211
203
|
* Home: <https://github.com/fakefs/fakefs>
|
212
204
|
* Bugs: <https://github.com/fakefs/fakefs/issues>
|
213
|
-
* Test: <https://
|
205
|
+
* Test: <https://github.com/fakefs/fakefs/actions?query=branch%3Amaster>
|
214
206
|
* Gems: <https://rubygems.org/gems/fakefs>
|
215
207
|
|
216
208
|
[0]: https://help.github.com/forking/
|
data/lib/fakefs/dir.rb
CHANGED
@@ -85,14 +85,14 @@ module FakeFS
|
|
85
85
|
FileSystem.delete(string)
|
86
86
|
end
|
87
87
|
|
88
|
-
def self.entries(dirname,
|
88
|
+
def self.entries(dirname, _options = nil)
|
89
89
|
_check_for_valid_file(dirname)
|
90
90
|
|
91
91
|
Dir.new(dirname).map { |file| File.basename(file) }
|
92
92
|
end
|
93
93
|
|
94
|
-
def self.children(dirname,
|
95
|
-
entries(dirname
|
94
|
+
def self.children(dirname, _options = nil)
|
95
|
+
entries(dirname) - ['.', '..']
|
96
96
|
end
|
97
97
|
|
98
98
|
def self.each_child(dirname, &_block)
|
@@ -120,11 +120,13 @@ module FakeFS
|
|
120
120
|
def self.glob(pattern, flags = 0, &block)
|
121
121
|
matches_for_pattern = lambda do |matcher|
|
122
122
|
[FileSystem.find(matcher, flags, true) || []].flatten.map do |e|
|
123
|
-
|
124
|
-
|
123
|
+
pwd = Dir.pwd
|
124
|
+
pwd_regex = %r{\A#{pwd.gsub('+') { '\+' }}/?}
|
125
|
+
if pwd.match(%r{\A/?\z}) ||
|
126
|
+
!e.to_s.match(pwd_regex)
|
125
127
|
e.to_s
|
126
128
|
else
|
127
|
-
e.to_s.match(
|
129
|
+
e.to_s.match(pwd_regex).post_match
|
128
130
|
end
|
129
131
|
end.sort
|
130
132
|
end
|
@@ -198,7 +200,9 @@ module FakeFS
|
|
198
200
|
opts = {}
|
199
201
|
end
|
200
202
|
tmpdir, = *rest
|
201
|
-
tmpdir ||= self.tmpdir
|
203
|
+
tmpdir ||= self.tmpdir
|
204
|
+
Dir.mkdir(tmpdir) unless Dir.exist?(tmpdir)
|
205
|
+
|
202
206
|
n = nil
|
203
207
|
begin
|
204
208
|
path = File.join(tmpdir, make_tmpname(basename, n))
|
data/lib/fakefs/file.rb
CHANGED
@@ -197,11 +197,11 @@ module FakeFS
|
|
197
197
|
file.read(length)
|
198
198
|
end
|
199
199
|
|
200
|
-
def self.readlines(path)
|
200
|
+
def self.readlines(path, chomp: false)
|
201
201
|
file = new(path)
|
202
202
|
if file.exists?
|
203
203
|
FileSystem.find(path).atime = Time.now
|
204
|
-
file.readlines
|
204
|
+
chomp ? file.readlines.map(&:chomp) : file.readlines
|
205
205
|
else
|
206
206
|
raise Errno::ENOENT
|
207
207
|
end
|
@@ -231,6 +231,8 @@ module FakeFS
|
|
231
231
|
end
|
232
232
|
|
233
233
|
if (target = FileSystem.find(source))
|
234
|
+
return 0 if source == dest
|
235
|
+
|
234
236
|
if target.is_a?(FakeFS::FakeSymlink)
|
235
237
|
File.symlink(target.target, dest)
|
236
238
|
else
|
@@ -528,7 +530,7 @@ module FakeFS
|
|
528
530
|
end
|
529
531
|
|
530
532
|
def is_a?(klass)
|
531
|
-
RealFile.is_a?(klass)
|
533
|
+
RealFile.allocate.is_a?(klass)
|
532
534
|
end
|
533
535
|
|
534
536
|
def string
|
data/lib/fakefs/fileutils.rb
CHANGED
@@ -66,11 +66,11 @@ module FakeFS
|
|
66
66
|
alias remove rm
|
67
67
|
|
68
68
|
def rm_f(list, options = {})
|
69
|
-
rm(list,
|
69
|
+
rm(list, options.merge(force: true))
|
70
70
|
end
|
71
71
|
|
72
72
|
def rm_rf(list, options = {})
|
73
|
-
rm_r(list,
|
73
|
+
rm_r(list, options.merge(force: true))
|
74
74
|
end
|
75
75
|
alias rmtree rm_rf
|
76
76
|
alias safe_unlink rm_f
|
data/lib/fakefs/globber.rb
CHANGED
@@ -63,20 +63,21 @@ module FakeFS
|
|
63
63
|
def regexp(pattern, find_flags = 0, gave_char_class = false)
|
64
64
|
pattern = pattern.to_s
|
65
65
|
|
66
|
+
# Escape .+?*()$ characters unless already escaped.
|
66
67
|
regex_body =
|
67
68
|
pattern
|
68
|
-
.gsub(
|
69
|
-
.gsub(
|
70
|
-
.gsub(
|
71
|
-
.gsub(
|
72
|
-
.gsub(
|
73
|
-
.gsub(
|
74
|
-
.gsub(
|
75
|
-
|
76
|
-
#
|
77
|
-
# since if we're expecting them, the string should already be properly escaped
|
69
|
+
.gsub(/(?<!\\)\./, '\.')
|
70
|
+
.gsub(/(?<!\\)\+/) { '\+' }
|
71
|
+
.gsub(/(?<!\\)\?/, '.')
|
72
|
+
.gsub(/(?<!\\)\*/, '.*')
|
73
|
+
.gsub(/(?<!\\)\(/, '\(')
|
74
|
+
.gsub(/(?<!\\)\)/, '\)')
|
75
|
+
.gsub(/(?<!\\)\$/, '\$')
|
76
|
+
|
77
|
+
# Unless we're expecting character class contructs in regexes, escape all brackets
|
78
|
+
# since if we're expecting them, the string should already be properly escaped.
|
78
79
|
unless gave_char_class
|
79
|
-
regex_body = regex_body.gsub(
|
80
|
+
regex_body = regex_body.gsub(/(?<!\\)([\[\]])/, '\\\\\1')
|
80
81
|
end
|
81
82
|
|
82
83
|
# This matches nested braces and attempts to do something correct most of the time
|
data/lib/fakefs/pathname.rb
CHANGED
@@ -109,10 +109,10 @@ module FakeFS
|
|
109
109
|
if File::ALT_SEPARATOR
|
110
110
|
SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}" \
|
111
111
|
"#{Regexp.quote File::SEPARATOR}".freeze
|
112
|
-
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]
|
112
|
+
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/.freeze
|
113
113
|
else
|
114
114
|
SEPARATOR_LIST = (Regexp.quote File::SEPARATOR).to_s.freeze
|
115
|
-
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}
|
115
|
+
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/.freeze
|
116
116
|
end
|
117
117
|
|
118
118
|
# Return a pathname which the extension of the basename is substituted by
|
@@ -442,9 +442,9 @@ module FakeFS
|
|
442
442
|
def chop_basename(path)
|
443
443
|
base = File.basename(path)
|
444
444
|
if /\A#{SEPARATOR_PAT}?\z/o =~ base
|
445
|
-
|
445
|
+
nil
|
446
446
|
else
|
447
|
-
|
447
|
+
[path[0, path.rindex(base)], base]
|
448
448
|
end
|
449
449
|
end
|
450
450
|
|
data/lib/fakefs/version.rb
CHANGED
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: 1.2
|
4
|
+
version: 1.3.2
|
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:
|
15
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bump
|
@@ -29,33 +29,19 @@ dependencies:
|
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 0.5.3
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
32
|
+
name: maxitest
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
35
|
- - "~>"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '3.6'
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - "~>"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: minitest-rg
|
47
|
-
requirement: !ruby/object:Gem::Requirement
|
48
|
-
requirements:
|
49
|
-
- - "~>"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '5.1'
|
52
|
-
type: :development
|
53
|
-
prerelease: false
|
54
|
-
version_requirements: !ruby/object:Gem::Requirement
|
55
|
-
requirements:
|
56
|
-
- - "~>"
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: '5.1'
|
44
|
+
version: '3.6'
|
59
45
|
- !ruby/object:Gem::Dependency
|
60
46
|
name: rake
|
61
47
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,14 +76,14 @@ dependencies:
|
|
90
76
|
requirements:
|
91
77
|
- - "~>"
|
92
78
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.
|
79
|
+
version: 0.82.0
|
94
80
|
type: :development
|
95
81
|
prerelease: false
|
96
82
|
version_requirements: !ruby/object:Gem::Requirement
|
97
83
|
requirements:
|
98
84
|
- - "~>"
|
99
85
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.
|
86
|
+
version: 0.82.0
|
101
87
|
description: A fake filesystem. Use it in your tests.
|
102
88
|
email:
|
103
89
|
- chris@ozmm.org
|
@@ -136,14 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
122
|
requirements:
|
137
123
|
- - ">="
|
138
124
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.
|
125
|
+
version: 2.4.0
|
140
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
127
|
requirements:
|
142
128
|
- - ">="
|
143
129
|
- !ruby/object:Gem::Version
|
144
130
|
version: '0'
|
145
131
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.1.3
|
147
133
|
signing_key:
|
148
134
|
specification_version: 4
|
149
135
|
summary: A fake filesystem. Use it in your tests.
|