Class: Solargraph::Server

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

Defined Under Namespace

Classes: Helpers

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_api_map(workspace) ⇒ Solargraph::ApiMap



137
138
139
140
141
142
143
# File 'lib/solargraph/server.rb', line 137

def self.get_api_map workspace
  api_map = nil
  @@semaphore.synchronize {
    api_map = @@api_hash[workspace]
  }
  api_map
end

.prepare_workspace(directory) ⇒ Object



165
166
167
168
169
170
171
172
173
# File 'lib/solargraph/server.rb', line 165

def prepare_workspace directory
  Thread.new do
    api_map = Solargraph::ApiMap.new(directory)
    api_map.yard_map
    @@semaphore.synchronize do
      @@api_hash[directory] = api_map
    end
  end
end

.wait ⇒ Object



18
19
20
21
# File 'lib/solargraph/server.rb', line 18

def self.wait
  @@semaphore.lock
  @@semaphore.unlock
end

Instance Method Details

#get_api_map(workspace) ⇒ Solargraph::ApiMap



146
147
148
# File 'lib/solargraph/server.rb', line 146

def get_api_map workspace
  Server.get_api_map workspace
end

#htmlify(text) ⇒ Object



150
151
152
# File 'lib/solargraph/server.rb', line 150

def htmlify text
  rdoc_to_html text
end

#rdoc_to_html(text) ⇒ Object



154
155
156
157
# File 'lib/solargraph/server.rb', line 154

def rdoc_to_html text
  h = Helpers.new
  h.html_markup_rdoc(text)
end

#ruby_to_html(code) ⇒ Object



159
160
161
162
# File 'lib/solargraph/server.rb', line 159

def ruby_to_html code
  h = Helpers.new
  h.html_markup_ruby(code)
end