robot

package
v0.0.0-...-815af93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertRepoURL

func ConvertRepoURL(rawurl string) (string, error)

Convert the given repository URL into an API URL https://github.com/kkochis/adoptmyapp to https://api.github.com/repos/kkochis/adoptmyapp TODO Error checking, what if a github.com URL was not given

func NormalizeGitHubSSH

func NormalizeGitHubSSH(rawssh string) (*url.URL, error)

Convert a GitHub SSH link into a URL

func NormalizeGitHubURL

func NormalizeGitHubURL(rawurl string) (*url.URL, error)

Normalize GitHub URL * Convert the Scheme to HTTPS * Normalize the Host to github.com * Remove any extraneous information at the end of the url This normalized URL will be used to check uniqueness in the database

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func New

func New(db DB) (*API, error)

Start the API

func (*API) Root

func (api *API) Root(w http.ResponseWriter, r *http.Request)

The sole HTTP function Can be tested with curl: curl localhost:8081 -d "url=git@github.com:kkochis/adoptmyapp.git"

type DB

type DB interface {
	Get(string) (*Meta, error)
	Save(string) (*Meta, error)
}

Wraps an existing connection

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

func NewMemoryDB

func NewMemoryDB() *Memory

func (*Memory) Get

func (db *Memory) Get(url string) (*Meta, error)

func (*Memory) Save

func (db *Memory) Save(url string) (*Meta, error)

type Meta

type Meta struct {
	URL   string    `json:"url"`
	Added time.Time `json:"added"`
}

type Mongo

type Mongo struct {
	// contains filtered or unexported fields
}

func NewMongoDB

func NewMongoDB(session *mgo.Session, name string) *Mongo

func (*Mongo) Get

func (db *Mongo) Get(url string) (meta *Meta, err error)

Get the repository from the database using the normalized URL. If no repository exists, return nil and an error.

func (*Mongo) Save

func (db *Mongo) Save(url string) (*Meta, error)

type Repository

type Repository struct {
	URL         string    `json:"url"` // Normalized URL
	Id          int64     `json:"id"`
	Name        string    `json:"name"`
	FullName    string    `json:"full_name"`
	Owner       *User     `json:"owner"`
	HtmlURL     string    `json:"html_url"`
	Description string    `json:"description"`
	IsPrivate   bool      `json:"private"`
	IsFork      bool      `json:"fork"`
	Created     time.Time `json:"created_at"`
	Updated     time.Time `json:"updated_at"`
	Subscribers int64     `json:"subscribers"`
}

The JSON object returned from a GET to the github API for repositories curl -i https://api.github.com/repos/kkochis/adoptmyapp TODO Are owners always Users?

func GetRepoInfo

func GetRepoInfo(repositoryURL string) (*Repository, error)

func ParseRepository

func ParseRepository(data []byte) (*Repository, error)

type User

type User struct {
	Login     string `json:"login"`
	Id        int64  `json:"id"`
	HtmlURL   string `json:"html_url"`
	AvatarURL string `json:"avatar_url"`
}

The JSON object contained in the owner field of the repository API object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL