fakefs 2.7.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fakefs/base.rb +2 -0
- data/lib/fakefs/dir.rb +7 -3
- data/lib/fakefs/fake/dir.rb +2 -0
- data/lib/fakefs/fake/file.rb +3 -4
- data/lib/fakefs/fake/inode.rb +5 -7
- data/lib/fakefs/fake/symlink.rb +3 -1
- data/lib/fakefs/file.rb +15 -12
- data/lib/fakefs/file_system.rb +2 -0
- data/lib/fakefs/file_test.rb +2 -0
- data/lib/fakefs/fileutils.rb +2 -0
- data/lib/fakefs/flockable_file.rb +2 -0
- data/lib/fakefs/globber.rb +8 -6
- data/lib/fakefs/io.rb +2 -0
- data/lib/fakefs/irb.rb +2 -0
- data/lib/fakefs/kernel.rb +3 -1
- data/lib/fakefs/pathname.rb +6 -3
- data/lib/fakefs/pry.rb +2 -0
- data/lib/fakefs/safe.rb +2 -0
- data/lib/fakefs/spec_helpers.rb +2 -0
- data/lib/fakefs/version.rb +3 -1
- data/lib/fakefs.rb +2 -0
- metadata +48 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e3224ff5a1d920e4564617bcb22fa5a7ece1e956cd8d4ea5602f3486780ac2f
|
4
|
+
data.tar.gz: 66ee5d6658990778978ed1531c115ae28ad08414cf9aa1bc90f6fd7e6400b22f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42daab712ce7b73ca3ffef7b383834eac7e624bdbf43e4098000fdca7d16cc92d505a5631e256248734962d8db7cb148842d4efc1853686f9cbe5d8b288c6c89
|
7
|
+
data.tar.gz: 5514fc676ba615bd6387ad44cc3fa447fc566e265178729d8bb30a4098834e11a9f562f6cc8f25cc88b2c9d386827cc67506b46226008241510c67edbbeb6f81
|
data/lib/fakefs/base.rb
CHANGED
data/lib/fakefs/dir.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'English'
|
2
4
|
|
3
5
|
module FakeFS
|
@@ -127,10 +129,10 @@ module FakeFS
|
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
130
|
-
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, &block) # rubocop:disable Lint/UnderscorePrefixedVariableName
|
132
|
+
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, sort: true, &block) # rubocop:disable Lint/UnderscorePrefixedVariableName
|
131
133
|
pwd = FileSystem.normalize_path(base || Dir.pwd)
|
132
134
|
matches_for_pattern = lambda do |matcher|
|
133
|
-
[FileSystem.find_with_glob(matcher, flags, true, dir: pwd) || []].flatten.map do |e|
|
135
|
+
matched = [FileSystem.find_with_glob(matcher, flags, true, dir: pwd) || []].flatten.map do |e|
|
134
136
|
pwd_regex = %r{\A#{pwd.gsub('+') { '\+' }}/?}
|
135
137
|
if pwd.match(%r{\A/?\z}) ||
|
136
138
|
!e.to_s.match(pwd_regex)
|
@@ -138,7 +140,9 @@ module FakeFS
|
|
138
140
|
else
|
139
141
|
e.to_s.match(pwd_regex).post_match
|
140
142
|
end
|
141
|
-
end
|
143
|
+
end
|
144
|
+
matched.sort! if sort
|
145
|
+
matched
|
142
146
|
end
|
143
147
|
|
144
148
|
files =
|
data/lib/fakefs/fake/dir.rb
CHANGED
data/lib/fakefs/fake/file.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FakeFS
|
2
4
|
# Fake file class
|
3
5
|
class FakeFile
|
4
|
-
attr_accessor :name, :parent, :mtime, :atime, :mode, :uid, :gid
|
5
|
-
attr_reader :ctime, :birthtime
|
6
|
+
attr_accessor :name, :parent, :mtime, :atime, :mode, :uid, :gid, :ctime, :birthtime, :inode
|
6
7
|
|
7
8
|
def initialize(name = nil, parent = nil)
|
8
9
|
@name = name
|
@@ -17,8 +18,6 @@ module FakeFS
|
|
17
18
|
@gid = Process.gid
|
18
19
|
end
|
19
20
|
|
20
|
-
attr_accessor :inode
|
21
|
-
|
22
21
|
def content
|
23
22
|
@inode.content
|
24
23
|
end
|
data/lib/fakefs/fake/inode.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FakeFS
|
2
4
|
# Inode class
|
3
5
|
class FakeInode
|
@@ -10,14 +12,11 @@ module FakeFS
|
|
10
12
|
assign_inode_num
|
11
13
|
end
|
12
14
|
|
13
|
-
attr_accessor :content
|
14
|
-
attr_accessor :links
|
15
|
-
attr_accessor :inode_num
|
15
|
+
attr_accessor :content, :links, :inode_num
|
16
16
|
|
17
17
|
# please see: http://iacobson.net/beware-of-ruby-class-variables/
|
18
18
|
class << self
|
19
|
-
attr_accessor :freed_inodes
|
20
|
-
attr_accessor :next_inode_num
|
19
|
+
attr_accessor :freed_inodes, :next_inode_num
|
21
20
|
|
22
21
|
# This method should only be used for tests
|
23
22
|
# When called, it will reset the current inode information of the FakeFS
|
@@ -28,8 +27,7 @@ module FakeFS
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def assign_inode_num
|
31
|
-
|
32
|
-
else
|
30
|
+
unless (@inode_num = self.class.freed_inodes.shift)
|
33
31
|
@inode_num = self.class.next_inode_num
|
34
32
|
self.class.next_inode_num += 1
|
35
33
|
end
|
data/lib/fakefs/fake/symlink.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FakeFS
|
2
4
|
# Fake symlink class
|
3
5
|
class FakeSymlink
|
@@ -29,7 +31,7 @@ module FakeFS
|
|
29
31
|
|
30
32
|
private
|
31
33
|
|
32
|
-
def method_missing(*args, &block)
|
34
|
+
def method_missing(*args, &block)
|
33
35
|
entry.send(*args, &block)
|
34
36
|
end
|
35
37
|
end
|
data/lib/fakefs/file.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'stringio'
|
2
4
|
|
3
5
|
module FakeFS
|
4
6
|
# FakeFS File class inherit StringIO
|
5
7
|
class File < StringIO
|
6
8
|
MODES = [
|
7
|
-
READ_ONLY = 'r'
|
8
|
-
READ_WRITE = 'r+'
|
9
|
-
WRITE_ONLY = 'w'
|
10
|
-
READ_WRITE_TRUNCATE = 'w+'
|
11
|
-
APPEND_WRITE_ONLY = 'a'
|
12
|
-
APPEND_READ_WRITE = 'a+'
|
9
|
+
READ_ONLY = 'r',
|
10
|
+
READ_WRITE = 'r+',
|
11
|
+
WRITE_ONLY = 'w',
|
12
|
+
READ_WRITE_TRUNCATE = 'w+',
|
13
|
+
APPEND_WRITE_ONLY = 'a',
|
14
|
+
APPEND_READ_WRITE = 'a+'
|
13
15
|
].freeze
|
14
16
|
|
15
17
|
FMODE_READABLE = 0x00000001
|
@@ -277,7 +279,7 @@ module FakeFS
|
|
277
279
|
|
278
280
|
def self.delete(*files)
|
279
281
|
files.each do |file|
|
280
|
-
file_name = (file.
|
282
|
+
file_name = (file.instance_of?(FakeFS::File) ? file.path : file.to_s)
|
281
283
|
raise Errno::ENOENT, file_name unless exist?(file_name)
|
282
284
|
|
283
285
|
FileUtils.rm(file_name)
|
@@ -362,8 +364,7 @@ module FakeFS
|
|
362
364
|
|
363
365
|
# FakeFS Stat class
|
364
366
|
class Stat
|
365
|
-
attr_reader :ctime, :mtime, :atime, :mode, :uid, :gid
|
366
|
-
attr_reader :birthtime
|
367
|
+
attr_reader :ctime, :mtime, :atime, :mode, :uid, :gid, :birthtime
|
367
368
|
|
368
369
|
def initialize(file, lstat = false)
|
369
370
|
raise(Errno::ENOENT, file.to_s) unless File.exist?(file)
|
@@ -574,7 +575,9 @@ module FakeFS
|
|
574
575
|
# and force set it back.
|
575
576
|
|
576
577
|
# truncate doesn't work
|
577
|
-
@file.
|
578
|
+
unless @file.is_a?(FakeFS::FakeDir)
|
579
|
+
@file.content = @file.content.dup.force_encoding(Encoding.default_external)
|
580
|
+
end
|
578
581
|
# StringIO.new 'content', nil, **{} # works in MRI, but fails in JRuby
|
579
582
|
# but File.open 'filename', nil, **{} is ok both in MRI and JRuby
|
580
583
|
|
@@ -906,9 +909,9 @@ module FakeFS
|
|
906
909
|
# note we multiply by 7 since the group num is 1, and octal represents digits 1-7 and we want all 3 bits
|
907
910
|
current_group_mode = current_file_mode & (group_num * 7)
|
908
911
|
if group_num == 0o100
|
909
|
-
current_group_mode
|
912
|
+
current_group_mode >>= 6
|
910
913
|
elsif group_num == 0o10
|
911
|
-
current_group_mode
|
914
|
+
current_group_mode >>= 3
|
912
915
|
end
|
913
916
|
|
914
917
|
current_group_mode
|
data/lib/fakefs/file_system.rb
CHANGED
data/lib/fakefs/file_test.rb
CHANGED
data/lib/fakefs/fileutils.rb
CHANGED
data/lib/fakefs/globber.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FakeFS
|
2
4
|
# Handles globbing for FakeFS.
|
3
5
|
module Globber
|
@@ -8,14 +10,14 @@ module FakeFS
|
|
8
10
|
|
9
11
|
return [pattern] if pattern[0] != '{' || pattern[-1] != '}'
|
10
12
|
|
11
|
-
part = ''
|
13
|
+
part = +''
|
12
14
|
result = []
|
13
15
|
|
14
16
|
each_char_with_levels pattern, '{', '}' do |chr, level|
|
15
17
|
case level
|
16
18
|
when 0
|
17
19
|
case chr
|
18
|
-
when '{'
|
20
|
+
when '{'
|
19
21
|
# noop
|
20
22
|
else
|
21
23
|
part << chr
|
@@ -24,8 +26,8 @@ module FakeFS
|
|
24
26
|
case chr
|
25
27
|
when ','
|
26
28
|
result << part
|
27
|
-
part = ''
|
28
|
-
when '}'
|
29
|
+
part = +''
|
30
|
+
when '}'
|
29
31
|
# noop
|
30
32
|
else
|
31
33
|
part << chr
|
@@ -43,13 +45,13 @@ module FakeFS
|
|
43
45
|
def path_components(pattern)
|
44
46
|
pattern = pattern.to_s
|
45
47
|
|
46
|
-
part = ''
|
48
|
+
part = +''
|
47
49
|
result = []
|
48
50
|
|
49
51
|
each_char_with_levels pattern, '{', '}' do |chr, level|
|
50
52
|
if level == 0 && chr == File::SEPARATOR
|
51
53
|
result << part
|
52
|
-
part = ''
|
54
|
+
part = +''
|
53
55
|
else
|
54
56
|
part << chr
|
55
57
|
end
|
data/lib/fakefs/io.rb
CHANGED
data/lib/fakefs/irb.rb
CHANGED
data/lib/fakefs/kernel.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FakeFS
|
2
4
|
# Kernel Module
|
3
5
|
module Kernel
|
@@ -16,7 +18,7 @@ module FakeFS
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.unhijack!
|
19
|
-
captives[:original].
|
21
|
+
captives[:original].each_key do |name|
|
20
22
|
::Kernel.send(:remove_method, name.to_sym)
|
21
23
|
::Kernel.send(:define_method, name.to_sym, proc do |*args, **kwargs, &block|
|
22
24
|
::FakeFS::Kernel.captives[:original][name].call(*args, **kwargs, &block)
|
data/lib/fakefs/pathname.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# FakeFS module
|
2
4
|
module FakeFS
|
3
5
|
#
|
@@ -109,10 +111,10 @@ module FakeFS
|
|
109
111
|
if File::ALT_SEPARATOR
|
110
112
|
SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}" \
|
111
113
|
"#{Regexp.quote File::SEPARATOR}".freeze
|
112
|
-
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]
|
114
|
+
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/
|
113
115
|
else
|
114
116
|
SEPARATOR_LIST = (Regexp.quote File::SEPARATOR).to_s.freeze
|
115
|
-
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}
|
117
|
+
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
|
116
118
|
end
|
117
119
|
|
118
120
|
# Return a pathname which the extension of the basename is substituted by
|
@@ -483,7 +485,8 @@ module FakeFS
|
|
483
485
|
while (r = chop_basename(pre))
|
484
486
|
pre, base = r
|
485
487
|
case base
|
486
|
-
when '.'
|
488
|
+
when '.'
|
489
|
+
# ignored
|
487
490
|
when '..'
|
488
491
|
names.unshift base
|
489
492
|
else
|
data/lib/fakefs/pry.rb
CHANGED
data/lib/fakefs/safe.rb
CHANGED
data/lib/fakefs/spec_helpers.rb
CHANGED
data/lib/fakefs/version.rb
CHANGED
data/lib/fakefs.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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -9,39 +9,66 @@ authors:
|
|
9
9
|
- Jeff Hodges
|
10
10
|
- Pat Nakajima
|
11
11
|
- Brian Donovan
|
12
|
-
autorequire:
|
13
12
|
bindir: bin
|
14
13
|
cert_chain: []
|
15
|
-
date:
|
14
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: bump
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
20
19
|
requirements:
|
21
|
-
- - "
|
20
|
+
- - ">="
|
22
21
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0
|
22
|
+
version: '0'
|
24
23
|
type: :development
|
25
24
|
prerelease: false
|
26
25
|
version_requirements: !ruby/object:Gem::Requirement
|
27
26
|
requirements:
|
28
|
-
- - "
|
27
|
+
- - ">="
|
29
28
|
- !ruby/object:Gem::Version
|
30
|
-
version: 0
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: csv
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
31
44
|
- !ruby/object:Gem::Dependency
|
32
45
|
name: maxitest
|
33
46
|
requirement: !ruby/object:Gem::Requirement
|
34
47
|
requirements:
|
35
|
-
- - "
|
48
|
+
- - ">="
|
36
49
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
50
|
+
version: '0'
|
38
51
|
type: :development
|
39
52
|
prerelease: false
|
40
53
|
version_requirements: !ruby/object:Gem::Requirement
|
41
54
|
requirements:
|
42
|
-
- - "
|
55
|
+
- - ">="
|
43
56
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
57
|
+
version: '0'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mutex_m
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
45
72
|
- !ruby/object:Gem::Dependency
|
46
73
|
name: pry
|
47
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,42 +89,42 @@ dependencies:
|
|
62
89
|
requirements:
|
63
90
|
- - ">="
|
64
91
|
- !ruby/object:Gem::Version
|
65
|
-
version: '
|
92
|
+
version: '0'
|
66
93
|
type: :development
|
67
94
|
prerelease: false
|
68
95
|
version_requirements: !ruby/object:Gem::Requirement
|
69
96
|
requirements:
|
70
97
|
- - ">="
|
71
98
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
99
|
+
version: '0'
|
73
100
|
- !ruby/object:Gem::Dependency
|
74
101
|
name: rspec
|
75
102
|
requirement: !ruby/object:Gem::Requirement
|
76
103
|
requirements:
|
77
|
-
- - "
|
104
|
+
- - ">="
|
78
105
|
- !ruby/object:Gem::Version
|
79
|
-
version: '
|
106
|
+
version: '0'
|
80
107
|
type: :development
|
81
108
|
prerelease: false
|
82
109
|
version_requirements: !ruby/object:Gem::Requirement
|
83
110
|
requirements:
|
84
|
-
- - "
|
111
|
+
- - ">="
|
85
112
|
- !ruby/object:Gem::Version
|
86
|
-
version: '
|
113
|
+
version: '0'
|
87
114
|
- !ruby/object:Gem::Dependency
|
88
115
|
name: rubocop
|
89
116
|
requirement: !ruby/object:Gem::Requirement
|
90
117
|
requirements:
|
91
118
|
- - "~>"
|
92
119
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
120
|
+
version: 1.70.0
|
94
121
|
type: :development
|
95
122
|
prerelease: false
|
96
123
|
version_requirements: !ruby/object:Gem::Requirement
|
97
124
|
requirements:
|
98
125
|
- - "~>"
|
99
126
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
127
|
+
version: 1.70.0
|
101
128
|
description: A fake filesystem. Use it in your tests.
|
102
129
|
email:
|
103
130
|
- chris@ozmm.org
|
@@ -132,7 +159,6 @@ homepage: https://github.com/fakefs/fakefs
|
|
132
159
|
licenses:
|
133
160
|
- MIT
|
134
161
|
metadata: {}
|
135
|
-
post_install_message:
|
136
162
|
rdoc_options: []
|
137
163
|
require_paths:
|
138
164
|
- lib
|
@@ -140,15 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
166
|
requirements:
|
141
167
|
- - ">="
|
142
168
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
169
|
+
version: 3.0.0
|
144
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
171
|
requirements:
|
146
172
|
- - ">="
|
147
173
|
- !ruby/object:Gem::Version
|
148
174
|
version: '0'
|
149
175
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
151
|
-
signing_key:
|
176
|
+
rubygems_version: 3.6.2
|
152
177
|
specification_version: 4
|
153
178
|
summary: A fake filesystem. Use it in your tests.
|
154
179
|
test_files: []
|