Skip to content

Commit ed47e6f

Browse files
authored
Merge pull request #2777 from ksss/pathname-ext
2 parents c2a2e95 + f6ab919 commit ed47e6f

5 files changed

Lines changed: 66 additions & 61 deletions

File tree

core/pathname.rbs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -670,28 +670,6 @@ class Pathname
670670
#
671671
def file?: () -> bool
672672

673-
# <!--
674-
# rdoc-file=lib/pathname.rb
675-
# - find(ignore_error: true) { |pathname| ... }
676-
# -->
677-
# Iterates over the directory tree in a depth first manner, yielding a Pathname
678-
# for each file under "this" directory.
679-
#
680-
# Note that you need to require 'pathname' to use this method.
681-
#
682-
# Returns an Enumerator if no block is given.
683-
#
684-
# Since it is implemented by the standard library module Find, Find.prune can be
685-
# used to control the traversal.
686-
#
687-
# If `self` is `.`, yielded pathnames begin with a filename in the current
688-
# directory, not `./`.
689-
#
690-
# See Find.find
691-
#
692-
def find: (?ignore_error: boolish) { (Pathname) -> untyped } -> nil
693-
| (?ignore_error: boolish) -> Enumerator[Pathname, nil]
694-
695673
# <!--
696674
# rdoc-file=pathname_builtin.rb
697675
# - fnmatch(pattern, ...)
@@ -1017,18 +995,6 @@ class Pathname
1017995
#
1018996
def rmdir: () -> 0
1019997

1020-
# <!--
1021-
# rdoc-file=lib/pathname.rb
1022-
# - rmtree(noop: nil, verbose: nil, secure: nil)
1023-
# -->
1024-
# Recursively deletes a directory, including all directories beneath it.
1025-
#
1026-
# Note that you need to require 'pathname' to use this method.
1027-
#
1028-
# See FileUtils.rm_rf
1029-
#
1030-
def rmtree: () -> self
1031-
1032998
# <!--
1033999
# rdoc-file=pathname_builtin.rb
10341000
# - root?()

lib/rbs/environment_loader.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ def add(path: nil, library: nil, version: nil, resolve_dependencies: true)
5050
when path
5151
dirs << path
5252
when library
53-
case library
54-
when 'pathname'
55-
RBS.logger.warn "`#{library}` has been moved to core library, so it is always loaded. Remove explicit loading `#{library}`"
56-
return
57-
end
58-
5953
if libs.add?(Library.new(name: library, version: version)) && resolve_dependencies
6054
resolve_dependencies(library: library, version: version)
6155
end

stdlib/pathname/0/pathname.rbs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
%a{annotate:rdoc:skip}
2+
class Pathname
3+
# <!--
4+
# rdoc-file=lib/pathname.rb
5+
# - find(ignore_error: true) { |pathname| ... }
6+
# -->
7+
# Iterates over the directory tree in a depth first manner, yielding a Pathname
8+
# for each file under "this" directory.
9+
#
10+
# Note that you need to require 'pathname' to use this method.
11+
#
12+
# Returns an Enumerator if no block is given.
13+
#
14+
# Since it is implemented by the standard library module Find, Find.prune can be
15+
# used to control the traversal.
16+
#
17+
# If `self` is `.`, yielded pathnames begin with a filename in the current
18+
# directory, not `./`.
19+
#
20+
# See Find.find
21+
#
22+
def find: (?ignore_error: boolish) { (Pathname) -> untyped } -> nil
23+
| (?ignore_error: boolish) -> Enumerator[Pathname, nil]
24+
25+
# <!--
26+
# rdoc-file=lib/pathname.rb
27+
# - rmtree(noop: nil, verbose: nil, secure: nil)
28+
# -->
29+
# Recursively deletes a directory, including all directories beneath it.
30+
#
31+
# Note that you need to require 'pathname' to use this method.
32+
#
33+
# See FileUtils.rm_rf
34+
#
35+
def rmtree: () -> self
36+
end

test/stdlib/Pathname_ext_test.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require_relative "test_helper"
2+
require 'pathname'
3+
4+
class PathnameExtInstanceTest < Test::Unit::TestCase
5+
include TestHelper
6+
7+
library 'pathname'
8+
testing '::Pathname'
9+
10+
def test_find
11+
assert_send_type '() { (Pathname) -> untyped } -> nil',
12+
Pathname(__dir__), :find do end
13+
assert_send_type '(ignore_error: bool) -> Enumerator[Pathname, nil]',
14+
Pathname(__dir__), :find, ignore_error: true
15+
assert_send_type '(ignore_error: Symbol) -> Enumerator[Pathname, nil]',
16+
Pathname(__dir__), :find, ignore_error: :true
17+
assert_send_type '() -> Enumerator[Pathname, nil]',
18+
Pathname(__dir__), :find
19+
end
20+
21+
def test_rmtree
22+
Dir.mktmpdir do |dir|
23+
target = Pathname(dir).join('target')
24+
target.mkdir
25+
assert_send_type '() -> Pathname',
26+
target, :rmtree
27+
end
28+
end
29+
end

test/stdlib/Pathname_test.rb

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require_relative "test_helper"
2-
require 'pathname'
2+
require "pathname" unless defined?(Pathname)
33

44
class PathnameSingletonTest < Test::Unit::TestCase
55
include TestHelper
@@ -314,17 +314,6 @@ def test_file?
314314
Pathname('/unknown'), :file?
315315
end
316316

317-
def test_find
318-
assert_send_type '() { (Pathname) -> untyped } -> nil',
319-
Pathname(__dir__), :find do end
320-
assert_send_type '(ignore_error: bool) -> Enumerator[Pathname, nil]',
321-
Pathname(__dir__), :find, ignore_error: true
322-
assert_send_type '(ignore_error: Symbol) -> Enumerator[Pathname, nil]',
323-
Pathname(__dir__), :find, ignore_error: :true
324-
assert_send_type '() -> Enumerator[Pathname, nil]',
325-
Pathname(__dir__), :find
326-
end
327-
328317
def test_fnmatch
329318
assert_send_type '(String) -> bool',
330319
Pathname('foo'), :fnmatch, 'fo*'
@@ -638,15 +627,6 @@ def test_rmdir
638627
end
639628
end
640629

641-
def test_rmtree
642-
Dir.mktmpdir do |dir|
643-
target = Pathname(dir).join('target')
644-
target.mkdir
645-
assert_send_type '() -> Pathname',
646-
target, :rmtree
647-
end
648-
end
649-
650630
def test_root?
651631
assert_send_type '() -> bool',
652632
Pathname('.'), :root?

0 commit comments

Comments
 (0)