class LitmusPaper::StatusFile

Attributes

forced[R]

Public Class Methods

global_down_file() click to toggle source
# File lib/litmus_paper/status_file.rb, line 5
def self.global_down_file
  new("global_down", :down)
end
global_health_file() click to toggle source
# File lib/litmus_paper/status_file.rb, line 13
def self.global_health_file
  new("global_health", :health)
end
global_up_file() click to toggle source
# File lib/litmus_paper/status_file.rb, line 9
def self.global_up_file
  new("global_up", :up)
end
new(filename, forced) click to toggle source
# File lib/litmus_paper/status_file.rb, line 40
def initialize(filename, forced)
  @path = File.join(LitmusPaper.data_directory, filename)
  @forced = forced
end
priority_check_order_for_service(service_name) click to toggle source
# File lib/litmus_paper/status_file.rb, line 29
def self.priority_check_order_for_service(service_name)
  [
    global_down_file,
    global_up_file,
    global_health_file,
    service_down_file(service_name),
    service_up_file(service_name),
    service_health_file(service_name),
  ]
end
service_down_file(service_name) click to toggle source
# File lib/litmus_paper/status_file.rb, line 17
def self.service_down_file(service_name)
  new("#{service_name}_down", :down)
end
service_health_file(service_name) click to toggle source
# File lib/litmus_paper/status_file.rb, line 25
def self.service_health_file(service_name)
  new("#{service_name}_health", :health)
end
service_up_file(service_name) click to toggle source
# File lib/litmus_paper/status_file.rb, line 21
def self.service_up_file(service_name)
  new("#{service_name}_up", :up)
end

Public Instance Methods

content() click to toggle source
# File lib/litmus_paper/status_file.rb, line 45
def content
  File.read(@path).chomp
end
create(reason, health = nil) click to toggle source
# File lib/litmus_paper/status_file.rb, line 49
def create(reason, health = nil)
  FileUtils.mkdir_p(File.dirname(@path))
  File.open(@path, 'w') do |file|
    file.puts(reason)
    file.puts(health) if health
  end
end
delete() click to toggle source
# File lib/litmus_paper/status_file.rb, line 57
def delete
  FileUtils.rm(@path)
end
exists?() click to toggle source
# File lib/litmus_paper/status_file.rb, line 61
def exists?
  File.exists?(@path)
end