Skip to content

Commit

Permalink
🔀 Update glance to 2.0.0
Browse files Browse the repository at this point in the history
* Update glance to 2.0.0
* resolve reviews
* resolve reviews
  • Loading branch information
dinkelspiel authored Dec 19, 2024
1 parent 6bd41fa commit df730b6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gleam_community_ansi = ">= 1.4.0 and < 2.0.0"
argv = ">= 1.0.2 and < 2.0.0"
gleam_erlang = ">= 0.25.0 and < 1.0.0"
rank = ">= 1.0.0 and < 2.0.0"
glance = ">= 1.0.0 and < 2.0.0"
glance = ">= 2.0.0 and < 3.0.0"
filepath = ">= 1.1.0 and < 2.0.0"
trie_again = ">= 1.1.2 and < 2.0.0"
simplifile = ">= 2.2.0 and < 3.0.0"
Expand Down
6 changes: 3 additions & 3 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "edit_distance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "edit_distance", source = "hex", outer_checksum = "A1E485C69A70210223E46E63985FA1008B8B2DDA9848B7897469171B29020C05" },
{ name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" },
{ name = "glance", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "1510D4A03C28880E62974389E5BF1A5A185036BA07392F1D769620706A9E042F" },
{ name = "glance", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "784CE3B5658CF589B2E811031992FDADDFA9C7FD2A51F1140EE019F121D6D0EB" },
{ name = "gleam_community_ansi", version = "1.4.1", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "4CD513FC62523053E62ED7BAC2F36136EC17D6A8942728250A9A00A15E340E4B" },
{ name = "gleam_community_colour", version = "1.4.1", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "386CB9B01B33371538672EEA8A6375A0A0ADEF41F17C86DDCB81C92AD00DA610" },
{ name = "gleam_erlang", version = "0.30.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "760618870AE4A497B10C73548E6E44F43B76292A54F0207B3771CBB599C675B4" },
{ name = "gleam_json", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "0A57FB5666E695FD2BEE74C0428A98B0FC11A395D2C7B4CDF5E22C5DD32C74C6" },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "glexer", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glexer", source = "hex", outer_checksum = "BD477AD657C2B637FEF75F2405FAEFFA533F277A74EF1A5E17B55B1178C228FB" },
{ name = "glexer", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glexer", source = "hex", outer_checksum = "25E87F25706749E40C3CDC72D2E52AEA12260B23D14FD9E09A1B524EF393485E" },
{ name = "justin", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "justin", source = "hex", outer_checksum = "7FA0C6DB78640C6DC5FBFD59BF3456009F3F8B485BF6825E97E1EB44E9A1E2CD" },
{ name = "rank", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "rank", source = "hex", outer_checksum = "5660E361F0E49CBB714CC57CC4C89C63415D8986F05B2DA0C719D5642FAD91C9" },
{ name = "simplifile", version = "2.2.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0DFABEF7DC7A9E2FF4BB27B108034E60C81BEBFCB7AB816B9E7E18ED4503ACD8" },
Expand All @@ -23,7 +23,7 @@ packages = [
argv = { version = ">= 1.0.2 and < 2.0.0" }
edit_distance = { version = ">= 2.0.1 and < 3.0.0" }
filepath = { version = ">= 1.1.0 and < 2.0.0" }
glance = { version = ">= 1.0.0 and < 2.0.0" }
glance = { version = ">= 2.0.0 and < 3.0.0" }
gleam_community_ansi = { version = ">= 1.4.0 and < 2.0.0" }
gleam_erlang = { version = ">= 0.25.0 and < 1.0.0" }
gleam_stdlib = { version = ">= 0.43.0 and < 1.0.0" }
Expand Down
67 changes: 53 additions & 14 deletions src/birdie/internal/titles.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -238,29 +238,46 @@ fn snap_call(
glance.Call(
function:,
arguments: [
glance.Field(None, title),
glance.Field(Some("content"), _snapshot_content),
glance.UnlabelledField(title),
glance.LabelledField("content", _snapshot_content),
],
)
| glance.Call(
function:,
arguments: [
glance.Field(None, _snapshot_content),
glance.Field(_, title),
glance.UnlabelledField(_snapshot_content),
glance.LabelledField(_, title),
],
)
| glance.Call(
function:,
arguments: [
glance.Field(Some("content"), _snapshot_content),
glance.Field(_, title),
glance.UnlabelledField(_snapshot_content),
glance.UnlabelledField(title),
],
)
| glance.Call(
function:,
arguments: [
glance.LabelledField("content", _snapshot_content),
glance.LabelledField(_, title),
],
)
| // A direct function call to the `birdie.snap` function where the first
// argument is the labelled title.
glance.Call(
function:,
arguments: [glance.Field(Some("title"), title), glance.Field(_, _)],
arguments: [
glance.LabelledField("title", title),
glance.LabelledField(_, _),
],
)
| glance.Call(
function:,
arguments: [
glance.LabelledField("title", title),
glance.UnlabelledField(_),
],
)
| // A call to the `birdie.snap` function where the title is piped into it
// and the content is passed as a labelled argument.
Expand All @@ -269,15 +286,26 @@ fn snap_call(
left: title,
right: glance.Call(
function:,
arguments: [glance.Field(Some("content"), _snapshot_content)],
arguments: [glance.LabelledField("content", _snapshot_content)],
),
)
| // A call to the `birdie.snap` function where the content is piped into
// it and the title is passed as an argument - labelled or not.
glance.BinaryOperator(
name: glance.Pipe,
left: _snapshot_content,
right: glance.Call(function:, arguments: [glance.Field(_, title)]),
right: glance.Call(
function:,
arguments: [glance.LabelledField(_, title)],
),
)
| glance.BinaryOperator(
name: glance.Pipe,
left: _snapshot_content,
right: glance.Call(
function:,
arguments: [glance.UnlabelledField(title)],
),
)
| // We pipe into `title: _`, since we're using a label we don't have to
// check the position.
Expand All @@ -300,7 +328,7 @@ fn snap_call(
right: glance.FnCapture(
function:,
label: _,
arguments_before: [glance.Field(None, _snapshot_content)],
arguments_before: [glance.UnlabelledField(_snapshot_content)],
arguments_after: [],
),
) -> {
Expand Down Expand Up @@ -402,8 +430,14 @@ fn try_fold_expression(

glance.RecordUpdate(module: _, constructor: _, record:, fields:) -> {
use acc <- result.try(try_fold_expression(record, acc, fun))
use acc, #(_field, expression) <- list.try_fold(over: fields, from: acc)
try_fold_expression(expression, acc, fun)
use acc, glance.RecordUpdateField(label: _field, item: expression) <- list.try_fold(
over: fields,
from: acc,
)
case expression {
Some(expression) -> try_fold_expression(expression, acc, fun)
None -> Ok(acc)
}
}

glance.Call(function:, arguments:) -> {
Expand Down Expand Up @@ -446,8 +480,13 @@ fn try_fold_fields(
fun: fn(a, glance.Expression) -> Result(a, b),
) -> Result(a, b) {
use acc, field <- list.try_fold(over: fields, from: acc)
let glance.Field(item: expression, label: _) = field
try_fold_expression(expression, acc, fun)
case field {
glance.LabelledField(item: expression, label: _) ->
try_fold_expression(expression, acc, fun)
glance.UnlabelledField(item: expression) ->
try_fold_expression(expression, acc, fun)
glance.ShorthandField(label: _) -> Ok(acc)
}
}

fn try_fold_clauses(
Expand Down

0 comments on commit df730b6

Please sign in to comment.