worker_tracker v0.3.0 WorkerTracker.ProcessHelper

A module to help with processing process strings

Link to this section Summary

Functions

A function that creates a list from the given process_string

This function filters the process_list for the given filter_string and returns the result of applying the filter_function.

This function populates the given accumulator with the contents of the process_string based on the provided callback function.

Splits a space-delimited string and returns a list with the index

Link to this section Functions

Link to this function

create_list_from_string(process_string)

A function that creates a list from the given process_string

Example

iex(1)> WorkerTracker.ProcessHelper.create_list_from_string("a\nb\nc\n")
["a", "b", "c"]
Link to this function

filter_and_transform_process_list(process_list, filter_string, parser_function)

This function filters the process_list for the given filter_string and returns the result of applying the filter_function.

Example

iex(1)> WorkerTracker.ProcessHelper.filter_and_transform_process_list(["a b", "c d"], "a", &String.split(&1))
[["a", "b"]]
Link to this function

process_fields(process_string, accumulator, function)

This function populates the given accumulator with the contents of the process_string based on the provided callback function.

Example

iex> "1 2 3" |> WorkerTracker.ProcessHelper.process_fields(%{}, fn({value, index}, acc) -> Map.put(acc,value,index) end)
%{"1" => 0, "2" => 1, "3" => 2}
iex> "1 2 3" |> WorkerTracker.ProcessHelper.process_fields([], fn({value, _index}, acc) -> [value | acc] end)
["3", "2", "1"]
Link to this function

process_fields_with_index(process_string)

Splits a space-delimited string and returns a list with the index

Example

iex> "deploy 1123 10" |> WorkerTracker.ProcessHelper.process_fields_with_index()
[{"deploy", 0}, {"1123", 1}, {"10", 2}]