-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Indexable as the unit of items to be indexed
- Loading branch information
Showing
13 changed files
with
150 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
module RubyIndexer | ||
class IndexablePath | ||
extend T::Sig | ||
|
||
sig { returns(T.nilable(String)) } | ||
attr_reader :require_path | ||
|
||
sig { returns(String) } | ||
attr_reader :full_path | ||
|
||
# An IndexablePath is instantiated with a load_path_entry and a full_path. The load_path_entry is where the file can | ||
# be found in the $LOAD_PATH, which we use to determine the require_path. The load_path_entry may be `nil` if the | ||
# indexer is configured to go through files that do not belong in the $LOAD_PATH. For example, | ||
# `sorbet/tapioca/require.rb` ends up being a part of the paths to be indexed because it's a Ruby file inside the | ||
# project, but the `sorbet` folder is not a part of the $LOAD_PATH. That means that both its load_path_entry and | ||
# require_path will be `nil`, since it cannot be required by the project | ||
sig { params(load_path_entry: T.nilable(String), full_path: String).void } | ||
def initialize(load_path_entry, full_path) | ||
@full_path = full_path | ||
@require_path = T.let( | ||
load_path_entry ? Pathname.new(full_path).relative_path_from(load_path_entry).to_s.delete_suffix(".rb") : nil, | ||
T.nilable(String), | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.