Skip to content

Commit

Permalink
Update Alchemist-Server
Browse files Browse the repository at this point in the history
* Fix some issue with Alchemist-Server Elixir version legacy
* New Socket Server functionality
* Fix Alchemist Issue with wrong empty server doc string
  • Loading branch information
tonini committed Mar 30, 2017
1 parent 20a0c04 commit bcb9c66
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 23 deletions.
5 changes: 3 additions & 2 deletions alchemist-server/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: elixir
elixir:
- 1.2.6
- 1.3.4
- 1.1.1
- 1.2.0-rc.0
- 1.3.3
otp_release:
- 18.0
- 19.0
Expand Down
13 changes: 13 additions & 0 deletions alchemist-server/lib/api/version.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Code.require_file "../helpers/response.exs", __DIR__

defmodule Alchemist.API.Version do

@moduledoc false
@version "0.1.0-beta"

alias Alchemist.Helpers.Response

def request do
@version |> Response.endmark("VERSION")
end
end
2 changes: 0 additions & 2 deletions alchemist-server/lib/helpers/capture_io.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
defmodule Alchemist.Helpers.CaptureIO do

@docmodule false

def capture_io(fun) do
do_capture_io(:standard_io, [], fun)
end
Expand Down
5 changes: 4 additions & 1 deletion alchemist-server/lib/helpers/process_commands.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Code.require_file "../api/defl.exs", __DIR__
Code.require_file "../api/eval.exs", __DIR__
Code.require_file "../api/info.exs", __DIR__
Code.require_file "../api/ping.exs", __DIR__
Code.require_file "../api/version.exs", __DIR__

defmodule Alchemist.Helpers.ProcessCommands do

Expand All @@ -12,7 +13,7 @@ defmodule Alchemist.Helpers.ProcessCommands do
alias Alchemist.API

def process(line, env) do
loaded = all_loaded
loaded = all_loaded()

paths = load_paths(env)
apps = load_apps(env)
Expand All @@ -38,6 +39,8 @@ defmodule Alchemist.Helpers.ProcessCommands do
API.Defl.request(args)
["PING"] ->
API.Ping.request()
["VERSION"] ->
API.Version.request()
_ ->
nil
end
Expand Down
6 changes: 2 additions & 4 deletions alchemist-server/lib/server.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Code.require_file "server/socket.exs", __DIR__

defmodule Alchemist.Server do

@version "0.1.0-beta"

@moduledoc """
The Alchemist-Server operates as an informant for a specific desired
Elixir Mix project and serves with informations as the following:
Expand All @@ -21,13 +19,13 @@ defmodule Alchemist.Server do
alias Alchemist.Server.Socket, as: ServerSocket

def start([args]) do
{opts, _, _} = OptionParser.parse(args)
{opts, _, _} = OptionParser.parse(args, switches: [port: :integer])
env = Keyword.get(opts, :env, "dev")
noansi = Keyword.get(opts, :no_ansi, false)
Application.put_env(:iex, :colors, [enabled: !noansi])
case Keyword.get(opts, :listen, false) do
false -> ServerIO.start([env: env])
true -> ServerSocket.start([env: env])
true -> ServerSocket.start(opts)
end
:timer.sleep :infinity
end
Expand Down
2 changes: 1 addition & 1 deletion alchemist-server/lib/server/io.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Alchemist.Server.IO do
end

def handle_info(:timeout, env) do
ProcessCommands.process(read_line, env)
ProcessCommands.process(read_line(), env)
|> IO.write
{:noreply, env, 0}
end
Expand Down
8 changes: 0 additions & 8 deletions alchemist-server/test/api/docl_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,12 @@ defmodule Alchemist.API.DoclTest do
test "DOCL request for List.flatten" do
assert Docl.process(["List.flatten", [], []]) =~ """
Flattens the given \e[36mlist\e[0m of nested lists.
\e[0m
\e[33mExamples\e[0m
\e[0m
\e[36m\e[1m┃ iex> List.flatten([1, [[2], 3]])
"""
end

test "DOCL request for MyCustomList.flatten with alias" do
assert Docl.process(["MyCustomList.flatten", [], [{MyCustomList, List}]]) =~ """
Flattens the given \e[36mlist\e[0m of nested lists.
\e[0m
\e[33mExamples\e[0m
\e[0m
\e[36m\e[1m┃ iex> List.flatten([1, [[2], 3]])
"""
end

Expand Down
4 changes: 2 additions & 2 deletions alchemist-server/test/helpers/complete_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ defmodule CompleteTest do
assert run('List') == ['List.', 'Chars', 'first/1', 'last/1', 'to_atom/1',
'to_existing_atom/1', 'to_float/1', 'to_string/1', 'to_tuple/1',
'wrap/1', 'zip/1', 'delete/2', 'delete_at/2', 'duplicate/2',
'keysort/2', 'flatten/1', 'flatten/2', 'to_integer/1',
'keysort/2', 'myers_difference/2', 'flatten/1', 'flatten/2', 'to_integer/1',
'to_integer/2', 'foldl/3', 'foldr/3', 'insert_at/3', 'keydelete/3',
'keymember?/3', 'keytake/3', 'replace_at/3', 'update_at/3',
'keymember?/3', 'keytake/3', 'pop_at/3', 'replace_at/3', 'update_at/3',
'keyfind/4', 'keyreplace/4', 'keystore/4']
end

Expand Down
4 changes: 2 additions & 2 deletions alchemist-server/test/helpers/process_commands_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ defmodule ServerTest do
if Version.match?(System.version, ">=1.2.0-rc") do
test "Get information from data type" do
assert send_signal("INFO { :type, :info, List}") =~ """
Reference modules\e[0m\n\e[22m Module, Atom\e[0m\nEND-OF-INFO
END-OF-INFO
"""
end

test "Don't crash server if data type argument is faulty" do
assert send_signal("INFO { :type, :info, whatever}") =~ """
assert send_signal("INFO { :type, :info, whatever()}") =~ """
END-OF-INFO
"""
end
Expand Down
2 changes: 1 addition & 1 deletion alchemist-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"Return non-nil if STRING is null, blank or whitespace only."
(or (null string)
(string= string "")
(if (string-match-p "^\s+$" string) t)))
(if (zerop (length (s-trim string))) t)))

(defun alchemist-utils-prepare-aliases-for-elixir (aliases)
(let* ((aliases (-map (lambda (a)
Expand Down

0 comments on commit bcb9c66

Please sign in to comment.