fakefs 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fakefs/dir.rb +8 -7
- data/lib/fakefs/file.rb +14 -9
- data/lib/fakefs/pathname.rb +14 -12
- data/lib/fakefs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c03fdf5b7df7f95245c25016ce671ca0d128edc
|
4
|
+
data.tar.gz: 2eca67ca2151d1c6763a1a560b6a10f7b3942fde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eca7bba56ed5cee735c0bb3ad0c8a1b662ac7f48bd7f1a35e97fac032709568e7502973d95b9397de7b161dc883bbbbcda77a4cded668c75c30fb222db2a8bf2
|
7
|
+
data.tar.gz: fd6a82e87eb2d2dc9d4e66e5d7c23ae15c9047c74ba2882fca47547933795e3b706bee7101a0ec0cacada7b6615d1b3151956cfb364cb96c8f66ae4a304c74cf
|
data/lib/fakefs/dir.rb
CHANGED
@@ -104,13 +104,14 @@ module FakeFS
|
|
104
104
|
end.sort
|
105
105
|
end
|
106
106
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
107
|
+
files =
|
108
|
+
if pattern.is_a?(Array)
|
109
|
+
pattern.map do |matcher|
|
110
|
+
matches_for_pattern.call matcher
|
111
|
+
end.flatten
|
112
|
+
else
|
113
|
+
matches_for_pattern.call pattern
|
114
|
+
end
|
114
115
|
|
115
116
|
block_given? ? files.each { |file| block.call(file) } : files
|
116
117
|
end
|
data/lib/fakefs/file.rb
CHANGED
@@ -4,15 +4,15 @@ module FakeFS
|
|
4
4
|
# FakeFS File class inherit StringIO
|
5
5
|
class File < StringIO
|
6
6
|
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+'
|
13
|
-
]
|
7
|
+
READ_ONLY = 'r'.freeze,
|
8
|
+
READ_WRITE = 'r+'.freeze,
|
9
|
+
WRITE_ONLY = 'w'.freeze,
|
10
|
+
READ_WRITE_TRUNCATE = 'w+'.freeze,
|
11
|
+
APPEND_WRITE_ONLY = 'a'.freeze,
|
12
|
+
APPEND_READ_WRITE = 'a+'.freeze
|
13
|
+
].freeze
|
14
14
|
|
15
|
-
FILE_CREATION_MODES = MODES - [READ_ONLY, READ_WRITE]
|
15
|
+
FILE_CREATION_MODES = (MODES - [READ_ONLY, READ_WRITE]).freeze
|
16
16
|
|
17
17
|
MODE_BITMASK = RealFile::RDONLY |
|
18
18
|
RealFile::WRONLY |
|
@@ -209,7 +209,12 @@ module FakeFS
|
|
209
209
|
end
|
210
210
|
|
211
211
|
if (target = FileSystem.find(source))
|
212
|
-
|
212
|
+
if target.is_a?(FakeFS::FakeSymlink)
|
213
|
+
File.symlink(target.target, dest)
|
214
|
+
else
|
215
|
+
FileSystem.add(dest, target.entry.clone)
|
216
|
+
end
|
217
|
+
|
213
218
|
FileSystem.delete(source)
|
214
219
|
else
|
215
220
|
fail Errno::ENOENT, "#{source} or #{dest}"
|
data/lib/fakefs/pathname.rb
CHANGED
@@ -17,11 +17,12 @@ module FakeFS
|
|
17
17
|
# usable with File.open, etc.
|
18
18
|
TO_PATH = :to_path
|
19
19
|
|
20
|
-
SAME_PATHS =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
SAME_PATHS =
|
21
|
+
if File::FNM_SYSCASE.nonzero?
|
22
|
+
proc { |a, b| a.casecmp(b).zero? }
|
23
|
+
else
|
24
|
+
proc { |a, b| a == b }
|
25
|
+
end
|
25
26
|
|
26
27
|
# :startdoc:
|
27
28
|
|
@@ -117,10 +118,10 @@ module FakeFS
|
|
117
118
|
|
118
119
|
if File::ALT_SEPARATOR
|
119
120
|
SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}" \
|
120
|
-
"#{Regexp.quote File::SEPARATOR}"
|
121
|
+
"#{Regexp.quote File::SEPARATOR}".freeze
|
121
122
|
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/
|
122
123
|
else
|
123
|
-
SEPARATOR_LIST = "#{Regexp.quote File::SEPARATOR}"
|
124
|
+
SEPARATOR_LIST = "#{Regexp.quote File::SEPARATOR}".freeze
|
124
125
|
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
|
125
126
|
end
|
126
127
|
|
@@ -529,11 +530,12 @@ module FakeFS
|
|
529
530
|
result = []
|
530
531
|
Dir.foreach(@path) do |e|
|
531
532
|
next if e == '.' || e == '..'
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
533
|
+
result <<
|
534
|
+
if with_directory
|
535
|
+
self.class.new(File.join(@path, e))
|
536
|
+
else
|
537
|
+
self.class.new(e)
|
538
|
+
end
|
537
539
|
end
|
538
540
|
result
|
539
541
|
end
|
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: 0.10.
|
4
|
+
version: 0.10.1
|
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: 2016-
|
15
|
+
date: 2016-12-07 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.
|
160
|
+
rubygems_version: 2.5.1
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: A fake filesystem. Use it in your tests.
|