Skip to content

Commit c20ed1c

Browse files
committed
newline 3.0.1
1 parent 8583b91 commit c20ed1c

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v3.0.1 - 13 November 2024
4+
- `from_lists` and consequently `from_dicts` now append a line ending to the end
5+
of the produced string. This is a patch release because the RFC states line endings
6+
after the final row are optional, but most people will want them.
7+
38
## v3.0.0 - 4 November 2024
49
- Improved performance of `to_lists`, `to_dicts`, `from_lists` and `from_lists`.
510
- Parsing now doesn't trim the csv fields, conforming to RFC4180.

gleam.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "gsv"
2-
version = "3.0.0"
2+
version = "3.0.1"
33
gleam = ">= 0.32.0"
44
description = "A simple csv parser and generator written in gleam "
55

src/gsv.gleam

+1
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ pub fn from_lists(
400400
|> string.join(with: separator)
401401
})
402402
|> string.join(with: line_ending)
403+
|> string.append(line_ending)
403404
}
404405

405406
fn escape_field(field: String, separator: String) -> String {

test/gsv_test.gleam

+7-4
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub fn dicts_with_missing_values_test() {
191191
]
192192
gsv.from_dicts(data, ",", gsv.Unix)
193193
|> should.equal(
194-
"colour,name,score,youtube\nPink,Lucy,100,\n,Isaac,99,@IsaacHarrisHolt",
194+
"colour,name,score,youtube\nPink,Lucy,100,\n,Isaac,99,@IsaacHarrisHolt\n",
195195
)
196196
}
197197

@@ -257,7 +257,7 @@ Austin, 25, FALSE"
257257
|> string.replace(each: "\"", with: "'")
258258
|> should.equal(
259259
"Ben, 25,' TRUE\n\r'' '\r
260-
Austin, 25, FALSE",
260+
Austin, 25, FALSE\r\n",
261261
)
262262
}
263263

@@ -271,7 +271,7 @@ Austin,27,"
271271
|> should.equal(
272272
"age,name
273273
27,Ben
274-
27,Austin",
274+
27,Austin\n",
275275
)
276276
}
277277

@@ -284,7 +284,10 @@ fn test_lists_roundtrip(
284284
) -> Nil {
285285
let assert Ok(parsed) = gsv.to_lists(input)
286286
let encoded = gsv.from_lists(parsed, separator, line_ending)
287-
encoded |> should.equal(input)
287+
case input |> string.ends_with("\n") {
288+
True -> encoded |> should.equal(input)
289+
False -> encoded |> should.equal(input <> "\n")
290+
}
288291
}
289292

290293
fn pretty_print_error(input: String) -> String {

0 commit comments

Comments
 (0)