fakefs 0.7.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e41d41305c22bf0ef89f9e3e00e3b1888db74f0c
4
- data.tar.gz: 23cf2892e9ef0c928b72436863cda9a22a0e4692
3
+ metadata.gz: 0f8537aa4162b3719ec77e1473ff51f15534088c
4
+ data.tar.gz: e07735c800c2d357a4bccea0192f8f1f5d811de8
5
5
  SHA512:
6
- metadata.gz: 082a1ae98f913c68711d60091f6554fc8a87bf286b57fc7a909e25f5890cdece9851ee25ed3912f7ab9a398ea9fe920723ccf3437d26f1041252e84cec6beb2a
7
- data.tar.gz: 817fb7bc5bd120f4f5d774a020fbc25dc0334311eb5fdcdaf391b4c089afa83cdf62c6c7cd298a1bec27c982a263cf971fc87be4a3681290690f344dec16ecea
6
+ metadata.gz: adbcc925b19c3ab19b319dab7e8d08d54d17c39524452b8824202e21000c66d75d9f9abe5b9f0a18fa2add08ea3ef547e0b6add273ae60154047f83117147503
7
+ data.tar.gz: e81a430d7ecdd264a8e9b72f522786849622b5a4aedcacfa06a2f020fd91062ab3b2b6a63fdb19c67038a633374d6cc79b6656b88edf6650e369af607416a529
data/README.markdown CHANGED
@@ -136,7 +136,7 @@ Speed?
136
136
  Installation
137
137
  ------------
138
138
 
139
- ### [RubyGems](http://rubygems.org/)
139
+ ### [RubyGems](https://rubygems.org/)
140
140
 
141
141
  $ gem install fakefs
142
142
 
@@ -156,14 +156,14 @@ Meta
156
156
  ----
157
157
 
158
158
  * Code: `git clone git://github.com/defunkt/fakefs.git`
159
- * Home: <http://github.com/defunkt/fakefs>
160
- * Docs: <http://rdoc.info/github/defunkt/fakefs>
161
- * Bugs: <http://github.com/defunkt/fakefs/issues>
162
- * Test: <http://travisci.org/#!/defunkt/fakefs>
163
- * Gems: <http://rubygems.org/gems/fakefs>
164
-
165
- [0]: http://help.github.com/forking/
166
- [1]: http://help.github.com/send-pull-requests/
159
+ * Home: <https://github.com/fakefs/fakefs>
160
+ * Docs: <http://www.rubydoc.info/github/defunkt/fakefs>
161
+ * Bugs: <https://github.com/fakefs/fakefs/issues>
162
+ * Test: <https://travis-ci.org/#!/defunkt/fakefs>
163
+ * Gems: <https://rubygems.org/gems/fakefs>
164
+
165
+ [0]: https://help.github.com/forking/
166
+ [1]: https://help.github.com/send-pull-requests/
167
167
 
168
168
  Releasing
169
169
  ---------
data/lib/fakefs/dir.rb CHANGED
@@ -24,9 +24,13 @@ module FakeFS
24
24
  nil
25
25
  end
26
26
 
27
- def each(&_block)
28
- while (f = read)
29
- yield f
27
+ def each
28
+ if block_given?
29
+ while (f = read)
30
+ yield f
31
+ end
32
+ else
33
+ @contents.map { |entry| entry_to_relative_path(entry) }.each
30
34
  end
31
35
  end
32
36
 
@@ -39,16 +43,10 @@ module FakeFS
39
43
  end
40
44
 
41
45
  def read
42
- fail IOError, 'closed directory' if @pointer.nil?
43
- n = @contents[@pointer]
46
+ fail IOError, 'closed directory' unless @pointer
47
+ entry = @contents[@pointer]
44
48
  @pointer += 1
45
- return unless n
46
-
47
- if n.to_s[0, path.size + 1] == path + '/'
48
- n.to_s[path.size + 1..-1]
49
- else
50
- n.to_s
51
- end
49
+ entry_to_relative_path(entry) if entry
52
50
  end
53
51
 
54
52
  def rewind
@@ -200,6 +198,13 @@ module FakeFS
200
198
  end
201
199
  end
202
200
 
201
+ private
202
+
203
+ def entry_to_relative_path(entry)
204
+ filename = entry.to_s
205
+ filename.start_with?("#{path}/") ? filename[path.size + 1..-1] : filename
206
+ end
207
+
203
208
  # This code has been borrowed from Rubinius
204
209
  def self.mktmpdir(prefix_suffix = nil, tmpdir = nil)
205
210
  case prefix_suffix
@@ -1,7 +1,7 @@
1
1
  module FakeFS
2
2
  # Fake file class
3
3
  class FakeFile
4
- attr_accessor :name, :parent, :content, :mtime, :atime, :mode, :uid, :gid
4
+ attr_accessor :name, :parent, :mtime, :atime, :mode, :uid, :gid
5
5
  attr_reader :ctime, :birthtime
6
6
 
7
7
  # Inode class
data/lib/fakefs/file.rb CHANGED
@@ -136,6 +136,10 @@ module FakeFS
136
136
  end
137
137
  end
138
138
 
139
+ def self.ftype(filename)
140
+ File.lstat(filename).ftype
141
+ end
142
+
139
143
  def self.expand_path(file_name, dir_string = FileSystem.current_dir.to_s)
140
144
  RealFile.expand_path(file_name, RealFile.expand_path(dir_string, Dir.pwd))
141
145
  end
@@ -177,6 +181,20 @@ module FakeFS
177
181
  end
178
182
  end
179
183
 
184
+ def self.foreach(path, *args, &block)
185
+ file = new(path)
186
+ if file.exists?
187
+ FileSystem.find(path).atime = Time.now
188
+ if block_given?
189
+ file.each_line(*args, &block)
190
+ else
191
+ file.each_line(*args)
192
+ end
193
+ else
194
+ fail Errno::ENOENT
195
+ end
196
+ end
197
+
180
198
  def self.rename(source, dest)
181
199
  if directory?(source) && file?(dest)
182
200
  fail Errno::ENOTDIR, "#{source} or #{dest}"
@@ -136,12 +136,18 @@ module FakeFS
136
136
  return if options[:noop]
137
137
 
138
138
  Array(src).each do |source|
139
- # This error sucks, but it conforms to the original Ruby
140
- # method.
141
- fail "unknown file type: #{source}" unless
142
- (dir = FileSystem.find(source))
143
- new_dir = FileSystem.find(dest)
139
+ dir = FileSystem.find(source)
140
+ unless dir
141
+ if RUBY_VERSION >= '1.9.1'
142
+ fail Errno::ENOENT, source
143
+ else
144
+ # This error sucks, but it conforms to the original Ruby
145
+ # method.
146
+ fail "unknown file type: #{source}"
147
+ end
148
+ end
144
149
 
150
+ new_dir = FileSystem.find(dest)
145
151
  fail Errno::EEXIST, dest if new_dir && !File.directory?(dest)
146
152
  fail Errno::ENOENT, dest if !new_dir && !FileSystem.find(dest + '/../')
147
153
 
@@ -276,5 +282,16 @@ module FakeFS
276
282
 
277
283
  alias_method :cmp, :compare_file
278
284
  alias_method :identical?, :compare_file
285
+
286
+ def uptodate?(new, old_list)
287
+ return false unless File.exist?(new)
288
+ new_time = File.mtime(new)
289
+ old_list.each do |old|
290
+ if File.exist?(old)
291
+ return false unless new_time > File.mtime(old)
292
+ end
293
+ end
294
+ true
295
+ end
279
296
  end
280
297
  end
@@ -62,6 +62,7 @@ module FakeFS
62
62
  .gsub('*', '.*')
63
63
  .gsub('(', '\(')
64
64
  .gsub(')', '\)')
65
+ .gsub('$', '\$')
65
66
  .gsub(/\{(.*?)\}/) do
66
67
  "(#{Regexp.last_match[1].gsub(',', '|')})"
67
68
  end
@@ -327,7 +327,7 @@ module FakeFS
327
327
  # pathnames which points to roots such as <tt>/usr/..</tt>.
328
328
  #
329
329
  def root?
330
- !(chop_basename(@path).nil? && /#{SEPARATOR_PAT}/o =~ @path).nil?
330
+ chop_basename(@path).nil? && /#{SEPARATOR_PAT}/o =~ @path
331
331
  end
332
332
 
333
333
  # Predicate method for testing whether a path is absolute.
@@ -1009,8 +1009,11 @@ module FakeFS
1009
1009
  # Removes a file or directory, using <tt>File.unlink</tt> or
1010
1010
  # <tt>Dir.unlink</tt> as necessary.
1011
1011
  def unlink
1012
- Dir.unlink @path if File.directory? @path
1013
- File.unlink @path unless File.directory? @path
1012
+ if File.directory? @path
1013
+ Dir.unlink @path
1014
+ else
1015
+ File.unlink @path
1016
+ end
1014
1017
  end
1015
1018
 
1016
1019
  alias_method :delete, :unlink
@@ -1,7 +1,7 @@
1
1
  module FakeFS
2
2
  # Version module
3
3
  module Version
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
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: 0.7.0
4
+ version: 0.8.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: 2016-01-23 00:00:00.000000000 Z
15
+ date: 2016-02-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -70,6 +70,20 @@ dependencies:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
72
  version: 0.35.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: bump
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: 0.5.3
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: 0.5.3
73
87
  - !ruby/object:Gem::Dependency
74
88
  name: minitest
75
89
  requirement: !ruby/object:Gem::Requirement
@@ -105,18 +119,8 @@ executables: []
105
119
  extensions: []
106
120
  extra_rdoc_files: []
107
121
  files:
108
- - ".autotest"
109
- - ".gitignore"
110
- - ".rspec"
111
- - ".rubocop.yml"
112
- - ".travis.yml"
113
- - CONTRIBUTORS
114
- - Gemfile
115
122
  - LICENSE
116
123
  - README.markdown
117
- - Rakefile
118
- - etc/git-rank-contributors
119
- - fakefs.gemspec
120
124
  - lib/fakefs.rb
121
125
  - lib/fakefs/base.rb
122
126
  - lib/fakefs/dir.rb
@@ -133,27 +137,7 @@ files:
133
137
  - lib/fakefs/safe.rb
134
138
  - lib/fakefs/spec_helpers.rb
135
139
  - lib/fakefs/version.rb
136
- - spec/fakefs/fakefs_bug_ruby_2.1.0-preview2_spec.rb
137
- - spec/fakefs/spec_helpers_spec.rb
138
- - spec/spec.opts
139
- - spec/spec_helper.rb
140
- - test/dir/tempfile_test.rb
141
- - test/fake/file/join_test.rb
142
- - test/fake/file/lstat_test.rb
143
- - test/fake/file/stat_test.rb
144
- - test/fake/file/sysseek_test.rb
145
- - test/fake/file/syswrite_test.rb
146
- - test/fake/file_test.rb
147
- - test/fake/symlink_test.rb
148
- - test/fakefs_test.rb
149
- - test/file/stat_test.rb
150
- - test/globber_test.rb
151
- - test/kernel_test.rb
152
- - test/pathname_test.rb
153
- - test/safe_test.rb
154
- - test/test_helper.rb
155
- - test/verify.rb
156
- homepage: http://github.com/defunkt/fakefs
140
+ homepage: https://github.com/defunkt/fakefs
157
141
  licenses:
158
142
  - MIT
159
143
  metadata: {}
@@ -173,28 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
157
  version: '0'
174
158
  requirements: []
175
159
  rubyforge_project:
176
- rubygems_version: 2.4.8
160
+ rubygems_version: 2.4.5.1
177
161
  signing_key:
178
162
  specification_version: 4
179
163
  summary: A fake filesystem. Use it in your tests.
180
- test_files:
181
- - spec/fakefs/fakefs_bug_ruby_2.1.0-preview2_spec.rb
182
- - spec/fakefs/spec_helpers_spec.rb
183
- - spec/spec.opts
184
- - spec/spec_helper.rb
185
- - test/dir/tempfile_test.rb
186
- - test/fake/file/join_test.rb
187
- - test/fake/file/lstat_test.rb
188
- - test/fake/file/stat_test.rb
189
- - test/fake/file/sysseek_test.rb
190
- - test/fake/file/syswrite_test.rb
191
- - test/fake/file_test.rb
192
- - test/fake/symlink_test.rb
193
- - test/fakefs_test.rb
194
- - test/file/stat_test.rb
195
- - test/globber_test.rb
196
- - test/kernel_test.rb
197
- - test/pathname_test.rb
198
- - test/safe_test.rb
199
- - test/test_helper.rb
200
- - test/verify.rb
164
+ test_files: []
data/.autotest DELETED
@@ -1,5 +0,0 @@
1
- Autotest.add_hook :initialize do |at|
2
- at.add_mapping(%r%^test/.+_test.rb$%) do |filename, _|
3
- filename
4
- end
5
- end
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- *.sw?
2
- pkg
3
- Gemfile.lock
4
- .rbenv-version
5
- docs
6
- pkg
7
- .rbx
8
- .idea
9
- .bundle
10
- .project
11
- .ruby-version
12
- Gemfile.lock
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/.rubocop.yml DELETED
@@ -1,54 +0,0 @@
1
- AllCops:
2
- UseCache: true
3
- Include:
4
- - '**/Gemfile'
5
- - lib/**/*
6
- - spec/**/*
7
- - gemirro.gemspec
8
- Exclude:
9
- - files/**/*
10
- - templates/**/*
11
- - etc/**/*
12
- Metrics/MethodLength:
13
- Exclude:
14
- - lib/**/*
15
- - test/**/*.rb
16
- - spec/**/*.rb
17
- Metrics/ClassLength:
18
- Enabled: false
19
- Metrics/ModuleLength:
20
- Enabled: false
21
- Metrics/LineLength:
22
- Exclude:
23
- - test/**/*
24
- Metrics/ParameterLists:
25
- Enabled: false
26
- Metrics/CyclomaticComplexity:
27
- Severity: warning
28
- Max: 20
29
- Metrics/PerceivedComplexity:
30
- Severity: warning
31
- Max: 20
32
- Lint/Eval:
33
- Enabled: false
34
- Metrics/BlockNesting:
35
- Severity: warning
36
- Max: 4
37
- Metrics/AbcSize:
38
- Enabled: false
39
- Performance/StringReplacement:
40
- Enabled: false
41
- Style/ParallelAssignment:
42
- Enabled: false
43
- Style/PredicateName:
44
- Exclude:
45
- - lib/fakefs/file.rb
46
- Style/MethodName:
47
- Enabled: false
48
- Style/ModuleFunction:
49
- Enabled: false
50
- Style/SymbolProc:
51
- Enabled: false
52
- Style/TrivialAccessors:
53
- Enabled: true
54
- ExactNameMatch: true
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1.1
7
- - 2.2.0
8
- - jruby
9
- - rbx-19mode
10
- matrix:
11
- allow_failures:
12
- - rvm: jruby
13
- - rvm: rbx-19mode
14
- before_install:
15
- - gem --version
data/CONTRIBUTORS DELETED
@@ -1,97 +0,0 @@
1
- Scott Taylor <scott@railsnewbie.com>
2
- Pierre RAMBAUD <pierre.rambaud@numergy.com>
3
- Pat Nakajima <patnakajima@gmail.com>
4
- Chris Wanstrath <chris@ozmm.org>
5
- Lukas Oberhuber <lukaso@gmail.com>
6
- Brian Donovan <donovan@squareup.com>
7
- Myles Eftos <myles@madpilot.com.au>
8
- Jeff Hodges <jeff@somethingsimilar.com>
9
- Jakub Jirutka <jakub@jirutka.cz>
10
- Brian Donovan <me@brian-donovan.com>
11
- Pierre RAMBAUD <pierre.rambaud86@gmail.com>
12
- Morten Møller Riis <mortenmoellerriis@gmail.com>
13
- Matt Freels <matt@freels.name>
14
- Eero Saynatkari <projects@kittensoft.org>
15
- Andres Riofrio <riofrios@gmail.com>
16
- Jacob Evans <jacob@dekz.net>
17
- Víctor Martínez <knoopx@gmail.com>
18
- Mariusz Pietrzyk <wijet@wijet.pl>
19
- John Firebaugh <john.firebaugh@gmail.com>
20
- Sebastian Boehm <sebastian@sometimesfood.org>
21
- Dan Duvall <dduvall@wikimedia.org>
22
- Carlos Pardo <cpardo@altavistaed.com>
23
- AlphaHydrae <hydrae.alpha@gmail.com>
24
- Nick Quaranto <nick@quaran.to>
25
- Toby Ovod-Everett <toby@ovod-everett.org>
26
- Aaron Suggs <aaron@ktheory.com>
27
- Victor Costan <costan@gmail.com>
28
- Mateusz Juraszek <meceo00@gmail.com>
29
- Eric MSP Veith <eveith@wwweb-library.net>
30
- Leigh Caplan <lcaplan@onehub.com>
31
- Daniel Dyba <daniel.dyba@gmail.com>
32
- Maarten Hoogendoorn <maarten@moretea.nl>
33
- Jon Yurek <jyurek@thoughtbot.com>
34
- Jared Luxenberg <jared@jaredlux.com>
35
- DSIW <dsiw@dsiw-it.de>
36
- doc75 <github@virlet.org>
37
- Lars Gierth <lars.gierth@gmail.com>
38
- Greg Campbell <gtcampbell@gmail.com>
39
- Benjamin Quorning <benjamin@quorning.net>
40
- marano <thiagomarano@gmail.com>
41
- Ben Mabey <ben@benmabey.com>
42
- Jorge Orlando Munoz <jmunoz@altavistaed.com>
43
- Mark <mark@amerine.net>
44
- Sam Goldstein <sam@aboutus.org>
45
- Adam Alboyadjian <adam@vistahigherlearning.com>
46
- Rick Salevsky <rsalevsky@suse.com>
47
- Scott Petersen <petersen@centtech.com>
48
- Noah Paessel <knowuh@gmail.com>
49
- Ryan McGeary <ryan@mcgeary.org>
50
- Emil Soman <emil.soman@gmail.com>
51
- Matt Todd <chiology@gmail.com>
52
- dmathieu <42@dmathieu.com>
53
- Oleg Sukhodolsky <os97673@gmail.com>
54
- Winston Lee <lee.winston@gmail.com>
55
- Radek Simko <radek.simko@gmail.com>
56
- Grayson Wright <wright.grayson@gmail.com>
57
- Zequez <zequez@gmail.com>
58
- jameswilding <james@jameswilding.net>
59
- Ed Ruder <ed@squareup.com>
60
- Tymon Tobolski <i@teamon.eu>
61
- Scott Barron <scott@elitists.net>
62
- Benjamin Oakes <hello@benjaminoakes.com>
63
- Andrius Chamentauskas <andrius.chamentauskas@gmail.com>
64
- Eric Daspet <eric.daspet@survol.fr>
65
- Matt Hoyle <matt@deployable.co>
66
- W. Andrew Loe III <andrew@andrewloe.com>
67
- Misha Gorodnitzky <misaka@pobox.com>
68
- Xavier Shay <xavier@squareup.com>
69
- Keita Urashima <ursm@ursm.jp>
70
- rambutan <usul@usul-HP-EliteBook-8460p.(none)>
71
- Travis Herrick <travis@carbonfive.com>
72
- msassak <msassak@gmail.com>
73
- = <gokulnath@mobme.in>
74
- andrea longhi <andrea@spaghetticode.it>
75
- Matthew Morgan <lytithwyn@gmail.com>
76
- David Reese <david@whatcould.com>
77
- Andrius Chamentauskas <sinsiliux@gmail.com>
78
- timo3377 <tim.linquist@gmail.com>
79
- Matt Rogers <mattrogers@sbcglobal.net>
80
- Michael Scherer <misc@zarb.org>
81
- Paolo Gianrossi <paolino.gianrossi@gmail.com>
82
- Mislav Marohnić <mislav.marohnic@gmail.com>
83
- Andrew Ryan <nerdrew@gmail.com>
84
- Rob Sanheim <rsanheim@gmail.com>
85
- Jacob Atzen <jatzen@gmail.com>
86
- Toon Willems <willemstoon@gmail.com>
87
- Chris Knadler <takeshi91k@gmail.com>
88
- Ryan Scott Lewis <ryanscottlewis@lewis-software.com>
89
- Chris Wanstrath <chris@github.com>
90
- Yuta Shimizu <pachirel@gmail.com>
91
- Benjamin Quorning <bquorning@zendesk.com>
92
- Dane O'Connor <dane.oconnor@gmail.com>
93
- Sven Riedel <sr@gimp.org>
94
- Benjamin Fleischer <github@benjaminfleischer.com>
95
- Jordi Massaguer Pla <jmassaguerpla@suse.de>
96
- Maria Shaldibina <mariash@pivotallabs.com>
97
- Vít Ondruch <vondruch@redhat.com>