file_exists 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: cbb719dfd23823ba0d8acb3f749ac50a197e9de886a29351b4c2be3fb8f2078a
4
- data.tar.gz: 59e06945e7330963889471755b02b0e666dcf216677db6aeb7a119bb67cb99ed
3
+ metadata.gz: 2949fd0efe630e88431768a2564e2321fe55be4eea3fec9915583ebea421c70d
4
+ data.tar.gz: ee1486540d72b0c21da85cdeb2b7872a7943132315dedca97afc0810d9bb3d83
5
5
  SHA512:
6
- metadata.gz: 6b7f326f9722aa398aa60a4c24fbc6f77f4fcaaa49c50b8b65a57dc9a93a3b314a68b97607be3a94c229115fcc281cc718e99cd392789c0dd58a58266d9adfc2
7
- data.tar.gz: b7344c7856542ff2ef29ef951a2c5c58e4508341968aee3a6bb7e8107f7325d5f2b647fc01082d342d02f50e072ab254dc64d2cbf767565e7b0e4d249b6eeda2
6
+ metadata.gz: 35474dfe3830387147bbf5d506e0f37b7ef3b5c7791051abf6ced343ddf08d327c3751bf716dcc6fcfb086a8c1ea04eaa842b9af8f4df63833cd56eaeed0f304
7
+ data.tar.gz: 3d6955d7b4defafd2593e9ebcfeace4602ca300afe09207bbcec969af425579fb1d43cebb06a1ad16343923c18c7fcbdc177512200070934668f4a53749417b0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # FileExists
2
2
 
3
- File.exists? and Dir.exists? were deprecated in Ruby 3.2. If you still need these methods. just require this Gem
3
+ File.exists? and Dir.exists? were deprecated a long time ago and removed in Ruby 3.2. If you still need these methods just require this Gem
4
4
 
5
5
  ## Installation
6
6
 
@@ -14,6 +14,13 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
 
15
15
  ## Usage
16
16
 
17
+ The following command needs to go to the top of your first file before any other requires.
18
+
19
+ ```
20
+ require 'file_exists'
21
+ ```
22
+
23
+
17
24
  ```
18
25
  require 'file_exists'
19
26
  File.exists?("Filename.txt")
data/file_exists.gemspec CHANGED
@@ -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
@@ -1,5 +1,5 @@
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
data/lib/file_exists.rb CHANGED
@@ -1,14 +1,17 @@
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_exists
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andi Idogawa
@@ -43,7 +43,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 3.2.0
46
+ version: 2.0.0
47
47
  required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - ">="