Skip to content

Commit 8c6f01c

Browse files
committed
replace yaml pkg with yaml12 fix #556
1 parent 2ee3e0e commit 8c6f01c

6 files changed

Lines changed: 19 additions & 18 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Imports:
3535
rlang (>= 1.1.0),
3636
rprojroot,
3737
waldo,
38-
yaml
38+
yaml12
3939
Suggests:
4040
crul (>= 1.6.0),
4141
desc,

R/serializer.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Serializer <- R6::R6Class(
2525
) {
2626
self$file_extension <- ext
2727
self$path <- paste0(path, "/", name, self$file_extension)
28-
self$preserve_bytes = preserve_bytes
28+
self$preserve_bytes <- preserve_bytes
2929
self$matchers <- matchers
3030
},
3131
serialize = function(data) NULL,
@@ -98,11 +98,11 @@ YAML <- R6::R6Class(
9898
preserve_bytes = self$preserve_bytes,
9999
matchers = self$matchers
100100
)
101-
yaml::write_yaml(out, self$path)
101+
yaml12::write_yaml(out, self$path)
102102
},
103103

104104
deserialize = function() {
105-
input <- yaml::read_yaml(self$path)
105+
input <- yaml12::read_yaml(self$path)
106106
decode_interactions(input, self$preserve_bytes)
107107
}
108108
)

R/vcr-package.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@ NULL
3333

3434
# https://r-pkgs.org/dependencies-in-practice.html#how-to-not-use-a-package-in-imports
3535
ignore_unused_imports <- function() {
36-
yaml::read_yaml
3736
R6::R6Class
3837
}

tests/testthat/_snaps/serializer.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@
3838
Code
3939
writeLines(readLines(ser$path))
4040
Output
41+
---
4142
http_interactions:
42-
- request:
43-
method: GET
44-
uri: http://example.com/
45-
response:
46-
status: 200
47-
headers:
48-
name: val
49-
body:
50-
string: body
51-
recorded_at: 2024-01-01 12:00:00
43+
- request:
44+
method: GET
45+
uri: "http://example.com/"
46+
response:
47+
status: 200
48+
headers:
49+
name: val
50+
body:
51+
string: body
52+
recorded_at: "2024-01-01 12:00:00"
5253
recorded_with: VCR-<package_versions>
54+
...
5355

tests/testthat/helper-vcr.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ read_yaml <- function(path) {
9595
if (!file.exists(path)) {
9696
cli::cli_abort("{.path {path}} does not exist.")
9797
}
98-
yaml::yaml.load_file(path)
98+
yaml12::read_yaml(path)
9999
}
100100

101101
testthat::set_state_inspector(\() {

tests/testthat/test-serializer.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ test_that("YAML usage", {
234234
expect_equal(basename(z$path), "name.yml")
235235

236236
# before file exists:
237-
expect_error(suppressWarnings(z$deserialize()), "cannot open")
237+
expect_error(z$deserialize(), "Failed to read")
238238

239239
# after file exists, before any yaml in it:
240240
file.create(z$path)
241241
expect_equal(z$deserialize(), list())
242242
# after file exists, with yaml in it, with incomplete final line:
243243
cat("foo: 123\nbar: 456", file = z$path)
244-
expect_warning(z$deserialize(), "incomplete final line")
244+
expect_type(z$deserialize(), "list")
245245
# after file exists, with yaml in it, without incomplete final line:
246246
cat("foo: 123\nbar: 456\n", file = z$path)
247247
expect_type(z$deserialize(), "list")

0 commit comments

Comments
 (0)