View Source Igniter.Libs.Phoenix (igniter v0.4.0)

Codemods & utilities for working with Phoenix

Summary

Functions

Adds a pipeline to a Phoenix router.

Adds a scope to a Phoenix router.

Appends code to a Phoenix router pipeline.

Appends to a phoenix router scope.

Returns true if the module is a Phoenix controller

Gets the list of endpoints that use a given router

Returns true if the module is a Phoenix HTML module

Lists all routers found in the project.

Moves to the use statement in a module that matches use TheirWebModule, :router

Selects a router to be used in a later step. If only one router is found, it will be selected automatically.

Returns the web module name for the current app

web_module_name() deprecated

Returns the web module name for the current app

Generates a module name that lives in the Web directory of the current app.

Generates a module name that lives in the Web directory of the current app.

Functions

Link to this function

add_pipeline(igniter, name, contents, opts \\ [])

View Source
@spec add_pipeline(Igniter.t(), atom(), String.t(), Keyword.t()) :: Igniter.t()

Adds a pipeline to a Phoenix router.

Options

  • :router - The router module to append to. Will be looked up if not provided.
  • :arg2 - The second argument to the scope macro. Must be a value (typically a module).
Link to this function

add_scope(igniter, route, contents, opts \\ [])

View Source
@spec add_scope(Igniter.t(), String.t(), String.t(), Keyword.t()) :: Igniter.t()

Adds a scope to a Phoenix router.

Options

  • :router - The router module to append to. Will be looked up if not provided.
  • :arg2 - The second argument to the scope macro. Must be a value (typically a module).
Link to this function

append_to_pipeline(igniter, name, contents, opts \\ [])

View Source
@spec append_to_pipeline(Igniter.t(), atom(), String.t(), Keyword.t()) :: Igniter.t()

Appends code to a Phoenix router pipeline.

Options

  • :router - The router module to append to. Will be looked up if not provided.
Link to this function

append_to_scope(igniter, route, contents, opts \\ [])

View Source
@spec append_to_scope(Igniter.t(), String.t(), String.t(), Keyword.t()) :: Igniter.t()

Appends to a phoenix router scope.

Relatively limited currently only exact matches of a top level route, second argument, and pipelines.

Options

  • :router - The router module to append to. Will be looked up if not provided.
  • :arg2 - The second argument to the scope macro. Must be a value (typically a module).
  • :with_pipelines - A list of pipelines that the pipeline must be using to be considered a match.
Link to this function

controller?(igniter, module)

View Source
@spec controller?(Igniter.t(), module()) :: boolean()

Returns true if the module is a Phoenix controller

Link to this function

endpoints_for_router(igniter, router)

View Source
@spec endpoints_for_router(igniter :: Igniter.t(), router :: module()) ::
  {Igniter.t(), [module()]}

Gets the list of endpoints that use a given router

@spec html?(Igniter.t(), module()) :: boolean()

Returns true if the module is a Phoenix HTML module

@spec list_routers(Igniter.t()) :: {Igniter.t(), [module()]}

Lists all routers found in the project.

Link to this function

move_to_router_use(igniter, zipper)

View Source
@spec move_to_router_use(Igniter.t(), Sourceror.Zipper.t()) ::
  :error | {:ok, Sourceror.Zipper.t()}

Moves to the use statement in a module that matches use TheirWebModule, :router

Link to this function

select_router(igniter, label \\ "Which router should be modified?")

View Source
@spec select_router(Igniter.t(), String.t()) :: {Igniter.t(), module() | nil}

Selects a router to be used in a later step. If only one router is found, it will be selected automatically.

If no routers exist, {igniter, nil} is returned.

If multiple routes are found, the user is prompted to select one of them.

@spec web_module(Igniter.t()) :: module()

Returns the web module name for the current app

This function is deprecated. Use `web_module/0` instead..
@spec web_module_name() :: module()

Returns the web module name for the current app

This function is deprecated. Use `web_module_name/2` instead..
@spec web_module_name(String.t()) :: module()

Generates a module name that lives in the Web directory of the current app.

Link to this function

web_module_name(igniter, suffix)

View Source
@spec web_module_name(Igniter.t(), String.t()) :: module()

Generates a module name that lives in the Web directory of the current app.