Skip to content

Commit

Permalink
Root name space is now the same as the repo name
Browse files Browse the repository at this point in the history
  • Loading branch information
BjRo committed Jan 20, 2014
1 parent 4ab1042 commit 4226b33
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 88 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -17,8 +17,7 @@ Add to your mix.exs
### Usage ###

```elixir
Ap.start_link
import AP
import Apex
ap data
```

Expand Down
5 changes: 0 additions & 5 deletions lib/ap.ex

This file was deleted.

65 changes: 0 additions & 65 deletions lib/ap/format.ex

This file was deleted.

5 changes: 5 additions & 0 deletions lib/apex.ex
@@ -0,0 +1,5 @@
defmodule Apex do
def ap(data, options // []) do
IO.puts(Apex.Format.format(data, options))
end
end
65 changes: 65 additions & 0 deletions lib/apex/format.ex
@@ -0,0 +1,65 @@
defprotocol Apex.Format do
def format(data, options // [])
end

defimpl Apex.Format, for: BitString do
def format(data, _ // []), do: "\"#{data}\"" <> Apex.Format.Utils.new_line
end

defimpl Apex.Format, for: Integer do
def format(data, _ // []), do: "#{data}" <> Apex.Format.Utils.new_line
end

defimpl Apex.Format, for: Float do
def format(data, _ // []) do
"#{float_to_binary(data, decimals: 15, compact: true)}" <> Apex.Format.Utils.new_line
end
end

defimpl Apex.Format, for: Atom do
def format(data, _ // []), do: "#{data}" <> Apex.Format.Utils.new_line
end

defimpl Apex.Format, for: List do
def format(data, options // []), do: Apex.Format.Seq.format(data, options)
end

defimpl Apex.Format, for: Range do
def format({name, lower_bound, upper_bound}, options // []) do
"##{name} #{lower_bound}..#{upper_bound}" <> Apex.Format.Utils.new_line
end
end

defimpl Apex.Format, for: PID do
def format(data, options // []) do
inspect(data) <> Apex.Format.Utils.new_line
end
end

defimpl Apex.Format, for: Function do
def format(data, options // []) do
inspect(data) <> Apex.Format.Utils.new_line
end
end

defimpl Apex.Format, for: HashDict do
def format(data, options // []) do
Apex.Format.Seq.format(
Dict.to_list(data),
options,
start_token: "#HashDict <",
end_token: ">",
numbers: false)
end
end

defimpl Apex.Format, for: HashSet do
def format(data, options // []) do
Apex.Format.Seq.format(
Set.to_list(data),
options,
start_token: "#HashSet <",
end_token: ">",
numbers: false)
end
end
6 changes: 3 additions & 3 deletions lib/ap/format/seq.ex → lib/apex/format/seq.ex
@@ -1,5 +1,5 @@
defmodule AP.Format.Seq do
import AP.Format.Utils
defmodule Apex.Format.Seq do
import Apex.Format.Utils

def format(data, options, config // []) do
pre = start_token(config) <> new_line
Expand All @@ -15,7 +15,7 @@ defmodule AP.Format.Seq do

defp do_format({entry, i}, options, config) do
number = if numbers?(config), do: "[#{i}] ", else: ""
indent(options) <> number <> AP.Format.format(entry, options)
indent(options) <> number <> Apex.Format.format(entry, options)
end

defp start_token(config), do: config[:start_token] || "["
Expand Down
8 changes: 4 additions & 4 deletions lib/ap/format/tuple.ex → lib/apex/format/tuple.ex
@@ -1,10 +1,10 @@
defimpl AP.Format, for: Tuple do
import AP.Format.Utils
defimpl Apex.Format, for: Tuple do
import Apex.Format.Utils

def format(data, options // []), do: do_format(data, options)

defp do_format({key, value}, options) when is_atom(key) do
"#{key}: " <> AP.Format.format(value, options)
"#{key}: " <> Apex.Format.format(value, options)
end

defp do_format(data, options) do
Expand All @@ -14,6 +14,6 @@ defimpl AP.Format, for: Tuple do
{ "{", tuple_to_list(data) }
end

AP.Format.Seq.format(entries, options, start_token: pre, end_token: "}")
Apex.Format.Seq.format(entries, options, start_token: pre, end_token: "}")
end
end
2 changes: 1 addition & 1 deletion lib/ap/format/utils.ex → lib/apex/format/utils.ex
@@ -1,4 +1,4 @@
defmodule AP.Format.Utils do
defmodule Apex.Format.Utils do
@default_indent 2
@default_level 0

Expand Down
4 changes: 2 additions & 2 deletions mix.exs
@@ -1,8 +1,8 @@
defmodule AP.Mixfile do
defmodule Apex.Mixfile do
use Mix.Project

def project do
[ app: :ap,
[ app: :apex,
version: "0.0.1",
elixir: "~> 0.12.2",
deps: deps ]
Expand Down
4 changes: 2 additions & 2 deletions test/format/utils_test.exs
@@ -1,6 +1,6 @@
defmodule AP.Format.List.Test do
defmodule Apex.Format.List.Test do
use ExUnit.Case
import AP.Format.Utils
import Apex.Format.Utils

test "#next_indent_level" do
options = []
Expand Down
8 changes: 4 additions & 4 deletions test/format_test.exs
@@ -1,6 +1,6 @@
defmodule AP.Format.Test do
defmodule Apex.Format.Test do
use ExUnit.Case
import AP.Format
import Apex.Format

test "Can format a list of strings" do
assert format(%w(a b c d), color: false) == """
Expand Down Expand Up @@ -62,7 +62,7 @@ defmodule AP.Format.Test do
defrecord User, first_name: nil, last_name: nil
test "Can format records" do
assert format(User.new(first_name: "John", last_name: "Doe"), color: false) == """
#Elixir.AP.Format.Test.User {
#Elixir.Apex.Format.Test.User {
[0] first_name: "John"
[1] last_name: "Doe"
}
Expand All @@ -81,7 +81,7 @@ defmodule AP.Format.Test do

test "Can format function" do
f = fn(a) -> "#{a}" end
assert format(f, color: false) =~ %r(#Function<0.\d+ in AP.Format.Test.test Can format function/1>\n)
assert format(f, color: false) =~ %r(#Function<0.\d+ in Apex.Format.Test.test Can format function/1>\n)
end

test "Can format Dicts" do
Expand Down

0 comments on commit 4226b33

Please sign in to comment.