Compare commits

...

8 Commits

4 changed files with 48 additions and 44 deletions
Split View
  1. +3
    -0
      .gitignore
  2. +21
    -38
      Makefile
  3. +2
    -2
      README.org
  4. +22
    -4
      libelcouch.el

+ 3
- 0
.gitignore View File

@ -0,0 +1,3 @@
makel.mk
*.elc
*-autoloads.el

+ 21
- 38
Makefile View File

@ -1,44 +1,27 @@
SRCS = libelcouch.el
TESTS = test/libelcouch-test.el
ELPA_DEPENDENCIES=package-lint request let-alist
LOAD_PATH = -L . -L ../package-lint -L ../request
ELPA_ARCHIVES=melpa gnu
EMACSBIN ?= emacs
BATCH = $(EMACSBIN) -Q --batch $(LOAD_PATH) \
--eval "(setq load-prefer-newer t)" \
--eval "(require 'package)" \
--eval "(add-to-list 'package-archives '(\"melpa-stable\" . \"http://stable.melpa.org/packages/\"))" \
--eval "(setq enable-dir-local-variables nil)" \
--funcall package-initialize
TEST_ERT_FILES=test/libelcouch-test.el
.PHONY: all ci-dependencies check test lint
LINT_CHECKDOC_FILES=$(wildcard *.el) $(wildcard test/*.el)
LINT_CHECKDOC_OPTIONS=--eval "(setq checkdoc-arguments-in-order-flag nil)"
LINT_PACKAGE_LINT_FILES=$(wildcard *.el)
LINT_COMPILE_FILES=$(wildcard *.el) $(wildcard test/*.el)
all: check
CURL = curl --fail --silent --show-error --insecure --location --retry 9 --retry-delay 9
GITHUB = https://raw.githubusercontent.com
ci-dependencies:
# Install dependencies in ~/.emacs.d/elpa
$(BATCH) \
--funcall package-refresh-contents \
--eval "(package-install 'package-lint)" \
--eval "(package-install 'request)"
makel.mk:
# Download makel
@if [ -f ../makel/makel.mk ]; then \
ln -s ../makel/makel.mk .; \
else \
curl \
--fail --silent --show-error --insecure --location \
--retry 9 --retry-delay 9 \
-O https://gitlab.petton.fr/DamienCassou/makel/raw/v0.5.1/makel.mk; \
fi
check: lint test
test:
$(BATCH) --eval "(progn\
(load-file \"test/libelcouch-test.el\")\
(ert-run-tests-batch-and-exit))"
lint :
# Byte compile all and stop on any warning or error
$(BATCH) \
--eval "(setq byte-compile-error-on-warn t)" \
-f batch-byte-compile ${SRCS} ${TESTS}
# Run package-lint to check for packaging mistakes
$(BATCH) \
--eval "(require 'package-lint)" \
-f package-lint-batch-and-exit ${SRCS}
# Run checkdoc to check Emacs Lisp conventions
$(BATCH) --eval "(mapcar #'checkdoc-file '($(patsubst %, \"%\", ${SRCS})))"
# Include emake.mk if present
-include makel.mk

+ 2
- 2
README.org View File

@ -10,8 +10,8 @@
<img alt="MELPA" src="https://melpa.org/packages/libelcouch-badge.svg"/>
</a>
<a href="https://gitlab.petton.fr/elcouch/libelcouch/commits/master">
<img alt="pipeline status" src="https://gitlab.petton.fr/elcouch/libelcouch/badges/master/pipeline.svg" />
<a href="https://gitlab.com/DamienCassou/libelcouch/commits/master">
<img alt="pipeline status" src="https://gitlab.com/DamienCassou/libelcouch/badges/master/pipeline.svg" />
</a>
</p>
#+END_HTML


+ 22
- 4
libelcouch.el View File

@ -6,7 +6,7 @@
;; Keywords: tools
;; Url: https://gitlab.petton.fr/elcouch/libelcouch/
;; Package-requires: ((emacs "25.1") (request "0.3.0"))
;; Version: 0.8.0
;; Version: 0.9.0
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@ -240,17 +240,35 @@ considered to have failed."
:error #'libelcouch--request-error)
nil)
(defun libelcouch-document-delete (document revision function)
"Delete DOCUMENT at REVISION and evaluate FUNCTION."
(defun libelcouch-document-latest-revision (document function)
"Pass the revision of DOCUMENT to FUNCTION."
(libelcouch-document-content
document
(lambda (content)
(with-temp-buffer
(insert content)
(goto-char (point-min))
(funcall function (map-elt (json-read) '_rev))))))
(defun libelcouch-document-delete (document revision &optional function)
"Delete DOCUMENT and evaluate FUNCTION.
If REVISION is not the latest, signal an error."
(request
(url-encode-url (libelcouch-entity-url document))
:type "DELETE"
:params `(("rev" . ,revision))
:headers '(("Content-Type" . "application/json")
("Accept" . "application/json"))
:success (cl-function (lambda (&rest _args) (funcall function)))
:success (cl-function (lambda (&rest _args) (when function (funcall function))))
:error #'libelcouch--request-error)
nil)
(defun libelcouch-document-delete-latest (document &optional function)
"Delete DOCUMENT and evaluate FUNCTION."
(libelcouch-document-latest-revision
document
(lambda (revision)
(libelcouch-document-delete document revision function))))
(provide 'libelcouch)
;;; libelcouch.el ends here

Loading…
Cancel
Save