fakefs 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTIzY2Q2ZDAyZTJlNGQ5ODc4NDM1ODY1OGM0YThhNDRjYWNjOWQ0OQ==
5
+ data.tar.gz: !binary |-
6
+ MzU3YWZlYzg4MmE5ZDg2ZGI0NzE4ZjNhZDZjYTgzMDZhZjQ3Y2Q4YQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzcxODdlNzE1MzBiOTM5MDM0MWZjNDA1YTc1MDNjN2E2ZmU3NmM0MmQ0ZGNh
10
+ OTY5N2NhYjFhZGFlZDk4YzY2OTU1OTRhZjA2OTc1NTA0NzMwNDMzNTUwNDcx
11
+ NzkxOTczYTcxMDcwNmViYTQ0Y2RiMDQzNTBjMzUxMjU5ODFmOGI=
12
+ data.tar.gz: !binary |-
13
+ OWFjNTJlZGI2Y2FiN2ViZGE4YjM0MDU0MTRlN2FhNDRkNDgwMGEwOGQ0MzBm
14
+ YjhlMjdkYTAxN2Y3YTc2NmVlMWYwNjNhYTExMmUwYTYxZmRiNWU3ZmUyYWM5
15
+ NjE2YjQxNGM1YmFiNWVjZDAyZjM1YjA4NDE4MTNmMGI4MWFjY2U=
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.sw?
2
+ pkg
3
+ Gemfile.lock
4
+ .rbenv-version
5
+ docs
6
+ pkg
7
+ fakefs.gemspec
8
+ .rbx
9
+ .idea
10
+ .bundle
11
+ Gemfile.lock
data/.travis.yml CHANGED
@@ -1,9 +1,14 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 1.9.3
4
+ - 2.0.0
4
5
  - jruby
5
6
  - rbx-19mode
6
7
  matrix:
7
8
  allow_failures:
9
+ - rvm: 2.0.0
8
10
  - rvm: jruby
9
11
  - rvm: rbx-19mode
12
+ before_install:
13
+ - gem update --system 2.1.11
14
+ - gem --version
data/CONTRIBUTORS CHANGED
@@ -1,35 +1,73 @@
1
1
  Scott Taylor <scott@railsnewbie.com>
2
2
  Pat Nakajima <patnakajima@gmail.com>
3
3
  Chris Wanstrath <chris@ozmm.org>
4
+ Lukas Oberhuber <lukaso@gmail.com>
4
5
  Myles Eftos <myles@madpilot.com.au>
5
6
  Jeff Hodges <jeff@somethingsimilar.com>
7
+ Morten Møller Riis <mortenmoellerriis@gmail.com>
6
8
  Matt Freels <matt@freels.name>
7
9
  Eero Saynatkari <projects@kittensoft.org>
10
+ Andres Riofrio <riofrios@gmail.com>
8
11
  Víctor Martínez <knoopx@gmail.com>
12
+ Brian Donovan <donovan@squareup.com>
13
+ Mariusz Pietrzyk <wijet@wijet.pl>
14
+ John Firebaugh <john.firebaugh@gmail.com>
15
+ Sebastian Boehm <sebastian@sometimesfood.org>
16
+ AlphaHydrae <hydrae.alpha@gmail.com>
9
17
  Nick Quaranto <nick@quaran.to>
10
18
  Aaron Suggs <aaron@ktheory.com>
11
19
  Victor Costan <costan@gmail.com>
20
+ Mateusz Juraszek <meceo00@gmail.com>
12
21
  Eric MSP Veith <eveith@wwweb-library.net>
22
+ Daniel Dyba <daniel.dyba@gmail.com>
23
+ Maarten Hoogendoorn <maarten@moretea.nl>
13
24
  Jon Yurek <jyurek@thoughtbot.com>
14
25
  Jared Luxenberg <jared@jaredlux.com>
15
- Lars Gierth <lars.gierth@gmail.com>
26
+ DSIW <dsiw@dsiw-it.de>
16
27
  Greg Campbell <gtcampbell@gmail.com>
28
+ Lars Gierth <lars.gierth@gmail.com>
29
+ doc75 <github@virlet.org>
30
+ marano <thiagomarano@gmail.com>
17
31
  Ben Mabey <ben@benmabey.com>
32
+ Jorge Orlando Munoz <jmunoz@altavistaed.com>
18
33
  Mark <mark@amerine.net>
19
34
  Sam Goldstein <sam@aboutus.org>
20
- Ryan McGeary <ryan@mcgeary.org>
35
+ Scott Petersen <petersen@centtech.com>
36
+ Matt Todd <chiology@gmail.com>
37
+ Emil Soman <emil.soman@gmail.com>
21
38
  Noah Paessel <knowuh@gmail.com>
39
+ Ryan McGeary <ryan@mcgeary.org>
22
40
  dmathieu <42@dmathieu.com>
23
- Mariusz Pietrzyk <wijet@wijet.pl>
24
- marano <thiagomarano@gmail.com>
41
+ Oleg Sukhodolsky <os97673@gmail.com>
42
+ Adam Alboyadjian <adam@vistahigherlearning.com>
25
43
  jameswilding <james@jameswilding.net>
44
+ Ed Ruder <ed@squareup.com>
26
45
  Tymon Tobolski <i@teamon.eu>
46
+ Benjamin Oakes <hello@benjaminoakes.com>
27
47
  Scott Barron <scott@elitists.net>
28
48
  Andrius Chamentauskas <andrius.chamentauskas@gmail.com>
49
+ W. Andrew Loe III <andrew@andrewloe.com>
50
+ Toby Ovod-Everett <toby@ovod-everett.org>
51
+ Xavier Shay <xavier@squareup.com>
52
+ Travis Herrick <travis@carbonfive.com>
53
+ rambutan <usul@usul-HP-EliteBook-8460p.(none)>
29
54
  Keita Urashima <ursm@ursm.jp>
30
- David Reese <david@whatcould.com>
55
+ Matthew Morgan <lytithwyn@gmail.com>
56
+ andrea longhi <andrea@spaghetticode.it>
31
57
  msassak <msassak@gmail.com>
32
- Andrius Chamentauskas <sinsiliux@gmail.com>
58
+ David Reese <david@whatcould.com>
33
59
  timo3377 <tim.linquist@gmail.com>
60
+ Andrius Chamentauskas <sinsiliux@gmail.com>
61
+ Michael Scherer <misc@zarb.org>
62
+ Matt Rogers <mattrogers@sbcglobal.net>
34
63
  Mislav Marohnić <mislav.marohnic@gmail.com>
64
+ Andrew Ryan <nerdrew@gmail.com>
35
65
  Rob Sanheim <rsanheim@gmail.com>
66
+ Chris Knadler <takeshi91k@gmail.com>
67
+ Chris Wanstrath <chris@github.com>
68
+ Toon Willems <willemstoon@gmail.com>
69
+ Ryan Scott Lewis <ryanscottlewis@lewis-software.com>
70
+ Yuta Shimizu <pachirel@gmail.com>
71
+ Jordi Massaguer Pla <jmassaguerpla@suse.de>
72
+ Benjamin Fleischer <github@benjaminfleischer.com>
73
+ Brian Donovan <me@brian-donovan.com>
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org/'
2
2
 
3
- group :development do
4
- gem 'rspec'
5
- gem 'jeweler'
6
- gem 'rdiscount'
7
- end
3
+ gemspec
data/README.markdown CHANGED
@@ -61,7 +61,9 @@ Rails
61
61
 
62
62
  If you are using fakefs in a rails project with bundler, you'll probably want to specify the following in your Gemfile:
63
63
 
64
- gem "fakefs", :require => "fakefs/safe"
64
+ ``` ruby
65
+ gem "fakefs", :require => "fakefs/safe"
66
+ ```
65
67
 
66
68
 
67
69
  RSpec
@@ -145,7 +147,7 @@ Meta
145
147
 
146
148
  * Code: `git clone git://github.com/defunkt/fakefs.git`
147
149
  * Home: <http://github.com/defunkt/fakefs>
148
- * Docs: <http://defunkt.github.com/fakefs>
150
+ * Docs: <http://rdoc.info/github/defunkt/fakefs>
149
151
  * Bugs: <http://github.com/defunkt/fakefs/issues>
150
152
  * Test: <http://travisci.org/#!/defunkt/fakefs>
151
153
  * Gems: <http://rubygems.org/gems/fakefs>
data/Rakefile CHANGED
@@ -21,39 +21,10 @@ end
21
21
 
22
22
  task :default => [:test, :spec]
23
23
 
24
- begin
25
- require 'jeweler'
26
-
27
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
28
- require 'fakefs/version'
29
-
30
- Jeweler::Tasks.new do |gemspec|
31
- gemspec.name = "fakefs"
32
- gemspec.summary = "A fake filesystem. Use it in your tests."
33
- gemspec.email = "chris@ozmm.org"
34
- gemspec.homepage = "http://github.com/defunkt/fakefs"
35
- gemspec.description = "A fake filesystem. Use it in your tests."
36
- gemspec.authors = ["Chris Wanstrath", "Scott Taylor", "Jeff Hodges", "Pat Nakajima"]
37
- gemspec.has_rdoc = false
38
- gemspec.version = FakeFS::Version.to_s
39
- end
40
- rescue LoadError
41
- puts "Jeweler not available."
42
- puts "Install it with: gem install jeweler"
43
- end
44
-
45
- desc "Build a gem"
46
- task :gem => [ :gemspec, :build ]
47
-
48
- desc "Push a new version to Gemcutter"
49
- task :publish => [ :gemspec, :build ] do
24
+ desc "Push a new version to rubygems.org"
25
+ task :publish do
50
26
  abort("Tests failed!") unless system("rake test")
51
- system "git tag v#{FakeFS::Version}"
52
- system "git push origin v#{FakeFS::Version}"
53
- system "git push origin master"
54
- system "gem push pkg/fakefs-#{FakeFS::Version}.gem"
55
- system "git clean -fd"
56
- exec "rake pages"
27
+ Rake::Task[:release].invoke
57
28
  end
58
29
 
59
30
  desc "Update contributors"
data/fakefs.gemspec CHANGED
@@ -1,83 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fakefs/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "fakefs"
8
- s.version = "0.4.3"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fakefs"
8
+ spec.version = FakeFS::Version.to_s
9
+ spec.authors = ["Chris Wanstrath", "Scott Taylor", "Jeff Hodges", "Pat Nakajima", "Brian Donovan"]
10
+ spec.email = ["chris@ozmm.org"]
11
+ spec.description = %q{A fake filesystem. Use it in your tests.}
12
+ spec.summary = %q{A fake filesystem. Use it in your tests.}
13
+ spec.homepage = "http://github.com/defunkt/fakefs"
14
+ spec.license = "MIT"
9
15
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Chris Wanstrath", "Scott Taylor", "Jeff Hodges", "Pat Nakajima"]
12
- s.date = "2013-09-07"
13
- s.description = "A fake filesystem. Use it in your tests."
14
- s.email = "chris@ozmm.org"
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".autotest",
21
- ".rspec",
22
- ".travis.yml",
23
- "CONTRIBUTORS",
24
- "Gemfile",
25
- "Gemfile.lock",
26
- "LICENSE",
27
- "README.markdown",
28
- "Rakefile",
29
- "fakefs.gemspec",
30
- "lib/fakefs.rb",
31
- "lib/fakefs/base.rb",
32
- "lib/fakefs/dir.rb",
33
- "lib/fakefs/fake/dir.rb",
34
- "lib/fakefs/fake/file.rb",
35
- "lib/fakefs/fake/symlink.rb",
36
- "lib/fakefs/file.rb",
37
- "lib/fakefs/file_system.rb",
38
- "lib/fakefs/file_test.rb",
39
- "lib/fakefs/fileutils.rb",
40
- "lib/fakefs/pathname.rb",
41
- "lib/fakefs/safe.rb",
42
- "lib/fakefs/spec_helpers.rb",
43
- "lib/fakefs/version.rb",
44
- "spec/fakefs/spec_helpers_spec.rb",
45
- "spec/spec.opts",
46
- "spec/spec_helper.rb",
47
- "test/fake/file/join_test.rb",
48
- "test/fake/file/lstat_test.rb",
49
- "test/fake/file/stat_test.rb",
50
- "test/fake/file/sysseek_test.rb",
51
- "test/fake/file/syswrite_test.rb",
52
- "test/fake/file_test.rb",
53
- "test/fake/symlink_test.rb",
54
- "test/fakefs_test.rb",
55
- "test/file/stat_test.rb",
56
- "test/safe_test.rb",
57
- "test/test_helper.rb",
58
- "test/verify.rb"
59
- ]
60
- s.homepage = "http://github.com/defunkt/fakefs"
61
- s.require_paths = ["lib"]
62
- s.rubygems_version = "1.8.24"
63
- s.summary = "A fake filesystem. Use it in your tests."
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
64
20
 
65
- if s.respond_to? :specification_version then
66
- s.specification_version = 3
67
-
68
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
- s.add_development_dependency(%q<rspec>, [">= 0"])
70
- s.add_development_dependency(%q<jeweler>, [">= 0"])
71
- s.add_development_dependency(%q<rdiscount>, [">= 0"])
72
- else
73
- s.add_dependency(%q<rspec>, [">= 0"])
74
- s.add_dependency(%q<jeweler>, [">= 0"])
75
- s.add_dependency(%q<rdiscount>, [">= 0"])
76
- end
77
- else
78
- s.add_dependency(%q<rspec>, [">= 0"])
79
- s.add_dependency(%q<jeweler>, [">= 0"])
80
- s.add_dependency(%q<rdiscount>, [">= 0"])
81
- end
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "rdiscount"
82
25
  end
83
-
data/lib/fakefs/dir.rb CHANGED
@@ -3,13 +3,13 @@ module FakeFS
3
3
  include Enumerable
4
4
 
5
5
  def self._check_for_valid_file(path)
6
- raise Errno::ENOENT, "No such file or directory - #{path}" unless FileSystem.find(path)
6
+ raise Errno::ENOENT, path unless FileSystem.find(path)
7
7
  end
8
8
 
9
9
  def initialize(string)
10
10
  self.class._check_for_valid_file(string)
11
11
 
12
- @path = string
12
+ @path = FileSystem.normalize_path(string)
13
13
  @open = true
14
14
  @pointer = 0
15
15
  @contents = [ '.', '..', ] + FileSystem.find(@path).entries
@@ -44,7 +44,13 @@ module FakeFS
44
44
  raise IOError, "closed directory" if @pointer == nil
45
45
  n = @contents[@pointer]
46
46
  @pointer += 1
47
- n.to_s.gsub(path + '/', '') if n
47
+ if n
48
+ if n.to_s[0, path.size+1] == path+'/'
49
+ n.to_s[path.size+1..-1]
50
+ else
51
+ n.to_s
52
+ end
53
+ end
48
54
  end
49
55
 
50
56
  def rewind
@@ -75,12 +81,12 @@ module FakeFS
75
81
 
76
82
  def self.delete(string)
77
83
  _check_for_valid_file(string)
78
- raise Errno::ENOTEMPTY, "Directory not empty - #{string}" unless FileSystem.find(string).empty?
84
+ raise Errno::ENOTEMPTY, string unless FileSystem.find(string).empty?
79
85
 
80
86
  FileSystem.delete(string)
81
87
  end
82
88
 
83
- def self.entries(dirname)
89
+ def self.entries(dirname, opts = {})
84
90
  _check_for_valid_file(dirname)
85
91
 
86
92
  Dir.new(dirname).map { |file| File.basename(file) }
@@ -7,7 +7,7 @@ module FakeFS
7
7
  end
8
8
 
9
9
  def inspect
10
- "symlink(#{target.split('/').last})"
10
+ "symlink(#{name} -> #{target.split('/').last})"
11
11
  end
12
12
 
13
13
  def entry
data/lib/fakefs/file.rb CHANGED
@@ -89,7 +89,7 @@ module FakeFS
89
89
  end
90
90
 
91
91
  def self.size(path)
92
- read(path).length
92
+ read(path).bytesize
93
93
  end
94
94
 
95
95
  def self.size?(path)
@@ -134,8 +134,9 @@ module FakeFS
134
134
  end
135
135
  end
136
136
 
137
- def self.expand_path(*args)
138
- RealFile.expand_path(*args)
137
+ def self.expand_path(file_name, dir_string=FileSystem.current_dir.to_s)
138
+ dir_string = FileSystem.find(dir_string).to_s
139
+ RealFile.expand_path(file_name, dir_string)
139
140
  end
140
141
 
141
142
  def self.basename(*args)
@@ -155,7 +156,7 @@ module FakeFS
155
156
  file = new(path)
156
157
 
157
158
  raise Errno::ENOENT if !file.exists?
158
- raise Errno::EISDIR, "Is a directory - #{path}" if directory?(path)
159
+ raise Errno::EISDIR, path if directory?(path)
159
160
 
160
161
  FileSystem.find(path).atime = Time.now
161
162
  file.read
@@ -173,16 +174,16 @@ module FakeFS
173
174
 
174
175
  def self.rename(source, dest)
175
176
  if directory?(source) && file?(dest)
176
- raise Errno::ENOTDIR, "Not a directory - #{source} or #{dest}"
177
+ raise Errno::ENOTDIR, "#{source} or #{dest}"
177
178
  elsif file?(source) && directory?(dest)
178
- raise Errno::EISDIR, "Is a directory - #{source} or #{dest}"
179
+ raise Errno::EISDIR, "#{source} or #{dest}"
179
180
  end
180
181
 
181
182
  if target = FileSystem.find(source)
182
183
  FileSystem.add(dest, target.entry.clone)
183
184
  FileSystem.delete(source)
184
185
  else
185
- raise Errno::ENOENT, "No such file or directory - #{source} or #{dest}"
186
+ raise Errno::ENOENT, "#{source} or #{dest}"
186
187
  end
187
188
 
188
189
  0
@@ -190,15 +191,15 @@ module FakeFS
190
191
 
191
192
  def self.link(source, dest)
192
193
  if directory?(source)
193
- raise Errno::EPERM, "Operation not permitted - #{source} or #{dest}"
194
+ raise Errno::EPERM, "#{source} or #{dest}"
194
195
  end
195
196
 
196
197
  if !exists?(source)
197
- raise Errno::ENOENT, "No such file or directory - #{source} or #{dest}"
198
+ raise Errno::ENOENT, "#{source} or #{dest}"
198
199
  end
199
200
 
200
201
  if exists?(dest)
201
- raise Errno::EEXIST, "File exists - #{source} or #{dest}"
202
+ raise Errno::EEXIST, "#{source} or #{dest}"
202
203
  end
203
204
 
204
205
  source = FileSystem.find(source)
@@ -210,7 +211,7 @@ module FakeFS
210
211
 
211
212
  def self.delete(file_name, *additional_file_names)
212
213
  if !exists?(file_name)
213
- raise Errno::ENOENT, "No such file or directory - #{file_name}"
214
+ raise Errno::ENOENT, file_name
214
215
  end
215
216
 
216
217
  FileUtils.rm(file_name)
@@ -285,7 +286,7 @@ module FakeFS
285
286
 
286
287
  def initialize(file, __lstat = false)
287
288
  if !File.exists?(file)
288
- raise(Errno::ENOENT, "No such file or directory - #{file}")
289
+ raise Errno::ENOENT, file
289
290
  end
290
291
 
291
292
  @file = file
@@ -307,6 +308,10 @@ module FakeFS
307
308
  File.directory?(@file)
308
309
  end
309
310
 
311
+ def file?
312
+ File.file?(@file)
313
+ end
314
+
310
315
  def ftype
311
316
  return 'link' if symlink?
312
317
  return 'directory' if directory?
@@ -317,6 +322,7 @@ module FakeFS
317
322
  def readable?
318
323
  true
319
324
  end
325
+
320
326
  def writable?
321
327
  true
322
328
  end
@@ -515,12 +521,24 @@ module FakeFS
515
521
  end
516
522
  end
517
523
 
524
+ def read(length = nil, buf = "")
525
+ read_buf = super(length, buf)
526
+ if read_buf.respond_to?(:force_encoding) && binary_mode? #change to binary only for ruby 1.9.3
527
+ read_buf = read_buf.force_encoding('ASCII-8BIT')
528
+ end
529
+ read_buf
530
+ end
531
+
518
532
  private
519
533
 
520
534
  def check_modes!
521
535
  StringIO.new("", @mode)
522
536
  end
523
537
 
538
+ def binary_mode?
539
+ @mode.is_a?(String) && (@mode.include?('b') || @mode.include?('binary')) && !@mode.include?('bom')
540
+ end
541
+
524
542
  def check_file_existence!
525
543
  raise Errno::ENOENT, @path unless @file
526
544
  end
@@ -540,7 +558,7 @@ module FakeFS
540
558
  # Create a missing file if the path is valid.
541
559
  #
542
560
  def create_missing_file
543
- raise Errno::EISDIR, "Is a directory - #{path}" if File.directory?(@path)
561
+ raise Errno::EISDIR, path if File.directory?(@path)
544
562
 
545
563
  if !File.exists?(@path) # Unnecessary check, probably.
546
564
  dirname = RealFile.dirname @path
@@ -549,7 +567,7 @@ module FakeFS
549
567
  dir = FileSystem.find dirname
550
568
 
551
569
  unless dir.kind_of? FakeDir
552
- raise Errno::ENOENT, "No such file or directory - #{path}"
570
+ raise Errno::ENOENT, path
553
571
  end
554
572
  end
555
573