Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions core/pathname.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -670,28 +670,6 @@ class Pathname
#
def file?: () -> bool

# <!--
# rdoc-file=lib/pathname.rb
# - find(ignore_error: true) { |pathname| ... }
# -->
# Iterates over the directory tree in a depth first manner, yielding a Pathname
# for each file under "this" directory.
#
# Note that you need to require 'pathname' to use this method.
#
# Returns an Enumerator if no block is given.
#
# Since it is implemented by the standard library module Find, Find.prune can be
# used to control the traversal.
#
# If `self` is `.`, yielded pathnames begin with a filename in the current
# directory, not `./`.
#
# See Find.find
#
def find: (?ignore_error: boolish) { (Pathname) -> untyped } -> nil
| (?ignore_error: boolish) -> Enumerator[Pathname, nil]

# <!--
# rdoc-file=pathname_builtin.rb
# - fnmatch(pattern, ...)
Expand Down Expand Up @@ -1017,18 +995,6 @@ class Pathname
#
def rmdir: () -> 0

# <!--
# rdoc-file=lib/pathname.rb
# - rmtree(noop: nil, verbose: nil, secure: nil)
# -->
# Recursively deletes a directory, including all directories beneath it.
#
# Note that you need to require 'pathname' to use this method.
#
# See FileUtils.rm_rf
#
def rmtree: () -> self

# <!--
# rdoc-file=pathname_builtin.rb
# - root?()
Expand Down
6 changes: 0 additions & 6 deletions lib/rbs/environment_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ def add(path: nil, library: nil, version: nil, resolve_dependencies: true)
when path
dirs << path
when library
case library
when 'pathname'
RBS.logger.warn "`#{library}` has been moved to core library, so it is always loaded. Remove explicit loading `#{library}`"
return
end

if libs.add?(Library.new(name: library, version: version)) && resolve_dependencies
resolve_dependencies(library: library, version: version)
end
Expand Down
36 changes: 36 additions & 0 deletions stdlib/pathname/0/pathname.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%a{annotate:rdoc:skip}
class Pathname
# <!--
# rdoc-file=lib/pathname.rb
# - find(ignore_error: true) { |pathname| ... }
# -->
# Iterates over the directory tree in a depth first manner, yielding a Pathname
# for each file under "this" directory.
#
# Note that you need to require 'pathname' to use this method.
#
# Returns an Enumerator if no block is given.
#
# Since it is implemented by the standard library module Find, Find.prune can be
# used to control the traversal.
#
# If `self` is `.`, yielded pathnames begin with a filename in the current
# directory, not `./`.
#
# See Find.find
#
def find: (?ignore_error: boolish) { (Pathname) -> untyped } -> nil
| (?ignore_error: boolish) -> Enumerator[Pathname, nil]

# <!--
# rdoc-file=lib/pathname.rb
# - rmtree(noop: nil, verbose: nil, secure: nil)
# -->
# Recursively deletes a directory, including all directories beneath it.
#
# Note that you need to require 'pathname' to use this method.
#
# See FileUtils.rm_rf
#
def rmtree: () -> self
end
29 changes: 29 additions & 0 deletions test/stdlib/Pathname_ext_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative "test_helper"
require 'pathname'

class PathnameExtInstanceTest < Test::Unit::TestCase
include TestHelper

library 'pathname'
testing '::Pathname'

def test_find
assert_send_type '() { (Pathname) -> untyped } -> nil',
Pathname(__dir__), :find do end
assert_send_type '(ignore_error: bool) -> Enumerator[Pathname, nil]',
Pathname(__dir__), :find, ignore_error: true
assert_send_type '(ignore_error: Symbol) -> Enumerator[Pathname, nil]',
Pathname(__dir__), :find, ignore_error: :true
assert_send_type '() -> Enumerator[Pathname, nil]',
Pathname(__dir__), :find
end

def test_rmtree
Dir.mktmpdir do |dir|
target = Pathname(dir).join('target')
target.mkdir
assert_send_type '() -> Pathname',
target, :rmtree
end
end
end
22 changes: 1 addition & 21 deletions test/stdlib/Pathname_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative "test_helper"
require 'pathname'
require "pathname" unless defined?(Pathname)

class PathnameSingletonTest < Test::Unit::TestCase
include TestHelper
Expand Down Expand Up @@ -314,17 +314,6 @@ def test_file?
Pathname('/unknown'), :file?
end

def test_find
assert_send_type '() { (Pathname) -> untyped } -> nil',
Pathname(__dir__), :find do end
assert_send_type '(ignore_error: bool) -> Enumerator[Pathname, nil]',
Pathname(__dir__), :find, ignore_error: true
assert_send_type '(ignore_error: Symbol) -> Enumerator[Pathname, nil]',
Pathname(__dir__), :find, ignore_error: :true
assert_send_type '() -> Enumerator[Pathname, nil]',
Pathname(__dir__), :find
end

def test_fnmatch
assert_send_type '(String) -> bool',
Pathname('foo'), :fnmatch, 'fo*'
Expand Down Expand Up @@ -638,15 +627,6 @@ def test_rmdir
end
end

def test_rmtree
Dir.mktmpdir do |dir|
target = Pathname(dir).join('target')
target.mkdir
assert_send_type '() -> Pathname',
target, :rmtree
end
end

def test_root?
assert_send_type '() -> bool',
Pathname('.'), :root?
Expand Down