JediHelpers (jedi_helpers v0.1.0)

Documentation for JediHelpers.

Summary

Functions

Converts an atom into a human-readable string by title-casing its segments.

Returns the underscored (snake_case) name of a struct's module as a string.

Extracts the path segment from a URI string.

Functions

atom_to_readable_string(atom)

@spec atom_to_readable_string(atom()) :: String.t()

Converts an atom into a human-readable string by title-casing its segments.

Useful for displaying labels or headings derived from atoms.

Examples

iex> JediHelpers.atom_to_readable_string(:user_profile)
"User Profile"

iex> JediHelpers.atom_to_readable_string(:admin)
"Admin"

resource_type(resource)

@spec resource_type(struct()) :: String.t()

Returns the underscored (snake_case) name of a struct's module as a string.

Useful for generating type identifiers from structs, especially in APIs or dynamic logic.

Example

iex> resource_type(%JediHelpers.BlogPost{})
"blog_post"

Parameters:

  • resource (struct): Any Elixir struct.

Returns:

  • String.t(): The snake_case name of the struct's module (last segment only).

uri_parse_path(uri)

@spec uri_parse_path(String.t()) :: String.t() | nil

Extracts the path segment from a URI string.

Useful for isolating the path portion of a full URL (e.g. /users/123).

Example

iex> uri_parse_path("https://example.com/users/123?ref=home")
"/users/123"

Parameters:

  • uri (String.t()): A URI string.

Returns:

  • String.t() or nil: The path component of the URI, or nil if absent.