Packages
altworx_runbox
5.0.0
25.0.0
24.0.0
23.1.0
23.0.0
22.2.0
22.1.0
22.0.0
21.2.0
21.1.2
21.1.1
21.1.0
21.0.0
20.0.0
19.0.0
18.0.0
17.2.0
17.1.0
17.0.1
17.0.0
16.2.0
16.1.0
16.0.0
15.0.0
14.1.0
14.0.1
14.0.0
13.0.3
13.0.2
13.0.1
13.0.0
12.1.0
12.0.0
11.0.1
11.0.0
10.0.0
9.0.0
8.0.0
7.0.1
7.0.0
6.0.0
5.0.0
4.0.0
3.0.0
2.1.0
2.0.0
1.4.1
1.4.0
1.3.0
1.2.0
1.1.0
1.0.0
0.1.3
0.1.2
0.1.1
0.1.0
Runbox is a library for running Altworx scenarios.
Current section
Files
Jump to
Current section
Files
lib/runbox/scenario.ex
defmodule Runbox.Scenario do
@moduledoc """
Holds information about scenario.
"""
defstruct [:manifest, :opts, :templates]
@type t :: %__MODULE__{
manifest: Runbox.Scenario.Manifest.t(),
opts: map(),
templates: [Runbox.ScenarioTemplate.t()]
}
@type component_def :: %{id: term(), mod: module(), fun: atom(), args: map}
@spec manifest_module?(module()) :: boolean()
def manifest_module?(module) do
case Module.split(module) do
["Scenario", _] -> true
["Scenarios", _] -> true
["Scenarios", "Test", _] -> true
_ -> false
end
end
@spec template_module?(module(), module()) :: boolean()
def template_module?(module, manifest_module) do
module |> Module.split() |> prefixed?(scenario_prefix(manifest_module))
end
@spec get_impl_for(String.t()) :: %{template_inspector: module()}
def get_impl_for("StageBased") do
%{template_inspector: Runbox.Scenario.Template.StageBased}
end
defp scenario_prefix(manifest_module) do
Module.split(manifest_module)
end
defp prefixed?(module_parts, prefix) do
List.starts_with?(module_parts, prefix) and module_parts != prefix
end
end