TechStackChanges (tech_stack_changes v1.0.0)

Copy Markdown View Source

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.

Summary

Functions

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 one snapshot. label is the file name used in error messages.

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 the comparison as text. top is how many entries the most-added and most-removed lists show.

Types

snapshot()

@type snapshot() :: %{
  domains: %{required(String.t()) => %{required(String.t()) => String.t()}},
  rows: non_neg_integer(),
  repeated: non_neg_integer()
}

Functions

compare(old, new)

@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(text, label)

@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(text)

@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(r, top \\ 5)

@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.