CL-GISTS ยป Overview

Description

Gists API Wrapper for Common Lisp.

Examples

1. credentials

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; By default, environment variables.

*github-username-env-var*
;; => "GITHUB_USERNAME"

*github-password-env-var*
;; => "GITHUB_PASSWORD"

*github-oauth-token-env-var*
;; => "GITHUB_OAUTH_TOKEN"


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; You can customize credential methods.

(defclass github-credentials ()
  ((username :initarg :username)
   (password :initarg :password)
   (oauth-token :initarg :oauth-token)))

;; username and password

(defmethod username ((obj github-credentials))
  (slot-value obj 'username))

(defmethod password ((obj github-credentials))
  (slot-value obj 'password))

(setq *credentials* (make-instance 'github-credentials
                                   :username "Rudolph-Miller"
                                   :password "PASSWORD"))

;; oauth-token

(defmethod oauth-token ((obj github-credentials))
  (slot-value obj 'oauth-token))

(setq *credentials* (make-instance 'github-credentials
                                   :oauth-token "OAUTHTOKEN"))

2. list-gists

(list-gists)
;; => (#S(GIST ...) ...)

(list-gists :public t)
;; => (#S(GIST ...) ...)

(list-gists :username "Rudolph-Miller")
;; => (#S(GIST ...) ...)

(list-gists :since (local-time:today))
;; => (#S(GIST ...) ...)

3. get-gist

(get-gist "gistid")
;; => #S(GIST ...)

(get-gist "gistid" :sha "gistsha")
;; => #S(GIST ...)

4. create-gist

(let ((gist (make-gist :description "sample"
                       :public t
                       :files '((:name "file1" :content "text1") (:name "file2" :content "text2")))))
  (create-gist gist))
;; => #S(GIST ...)

5. edit-gist

(let* ((gist (create-gist
              (make-gist :description "sample"
                         :public t
                         :files '((:name "file1" :content "text1")
                                  (:name "file2" :content "text2")))))
       (files (gist-files gist))
       (file1 (car files))
       (file2 (cadr files)))

  ;; Change description.
  (setf (gist-description gist) "changed")

  ;; Changed filename and content.
  (setf (file-name file1) "file3")
  (setf (file-content file1) "text3")

  ;; Delete a file.
  (setf (file-content file2) nil)

  (setf (gist-files) (list file1 file2))

  (edit-gist gist))
;; => #S(GIST ...)

6. list-gist-commits

(let ((id "gistid"))
  (list-gist-commits id))
;; => (#S(HISTORY ...) ...)

(let ((gist (get-gist "gistid")))
  (list-gist-commits gist))
;; => (#S(HISTORY ...) ...)

7. star-gist

(let ((id "gistid"))
  (star-gist id))
;; => T

(let ((gist (git-gist "gistid")))
  (star-gist gist))
;; => T

8. unstar-gist

(let ((id "gistid"))
  (unstar-gist id))
;; => T

(let ((gist (git-gist "gistid")))
  (unstar-gist gist))
;; => T

9. gist-starred-p

(let ((id "gistid"))
  (gist-starred-p id))
;; => T or NIL

(let ((gist (git-gist "gistid")))
  (gist-starred-p gist))
;; => T or NIL

10. list-gist-forks

(let ((id "gistid"))
  (list-gist-forks id))
;; => (#S(GIST ...) ...)

(let ((gist (git-gist "gistid")))
  (list-gist-forks gist))
;; => (#S(GIST ...) ...)

11. delete-gist

(let ((id "gistid"))
  (delete-gist id))
;; => T

(let ((gist (get-gist "gistid")))
  (delete-gist gist))
;; => T

Source

CL-GISTS

Author

Rudolph Miller

Licence

MIT