memfs 0.5.0 → 2.0.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
- SHA1:
3
- metadata.gz: d538c6d82cd4bab8b5771b26592034f441692420
4
- data.tar.gz: ef508f4172de7d3ab3c263dc147f70648178b0a7
2
+ SHA256:
3
+ metadata.gz: 27052207df96c7c9a518a8bcc018c62de8a72c388cb4d6c7bd241186ec2783c4
4
+ data.tar.gz: 61071eb92a7564fe81153161a7c3cca8f70e3193c8a4df4fc81342afcc5a13c9
5
5
  SHA512:
6
- metadata.gz: 96938d69ddeac5089c3524d7981d32f318df8dac36d60d74c79936588e1f6be79a3c17975c2f853fb604395115248329a269b9b86c0fbd2c3671523637f8e630
7
- data.tar.gz: e7858942b018d861c17b6c15b680409f86e247b14242f38ffad7a7b89f5a17e8fa3fc1dfc1c09579e54fa706016f1169945ca28622c355c76556d480a1a4cf10
6
+ metadata.gz: 326ca1b9bd8a07852236436122cd88ab8f4feb43a4b5ae89f75e7a39e41b7e9734d676833aa3fe9145472d5453824f4d307b1a073694d17269106ae3903e93bc
7
+ data.tar.gz: a6a10d22ca624cf414851f1af6a5b644b3d2778d2ef984707c0bb93097be8be803d6e4f71fd24c2b33a4a590bd0c5ee0b3453fbdb845907bd28cc8cc1361ef0e
@@ -0,0 +1,19 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: bundler
5
+ directory: /
6
+ schedule:
7
+ interval: weekly
8
+ day: monday
9
+ time: '00:00'
10
+ target-branch: main
11
+ versioning-strategy: increase-if-necessary
12
+
13
+ - package-ecosystem: github-actions
14
+ directory: /
15
+ schedule:
16
+ interval: weekly
17
+ day: monday
18
+ time: '00:00'
19
+ target-branch: main
@@ -0,0 +1,64 @@
1
+ name: CI Workflow
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ # Run workflow manually
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+ rubocop:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v6
20
+
21
+ - name: Setup Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: "4.0"
25
+ bundler-cache: true
26
+
27
+ - name: Rubocop
28
+ run: bin/rubocop
29
+
30
+ specs:
31
+ runs-on: ${{ matrix.os }}
32
+
33
+ strategy:
34
+ fail-fast: false
35
+ matrix:
36
+ os:
37
+ - ubuntu-latest
38
+ - windows-latest
39
+ ruby:
40
+ - "4.0"
41
+ - "3.4"
42
+ - "3.3"
43
+ - "3.2"
44
+
45
+ env:
46
+ # Check for frozen strings
47
+ RUBYOPT: "--enable=frozen-string-literal --debug=frozen-string-literal"
48
+
49
+ steps:
50
+ - name: Checkout
51
+ uses: actions/checkout@v6
52
+
53
+ - name: Setup Ruby
54
+ uses: ruby/setup-ruby@v1
55
+ with:
56
+ ruby-version: ${{ matrix.ruby }}
57
+ bundler-cache: true
58
+
59
+ - name: RSpec
60
+ run: bundle exec rspec
61
+
62
+ - name: Coverage Summary
63
+ if: success() || failure()
64
+ run: ruby bin/coverage_summary
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  lib/fileutils.rb
19
+ spec/examples.txt
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --color
2
- --format=documentation
1
+ --require spec_helper
2
+ --warnings
data/.rubocop.yml CHANGED
@@ -1,29 +1,98 @@
1
- AlignParameters:
2
- Enabled: false
1
+ ---
2
+ plugins:
3
+ - rubocop-performance
4
+ - rubocop-rake
5
+ - rubocop-rspec
3
6
 
4
- Blocks:
5
- Enabled: false
7
+ AllCops:
8
+ Exclude:
9
+ - bin/*
10
+ - memfs.gemspec
11
+ - spec/**/*
12
+ - vendor/bundle/**/*
13
+ NewCops: enable
14
+ TargetRubyVersion: 2.7
15
+
16
+ Layout/ArgumentAlignment:
17
+ EnforcedStyle: with_fixed_indentation
6
18
 
7
- ClassLength:
19
+ Layout/EmptyLineAfterGuardClause:
8
20
  Enabled: false
9
21
 
10
- Documentation:
22
+ Layout/FirstArrayElementIndentation:
23
+ EnforcedStyle: consistent
24
+
25
+ Layout/FirstHashElementIndentation:
26
+ EnforcedStyle: consistent
27
+
28
+ Layout/LineLength:
29
+ Exclude:
30
+ - Rakefile
31
+ Max: 100
32
+
33
+ Layout/MultilineMethodCallBraceLayout:
34
+ EnforcedStyle: same_line
35
+
36
+ Layout/MultilineMethodDefinitionBraceLayout:
37
+ EnforcedStyle: same_line
38
+
39
+ Layout/MultilineOperationIndentation:
40
+ EnforcedStyle: indented
41
+
42
+ Layout/ParameterAlignment:
43
+ EnforcedStyle: with_fixed_indentation
44
+
45
+ Metrics/AbcSize:
46
+ Max: 18
47
+
48
+ Metrics/ClassLength:
11
49
  Enabled: false
12
50
 
13
- DoubleNegation:
51
+ Metrics/MethodLength:
52
+ Max: 10
53
+
54
+ Naming/PredicatePrefix:
55
+ ForbiddenPrefixes:
56
+ - is_
57
+
58
+ Security/Open:
14
59
  Enabled: false
15
60
 
16
- EmptyLinesAroundBody:
61
+ Style/AccessModifierDeclarations:
17
62
  Enabled: false
18
63
 
19
- LineLength:
64
+ Style/AndOr:
20
65
  Enabled: false
21
66
 
22
- PercentLiteralDelimiters:
67
+ Style/Documentation:
23
68
  Enabled: false
24
69
 
25
- SpecialGlobalVars:
70
+ Style/DoubleNegation:
26
71
  Enabled: false
27
72
 
28
- TrivialAccessors:
73
+ Style/PercentLiteralDelimiters:
74
+ PreferredDelimiters:
75
+ '%': '{}'
76
+ '%i': '[]'
77
+ '%q': '{}'
78
+ '%Q': '{}'
79
+ '%r': '{}'
80
+ '%s': '{}'
81
+ '%w': '[]'
82
+ '%W': '[]'
83
+ '%x': '{}'
84
+
85
+ Style/RegexpLiteral:
86
+ EnforcedStyle: mixed
87
+
88
+ Style/SignalException:
89
+ EnforcedStyle: semantic
90
+
91
+ Style/SpecialGlobalVars:
29
92
  Enabled: false
93
+
94
+ Style/StringLiterals:
95
+ EnforcedStyle: single_quotes
96
+
97
+ Style/StringLiteralsInInterpolation:
98
+ EnforcedStyle: single_quotes
data/CHANGELOG.md CHANGED
@@ -1,27 +1,58 @@
1
1
  # Changelog
2
2
 
3
- ## HEAD
3
+ ## 2.0.0 (2026-02-03)
4
4
 
5
- ## 0.5.0
5
+ * ADD: Support for Ruby 3.x and 4.x
6
+ * ADD: `Dir.empty?`
7
+ * ADD: `IO#fileno` and `Dir#fileno` raise `NotImplementedError`
8
+ * ADD: `File.birthtime` and `File#birthtime`
9
+ * ADD: `File.empty?`
10
+ * ADD: `File::Stat#nlink` (#39 by @djberg96)
11
+ * ADD: `Dir.mktmpdir` (#52 by @djberg96)
12
+ * ADD: Support for `Tempfile.create`
13
+ * FIX: Fixing the inverted _read_ and _execute_ bitmasks (#41 by @micahlee)
14
+ * ADD: Dependabot configuration
15
+ * CHG: Replacing Travis CI with GitHub Actions
16
+ * ADD: Adding Windows support
17
+
18
+ ### Breaking
19
+
20
+ * **DEL: Dropping support for Ruby < 3.2**
21
+ * CHG: Renaming the `master` branch to `main`
22
+
23
+ ## 1.0.0 (2017-01-01)
24
+
25
+ :warning: This version drops support for Ruby 1.9.
26
+
27
+ * ADD: Support for Ruby 2.4.0
28
+ * ADD: Support for _Pathname_ in `Dir.glob` (PR #21 by @craigw)
29
+ * ADD: `MemFs.halt` to switch back to the real file-system (PR #24 by @thsur)
30
+ * ADD: Basic support for `IO.write` (PR #20 by @rmm5t)
31
+ * FIX: Reset the file position when reopened (PR #23 by @jimpo)
32
+ * FIX: Ignore trailing slashes when searching an entry (issue #26)
33
+ * FIX: Making `File` inherit from `IO` to fix 3rd-party related issues
34
+ * FIX: Ensure `File.new` on a symlink raises if target is absent
35
+
36
+ ## 0.5.0 (2015-09-13)
6
37
 
7
38
  * ADD: Support for _mode_ to `Dir.mkdir`, `FileUtils.mkdir` and `FileUtils.mkdir_p` (@raeno)
8
39
  * ADD: Support for Ruby 2.2 (@raeno)
9
40
 
10
- ## 0.4.3
41
+ ## 0.4.3 (2015-02-14)
11
42
 
12
43
  * ADD: `File::SEPARATOR` and `File::ALT_SEPARATOR`
13
44
  * FIX: Support `YAML.load_file` by handling `r:bom|utf-8` open mode
14
45
 
15
- ## 0.4.2
46
+ ## 0.4.2 (2015-02-14)
16
47
 
17
48
  * ADD: `File#external_encoding`
18
49
  * FIX: Undefined local variable or method `fs' for MemFs::File
19
50
 
20
- ## 0.4.1
51
+ ## 0.4.1 (2014-07-24)
21
52
 
22
53
  * FIX: Support for 1.9.3 broken by File::FNM_EXTGLOB
23
54
 
24
- ## 0.4.0
55
+ ## 0.4.0 (2014-07-18)
25
56
 
26
57
  * ADD: `Dir.chroot`
27
58
  * ADD: `Dir.glob` and `Dir[]`
@@ -38,11 +69,11 @@
38
69
  * ADD: `Dir#to_path`
39
70
  * FIX: Internal implementation methods are now private
40
71
 
41
- ## 0.3.0
72
+ ## 0.3.0 (2014-03-08)
42
73
 
43
74
  * FIX: The gem is now Ruby 1.9 compatible
44
75
 
45
- ## 0.2.0
76
+ ## 0.2.0 (2014-03-07)
46
77
 
47
78
  * ADD: Allowing magic creation of files with `MemFs.touch`
48
79
  * ADD: `Dir#each`
@@ -54,10 +85,10 @@
54
85
  * ADD: `Dir.unlink`
55
86
  * FIX: File.new now truncates a file when opening mode says so
56
87
 
57
- ## 0.1.0
88
+ ## 0.1.0 (2013-08-25)
58
89
 
59
90
  * ADD: Adding `File` missing methods - #3
60
91
 
61
- ## 0.0.2
92
+ ## 0.0.2 (2013-07-12)
62
93
 
63
94
  * ADD: Adding the MIT license to the gemspec file - #2
data/Gemfile CHANGED
@@ -1,4 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in memfs.gemspec
4
6
  gemspec
7
+
8
+ # Dev libs
9
+ gem 'irb'
10
+ gem 'listen', '~> 3.1'
11
+ gem 'rake', '~> 13.0'
12
+ gem 'rb-fchange', '~> 0.0'
13
+ gem 'rb-fsevent', '~> 0.9'
14
+ gem 'rb-inotify', '~> 0.8'
15
+ gem 'rspec', '~> 3.0'
16
+ gem 'simplecov'
17
+
18
+ # Dev tools / linter
19
+ gem 'guard-rspec', require: false
20
+ gem 'rubocop', require: false
21
+ gem 'rubocop-performance', require: false
22
+ gem 'rubocop-rake', require: false
23
+ gem 'rubocop-rspec', require: false
data/Guardfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  guard :rspec, cmd: 'bundle exec rspec', all_after_pass: true, all_on_start: true do
2
4
  watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
6
 
5
- watch('lib/memfs/io.rb') { |m| 'spec/memfs/file_spec.rb' }
6
- watch('spec/spec_helper.rb') { 'spec' }
7
+ watch('lib/memfs/io.rb') { 'spec/memfs/file_spec.rb' }
8
+ watch('spec/spec_helper.rb') { 'spec' }
7
9
  end
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
- ![MemFs Logo](https://raw.github.com/simonc/memfs/master/memfs.png)
1
+ ![MemFs Logo](https://raw.github.com/simonc/memfs/main/memfs.png)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/memfs.svg)](https://badge.fury.io/rb/memfs)
4
+ [![Build Status](https://github.com/simonc/memfs/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/simonc/memfs/actions/workflows/ci.yml)
5
+ [![Code Climate](https://codeclimate.com/github/simonc/memfs/badges/gpa.svg)](https://codeclimate.com/github/simonc/memfs)
2
6
 
3
- [![Gem Version](https://badge.fury.io/rb/memfs.png)](http://badge.fury.io/rb/memfs)
4
- [![Build Status](https://secure.travis-ci.org/simonc/memfs.png?branch=master)](http://travis-ci.org/simonc/memfs)
5
- [![Code Climate](https://codeclimate.com/github/simonc/memfs.png)](https://codeclimate.com/github/simonc/memfs)
6
- [![Coverage Status](https://coveralls.io/repos/simonc/memfs/badge.png?branch=master)](https://coveralls.io/r/simonc/memfs?branch=master)
7
7
 
8
8
  MemFs is an in-memory filesystem that can be used for your tests.
9
9
 
@@ -161,13 +161,14 @@ end
161
161
 
162
162
  ## Requirements
163
163
 
164
- * Ruby 1.9.3 or newer
164
+ * Ruby 2.0 or newer
165
165
 
166
166
  ## Known issues
167
167
 
168
168
  * MemFs doesn't implement IO so methods like `FileUtils.copy_stream` and `IO.write` are still the originals.
169
169
  * Similarly, MemFs doesn't implement Kernel, so don't use a naked `open()` call. This uses the `Kernel` class via `method_missing`, which MemFs will not intercept.
170
170
  * Pipes and Sockets are not handled for now.
171
+ * ~`require "pp"` will raise a _superclass mismatch_ exception since MemFs::File does not inherit from IO. The best thing to do is to require pp _before_ MemFs.~
171
172
 
172
173
  ## TODO
173
174
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'memfs'
@@ -6,8 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
6
8
 
7
9
  task default: :spec
8
10
 
9
- desc 'Compares a MemFs class to the original Ruby one ' \
10
- '(set CLASS to the compared class)'
11
+ desc 'Compares a MemFs class to the original Ruby one (set CLASS to the compared class)'
11
12
  task :compare do
12
13
  class_name = ENV['CLASS'] || 'File'
13
14
  klass = Object.const_get(class_name)
@@ -37,6 +38,7 @@ task :compare do
37
38
  puts implemented_i_methods - original_i_methods
38
39
  end
39
40
 
41
+ desc 'Starts a console session with the gem context loaded'
40
42
  task :console do
41
43
  require 'irb'
42
44
  require 'irb/completion'
data/bin/_guard-core ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application '_guard-core' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("guard", "_guard-core")
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "json"
5
+
6
+ FileCoverage = Data.define(:path, :total, :covered, :missed) do
7
+ def percent = total.positive? ? (covered.to_f / total * 100).round(2) : 100.0
8
+ end
9
+
10
+ file = "coverage/.resultset.json"
11
+ unless File.exist?(file)
12
+ warn "No coverage data found at #{file}"
13
+ exit
14
+ end
15
+
16
+ data = JSON.parse(File.read(file))
17
+ coverage_data = data.values.first&.dig("coverage") || {}
18
+
19
+ project_root = "#{Dir.pwd}/"
20
+
21
+ files = coverage_data.map do |filepath, line_data|
22
+ lines = line_data.is_a?(Hash) ? line_data["lines"] : line_data
23
+ relevant = lines.compact.select { _1.is_a?(Integer) }
24
+
25
+ FileCoverage.new(
26
+ path: filepath.delete_prefix(project_root),
27
+ total: relevant.size,
28
+ covered: relevant.count(&:positive?),
29
+ missed: relevant.count(&:zero?)
30
+ )
31
+ end
32
+
33
+ files.sort_by!(&:percent)
34
+
35
+ total_lines = files.sum(&:total)
36
+ total_covered = files.sum(&:covered)
37
+ total_missed = files.sum(&:missed)
38
+ overall = total_lines.positive? ? (total_covered.to_f / total_lines * 100).round(2) : 100.0
39
+
40
+ puts "Coverage: #{overall}% (#{total_covered}/#{total_lines} lines, #{total_missed} missed)"
41
+
42
+ summary_path = ENV["GITHUB_STEP_SUMMARY"] or exit
43
+
44
+ File.open(summary_path, "a") do |f|
45
+ f.puts "### Code Coverage: #{overall}%"
46
+ f.puts ""
47
+ f.puts "| File | Lines | Missed | Coverage |"
48
+ f.puts "|------|------:|-------:|---------:|"
49
+ files.each { f.puts "| #{_1.path} | #{_1.total} | #{_1.missed} | #{_1.percent}% |" }
50
+ f.puts "| **Total** | **#{total_lines}** | **#{total_missed}** | **#{overall}%** |"
51
+ end
data/bin/guard ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'guard' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("guard", "guard")
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/rubocop ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("rubocop", "rubocop")