ExFacts v0.1.9 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
Determines is the argument is a path, executable that exists on the host. Returns
Returns an empty map if the binary itself is empty
Internal wrapper function to convert binary to float, using Float.parse/1
.
If the item is solely an unparsable binary it is returned untouched, otherwise
only the float element of the resultant tuple is returned
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
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.
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"]
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
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
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
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
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
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
Determines is the argument is a path, executable that exists on the host. Returns:
{:ok, path} for a success {:error, “Path or executable not found”} for failures
Examples
iex> look_path("/")
{:ok, "/"}
iex> look_path("/somearbtritrailylongpaththatprobablyshouldnotexist")
{:error, "Path or executable not found"}
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.
Internal wrapper function to convert binary to float, using Float.parse/1
.
If the item is solely an unparsable binary it is returned untouched, otherwise
only the float element of the resultant tuple is returned.
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.