ExFacts v0.1.5 ExFacts.Utils

Contains common logic that is used mostly internally by other modules.

Summary

Functions

Iterates through a list and removes any items that math the argument. If the argument given is not in the specified list it returns the original list

Returns the path to /etc on the filesystem

Returns the path to somefile in /etc on the filesystem

Returns the path to /proc on the filesystem

Returns the path to somefile in /proc on the filesystem

Returns the path to /sys on the filesystem

Returns the path to somefile in /sys on the filesystem

Returns an empty map if the binary itself is empty

Reads in a file at the path provided in the binary using the binread method. This allows the caller to be able to read files that are provided by kernal calls that are not usual files

Types

option()
option() :: {:sane, boolean}

Functions

delete_all(list, value)
delete_all(list, any) :: list

Iterates through a list and removes any items that math the argument. If the argument given is not in the specified list it returns the original list.

Examples

iex> ["Some", "items", "are", "here"] |> delete_all("are")
["Some", "items", "here"]

iex> ["Some", "items", "are", "are", "here"] |> delete_all("are")
["Some", "items", "here"]

iex> ["Some", "items", "are", "here"] |> delete_all("foo")
["Some", "items", "are", "here"]
host_etc()
host_etc() :: binary

Returns the path to /etc on the filesystem.

Defaults to /etc and is only evaluated at compile time. Note: When MIX_ENV=test it defaults to __DIR <> /test/files/etc

host_etc(combine_with)
host_etc(binary) :: binary

Returns the path to somefile in /etc on the filesystem.

Defaults to /etc/somefile, it can also be overriden at runtime via environment variables. Note: When MIX_ENV=test it defaults to __DIR <> /test/files/etc/somefile

host_proc()
host_proc() :: binary

Returns the path to /proc on the filesystem.

Defaults to /proc and is only evaluated at compile time. Note: When MIX_ENV=test it defaults to __DIR <> /test/files/proc

host_proc(combine_with)
host_proc(binary) :: binary

Returns the path to somefile in /proc on the filesystem.

Defaults to /proc/somefile, it can also be overriden at runtime via environment variables. Note: When MIX_ENV=test it defaults to __DIR <> /test/files/proc

host_sys()
host_sys() :: binary

Returns the path to /sys on the filesystem.

Defaults to /sys and is only evaluated at compile time. Note: When MIX_ENV=test it defaults to __DIR <> /test/files/sys

host_sys(combine_with)
host_sys(binary) :: binary

Returns the path to somefile in /sys on the filesystem.

Defaults to /sys/somefile, can also be overriden at runtime via environment variables. Note: When MIX_ENV=test it defaults to __DIR <> /test/files/etc

normalize_with_underscore(item)
normalize_with_underscore(map) :: map
normalize_with_underscore(tuple) :: tuple
normalize_with_underscore(binary) :: map

Returns an empty map if the binary itself is empty.

read_file(filename, options \\ [])
read_file(binary, options :: [option]) :: [binary]

Reads in a file at the path provided in the binary using the binread method. This allows the caller to be able to read files that are provided by kernal calls that are not usual files.

If sane: true is passed then read in data is also split by new line characters and returned as a list of each line.