class Stashboardmanager::Manager

Main class for interacting with StashboardManager.

Public Class Methods

new(address, token, secret) click to toggle source

Create a new StashboardManager instance.

# File lib/stashboardmanager.rb, line 10
def initialize(address, token, secret)
  @stashboard = Stashboard::Stashboard.new(address, token, secret)
end

Public Instance Methods

service_ids() click to toggle source

Get an array of service ids. This is just for convenience/

@return [Array] Services Array containing just the service ids

# File lib/stashboardmanager.rb, line 35
def service_ids
  @stashboard.service_ids
end
service_status(service) click to toggle source

Get the current status of a service.

@param [String] service The service you are attempting to set @return [Hash] details A hash containing the details for this service

# File lib/stashboardmanager.rb, line 43
def service_status(service)
  #Do we have a service for this set up
  services = self.service_ids
  exists = services.include? service

  status = false

  #Make sure we have some services and that this one exists
  if exists
    #Get the service's details
    s = @stashboard.service(service)

    #Grab the current event
    current_event = s["current-event"]

    #Make sure we have a current event
    if(!current_event.nil?)
      status = current_event["status"]["id"]
    end
  end

  status
end
service_updatable(service, status) click to toggle source

Is this service updatable?

@param [String] service The name of the service you want to check @param [String] status The status you are trying to update the service to @return [Boolean] response Response containing a true if this service should be updated, a false if it shouldn't OR a nil if the service doesn't exist

# File lib/stashboardmanager.rb, line 72
def service_updatable(service, status)
  #What is the current service status?
  serv_stat = self.service_status(service)

  if serv_stat == status   #If match don't update
    return false
  else                        #No match - update
    return true
  end
end
service_update(service, status, message) click to toggle source
Check to see if a service is already set as 'status'. If not, update it.

@param [String] service The service you are attempting to set

 @param [String] status The status you are attempting to set

@param [String] message The message you wish to attach to this update
# File lib/stashboardmanager.rb, line 19
def service_update(service, status, message)
  if service_updatable(service, status)
    @stashboard.create_event(service, status, message)
  end
end
services() click to toggle source

Get all services attached to this stashboard.

@return [Hash] services A hash containing an array of service detail hashes, or an error message

# File lib/stashboardmanager.rb, line 28
def services
  @stashboard.services
end