Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Root name space is now the same as the repo name
- Loading branch information
Showing
11 changed files
with
87 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,7 @@ Add to your mix.exs | |
### Usage ### | ||
|
||
```elixir | ||
Ap.start_link | ||
import AP | ||
import Apex | ||
ap data | ||
``` | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule Apex do | ||
def ap(data, options // []) do | ||
IO.puts(Apex.Format.format(data, options)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
defmodule AP.Format.Utils do | ||
defmodule Apex.Format.Utils do | ||
@default_indent 2 | ||
@default_level 0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters