Skip to content

Commit

Permalink
Adds API and CLI command (server --version) to fetch server's expm ve…
Browse files Browse the repository at this point in the history
…rsion
  • Loading branch information
yrashk committed Sep 30, 2012
1 parent 7ecd63a commit 793f382
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/cli.ex
Expand Up @@ -7,6 +7,14 @@ defrecord Expm.CLI, repository: Expm.Repository.HTTP.new.url, username: nil, pas
IO.puts Expm.version
end
end

def run(["server"], rec) do
cond do
rec.version == true ->
IO.puts repo(rec).version
end
end

def run(["list"], rec) do
run(["search", ""], rec)
end
Expand Down
18 changes: 17 additions & 1 deletion lib/repositories/http.ex
@@ -1,4 +1,20 @@
defrecord Expm.Repository.HTTP, url: "http://expm.co", username: nil, password: nil
defrecord Expm.Repository.HTTP, url: "http://expm.co", username: nil, password: nil do
alias :hackney, as: H

def version(repo) do
{:ok, 200, _headers, client} =
H.request("GET", "#{repo.url}/__version__",
[
{"content-type","text/html"},
{"accept", "text/html"}
],
"", [follow_redirect: true])
{:ok, body, client} = H.body(client)
H.close(client)
body
end

end


defmodule Expm.Repository.HTTP.Decoder do
Expand Down

0 comments on commit 793f382

Please sign in to comment.