File tree 4 files changed +19
-10
lines changed
4 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 1
1
## [ Unreleased]
2
2
3
+ ## [ 0.2.0] - 2023-01-19
4
+ Changed the code to only add the monkeypatch if it is needed.
5
+ Use alias_method because it is faster after all.
6
+
7
+ Thanks Austin Ziegler
8
+
3
9
## [ 0.1.0] - 2023-01-19
4
10
5
11
- Initial release
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
spec . summary = "File.exists? and Dir.exists? for Ruby 3.2+"
12
12
spec . description = "File.exists? and Dir.exists? were deprecated in Ruby 3.2. If you still need these methods. just require this Gem"
13
13
spec . homepage = "https://github.com/largo/file_exists"
14
- spec . required_ruby_version = ">= 3.2 .0"
14
+ spec . required_ruby_version = ">= 2.0 .0"
15
15
16
16
17
17
spec . metadata [ "homepage_uri" ] = spec . homepage
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
require_relative "file_exists/version"
4
- module FileExists
5
- # Deprecated exists? method monkeypatched with the file_exists gem
6
- def exists? ( path )
7
- exist? ( path )
4
+
5
+ # Monkeypatch the File Class with the exists? method
6
+ unless Dir . respond_to? ( :exists? )
7
+ class << Dir
8
+ alias_method :exists? , :exist?
8
9
end
9
10
end
10
11
11
- # Monkeypatch the File Class with the exists? method
12
- File . singleton_class . prepend ( FileExists )
13
- # Monkeypatch the File Class with the exists? method
14
- Dir . singleton_class . prepend ( FileExists )
12
+ # Monkeypatch the Dir Class with the exists? method
13
+ unless File . respond_to? ( :exists? )
14
+ class << File
15
+ alias_method :exists? , :exist?
16
+ end
17
+ end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module FileExists
4
- VERSION = "0.1 .0"
4
+ VERSION = "0.2 .0"
5
5
end
You can’t perform that action at this time.
0 commit comments