Module: LcpRuby::GemPaths
- Defined in:
- lib/lcp_ruby/gem_paths.rb
Overview
Rails-free resolver for the installed gem’s bundled assets (docs, examples, skills). Anchors on this file’s own path so it resolves identically in a local checkout and an installed gem — and under ‘bundle exec` (the bundled gem) or the global `lcp` CLI (the global gem) — WITHOUT booting Rails.
NEVER use ‘LcpRuby::Engine.root` here: the Engine needs Rails loaded, and these paths must resolve from the CLI before any Rails boot.
Class Method Summary collapse
- .docs ⇒ Object
-
.example_names ⇒ Object
Names of the bundled example apps (directories under examples/).
- .examples ⇒ Object
-
.root ⇒ Object
Gem root.
- .skills ⇒ Object
Class Method Details
.docs ⇒ Object
30 31 32 |
# File 'lib/lcp_ruby/gem_paths.rb', line 30 def docs File.join(root, "docs") end |
.example_names ⇒ Object
Names of the bundled example apps (directories under examples/).
43 44 45 46 47 48 49 |
# File 'lib/lcp_ruby/gem_paths.rb', line 43 def example_names return [] unless Dir.exist?(examples) Dir.children(examples) .select { |c| File.directory?(File.join(examples, c)) } .sort end |
.examples ⇒ Object
34 35 36 |
# File 'lib/lcp_ruby/gem_paths.rb', line 34 def examples File.join(root, "examples") end |
.root ⇒ Object
Gem root. This file lives at ‘<root>/lib/lcp_ruby/gem_paths.rb`, so two levels up from its own directory is the gem root. Falls back to the loaded gemspec path only if the file layout is ever relocated.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lcp_ruby/gem_paths.rb', line 17 def root @root ||= begin from_file = File.("../..", __dir__) if Dir.exist?(File.join(from_file, "lib", "lcp_ruby")) from_file else spec = Gem.loaded_specs["lcp"] spec ? spec.full_gem_path : from_file end end end |
.skills ⇒ Object
38 39 40 |
# File 'lib/lcp_ruby/gem_paths.rb', line 38 def skills File.join(root, ".claude", "skills") end |