Skip to content

Commit

Permalink
Fixed lint issues and added coverall
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Bydeley committed Jan 29, 2015
1 parent f01576e commit 9653337
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repo_token: jGZeBASDkPbmgsMU8tNY04w7BSCMhP9j5
1 change: 1 addition & 0 deletions branch.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// Branch model
type Branch struct {
ID int `json:"ID"`
Name string `json:"name"`
Expand Down
1 change: 1 addition & 0 deletions branch_history.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// BranchHistory model
type BranchHistory struct {
Name string `json:"branch_name"`
URL string `json:"branch_url"`
Expand Down
1 change: 1 addition & 0 deletions branch_status.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// BranchStatus model
type BranchStatus struct {
Name string `json:"branch_name"`
BranchURL string `json:"branch_url"`
Expand Down
1 change: 1 addition & 0 deletions build.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// Build model
type Build struct {
URL string `json:"build_url"`
InfoURL string `json:"build_info_url"`
Expand Down
1 change: 1 addition & 0 deletions build_information.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// BuildInformation model
type BuildInformation struct {
Commits []Commit `json:"commits"`
ProjectName string `json:"project_name"`
Expand Down
1 change: 1 addition & 0 deletions build_log.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// BuildLog model
type BuildLog struct {
Threads []Thread `json:"threads"`
BuildInfoURL string `json:"build_info_url"`
Expand Down
1 change: 1 addition & 0 deletions command.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// Command model
type Command struct {
Name string `json:"name"`
Result string `json:"result"`
Expand Down
1 change: 1 addition & 0 deletions commit.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// Commit model
type Commit struct {
ID string `json:"ID"`
URL string `json:"url"`
Expand Down
1 change: 1 addition & 0 deletions project.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// Project model
type Project struct {
ID int `json:"ID"`
HashID string `json:"hash_ID"`
Expand Down
13 changes: 9 additions & 4 deletions semaphore.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Go-Semaphore
// Package semaphore API
package semaphore

import (
Expand Down Expand Up @@ -27,18 +27,18 @@ func (a *Semaphore) request(URL string) ([]byte, error) {
return ioutil.ReadAll(resp.Body)
}

// Semaphore API
type Semaphore struct {
authToken, baseURL string
httpClient *http.Client
}

// // For Example
// // api := NewApi("authorization_token")
// // branch, err := api.GetBranchStatus("hash_ID", branch_ID)
// NewSemaphore instantiates a new Semaphore API
func NewSemaphore(auth string) *Semaphore {
return &Semaphore{auth, "https://semaphoreapp.com", http.DefaultClient}
}

// GetProjects returns an array of projects
func (a *Semaphore) GetProjects() ([]Project, error) {
URL := fmt.Sprintf(getProjectsURL, a.baseURL, a.authToken)
response, err := a.request(URL)
Expand All @@ -53,6 +53,7 @@ func (a *Semaphore) GetProjects() ([]Project, error) {
return projects, nil
}

// GetBranches returns an array of branches for a given project
func (a *Semaphore) GetBranches(project string) ([]Branch, error) {
URL := fmt.Sprintf(getBranchesURL, a.baseURL, project, a.authToken)
response, err := a.request(URL)
Expand All @@ -67,6 +68,7 @@ func (a *Semaphore) GetBranches(project string) ([]Branch, error) {
return branches, nil
}

// GetBranchStatus returns a BranchStatus object for a given project + branch
func (a *Semaphore) GetBranchStatus(project string, branch int) (*BranchStatus, error) {
URL := fmt.Sprintf(getBranchStatusURL, a.baseURL, project, branch, a.authToken)
response, err := a.request(URL)
Expand All @@ -81,6 +83,7 @@ func (a *Semaphore) GetBranchStatus(project string, branch int) (*BranchStatus,
return status, nil
}

// GetBranchHistory returns a BranchHistory object for a given project + branch
func (a *Semaphore) GetBranchHistory(project string, branch int) (*BranchHistory, error) {
URL := fmt.Sprintf(getBranchHistoryURL, a.baseURL, project, branch, a.authToken)
response, err := a.request(URL)
Expand All @@ -95,6 +98,7 @@ func (a *Semaphore) GetBranchHistory(project string, branch int) (*BranchHistory
return history, nil
}

// GetBuildInformation returns a BuildInformation object for a given project + branch + build
func (a *Semaphore) GetBuildInformation(project string, branch, build int) (*BuildInformation, error) {
URL := fmt.Sprintf(getBuildInformationURL, a.baseURL, project, branch, build, a.authToken)
response, err := a.request(URL)
Expand All @@ -109,6 +113,7 @@ func (a *Semaphore) GetBuildInformation(project string, branch, build int) (*Bui
return info, nil
}

// GetBuildLog returns a BuildLog object for a given project + branch + build
func (a *Semaphore) GetBuildLog(project string, branch, build int) (*BuildLog, error) {
URL := fmt.Sprintf(getBuildLogURL, a.baseURL, project, branch, build, a.authToken)
response, err := a.request(URL)
Expand Down
1 change: 1 addition & 0 deletions server.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// Server model
type Server struct {
ProjectName string `json:"project_name"`
ServerName string `json:"server_name"`
Expand Down
1 change: 1 addition & 0 deletions thread.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package semaphore

// Thread model
type Thread struct {
Number int
Commands []Command
Expand Down

0 comments on commit 9653337

Please sign in to comment.