fakefs 1.3.2 → 1.4.0
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 +4 -4
- data/lib/fakefs/dir.rb +3 -3
- data/lib/fakefs/file_system.rb +7 -5
- data/lib/fakefs/pathname.rb +11 -3
- data/lib/fakefs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e62fc76c0ca1c48b09e7b4051d5888a3f361b7f6e72434275bf3820d972c05d0
|
4
|
+
data.tar.gz: fc2e3377b5948b04302f06893fd4b961311699c597dfe431a9ab04046b488d67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c43a34b04c1d010a783da8646dfff11d50892a15faa5660730e9d284b046dfdf921adbcaff550ca0b2a25bbc5537060b457f37e11c7d64aa6bb7271cd8975ae
|
7
|
+
data.tar.gz: e0523fab127204c4400921d2e1bc6bdbf8ed6c61b8c731707d92b8fa916e1c7320290c18546168bee757888dfd2ae3ad5953cb1b55557e9e5f40997428cb66d4
|
data/lib/fakefs/dir.rb
CHANGED
@@ -117,10 +117,10 @@ module FakeFS
|
|
117
117
|
Dir.open(dirname) { |file| yield file }
|
118
118
|
end
|
119
119
|
|
120
|
-
def self.glob(pattern,
|
120
|
+
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, &block) # rubocop:disable Lint/UnderscorePrefixedVariableName
|
121
|
+
pwd = FileSystem.normalize_path(base || Dir.pwd)
|
121
122
|
matches_for_pattern = lambda do |matcher|
|
122
|
-
[FileSystem.find(matcher, flags, true) || []].flatten.map do |e|
|
123
|
-
pwd = Dir.pwd
|
123
|
+
[FileSystem.find(matcher, flags, true, dir: pwd) || []].flatten.map do |e|
|
124
124
|
pwd_regex = %r{\A#{pwd.gsub('+') { '\+' }}/?}
|
125
125
|
if pwd.match(%r{\A/?\z}) ||
|
126
126
|
!e.to_s.match(pwd_regex)
|
data/lib/fakefs/file_system.rb
CHANGED
@@ -20,12 +20,12 @@ module FakeFS
|
|
20
20
|
fs.entries
|
21
21
|
end
|
22
22
|
|
23
|
-
def find(path, find_flags = 0, gave_char_class = false)
|
24
|
-
parts = path_parts(normalize_path(path))
|
23
|
+
def find(path, find_flags = 0, gave_char_class = false, dir: nil)
|
24
|
+
parts = path_parts(normalize_path(path, dir: dir))
|
25
25
|
return fs if parts.empty? # '/'
|
26
26
|
|
27
27
|
entries = Globber.expand(path).flat_map do |pattern|
|
28
|
-
parts = path_parts(normalize_path(pattern))
|
28
|
+
parts = path_parts(normalize_path(pattern, dir: dir))
|
29
29
|
find_recurser(fs, parts, find_flags, gave_char_class).flatten
|
30
30
|
end
|
31
31
|
|
@@ -100,11 +100,13 @@ module FakeFS
|
|
100
100
|
Globber.path_components(path)
|
101
101
|
end
|
102
102
|
|
103
|
-
def normalize_path(path)
|
103
|
+
def normalize_path(path, dir: nil)
|
104
104
|
if Pathname.new(path).absolute?
|
105
105
|
RealFile.expand_path(path)
|
106
106
|
else
|
107
|
-
|
107
|
+
dir ||= dir_levels
|
108
|
+
dir = Array(dir)
|
109
|
+
parts = dir + [path]
|
108
110
|
RealFile.expand_path(parts.reduce do |base, part|
|
109
111
|
Pathname(base) + part
|
110
112
|
end.to_s)
|
data/lib/fakefs/pathname.rb
CHANGED
@@ -909,11 +909,11 @@ module FakeFS
|
|
909
909
|
# Pathname class
|
910
910
|
class Pathname # * Dir *
|
911
911
|
# See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
|
912
|
-
def self.glob(*args) # :yield: pathname
|
912
|
+
def self.glob(*args, **opts) # :yield: pathname
|
913
913
|
if block_given?
|
914
|
-
Dir.glob(*args) { |f| yield new(f) }
|
914
|
+
Dir.glob(*args, **opts) { |f| yield new(f) }
|
915
915
|
else
|
916
|
-
Dir.glob(*args).map { |f| new(f) }
|
916
|
+
Dir.glob(*args, **opts).map { |f| new(f) }
|
917
917
|
end
|
918
918
|
end
|
919
919
|
|
@@ -953,6 +953,14 @@ module FakeFS
|
|
953
953
|
def opendir(&block) # :yield: dir
|
954
954
|
Dir.open(@path, &block)
|
955
955
|
end
|
956
|
+
|
957
|
+
def glob(pattern, flags = 0)
|
958
|
+
if block_given?
|
959
|
+
Dir.glob(pattern, flags: flags, base: self) { |f| yield join(f) }
|
960
|
+
else
|
961
|
+
Dir.glob(pattern, flags: flags, base: self).map { |f| join(f) }
|
962
|
+
end
|
963
|
+
end
|
956
964
|
end
|
957
965
|
|
958
966
|
# Pathname class
|
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.
|
4
|
+
version: 1.4.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: 2021-
|
15
|
+
date: 2021-10-21 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bump
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.2.16
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: A fake filesystem. Use it in your tests.
|