ruby3-backward-compatibility 1.1.0 → 1.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: 633e9d810f14371159a3119d1e2c713dfb79a00beae434fa1ae12d4bb6bd726b
4
- data.tar.gz: 1e37912bd6c3885a3b0c03fe47bdfd5033e79d44361234a5a8f4fc653e23d275
3
+ metadata.gz: b9eab8bda5ea5cf123ec7370aae33a25c1e6d3fe16976a778152d3fce153931c
4
+ data.tar.gz: 550c09a1aa034b4899f4e21d69b7a2949ec16c15bce430e6a23acf72eb91ad37
5
5
  SHA512:
6
- metadata.gz: bf74e2f1827ea9d397905258f6053000d74c3369b4b1f601a5250359c03fd31d1c2109e952050c1ab7ef19851f05f2efdfdd3861c34c985d6308f7b88a0966da
7
- data.tar.gz: 6674cc14712ed77e0698dd9956ef0ca9228f32c872ee4cd091d7b2d621e7d80612a5d555336da797ce933f8a8fba6b60993ae17c644d211f7535604e2918872c
6
+ metadata.gz: 645183527ce9549cebfe84924fcff6d8864088a1ef442fb797f6cc1225f2348aba11c170edb58d7633b396a89d5bb327c2863789bb4b4d893e8c15aaad5900b0
7
+ data.tar.gz: 6e6382750d9f27dda6195b5cc637bb2dae6b57dfd46ab7afa67dcd0992709017a05771d376f0064b5298db7157ae3cdd8ba1b43ac404df5df6491bafc13ac12b
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.3.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.2.0] - 2024-04-10
4
+
5
+ - First release with dedicated suport to Ruby 3.3.
6
+ - Added back `File.exists?` and `Dir.exists?` on Ruby 3.2+.
7
+ - Added back `Fixnum` as an alias for `Integer`.
8
+
9
+ ## [1.1.1] - 2022-12-01
10
+
11
+ - Gem no longer requires Ruby 3. It will not do anything when used on Ruby 2.x, but you can add it to your Gemfile if you need that for a Ruby migration strategy. (Thanks to @BigAirJosh)
12
+
3
13
  ## [1.1.0] - 2022-12-01
4
14
 
5
15
  - Change `callable_with_hash` to return a symbol, if called with a singular method.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby3-backward-compatibility (1.1.0)
4
+ ruby3-backward-compatibility (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -71,6 +71,16 @@ This will wrap the given method and convert a hash given as the last argument in
71
71
 
72
72
  *Note:* In case the method is also defined in a prepended module, you need to put the `extend Ruby3BackwardCompatibility::CallableWithHash` above the `prepend`.
73
73
 
74
+ ### Dir
75
+
76
+ `Dir.exists?` has been removed in favor of `Dir.exist?`.
77
+
78
+ To add `Dir.exists?` as an alias for `Dir.exist?`, use
79
+
80
+ ```
81
+ require 'ruby3_backward_compatibility/compatibility/dir'
82
+ ```
83
+
74
84
  ### ERB
75
85
 
76
86
  `ERB.new` used to have the signature
@@ -91,6 +101,25 @@ To allow both styles, use
91
101
  require 'ruby3_backward_compatibility/compatibility/erb'
92
102
  ```
93
103
 
104
+ ### File
105
+
106
+ `File.exists?` has been removed in favor of `File.exist?`.
107
+
108
+ To add `File.exists?` as an alias for `File.exist?`, use
109
+
110
+ ```
111
+ require 'ruby3_backward_compatibility/compatibility/file'
112
+ ```
113
+
114
+ ### Fixnum
115
+
116
+ `Fixnum` has been an alias for `Integer` for a while, but was removed.
117
+
118
+ To add back `Fixnum` as an alias for `Integer`, use
119
+
120
+ ```
121
+ require 'ruby3_backward_compatibility/compatibility/fixnum'
122
+ ```
94
123
 
95
124
  ### I18n
96
125
 
@@ -130,13 +159,13 @@ Psych version 4 (default for Ruby 3.1) has two changes:
130
159
  Psych.safe_load(yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil)
131
160
  ```
132
161
 
133
- To alias `Psych.unsafe_load` as `Psych.load`, and to allow both styles of calling `Psych.safe_load`, use
162
+ To allow both styles of calling `Psych.safe_load`, use
134
163
 
135
164
  ```
136
165
  require 'ruby3_backward_compatibility/compatibility/psych'
137
166
  ```
138
167
 
139
- **Attention:** There has been a very good reason why Psych renamed the `.load` method: You may never use `.load` on any external strings. It is possible to create valid YAML strings that lead to the execution of arbitrary code, so calling `YAML.load` on user input is a major security vulnerability.
168
+ **Attention:** There has been a very good reason why Psych renamed the `.load` method: You may never use `.load` on any external strings. It is possible to create valid YAML strings that lead to the execution of arbitrary code, so calling `YAML.load` on user input is a major security vulnerability. For that reason, this library does not change the safe behavior of `YAML.load`.
140
169
 
141
170
 
142
171
  ### String
data/Rakefile CHANGED
@@ -3,6 +3,18 @@
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
5
 
6
- RSpec::Core::RakeTask.new(:spec)
6
+ ruby2_specs = 'spec/ruby2/**/*_spec.rb'
7
+ rake_task = RSpec::Core::RakeTask.new(:spec)
8
+
9
+ if RUBY_VERSION < '3'
10
+ rake_task.pattern = 'spec/ruby2/**/*_spec.rb'
11
+ task default: :spec
12
+ else
13
+ rake_task.exclude_pattern = 'spec/{ruby2,isolated}/**/*_spec.rb'
14
+
15
+ isolated_rake_task = RSpec::Core::RakeTask.new(:isolated_specs)
16
+ isolated_rake_task.pattern = 'spec/isolated/**/*_spec.rb'
17
+
18
+ task default: [:spec, :isolated_specs]
19
+ end
7
20
 
8
- task default: :spec
@@ -1,6 +1,9 @@
1
1
  require 'ruby3_backward_compatibility'
2
2
 
3
+ require 'ruby3_backward_compatibility/compatibility/dir'
3
4
  require 'ruby3_backward_compatibility/compatibility/erb' if defined?(ERB)
5
+ require 'ruby3_backward_compatibility/compatibility/file'
6
+ require 'ruby3_backward_compatibility/compatibility/fixnum'
4
7
  require 'ruby3_backward_compatibility/compatibility/i18n' if defined?(I18n)
5
8
  require 'ruby3_backward_compatibility/compatibility/object'
6
9
  require 'ruby3_backward_compatibility/compatibility/psych' if defined?(Psych)
@@ -0,0 +1,5 @@
1
+ class Dir
2
+ class << self
3
+ alias_method :exists?, :exist? unless method_defined?(:exists?)
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class File
2
+ class << self
3
+ alias_method :exists?, :exist? unless method_defined?(:exists?)
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ unless defined?(::Fixnum)
2
+ Fixnum = Integer
3
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ruby3BackwardCompatibility
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ruby3BackwardCompatibility
4
- NOT_GIVEN = Object.new
3
+ if RUBY_VERSION.start_with?('3')
4
+ module Ruby3BackwardCompatibility
5
+ NOT_GIVEN = Object.new
6
+ end
5
7
 
6
- # TODO private?
8
+ require 'ruby3_backward_compatibility/callable_with_hash'
9
+ require 'ruby3_backward_compatibility/version'
7
10
  end
8
-
9
- require 'ruby3_backward_compatibility/callable_with_hash'
10
- require 'ruby3_backward_compatibility/version'
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = 'Backward compatibility for Ruby 3 stdlib'
12
12
  spec.homepage = 'https://github.com/makandra/ruby3-backward-compatibility'
13
13
  spec.license = 'MIT'
14
- spec.required_ruby_version = '>= 3.0.0'
15
14
 
16
15
  spec.metadata['homepage_uri'] = spec.homepage
17
16
  spec.metadata['source_code_uri'] = 'https://github.com/makandra/ruby3-backward-compatibility'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby3-backward-compatibility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-01 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -45,7 +45,10 @@ files:
45
45
  - lib/ruby3_backward_compatibility.rb
46
46
  - lib/ruby3_backward_compatibility/callable_with_hash.rb
47
47
  - lib/ruby3_backward_compatibility/compatibility/all.rb
48
+ - lib/ruby3_backward_compatibility/compatibility/dir.rb
48
49
  - lib/ruby3_backward_compatibility/compatibility/erb.rb
50
+ - lib/ruby3_backward_compatibility/compatibility/file.rb
51
+ - lib/ruby3_backward_compatibility/compatibility/fixnum.rb
49
52
  - lib/ruby3_backward_compatibility/compatibility/i18n.rb
50
53
  - lib/ruby3_backward_compatibility/compatibility/object.rb
51
54
  - lib/ruby3_backward_compatibility/compatibility/psych.rb
@@ -68,14 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
71
  requirements:
69
72
  - - ">="
70
73
  - !ruby/object:Gem::Version
71
- version: 3.0.0
74
+ version: '0'
72
75
  required_rubygems_version: !ruby/object:Gem::Requirement
73
76
  requirements:
74
77
  - - ">="
75
78
  - !ruby/object:Gem::Version
76
79
  version: '0'
77
80
  requirements: []
78
- rubygems_version: 3.3.7
81
+ rubygems_version: 3.5.3
79
82
  signing_key:
80
83
  specification_version: 4
81
84
  summary: Backward compatibility for Ruby 3 stdlib