Class: LanguageServer::FileStore
- Inherits:
-
Object
- Object
- LanguageServer::FileStore
- Includes:
- Enumerable
- Defined in:
- lib/language_server/file_store.rb
Defined Under Namespace
Classes: FilePath
Instance Method Summary collapse
- #cache(remote_uri, content) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(load_paths: [], remote_root: Dir.getwd, local_root: Dir.getwd) ⇒ FileStore
constructor
A new instance of FileStore.
- #path_from_remote_uri(remote_uri) ⇒ Object
- #read(path) ⇒ Object
- #read_remote_uri(remote_uri) ⇒ Object
Constructor Details
#initialize(load_paths: [], remote_root: Dir.getwd, local_root: Dir.getwd) ⇒ FileStore
Returns a new instance of FileStore.
39 40 41 42 43 |
# File 'lib/language_server/file_store.rb', line 39 def initialize(load_paths: [], remote_root: Dir.getwd, local_root: Dir.getwd) @load_paths = load_paths @remote_root = remote_root @local_root = local_root end |
Instance Method Details
#cache(remote_uri, content) ⇒ Object
45 46 47 |
# File 'lib/language_server/file_store.rb', line 45 def cache(remote_uri, content) cache_store[path_from_remote_uri(remote_uri)] = content end |
#each(&block) ⇒ Object
65 66 67 68 69 |
# File 'lib/language_server/file_store.rb', line 65 def each(&block) all_paths.each do |path| yield(read(path), path) end end |
#path_from_remote_uri(remote_uri) ⇒ Object
49 50 51 |
# File 'lib/language_server/file_store.rb', line 49 def path_from_remote_uri(remote_uri) FilePath.from_remote_uri(local_root: local_root, remote_root: remote_root, remote_uri: remote_uri) end |
#read(path) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/language_server/file_store.rb', line 53 def read(path) if exists_on_cache?(path) read_from_cache(path) else read_from_local(path) end end |
#read_remote_uri(remote_uri) ⇒ Object
61 62 63 |
# File 'lib/language_server/file_store.rb', line 61 def read_remote_uri(remote_uri) read(path_from_remote_uri(remote_uri)) end |