Class: RubyTestIDE::DocStore
- Inherits:
-
Object
- Object
- RubyTestIDE::DocStore
- Defined in:
- lib/ruby_test_ide/server.rb
Overview
Documentation comes from the installed ri database (same data ri String#strip uses). Method docs are fetched in-process via
RDoc::RI::Driver (~0.15ms warm vs ~290ms for shelling out to ri);
class docs and any driver failure fall back to the ri CLI. Memoised.
If lookups return nothing, generate the core docs once:
cd ~/.rvm/src/ruby-3.2.2 && rdoc --all --ri \
--op ~/.rvm/rubies/ruby-3.2.2/share/ri/3.2.0/system .
Instance Method Summary collapse
-
#initialize ⇒ DocStore
constructor
A new instance of DocStore.
- #lookup(*names) ⇒ Object
Constructor Details
#initialize ⇒ DocStore
Returns a new instance of DocStore.
382 383 384 385 386 |
# File 'lib/ruby_test_ide/server.rb', line 382 def initialize @cache = {} @mutex = Mutex.new @driver = :unloaded end |
Instance Method Details
#lookup(*names) ⇒ Object
388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/ruby_test_ide/server.rb', line 388 def lookup(*names) names.compact.uniq.each do |name| doc = @mutex.synchronize { @cache[name] } unless @mutex.synchronize { @cache.key?(name) } doc = fetch(name) @mutex.synchronize { @cache[name] = doc } end return doc if doc && !doc.empty? end nil end |