# `TechStackChanges`
[🔗](https://github.com/jaizendra-netizen/tech_stack_changes/blob/main/lib/tech_stack_changes.ex#L1)

Compare two snapshots of detected technologies per domain.

Each snapshot is a CSV with the columns `domain` and `technology`, one row per pair.
A domain is trimmed and lower-cased. A technology is trimmed, inner whitespace is
collapsed to one space, and it is compared case-insensitively; the first spelling seen
is the one shown. The same pair twice counts once (the repeated rows are counted).
Header names are matched trimmed and case-insensitive, extra columns are ignored, and a
UTF-8 BOM and CRLF line endings are accepted.

For a domain present in both snapshots the report lists the technologies added (in the
new snapshot only), removed (in the old snapshot only) and the number unchanged. A domain
present in only one snapshot is listed apart and gives no added or removed technology:
a missing domain is not proof that a technology was dropped.

# `snapshot`

```elixir
@type snapshot() :: %{
  domains: %{required(String.t()) =&gt; %{required(String.t()) =&gt; String.t()}},
  rows: non_neg_integer(),
  repeated: non_neg_integer()
}
```

# `compare`

```elixir
@spec compare(snapshot(), snapshot()) :: map()
```

Compare an old and a new snapshot. Returns a map with the counts, the changed domains
(sorted by added plus removed, descending, then domain), the domains found in only one
snapshot, and the technologies added or removed most often (count descending, then name).

# `parse`

```elixir
@spec parse(String.t(), String.t()) :: {:ok, snapshot()} | {:error, String.t()}
```

Parse one snapshot. `label` is the file name used in error messages.

# `parse_csv`

```elixir
@spec parse_csv(String.t()) :: {:ok, [[String.t()]]} | {:error, String.t()}
```

Parse CSV text into a list of records (lists of strings). Handles a UTF-8 BOM, CRLF,
double-quoted fields with commas, doubled quotes and line breaks. Blank lines are dropped.

# `render`

```elixir
@spec render(map(), pos_integer()) :: String.t()
```

Render the comparison as text. `top` is how many entries the most-added and
most-removed lists show.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
