Skip to content

Commit 181be43

Browse files
committed
Merge branch 'codox'
Fixes #8
2 parents 0a76461 + ef382a3 commit 181be43

19 files changed

+1180
-544
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ pom.xml.asc
99
/.nrepl-port
1010
.hgignore
1111
.hg/
12+
doc/api

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ parts to this library:
1717
should use this if you're transitioning code from `clj-ssh` to this
1818
library.
1919

20+
Documentation for the latest release should always be available at:
21+
http://conormcd.github.io/clj-libssh2/
22+
2023
## clj-libssh2 API
2124

2225
The primary public API for this library is the following set of functions:

project.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
:pedantic? :abort
77
:dependencies [[org.clojure/clojure "1.7.0"]
88
[net.n01se/clojure-jna "1.0.0"]]
9+
:profiles {:dev {:plugins [[lein-codox "0.9.1"]]}}
910
:deploy-repositories ^:replace [["clojars" {:url "https://clojars.org/repo"
1011
:username [:gpg :env/clojars_username]
1112
:password [:gpg :env/clojars_password]
1213
:sign-releases false}]]
14+
:codox {:output-path "doc/api"}
1315
:jvm-opts ["-Xmx1g"
1416
"-XX:+TieredCompilation"
1517
"-XX:TieredStopAtLevel=1"])

release.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,29 @@ save_artifacts() {
8585
fi
8686
}
8787

88+
update_api_docs() {
89+
local _version
90+
_version=$1
91+
92+
set -x
93+
git config --global user.email "${GITHUB_USER}@users.noreply.github.com"
94+
git config --global user.name "${GITHUB_USER}/${GITHUB_REPO} release.sh"
95+
git clone -b gh-pages [email protected]:${GITHUB_USER}/${GITHUB_REPO}.git doc/api
96+
lein codox
97+
(
98+
cd doc/api
99+
cat > circle.yml <<EOF
100+
general:
101+
branches:
102+
ignore:
103+
- gh-pages
104+
EOF
105+
git add .
106+
git commit -m "Docs for version ${_version}"
107+
git push origin gh-pages
108+
)
109+
}
110+
88111
ensure_github_release_tool_installed() {
89112
local _cwd
90113
_cwd=$(pwd)
@@ -124,6 +147,10 @@ clojars_deploy() {
124147
lein deploy clojars 2>&1 | sed -e 's,^, ,'
125148
}
126149

150+
cleanup() {
151+
git clean -ffdx
152+
}
153+
127154
v=$(new_version)
128155
update_project_clj "${v}"
129156
build_jars
@@ -145,4 +172,8 @@ if [ "$(branch)" = "master" ]; then
145172

146173
# Push to clojars
147174
clojars_deploy
175+
176+
# Push new docs
177+
update_api_docs "${v}"
148178
fi
179+
cleanup

src/clj_libssh2/agent.clj

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
(ns clj-libssh2.agent
2+
"Functions for interacting with an SSH agent. The agent is expected to be
3+
available on the UNIX domain socket referred to by the SSH_AUTH_SOCK
4+
environment variable."
25
(:require [clj-libssh2.error :refer [handle-errors with-timeout]]
3-
[clj-libssh2.libssh2 :as libssh2]
46
[clj-libssh2.libssh2.agent :as libssh2-agent])
57
(:import [com.sun.jna.ptr PointerByReference]))
68

79
(defn- get-identity
810
"Get the next available identity from the agent. Pass nil for previous to get
9-
the first entry."
11+
the first entry.
12+
13+
Arguments:
14+
15+
session A clj-libssh2.session.Session object.
16+
ssh-agent An ssh agent object from libssh2_agent_init.
17+
previous The last identity returned from a call to this function. Pass nil
18+
to get the first entry.
19+
20+
Return:
21+
22+
A native object as returned by libssh2_agent_get_identity."
1023
[session ssh-agent previous]
1124
(when (nil? previous)
1225
(handle-errors session
@@ -22,7 +35,18 @@
2235
(throw (Exception. "An unknown error occurred")))))
2336

2437
(defn authenticate
25-
"Attempt to authenticate a session using the agent."
38+
"Attempt to authenticate a session using the agent.
39+
40+
Arguments:
41+
42+
session A clj-libssh2.session.Session object which refers to a session
43+
which has not already been authenticated.
44+
username The username for the user who is trying to authenticate.
45+
46+
Return:
47+
48+
True on success. An exception will be thrown if the user could not be
49+
authenticated."
2650
[session username]
2751
(let [ssh-agent (libssh2-agent/init (:session session))]
2852
(when (nil? ssh-agent)

src/clj_libssh2/authentication.clj

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
(ns clj-libssh2.authentication
2+
"Authenticate a session."
23
(:require [clojure.java.io :refer [file]]
3-
[clj-libssh2.libssh2.userauth :as libssh2-userauth]
4-
[clj-libssh2.agent :as ssh-agent]
5-
[clj-libssh2.error :refer [handle-errors with-timeout]])
4+
[clj-libssh2.agent :as agent]
5+
[clj-libssh2.error :refer [handle-errors with-timeout]]
6+
[clj-libssh2.libssh2.userauth :as libssh2-userauth])
67
(:import clojure.lang.PersistentArrayMap))
78

89
(defprotocol Credentials
9-
(valid? [credentials]))
10+
"A datatype to represent a way of authentication and the necessary data to
11+
use that authentication method."
12+
(valid? [credentials]
13+
"Check if this Credentials instance is internally consistent."))
1014

1115
(defrecord AgentCredentials [username]
1216
Credentials
@@ -26,11 +30,25 @@
2630
(valid? [credentials] (and (some? username) (some? password))))
2731

2832
(defmulti authenticate
33+
"Authenticate a session.
34+
35+
Arguments:
36+
37+
session A clj-libssh2.session.Session object referring to an SSH
38+
session which has not yet been authenticated.
39+
credentials Either an instance of Credentials or a map which can be
40+
transformed into a Credentials object.
41+
42+
Return:
43+
44+
True on success. An exception will be thrown if ther session could not be
45+
authenticated."
46+
{:arglists '([session credentials])}
2947
(fn [session credentials] (type credentials)))
3048

3149
(defmethod authenticate AgentCredentials
3250
[session credentials]
33-
(ssh-agent/authenticate session (:username credentials)))
51+
(agent/authenticate session (:username credentials)))
3452

3553
(defmethod authenticate KeyCredentials
3654
[session credentials]

0 commit comments

Comments
 (0)