Class: LitmusPaper::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/litmus_paper/app.rb

Instance Method Summary collapse

Instance Method Details

#_cacheObject



127
128
129
130
131
132
133
# File 'lib/litmus_paper/app.rb', line 127

def _cache
  @cache ||= LitmusPaper::Cache.new(
    LitmusPaper.cache_location,
    "litmus_cache",
    LitmusPaper.cache_ttl
  )
end

#_create_status_file(status_file) ⇒ Object



135
136
137
138
# File 'lib/litmus_paper/app.rb', line 135

def _create_status_file(status_file)
  status_file.create(params[:reason], params[:health])
  _text 201, "File created"
end

#_delete_status_file(status_file) ⇒ Object



140
141
142
143
144
145
146
147
# File 'lib/litmus_paper/app.rb', line 140

def _delete_status_file(status_file)
  if status_file.exists?
    status_file.delete
    _text 200, "File deleted"
  else
    _text 404, "NOT FOUND"
  end
end

#_text(response_code, body, headers = {}) ⇒ Object



149
150
151
# File 'lib/litmus_paper/app.rb', line 149

def _text(response_code, body, headers ={})
  [response_code, { "Content-Type" => "text/plain" }.merge(headers), body]
end