Class: Solargraph::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/solargraph/server.rb

Constant Summary collapse

@@api_hash =
{}
@@semaphore =
Mutex.new

Class Method Summary collapse

Class Method Details

.constant_updatesObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/solargraph/server.rb', line 47

def constant_updates
  Thread.new {
    loop do
      @@api_hash.keys.each { |k|
        update = Solargraph::ApiMap.new(k)
        @@semaphore.synchronize {
          @@api_hash[k] = update
        }
      }
      sleep 2
    end
  }
end

.prepare_workspace(directory) ⇒ Object



40
41
42
43
44
45
# File 'lib/solargraph/server.rb', line 40

def prepare_workspace directory
  api_map = Solargraph::ApiMap.new(directory)
  @@semaphore.synchronize {
    @@api_hash[directory] = api_map
  }
end

.run!Object



35
36
37
38
# File 'lib/solargraph/server.rb', line 35

def run!
  constant_updates
  super
end