Skip to content

Commit

Permalink
Merge pull request #74 from Frameio/develop
Browse files Browse the repository at this point in the history
Release v0.10.0
  • Loading branch information
bceskavich authored Aug 13, 2019
2 parents e5d1d10 + e52342f commit a4e9333
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ deps in `mix.exs`:
```elixir
def deps do
[
{:rolodex, "~> 0.9.0"}
{:rolodex, "~> 0.10.0"}
]
end
```
28 changes: 4 additions & 24 deletions lib/rolodex/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -165,35 +165,15 @@ defmodule Rolodex.Router do
end

defp build_route(verb, path, phoenix_router, config) do
http_action_string = verb |> Atom.to_string() |> String.upcase()

phoenix_router
|> build_route_info(verb, path)
|> Phoenix.Router.route_info(http_action_string, path, "")
|> RouteInfo.from_route_info(verb)
|> with_doc_annotation()
|> Rolodex.Route.new(config)
end

# Backwards compatibility logic for fetching Phoenix route info:
#
# 1.4.0 ~ 1.4.7 — Lookup via private router tree
# >= 1.4.7 — Use publicly supported `Phoenix.Router.route_info/4`
defp build_route_info(phoenix_router, verb, path) do
case function_exported?(Phoenix.Router, :route_info, 4) do
true ->
http_action_string = verb |> Atom.to_string() |> String.upcase()

phoenix_router
|> Phoenix.Router.route_info(http_action_string, path, "")
|> RouteInfo.from_route_info(verb)

false ->
phoenix_router.__routes__()
|> Enum.find(fn
%{verb: ^verb, path: ^path} -> true
_ -> false
end)
|> RouteInfo.from_router_tree()
end
end

defp with_doc_annotation(%RouteInfo{controller: controller, action: action} = info) do
case Utils.fetch_doc_annotation(controller, action) do
{:error, :not_found} -> nil
Expand Down
18 changes: 0 additions & 18 deletions lib/rolodex/router/route_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,4 @@ defmodule Rolodex.Router.RouteInfo do
end

def from_route_info(_, _), do: nil

def from_router_tree(%{
plug: controller,
opts: action,
path: path,
verb: verb,
pipe_through: pipe_through
}) do
%__MODULE__{
controller: controller,
action: action,
path: path,
verb: verb,
pipe_through: pipe_through
}
end

def from_router_tree(_), do: nil
end
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Rolodex.MixProject do
app: :rolodex,
name: "Rolodex",
description: "Automated docs generation",
version: "0.9.0",
version: "0.10.0",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand All @@ -33,7 +33,7 @@ defmodule Rolodex.MixProject do
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
{:jason, "~> 1.1"},
{:phoenix, ">= 1.4.0"},
{:phoenix, ">= 1.4.7"},
{:dialyxir, "~> 1.0.0-rc.4", only: [:dev], runtime: false},
{:ex_doc, ">= 0.0.0", only: :dev}
]
Expand Down
7 changes: 4 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
"phoenix": {:hex, :phoenix, "1.4.0", "56fe9a809e0e735f3e3b9b31c1b749d4b436e466d8da627b8d82f90eaae714d2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"},
"plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix": {:hex, :phoenix, "1.4.9", "746d098e10741c334d88143d3c94cab1756435f94387a63441792e66ec0ee974", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"},
"plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"},
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
"telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm"},
}

0 comments on commit a4e9333

Please sign in to comment.