Class: YardGems::RackAdapter
- Inherits:
-
Object
- Object
- YardGems::RackAdapter
- Defined in:
- lib/yard_gems/rack_adapter.rb
Constant Summary collapse
- REFRESH_INTERVAL =
seconds
60
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ RackAdapter
constructor
A new instance of RackAdapter.
Constructor Details
#initialize ⇒ RackAdapter
Returns a new instance of RackAdapter.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/yard_gems/rack_adapter.rb', line 5 def initialize @cached_libraries = load_cached_libraries load_libraries if @cached_libraries != @libraries FileUtils.rm_f 'public.html' cache_libraries end @last_refresh = Time.now @yard_server = YARD::Server::RackAdapter.new(@libraries, {:caching => true}, :DocumentRoot => 'public') end |
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/yard_gems/rack_adapter.rb', line 21 def call(env) if Time.now - @last_refresh > REFRESH_INTERVAL $stderr.puts "Checking for new gems" Gem.source_index.refresh! load_libraries if @cached_libraries != @libraries $stderr.puts "Reloading gems" FileUtils.rm_f 'public.html' @yard_server.libraries = @libraries cache_libraries end @last_refresh = Time.now end @yard_server.call(env) end |