lib

package
v0.0.0-...-63079b4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RspMDPath    = "../_temp/ranks.md"
	RspJSONPath  = "../_temp/ranks.json"
	APIKeyPath   = "../_secret/api.key"
	GitHubToken  = "../_secret/token"
	SOApiURL     = "https://api.stackexchange.com/2.2"
	SOUsersQuery = `users?page=%d&pagesize=100&order=desc&sort=reputation&site=stackoverflow`
	SOUserTags   = `users/%d/top-answer-tags?page=1&pagesize=3&site=stackoverflow`
	GHApiURL     = "https://api.github.com/repos/klashxx/soranks"
)

Variables

View Source
var (
	Trace   *log.Logger
	Info    *log.Logger
	Warning *log.Logger
	Error   *log.Logger
)

Functions

func DumpJson

func DumpJson(data interface{}) error

func DumpLauncher

func DumpLauncher(ranks Ranks, location *string) error

func DumpMarkdown

func DumpMarkdown(ranks Ranks, location *string) error

func F2Base64

func F2Base64(path string) (string, error)

func GHPublisher

func GHPublisher(token string, publish *string, branch string, author Committer) error

func GetAPIKey

func GetAPIKey() (key string, err error)

func GetKey

func GetKey(path string) (string, error)

func GetTags

func GetTags(userid int, key string, offline bool) string

func GetToken

func GetToken() (token string)

func GetUserInfo

func GetUserInfo(users *SOUsers, min int, location *regexp.Regexp, counter *int, limit int, ranks *Ranks, term bool, offline bool, key string) bool

func GitHubConnector

func GitHubConnector(fmtpath string, target string, token string, branch string, author Committer) error

func Init

func Init(
	traceHandle io.Writer,
	infoHandle io.Writer,
	warningHandle io.Writer,
	errorHandle io.Writer)

func JSONDecoder

func JSONDecoder(r io.Reader, data interface{}) error

func JSONEncoder

func JSONEncoder(data interface{}) (buf io.ReadWriter, err error)

func StreamFile

func StreamFile(jsonfile string, data interface{}) error

func StreamHTTP

func StreamHTTP(url string, data interface{}, gzipped bool) error

Types

type Committer

type Committer struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type Create

type Create struct {
	Path      string `json:"path"`
	Message   string `json:"message"`
	Content   string `json:"content"`
	Branch    string `json:"branch"`
	Committer `json:"committer"`
}

type GHReqError

type GHReqError struct {
	Message          string `json:"message"`
	DocumentationURL string `json:"documentation_url"`
}

type GitHubUpdatePut

type GitHubUpdatePut struct {
	Message   string `json:"message"`
	Committer struct {
		Name  string `json:"name"`
		Email string `json:"email"`
	} `json:"committer"`
	Content string `json:"content"`
	Sha     string `json:"sha"`
}

type GitHubUpdateRsp

type GitHubUpdateRsp struct {
	Content struct {
		Name        string `json:"name"`
		Path        string `json:"path"`
		Sha         string `json:"sha"`
		Size        int    `json:"size"`
		URL         string `json:"url"`
		HTMLURL     string `json:"html_url"`
		GitURL      string `json:"git_url"`
		DownloadURL string `json:"download_url"`
		Type        string `json:"type"`
		Links       struct {
			Self string `json:"self"`
			Git  string `json:"git"`
			HTML string `json:"html"`
		} `json:"_links"`
	} `json:"content"`
	Commit struct {
		Sha     string `json:"sha"`
		URL     string `json:"url"`
		HTMLURL string `json:"html_url"`
		Author  struct {
			Date  time.Time `json:"date"`
			Name  string    `json:"name"`
			Email string    `json:"email"`
		} `json:"author"`
		Committer struct {
			Date  time.Time `json:"date"`
			Name  string    `json:"name"`
			Email string    `json:"email"`
		} `json:"committer"`
		Message string `json:"message"`
		Tree    struct {
			URL string `json:"url"`
			Sha string `json:"sha"`
		} `json:"tree"`
		Parents []struct {
			URL     string `json:"url"`
			HTMLURL string `json:"html_url"`
			Sha     string `json:"sha"`
		} `json:"parents"`
	} `json:"commit"`
}

type Ranks

type Ranks []SOUserRank

type Repo

type Repo struct {
	Sha  string `json:"sha"`
	URL  string `json:"url"`
	Tree []struct {
		Path string `json:"path"`
		Mode string `json:"mode"`
		Type string `json:"type"`
		Sha  string `json:"sha"`
		Size int    `json:"size,omitempty"`
		URL  string `json:"url"`
	} `json:"tree"`
	Truncated bool `json:"truncated"`
}

type SOTopTags

type SOTopTags struct {
	Items []struct {
		UserID        int    `json:"user_id"`
		AnswerCount   int    `json:"answer_count"`
		AnswerScore   int    `json:"answer_score"`
		QuestionCount int    `json:"question_count"`
		QuestionScore int    `json:"question_score"`
		TagName       string `json:"tag_name"`
	} `json:"items"`
	HasMore        bool `json:"has_more"`
	QuotaMax       int  `json:"quota_max"`
	QuotaRemaining int  `json:"quota_remaining"`
}

type SOUserRank

type SOUserRank struct {
	Rank         int    `json:"rank"`
	AccountID    int    `json:"account_id"`
	DisplayName  string `json:"display_name"`
	Reputation   int    `json:"reputation"`
	Location     string `json:"location,omitempty"`
	WebsiteURL   string `json:"website_url,omitempty"`
	Link         string `json:"link"`
	ProfileImage string `json:"profile_image"`
	TopTags      string `json:"top_tags"`
}

type SOUsers

type SOUsers struct {
	Items []struct {
		BadgeCounts struct {
			Bronze int `json:"bronze"`
			Silver int `json:"silver"`
			Gold   int `json:"gold"`
		} `json:"badge_counts"`
		AccountID               int    `json:"account_id"`
		IsEmployee              bool   `json:"is_employee"`
		LastModifiedDate        int    `json:"last_modified_date"`
		LastAccessDate          int    `json:"last_access_date"`
		Age                     int    `json:"age,omitempty"`
		ReputationChangeYear    int    `json:"reputation_change_year"`
		ReputationChangeQuarter int    `json:"reputation_change_quarter"`
		ReputationChangeMonth   int    `json:"reputation_change_month"`
		ReputationChangeWeek    int    `json:"reputation_change_week"`
		ReputationChangeDay     int    `json:"reputation_change_day"`
		Reputation              int    `json:"reputation"`
		CreationDate            int    `json:"creation_date"`
		UserType                string `json:"user_type"`
		UserID                  int    `json:"user_id"`
		AcceptRate              int    `json:"accept_rate,omitempty"`
		Location                string `json:"location,omitempty"`
		WebsiteURL              string `json:"website_url,omitempty"`
		Link                    string `json:"link"`
		ProfileImage            string `json:"profile_image"`
		DisplayName             string `json:"display_name"`
	} `json:"items"`
	HasMore        bool `json:"has_more"`
	QuotaMax       int  `json:"quota_max"`
	QuotaRemaining int  `json:"quota_remaining"`
}

type Update

type Update struct {
	Path      string `json:"path"`
	Message   string `json:"message"`
	Content   string `json:"content"`
	Sha       string `json:"sha"`
	Branch    string `json:"branch"`
	Committer `json:"committer"`
}

Jump to

Keyboard shortcuts

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