diff options
author | Abhiseck Paira <abhiseckpaira@disroot.org> | 2022-02-23 14:24:37 +0530 |
---|---|---|
committer | Abhiseck Paira <abhiseckpaira@disroot.org> | 2022-02-23 14:24:37 +0530 |
commit | 0af5b491d14d521c03ebc48d82608afd65166e90 (patch) | |
tree | 3cc559ec30068b1ec739ca6af893c2ba377f5a12 | |
parent | 77c173afc1f24fa371c41d0c59b94a8650eb4f61 (diff) |
change '-' to '--' in between function and namespace names
mastodon.el currently follows the convention where all function names
should have two dashes (not one dash) in between function and namespace
names. Update all function names to follow this convention.
See issue #205 and pull request #255
-rw-r--r-- | lisp/mastodon-auth.el | 20 | ||||
-rw-r--r-- | lisp/mastodon-client.el | 16 | ||||
-rw-r--r-- | lisp/mastodon-http.el | 2 | ||||
-rw-r--r-- | test/mastodon-auth-tests.el | 4 | ||||
-rw-r--r-- | test/mastodon-client-tests.el | 16 |
5 files changed, 29 insertions, 29 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index c09dfdf..2540598 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -40,11 +40,11 @@ (autoload 'mastodon-http--api "mastodon-http") (autoload 'mastodon-http--get-json "mastodon-http") (autoload 'mastodon-http--post "mastodon-http") -(autoload 'mastodon-http-append-query-string "mastodon-http") -(autoload 'mastodon-client-store-access-token "mastodon-client") -(autoload 'mastodon-client-active-user "mastodon-client") -(autoload 'mastodon-client-make-user-active "mastodon-client") -(autoload 'mastodon-client-form-user-from-vars "mastodon-client") +(autoload 'mastodon-http--append-query-string "mastodon-http") +(autoload 'mastodon-client--store-access-token "mastodon-client") +(autoload 'mastodon-client--active-user "mastodon-client") +(autoload 'mastodon-client--make-user-active "mastodon-client") +(autoload 'mastodon-client--form-user-from-vars "mastodon-client") (defvar mastodon-instance-url) (defvar mastodon-client-scopes) (defvar mastodon-client-redirect-uri) @@ -71,7 +71,7 @@ if you are happy with unencryped storage use e.g. \"~/authinfo\"." (defun mastodon-auth--get-browser-login-url () "Return properly formed browser login url." - (mastodon-http-append-query-string + (mastodon-http--append-query-string (concat mastodon-instance-url "/oauth/authorize/") `(("response_type" "code") ("redirect_uri" ,mastodon-client-redirect-uri) @@ -127,11 +127,11 @@ Generate/save token if none known yet." ;; initialised already. (alist-get mastodon-instance-url mastodon-auth--token-alist nil nil 'equal)) - ((plist-get (mastodon-client-active-user) :access_token) + ((plist-get (mastodon-client--active-user) :access_token) ;; user variables needs to initialised by reading from ;; plstore. (push (cons mastodon-instance-url - (plist-get (mastodon-client-active-user) :access_token)) + (plist-get (mastodon-client--active-user) :access_token)) mastodon-auth--token-alist) (alist-get mastodon-instance-url mastodon-auth--token-alist nil nil 'equal)) @@ -149,8 +149,8 @@ Handle any errors from the server." (pcase response ((and (let token (plist-get response :access_token)) (guard token)) - (mastodon-client-make-user-active - (mastodon-client-store-access-token token)) + (mastodon-client--make-user-active + (mastodon-client--store-access-token token)) (cdar (push (cons mastodon-instance-url token) mastodon-auth--token-alist))) diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index c577fec..80338b1 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -124,12 +124,12 @@ Return plist without the KEY." (defun mastodon-client--make-user-details-plist () "Make a plist with current user details. Return it." - `(:username ,(mastodon-client-form-user-from-vars) + `(:username ,(mastodon-client--form-user-from-vars) :instance ,mastodon-instance-url :client_id ,(plist-get (mastodon-client) :client_id) :client_secret ,(plist-get (mastodon-client) :client_secret))) -(defun mastodon-client-store-access-token (token) +(defun mastodon-client--store-access-token (token) "Save TOKEN as :access_token in plstore of the current user. Return the plist after the operation." (let* ((user-details (mastodon-client--make-user-details-plist)) @@ -144,7 +144,7 @@ Return the plist after the operation." (plstore-close plstore) plstore-value)) -(defun mastodon-client-make-user-active (user-details) +(defun mastodon-client--make-user-active (user-details) "USER-DETAILS is a plist consisting of user details." (let ((plstore (plstore-open (mastodon-client--token-file))) (print-length nil) @@ -153,7 +153,7 @@ Return the plist after the operation." (plstore-save plstore) (plstore-close plstore))) -(defun mastodon-client-form-user-from-vars () +(defun mastodon-client--form-user-from-vars () "Create a username from user variable. Return that username. Username in the form user@instance.com is formed from the @@ -165,23 +165,23 @@ variables `mastodon-instance-url' and `mastodon-active-user'." (defun mastodon-client--make-current-user-active () "Make the user specified by user variables active user. Return the details (plist)." - (let ((username (mastodon-client-form-user-from-vars)) + (let ((username (mastodon-client--form-user-from-vars)) user-plist) (when (setq user-plist (mastodon-client--general-read (concat "user-" username))) - (mastodon-client-make-user-active user-plist)) + (mastodon-client--make-user-active user-plist)) user-plist)) (defun mastodon-client--current-user-active-p () "Return user-details if the current user is active. Otherwise return nil." - (let ((username (mastodon-client-form-user-from-vars)) + (let ((username (mastodon-client--form-user-from-vars)) (user-details (mastodon-client--general-read "active-user"))) (when (and user-details (equal (plist-get user-details :username) username)) user-details))) -(defun mastodon-client-active-user () +(defun mastodon-client--active-user () "Return the details of the currently active user. Details is a plist." diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 8e96b39..05c9d2e 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -157,7 +157,7 @@ Pass response buffer to CALLBACK function." (with-temp-buffer (mastodon-http--url-retrieve-synchronously url)))) -(defun mastodon-http-append-query-string (url params) +(defun mastodon-http--append-query-string (url params) "Append PARAMS to URL as query strings and return it. PARAMS should be an alist as required `url-build-query-string'." diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el index 3ff745f..3bf65b2 100644 --- a/test/mastodon-auth-tests.el +++ b/test/mastodon-auth-tests.el @@ -56,8 +56,8 @@ (mastodon-auth--token-alist nil)) (with-mock (mock (mastodon-auth--get-token) => '(:access_token "foobaz")) - (mock (mastodon-client-store-access-token "foobaz")) - (stub mastodon-client-make-user-active) + (mock (mastodon-client--store-access-token "foobaz")) + (stub mastodon-client--make-user-active) (should (string= (mastodon-auth--access-token) "foobaz")) diff --git a/test/mastodon-client-tests.el b/test/mastodon-client-tests.el index c2ec50c..b302ed6 100644 --- a/test/mastodon-client-tests.el +++ b/test/mastodon-client-tests.el @@ -122,11 +122,11 @@ (should (equal mastodon-client--client-details-alist '(("http://mastodon.example" :client_id "foo" :client_secret "baz"))))))) -(ert-deftest mastodon-client-form-user-from-vars () +(ert-deftest mastodon-client--form-user-from-vars () (let ((mastodon-active-user "test9000") (mastodon-instance-url "https://mastodon.example")) (should - (equal (mastodon-client-form-user-from-vars) + (equal (mastodon-client--form-user-from-vars) "test9000@mastodon.example")))) (ert-deftest mastodon-client--current-user-active-p () @@ -142,7 +142,7 @@ (mock (mastodon-client--general-read "active-user") => '(:username "user@other.example" :client_id "id1")) (should (null (mastodon-client--current-user-active-p)))))) -(ert-deftest mastodon-client-store-access-token () +(ert-deftest mastodon-client--store-access-token () (let ((mastodon-instance-url "https://mastodon.example") (mastodon-active-user "test8000") (user-details @@ -150,14 +150,14 @@ :instance "https://mastodon.example" :client_id "id" :client_secret "secret" :access_token "token"))) - ;; test if mastodon-client-store-access-token /returns/ right + ;; test if mastodon-client--store-access-token /returns/ right ;; value (with-mock (mock (mastodon-client) => '(:client_id "id" :client_secret "secret")) (mock (mastodon-client--token-file) => "stubfile.plstore") - (should (equal (mastodon-client-store-access-token "token") + (should (equal (mastodon-client--store-access-token "token") user-details))) - ;; test if mastodon-client-store-access-token /stores/ right value + ;; test if mastodon-client--store-access-token /stores/ right value (with-mock (mock (mastodon-client--token-file) => "stubfile.plstore") (should (equal (mastodon-client--general-read @@ -165,10 +165,10 @@ user-details))) (delete-file "stubfile.plstore"))) -(ert-deftest mastodon-client-make-user-active () +(ert-deftest mastodon-client--make-user-active () (let ((user-details '(:username "test@mastodon.example"))) (with-mock (mock (mastodon-client--token-file) => "stubfile.plstore") - (mastodon-client-make-user-active user-details) + (mastodon-client--make-user-active user-details) (should (equal (mastodon-client--general-read "active-user") user-details))))) |