Skip to content

Commit

Permalink
newline 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt committed Nov 13, 2024
1 parent 8583b91 commit c20ed1c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v3.0.1 - 13 November 2024
- `from_lists` and consequently `from_dicts` now append a line ending to the end
of the produced string. This is a patch release because the RFC states line endings
after the final row are optional, but most people will want them.

## v3.0.0 - 4 November 2024
- Improved performance of `to_lists`, `to_dicts`, `from_lists` and `from_lists`.
- Parsing now doesn't trim the csv fields, conforming to RFC4180.
Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "gsv"
version = "3.0.0"
version = "3.0.1"
gleam = ">= 0.32.0"
description = "A simple csv parser and generator written in gleam "

Expand Down
1 change: 1 addition & 0 deletions src/gsv.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ pub fn from_lists(
|> string.join(with: separator)
})
|> string.join(with: line_ending)
|> string.append(line_ending)
}

fn escape_field(field: String, separator: String) -> String {
Expand Down
11 changes: 7 additions & 4 deletions test/gsv_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub fn dicts_with_missing_values_test() {
]
gsv.from_dicts(data, ",", gsv.Unix)
|> should.equal(
"colour,name,score,youtube\nPink,Lucy,100,\n,Isaac,99,@IsaacHarrisHolt",
"colour,name,score,youtube\nPink,Lucy,100,\n,Isaac,99,@IsaacHarrisHolt\n",
)
}

Expand Down Expand Up @@ -257,7 +257,7 @@ Austin, 25, FALSE"
|> string.replace(each: "\"", with: "'")
|> should.equal(
"Ben, 25,' TRUE\n\r'' '\r
Austin, 25, FALSE",
Austin, 25, FALSE\r\n",
)
}

Expand All @@ -271,7 +271,7 @@ Austin,27,"
|> should.equal(
"age,name
27,Ben
27,Austin",
27,Austin\n",
)
}

Expand All @@ -284,7 +284,10 @@ fn test_lists_roundtrip(
) -> Nil {
let assert Ok(parsed) = gsv.to_lists(input)
let encoded = gsv.from_lists(parsed, separator, line_ending)
encoded |> should.equal(input)
case input |> string.ends_with("\n") {
True -> encoded |> should.equal(input)
False -> encoded |> should.equal(input <> "\n")
}
}

fn pretty_print_error(input: String) -> String {
Expand Down

0 comments on commit c20ed1c

Please sign in to comment.