fakefs 1.0.0 → 1.2.3

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
  SHA256:
3
- metadata.gz: d66d45ce395ac98a16475005c6dcb2bea65987d13f035ca6fba22b891c49ed85
4
- data.tar.gz: b08159da06da614fbc5250e462deee6908bd11c66bbf349bc4476c60c20652af
3
+ metadata.gz: '05218e3b531393a48c565fe787759d6e4e89c64cc89047c3685d199ef0775921'
4
+ data.tar.gz: 59a65166fe4d0bc0dbc4d3fa002e0180d98a548548542447568d9e9ea45b0977
5
5
  SHA512:
6
- metadata.gz: 43041ad7acafb77fedfef6357953fc45bb9eead99eba2806aa7c5e350b3e647f09e36b53d3b974dfd96daaf36721d3d1c437917131f0e07fd14de8731b0df79f
7
- data.tar.gz: 0064c6914fd6df796be81324820d5700f711388297c72164eefc16f65de4ff827c9f1f014c4040bd79cc4e356cf0c277301581522195d0ab9500e41393b2298d
6
+ metadata.gz: a599803b52fd91196e05878a5570218de25884e2e0e47becebb49f0006b2d909b1de86f0699e983f7f315aedb2b789abe568765b42eefa2f8dce1080e6a2dc86
7
+ data.tar.gz: e6a99b4c246abbc1f2de43420b82dbc48700cdb50851c8b76906a14ed6147a4892511b7c70cbbf4a67c6d66ee9b8824db3dbc331da22f47614a6de83bf789b3b
data/README.md CHANGED
@@ -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
 
@@ -16,7 +16,7 @@ end
16
16
  module FakeFS
17
17
  class << self
18
18
  def activated?
19
- @activated ? true : false
19
+ @activated ||= false
20
20
  end
21
21
 
22
22
  # unconditionally activate
@@ -85,14 +85,14 @@ module FakeFS
85
85
  FileSystem.delete(string)
86
86
  end
87
87
 
88
- def self.entries(dirname, _opts = {})
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, opts = {})
95
- entries(dirname, opts) - ['.', '..']
94
+ def self.children(dirname, _options = nil)
95
+ entries(dirname) - ['.', '..']
96
96
  end
97
97
 
98
98
  def self.each_child(dirname, &_block)
@@ -194,20 +194,17 @@ module FakeFS
194
194
  if (opts = Hash.try_convert(rest[-1]))
195
195
  opts = opts.dup if rest.pop.equal?(opts)
196
196
  max_try = opts.delete(:max_try)
197
- opts = [opts]
198
197
  else
199
- opts = []
198
+ opts = {}
200
199
  end
201
200
  tmpdir, = *rest
202
- if $SAFE > 0 && tmpdir.tainted?
203
- tmpdir = '/tmp'
204
- else
205
- tmpdir ||= self.tmpdir
206
- end
201
+ tmpdir ||= self.tmpdir
202
+ Dir.mkdir(tmpdir) unless Dir.exist?(tmpdir)
203
+
207
204
  n = nil
208
205
  begin
209
206
  path = File.join(tmpdir, make_tmpname(basename, n))
210
- yield(path, n, *opts)
207
+ yield(path, n, opts)
211
208
  rescue Errno::EEXIST
212
209
  n ||= 0
213
210
  n += 1
@@ -53,6 +53,10 @@ module FakeFS
53
53
  class << self
54
54
  alias exists? exist?
55
55
 
56
+ def identical?(one_path, another_path)
57
+ FileSystem.find(one_path) == FileSystem.find(another_path)
58
+ end
59
+
56
60
  # Assume nothing is sticky.
57
61
  def sticky?(_path)
58
62
  false
@@ -183,7 +187,7 @@ module FakeFS
183
187
  options = args[-1].is_a?(Hash) ? args.pop : {}
184
188
  length = args.empty? ? nil : args.shift
185
189
  offset = args.empty? ? 0 : args.shift
186
- file = new(path, options)
190
+ file = new(path, **options)
187
191
 
188
192
  raise Errno::ENOENT unless file.exists?
189
193
  raise Errno::EISDIR, path.to_s if directory?(path)
@@ -227,6 +231,8 @@ module FakeFS
227
231
  end
228
232
 
229
233
  if (target = FileSystem.find(source))
234
+ return 0 if source == dest
235
+
230
236
  if target.is_a?(FakeFS::FakeSymlink)
231
237
  File.symlink(target.target, dest)
232
238
  else
@@ -253,14 +259,15 @@ module FakeFS
253
259
  0
254
260
  end
255
261
 
256
- def self.delete(*file_names)
257
- file_names.each do |file_name|
258
- raise Errno::ENOENT, file_name.to_s unless exists?(file_name)
262
+ def self.delete(*files)
263
+ files.each do |file|
264
+ file_name = (file.class == FakeFS::File ? file.path : file.to_s)
265
+ raise Errno::ENOENT, file_name unless exists?(file_name)
259
266
 
260
267
  FileUtils.rm(file_name)
261
268
  end
262
269
 
263
- file_names.size
270
+ files.size
264
271
  end
265
272
 
266
273
  class << self
@@ -497,8 +504,8 @@ module FakeFS
497
504
  true
498
505
  end
499
506
 
500
- def write(str)
501
- val = super(str)
507
+ def write(*args)
508
+ val = super(*args)
502
509
  @file.mtime = Time.now
503
510
  val
504
511
  end
@@ -690,7 +697,11 @@ module FakeFS
690
697
 
691
698
  def read(length = nil, buf = '')
692
699
  read_buf = super(length, buf)
693
- read_buf&.force_encoding('ASCII-8BIT') if binary_mode?
700
+ if binary_mode?
701
+ read_buf&.force_encoding('ASCII-8BIT')
702
+ else
703
+ read_buf&.force_encoding(Encoding.default_external)
704
+ end
694
705
  read_buf
695
706
  end
696
707
 
@@ -103,7 +103,7 @@ module FakeFS
103
103
  raise Errno::ENOENT, dest.to_s unless File.exist?(dest) || File.exist?(File.dirname(dest))
104
104
 
105
105
  # handle `verbose' flag
106
- RealFileUtils.cp src, dest, options.merge(noop: true)
106
+ RealFileUtils.cp src, dest, **options.merge(noop: true)
107
107
 
108
108
  # handle `noop' flag
109
109
  return if options[:noop]
@@ -145,7 +145,7 @@ module FakeFS
145
145
 
146
146
  def cp_r(src, dest, options = {})
147
147
  # handle `verbose' flag
148
- RealFileUtils.cp_r src, dest, options.merge(noop: true)
148
+ RealFileUtils.cp_r src, dest, **options.merge(noop: true)
149
149
 
150
150
  # handle `noop' flag
151
151
  return if options[:noop]
@@ -176,7 +176,7 @@ module FakeFS
176
176
 
177
177
  def mv(src, dest, options = {})
178
178
  # handle `verbose' flag
179
- RealFileUtils.mv src, dest, options.merge(noop: true)
179
+ RealFileUtils.mv src, dest, **options.merge(noop: true)
180
180
 
181
181
  # handle `noop' flag
182
182
  return if options[:noop]
@@ -36,8 +36,6 @@ module FakeFS
36
36
  if /\0/ =~ @path
37
37
  raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
38
38
  end
39
-
40
- taint if @path.tainted?
41
39
  end
42
40
 
43
41
  def freeze
@@ -46,18 +44,6 @@ module FakeFS
46
44
  self
47
45
  end
48
46
 
49
- def taint
50
- super
51
- @path.taint
52
- self
53
- end
54
-
55
- def untaint
56
- super
57
- @path.untaint
58
- self
59
- end
60
-
61
47
  #
62
48
  # Compare this pathname with +other+. The comparison is string-based.
63
49
  # Be aware that two different paths
@@ -123,10 +109,10 @@ module FakeFS
123
109
  if File::ALT_SEPARATOR
124
110
  SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}" \
125
111
  "#{Regexp.quote File::SEPARATOR}".freeze
126
- SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/
112
+ SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/.freeze
127
113
  else
128
114
  SEPARATOR_LIST = (Regexp.quote File::SEPARATOR).to_s.freeze
129
- SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
115
+ SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/.freeze
130
116
  end
131
117
 
132
118
  # Return a pathname which the extension of the basename is substituted by
@@ -456,9 +442,9 @@ module FakeFS
456
442
  def chop_basename(path)
457
443
  base = File.basename(path)
458
444
  if /\A#{SEPARATOR_PAT}?\z/o =~ base
459
- return nil
445
+ nil
460
446
  else
461
- return path[0, path.rindex(base)], base
447
+ [path[0, path.rindex(base)], base]
462
448
  end
463
449
  end
464
450
 
@@ -1,7 +1,7 @@
1
1
  module FakeFS
2
2
  # Version module
3
3
  module Version
4
- VERSION = '1.0.0'.freeze
4
+ VERSION = '1.2.3'.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: 1.0.0
4
+ version: 1.2.3
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: 2020-01-10 00:00:00.000000000 Z
15
+ date: 2020-12-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bump
@@ -29,45 +29,31 @@ dependencies:
29
29
  - !ruby/object:Gem::Version
30
30
  version: 0.5.3
31
31
  - !ruby/object:Gem::Dependency
32
- name: minitest
32
+ name: maxitest
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
35
  - - "~>"
36
36
  - !ruby/object:Gem::Version
37
- version: '5.5'
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: '5.5'
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
62
48
  requirements:
63
- - - "~>"
49
+ - - ">="
64
50
  - !ruby/object:Gem::Version
65
51
  version: '10.3'
66
52
  type: :development
67
53
  prerelease: false
68
54
  version_requirements: !ruby/object:Gem::Requirement
69
55
  requirements:
70
- - - "~>"
56
+ - - ">="
71
57
  - !ruby/object:Gem::Version
72
58
  version: '10.3'
73
59
  - !ruby/object:Gem::Dependency
@@ -90,14 +76,14 @@ dependencies:
90
76
  requirements:
91
77
  - - "~>"
92
78
  - !ruby/object:Gem::Version
93
- version: 0.58.1
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.58.1
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.3.0
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.0.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.