View Source Hologram.Reflection (hologram v0.2.0)
Summary
Functions
Determines whether the given term is an alias.
Returns BEAM definitions for the given BEAM file path.
Returns the build directory path.
Returns the call graph dump file name.
Returns true if the given term is a component module (a module that has a "use Hologram.Component" directive) Otherwise false is returned.
Returns true if the given term is an Ecto schema module, or false otherwise.
Returns true if the given term is an existing Elixir module, or false otherwise.
Returns true if the given term is an existing Erlang module, or false otherwise.
Returns true if module contains a public function with the given arity, otherwise false.
Determines whether the given module defines its struct.
Returns the IR PLT dump file name.
Lists all OTP applications, both loaded and not loaded.
Lists Elixir modules belonging to any of the loaded OTP applications used by the project (except :hex). Elixir modules listed in @ignored_modules module attribute, Elixir modules without a BEAM file, and Erlang modules are filtered out. The project OTP application is included.
Lists Elixir modules belonging to the given OTP apps. Elixir modules listed in @ignored_modules module attribute and Erlang modules are filtered out.
Lists loaded OTP applications.
Lists Elixir modules which are Hologram pages and that belong to any of the OTP apps in the project.
Returns the list of modules that are implementations of the given protocol.
Lists standard library Elixir modules, e.g. DateTime, Kernel, Calendar.ISO, etc. Elixir modules listed in @ignored_modules module attribute, Elixir modules without a BEAM file, and Erlang modules are filtered out.
Returns true if the given term is an existing (Elixir or Erlang) module, or false otherwise.
Returns the module BEAM path PLT dump file name.
Returns the module digest PLT dump file name.
Returns the module name without "Elixir" prefix at the beginning.
Returns the project OTP application name.
Returns true if the given term is a page module (a module that has a "use Hologram.Page" directive) Otherwise false is returned.
Returns the page digest PLT dump file name.
Determines the app's Phoenix endpoint module.
Returns true if the given term is a protocol module, or false otherwise.
Returns the release priv dir path.
Returns the release static dir path.
Returns the absolute dir path of the project.
Returns the absolute path of the project priv dir for Hologram.
Returns the file path of the given module's source code.
Returns true if the given term is a component (a module that has a "use Hologram.Component" directive) or a page (a module that has a "use Hologram.Page" directive). Otherwise false is returned.
Returns the absolute path of the tmp directory.
Functions
Determines whether the given term is an alias.
Examples
iex> alias?(Calendar.ISO)
true
iex> alias?(:abc)
false
Returns BEAM definitions for the given BEAM file path.
Examples
iex> beam_path = ~c"/Users/bartblast/Projects/hologram/_build/dev/lib/hologram/ebin/Elixir.Hologram.Reflection.beam"
iex> beam_defs()
[
...,
{{:alias?, 1}, :def, [line: 14],
[
{[line: 16], [{:term, [version: 0, line: 16], nil}],
[
{{:., [line: 16], [:erlang, :is_atom]}, [line: 16],
[{:term, [version: 0, line: 16], nil}]}
],
{{:., [line: 19], [String, :starts_with?]}, [line: 19],
[
{{:., [line: 18], [String.Chars, :to_string]}, [line: 18],
[{:term, [version: 0, line: 17], nil}]},
"Elixir."
]}},
{[line: 22], [{:_, [line: 22], nil}], [], false}
]}
]
@spec build_dir() :: String.t()
Returns the build directory path.
@spec call_graph_dump_file_name() :: String.t()
Returns the call graph dump file name.
Returns true if the given term is a component module (a module that has a "use Hologram.Component" directive) Otherwise false is returned.
Examples
iex> component?(MyComponent)
true
iex> component?(Hologram.Reflection)
false
Returns true if the given term is an Ecto schema module, or false otherwise.
Returns true if the given term is an existing Elixir module, or false otherwise.
Examples
iex> elixir_module?(Calendar.ISO)
true
iex> elixir_module?(MyModule)
false
iex> elixir_module?(:my_module)
false
iex> elixir_module?(123)
false
Returns true if the given term is an existing Erlang module, or false otherwise.
Examples
iex> erlang_module?(:maps)
true
iex> erlang_module?(:my_module)
false
iex> erlang_module?(Calendar.ISO)
false
iex> erlang_module?(123)
false
Returns true if module contains a public function with the given arity, otherwise false.
Kernel.function_exported?/3 does not load the module in case it is not loaded (in such cases it would return false even when the module has the given function).
Determines whether the given module defines its struct.
@spec ir_plt_dump_file_name() :: String.t()
Returns the IR PLT dump file name.
@spec list_all_otp_apps() :: [atom()]
Lists all OTP applications, both loaded and not loaded.
@spec list_elixir_modules() :: [module()]
Lists Elixir modules belonging to any of the loaded OTP applications used by the project (except :hex). Elixir modules listed in @ignored_modules module attribute, Elixir modules without a BEAM file, and Erlang modules are filtered out. The project OTP application is included.
Lists Elixir modules belonging to the given OTP apps. Elixir modules listed in @ignored_modules module attribute and Erlang modules are filtered out.
@spec list_loaded_otp_apps() :: [:atom]
Lists loaded OTP applications.
Examples
iex> list_loaded_otp_apps() [
:inets,
:logger,
:stdlib,
:file_system,
...
]
@spec list_pages() :: [module()]
Lists Elixir modules which are Hologram pages and that belong to any of the OTP apps in the project.
Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/reflection/list_pages_0/README.md
Returns the list of modules that are implementations of the given protocol.
@spec list_std_lib_elixir_modules() :: [module()]
Lists standard library Elixir modules, e.g. DateTime, Kernel, Calendar.ISO, etc. Elixir modules listed in @ignored_modules module attribute, Elixir modules without a BEAM file, and Erlang modules are filtered out.
Returns true if the given term is an existing (Elixir or Erlang) module, or false otherwise.
Examples
iex> module?(Calendar.ISO)
true
iex> module?(MyModule)
false
iex> module?(:maps)
true
iex> module?(:my_module)
false
iex> module?(123)
false
@spec module_beam_path_plt_dump_file_name() :: String.t()
Returns the module BEAM path PLT dump file name.
@spec module_digest_plt_dump_file_name() :: String.t()
Returns the module digest PLT dump file name.
Returns the module name without "Elixir" prefix at the beginning.
Examples
iex> module_name(Aaa.Bbb)
"Aaa.Bbb"
@spec otp_app() :: atom()
Returns the project OTP application name.
Returns true if the given term is a page module (a module that has a "use Hologram.Page" directive) Otherwise false is returned.
Examples
iex> page?(MyPage)
true
iex> page?(Hologram.Reflection)
false
@spec page_digest_plt_dump_file_name() :: String.t()
Returns the page digest PLT dump file name.
@spec phoenix_endpoint() :: module() | nil
Determines the app's Phoenix endpoint module.
Returns true if the given term is a protocol module, or false otherwise.
@spec release_priv_dir() :: String.t()
Returns the release priv dir path.
@spec release_static_dir() :: String.t()
Returns the release static dir path.
@spec root_dir() :: String.t()
Returns the absolute dir path of the project.
Examples
iex> root_dir()
"/Users/bartblast/Projects/my_project"
@spec root_priv_dir() :: String.t()
Returns the absolute path of the project priv dir for Hologram.
Examples
iex> root_priv_dir()
"/Users/bartblast/Projects/my_project/priv/hologram"
Returns the file path of the given module's source code.
Returns true if the given term is a component (a module that has a "use Hologram.Component" directive) or a page (a module that has a "use Hologram.Page" directive). Otherwise false is returned.
Examples
iex> component?(MyComponent)
true
iex> component?(MyPage)
true
iex> component?(Hologram.Reflection)
false
@spec tmp_dir() :: String.t()
Returns the absolute path of the tmp directory.
Examples
iex> tmp_dir()
"/Users/bartblast/Projects/my_project/tmp"