Module: StaticEmbeddings::Paths
- Defined in:
- lib/static_embeddings/paths.rb
Constant Summary collapse
- BUILTIN_DIR =
File.("../models", __dir__)
- BUILTIN_MODELS =
{ demo: "demo.semb" }.freeze
Class Method Summary collapse
- .builtin_available?(name = :demo) ⇒ Boolean
- .builtin_path(name) ⇒ Object
- .cache_dir(env = ENV) ⇒ Object
- .model_path(model_id, env = ENV) ⇒ Object
Class Method Details
.builtin_available?(name = :demo) ⇒ Boolean
24 25 26 27 |
# File 'lib/static_embeddings/paths.rb', line 24 def builtin_available?(name = :demo) file = BUILTIN_MODELS[name] !file.nil? && File.file?(File.join(BUILTIN_DIR, file)) end |
.builtin_path(name) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/static_embeddings/paths.rb', line 17 def builtin_path(name) file = BUILTIN_MODELS.fetch(name) do raise ModelNotFound, "unknown builtin model #{name.inspect}" end File.join(BUILTIN_DIR, file) end |
.cache_dir(env = ENV) ⇒ Object
8 9 10 11 |
# File 'lib/static_embeddings/paths.rb', line 8 def cache_dir(env = ENV) env["STATIC_EMBEDDINGS_CACHE"] || File.join(env["XDG_CACHE_HOME"] || File.join(Dir.home, ".cache"), "static_embeddings") end |
.model_path(model_id, env = ENV) ⇒ Object
13 14 15 |
# File 'lib/static_embeddings/paths.rb', line 13 def model_path(model_id, env = ENV) File.join(cache_dir(env), "models", "#{model_id}.semb") end |