Class: LitmusPaper::App

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

Instance Method Summary collapse

Instance Method Details

#_cacheObject



108
109
110
111
112
113
114
# File 'lib/litmus_paper/app.rb', line 108

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

#_create_status_file(status_file) ⇒ Object



116
117
118
119
# File 'lib/litmus_paper/app.rb', line 116

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

#_delete_status_file(status_file) ⇒ Object



121
122
123
124
125
126
127
128
# File 'lib/litmus_paper/app.rb', line 121

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



130
131
132
# File 'lib/litmus_paper/app.rb', line 130

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