Current section
7 Versions
Jump to
Current section
7 Versions
Compare versions
9
files changed
+75
additions
-52
deletions
| @@ -0,0 +1,3 @@ | |
| 1 | + [ |
| 2 | + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] |
| 3 | + ] |
| @@ -10,10 +10,14 @@ This package can be installed by adding `accent` to your list of dependencies in | |
| 10 10 | |
| 11 11 | ```elixir |
| 12 12 | def deps do |
| 13 | - [{:accent, "~> 0.1.0"}] |
| 13 | + [{:accent, "~> 0.2"}] |
| 14 14 | end |
| 15 15 | ``` |
| 16 16 | |
| 17 | + Please note that you will need to provide `accent` with a JSON codec. Both |
| 18 | + [`poison`](https://github.com/devinus/poison) and |
| 19 | + [`jason`](https://github.com/michalmuskala/jason) are supported. |
| 20 | + |
| 17 21 | ## Usage |
| 18 22 | |
| 19 23 | This project provides two plugs for handling the conversion of JSON keys to |
| @@ -127,3 +131,4 @@ A special thanks to all of our contributors! | |
| 127 131 | |
| 128 132 | * [@anthonator](https://github.com/anthonator) |
| 129 133 | * [@maxsalven](https://github.com/maxsalven) |
| 134 | + * [@szajbus](https://github.com/szajbus) |
| @@ -3,19 +3,30 @@ | |
| 3 3 | {<<"description">>,<<"Plug for converting JSON API keys to different cases">>}. |
| 4 4 | {<<"elixir">>,<<"~> 1.3">>}. |
| 5 5 | {<<"files">>, |
| 6 | - [<<"lib/accent/plugs/request.ex">>,<<"lib/accent/plugs/response.ex">>, |
| 7 | - <<"lib/accent/transformer.ex">>,<<"lib/accent/transformers/camel_case.ex">>, |
| 6 | + [<<"lib">>,<<"lib/accent">>,<<"lib/accent/plugs">>, |
| 7 | + <<"lib/accent/plugs/request.ex">>,<<"lib/accent/plugs/response.ex">>, |
| 8 | + <<"lib/accent/transformer.ex">>,<<"lib/accent/transformers">>, |
| 9 | + <<"lib/accent/transformers/camel_case.ex">>, |
| 8 10 | <<"lib/accent/transformers/pascal_case.ex">>, |
| 9 | - <<"lib/accent/transformers/snake_case.ex">>,<<"mix.exs">>,<<"README.md">>, |
| 10 | - <<"LICENSE">>]}. |
| 11 | + <<"lib/accent/transformers/snake_case.ex">>,<<".formatter.exs">>, |
| 12 | + <<"mix.exs">>,<<"README.md">>,<<"LICENSE">>]}. |
| 11 13 | {<<"licenses">>,[<<"MIT">>]}. |
| 12 14 | {<<"links">>,[{<<"GitHub">>,<<"https://github.com/sticksnleaves/accent">>}]}. |
| 13 | - {<<"maintainers">>,[<<"Anthony Smith">>]}. |
| 14 15 | {<<"name">>,<<"accent">>}. |
| 15 16 | {<<"requirements">>, |
| 16 | - [[{<<"app">>,<<"plug">>}, |
| 17 | + [[{<<"app">>,<<"jason">>}, |
| 18 | + {<<"name">>,<<"jason">>}, |
| 19 | + {<<"optional">>,true}, |
| 20 | + {<<"repository">>,<<"hexpm">>}, |
| 21 | + {<<"requirement">>,<<"~> 1.0">>}], |
| 22 | + [{<<"app">>,<<"poison">>}, |
| 23 | + {<<"name">>,<<"poison">>}, |
| 24 | + {<<"optional">>,true}, |
| 25 | + {<<"repository">>,<<"hexpm">>}, |
| 26 | + {<<"requirement">>,<<">= 3.1.0 and < 5.0.0">>}], |
| 27 | + [{<<"app">>,<<"plug">>}, |
| 17 28 | {<<"name">>,<<"plug">>}, |
| 18 29 | {<<"optional">>,false}, |
| 19 30 | {<<"repository">>,<<"hexpm">>}, |
| 20 | - {<<"requirement">>,<<"~> 1.3.4">>}]]}. |
| 21 | - {<<"version">>,<<"0.2.0">>}. |
| 31 | + {<<"requirement">>,<<"~> 1.3">>}]]}. |
| 32 | + {<<"version">>,<<"0.2.1">>}. |
| @@ -43,8 +43,12 @@ defmodule Accent.Plug.Response do | |
| 43 43 | def init(opts \\ []) do |
| 44 44 | %{ |
| 45 45 | header: opts[:header] || "accent", |
| 46 | - json_decoder: opts[:json_decoder] || raise(ArgumentError, "Accent.Plug.Response expects a :json_decoder option"), |
| 47 | - json_encoder: opts[:json_encoder] || raise(ArgumentError, "Accent.Plug.Response expects a :json_encoder option"), |
| 46 | + json_decoder: |
| 47 | + opts[:json_decoder] || |
| 48 | + raise(ArgumentError, "Accent.Plug.Response expects a :json_decoder option"), |
| 49 | + json_encoder: |
| 50 | + opts[:json_encoder] || |
| 51 | + raise(ArgumentError, "Accent.Plug.Response expects a :json_encoder option"), |
| 48 52 | supported_cases: opts[:supported_cases] || @default_cases |
| 49 53 | } |
| 50 54 | end |
| @@ -53,7 +57,7 @@ defmodule Accent.Plug.Response do | |
| 53 57 | def call(conn, opts) do |
| 54 58 | if do_call?(conn, opts) do |
| 55 59 | conn |
| 56 | - |> register_before_send(fn(conn) -> before_send_callback(conn, opts) end) |
| 60 | + |> register_before_send(fn conn -> before_send_callback(conn, opts) end) |
| 57 61 | else |
| 58 62 | conn |
| 59 63 | end |
| @@ -2,7 +2,7 @@ defmodule Accent.Transformer do | |
| 2 2 | @doc """ |
| 3 3 | Converts a string or atom to the same or different case. |
| 4 4 | """ |
| 5 | - @callback call(String.t | atom) :: String.t | atom |
| 5 | + @callback call(String.t() | atom) :: String.t() | atom |
| 6 6 | |
| 7 7 | @doc """ |
| 8 8 | Convert the keys of a map based on the provided transformer. |
Loading more files…