Class: Autoloaded::LoadPathedDirectory Private
- Inherits:
-
Object
- Object
- Autoloaded::LoadPathedDirectory
- Defined in:
- lib/autoloaded/load_pathed_directory.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Enumerates the source files in a directory, relativizing their paths using the Ruby load path.
Constant Summary collapse
- SOURCE_FILE_EXTENSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The file extension of source files.
'.rb'
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
private
The full path of a source directory.
Instance Method Summary collapse
-
#each_source_filename {|String| ... } ⇒ LoadPathedDirectory
private
Enumerates the source files in #path, relativizing their paths if possible using the longest applicable entry in the Ruby load path (that is,
$:
). -
#initialize(path) ⇒ LoadPathedDirectory
constructor
private
Constructs a new LoadPathedDirectory with the specified path.
Constructor Details
#initialize(path) ⇒ LoadPathedDirectory
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Constructs a new LoadPathedDirectory with the specified path.
43 44 45 46 47 48 49 50 |
# File 'lib/autoloaded/load_pathed_directory.rb', line 43 def initialize(path) raise ::ArgumentError, "can't be nil" if path.nil? @path = path.dup.freeze if ::Pathname.new(@path).relative? raise ::ArgumentError, "can't be relative" end end |
Instance Attribute Details
#path ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The full path of a source directory.
36 37 38 |
# File 'lib/autoloaded/load_pathed_directory.rb', line 36 def path @path end |
Instance Method Details
#each_source_filename {|String| ... } ⇒ LoadPathedDirectory
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Enumerates the source files in #path, relativizing their paths if possible using the longest applicable entry in the Ruby load path (that is, $:
). File names are rendered without SOURCE_FILE_EXTENSION. Yielded paths are guaranteed usable in require
statements unless elements of the Ruby load path are removed or changed.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/autoloaded/load_pathed_directory.rb', line 65 def each_source_filename if (ruby_load_path = closest_ruby_load_path) ::Dir.chdir ruby_load_path do glob = self.class.join(path_from(ruby_load_path), "*#{SOURCE_FILE_EXTENSION}") ::Dir.glob glob do |file| yield without_source_file_extension(file) end end else glob = self.class.join(path, "*#{SOURCE_FILE_EXTENSION}") ::Dir.glob glob do |file| yield without_source_file_extension(file) end end self end |