File tree Expand file tree Collapse file tree 5 files changed +40
-0
lines changed
lib/active_support/core_ext Expand file tree Collapse file tree 5 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ * ` Pathname.blank? ` only returns true for ` Pathname.new("") `
2
+
3
+ Previously it would end up calling ` Pathname#empty? ` which returned true
4
+ if the path existed and was an empty directory or file.
5
+
6
+ That behavior was unlikely to be expected.
7
+
8
+ * Jean Boussier*
9
+
1
10
* Deprecate ` Notification::Event ` 's ` #children ` and ` #parent_of? `
2
11
3
12
* Change default serialization format of ` MessageEncryptor ` from ` Marshal ` to ` JSON ` for Rails 7.1.
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
+ require "active_support/core_ext/pathname/blank"
3
4
require "active_support/core_ext/pathname/existence"
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ class Pathname
6
+ # An Pathname is blank if it's empty:
7
+ #
8
+ # Pathname.new("").blank? # => true
9
+ # Pathname.new(" ").blank? # => false
10
+ # Pathname.new("test).blank? # => false
11
+ #
12
+ # @return [true, false]
13
+ def blank?
14
+ to_s . empty?
15
+ end
16
+ end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
+ require "pathname"
4
+
3
5
class Pathname
4
6
# Returns the receiver if the named file exists otherwise returns +nil+.
5
7
# <tt>pathname.existence</tt> is equivalent to
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../abstract_unit"
4
+ require "active_support/core_ext/pathname/blank"
5
+
6
+ class PathnameBlankTest < ActiveSupport ::TestCase
7
+ def test_blank
8
+ assert_predicate Pathname . new ( "" ) , :blank?
9
+ assert_not_predicate Pathname . new ( "test" ) , :blank?
10
+ assert_not_predicate Pathname . new ( " " ) , :blank?
11
+ end
12
+ end
You can’t perform that action at this time.
0 commit comments