Skip to content

Instantly share code, notes, and snippets.

@willrax
Created May 20, 2016 11:41
Show Gist options
  • Save willrax/cfcf1236ae96c794611de03c2e3661b9 to your computer and use it in GitHub Desktop.
Save willrax/cfcf1236ae96c794611de03c2e3661b9 to your computer and use it in GitHub Desktop.
defmodule Site.CircleCi do
use Status.Site
def handle_response(response) do
Poison.Parser.parse!(response.body)
|> determine_app_state
end
defp url(site) do
"https://circleci.com/api/v1/project/#{site.app}/tree/master?limit=1&circle-token=#{System.get_env("CIRCLECI_TOKEN")}"
end
def determine_app_state([%{"status" => "running"} | _]), do: :pending
def determine_app_state([%{"status" => "queued"} | _]), do: :pending
def determine_app_state([%{"status" => "not_running"} | _]), do: :pending
def determine_app_state([%{"status" => "success"} | _]), do: :ok
def determine_app_state([%{"status" => "fixed"} | _]), do: :ok
def determine_app_state([%{"status" => "not_run"} | _]), do: :ok
def determine_app_state(_), do: :notok
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment