Skip to content

Commit 2c2d4b9

Browse files
committed
update CRAN
1 parent 3305f47 commit 2c2d4b9

12 files changed

Lines changed: 54 additions & 50 deletions

NAMESPACE

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(apply_hotfix_file)
4+
export(dummy_child_func)
5+
export(dummy_parent_func)
16
export(inject_patch)
27
export(test_patched_dir)
38
export(undo_patch)
4-
export(apply_hotfix_file)

NEWS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# hotpatchR NEWS
1+
# hotpatchR
22

33
## 0.1.0
44

55
- Initial package scaffold for runtime namespace hotfixing.
66
- Added `inject_patch()`, `undo_patch()`, `test_patched_dir()`, and `apply_hotfix_file()`.
7-
- Added README, vignette, and documentation support files.

R/hotpatch.R

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#' @return Invisibly TRUE on success.
77
#' @examples
88
#' # Show baseline behavior with broken function
9-
#' baseline <- hotpatchR:::dummy_parent_func("test")
9+
#' baseline <- dummy_parent_func("test")
1010
#' print(baseline)
1111
#'
12-
#' # Inject a patched version of the internal child function
12+
#' # Inject a patched version of the child function
1313
#' inject_patch(
1414
#' pkg = "hotpatchR",
1515
#' patch_list = list(dummy_child_func = function(x) {
@@ -18,7 +18,7 @@
1818
#' )
1919
#'
2020
#' # Call the parent function again - it now uses the patched child
21-
#' patched_result <- hotpatchR:::dummy_parent_func("test")
21+
#' patched_result <- dummy_parent_func("test")
2222
#' print(patched_result)
2323
#' @export
2424
inject_patch <- function(pkg, patch_list, lock = TRUE) {
@@ -122,14 +122,14 @@ inject_patch <- function(pkg, patch_list, lock = TRUE) {
122122
#' )
123123
#'
124124
#' # Call with patched function
125-
#' patched <- hotpatchR:::dummy_parent_func("test")
125+
#' patched <- dummy_parent_func("test")
126126
#' print(patched)
127127
#'
128128
#' # Restore the original function
129129
#' undo_patch(pkg = "hotpatchR", names = "dummy_child_func")
130130
#'
131131
#' # Now it's back to the original
132-
#' restored <- hotpatchR:::dummy_parent_func("test")
132+
#' restored <- dummy_parent_func("test")
133133
#' print(restored)
134134
#' @export
135135
undo_patch <- function(pkg, names = NULL) {
@@ -185,17 +185,18 @@ undo_patch <- function(pkg, names = NULL) {
185185
#' @param reporter testthat reporter name or object.
186186
#' @return Result object from testthat::test_dir.
187187
#' @examples
188-
#' # Inject a patch to the package
189-
#' inject_patch(
190-
#' pkg = "hotpatchR",
191-
#' patch_list = list(dummy_child_func = function(x) {
192-
#' paste("PATCHED! Input:", x)
193-
#' })
194-
#' )
188+
#' \dontrun{
189+
#' # Inject a patch to the package
190+
#' inject_patch(
191+
#' pkg = "hotpatchR",
192+
#' patch_list = list(dummy_child_func = function(x) {
193+
#' paste("PATCHED! Input:", x)
194+
#' })
195+
#' )
195196
#'
196-
#' # Run tests against the patched package
197-
#' # (Note: this requires tests to exist in tests/testthat directory)
198-
#' # test_patched_dir(pkg = "hotpatchR")
197+
#' # Run tests against the patched package
198+
#' test_patched_dir(pkg = "hotpatchR")
199+
#' }
199200
#' @export
200201
test_patched_dir <- function(pkg, test_path = "tests/testthat", reporter = "summary") {
201202
if (!requireNamespace("testthat", quietly = TRUE)) {
@@ -239,7 +240,7 @@ test_patched_dir <- function(pkg, test_path = "tests/testthat", reporter = "summ
239240
#' apply_hotfix_file(file = hotfix_file, pkg = "hotpatchR")
240241
#'
241242
#' # Verify the patch works
242-
#' result <- hotpatchR:::dummy_parent_func("test")
243+
#' result <- dummy_parent_func("test")
243244
#' print(result)
244245
#'
245246
#' # Clean up

R/utils.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#'
99
#' @examples
1010
#' # Call the parent function which internally calls dummy_child_func
11-
#' result <- hotpatchR:::dummy_parent_func("sample")
11+
#' result <- dummy_parent_func("sample")
1212
#' print(result)
1313
#'
1414
#' @export
@@ -25,12 +25,12 @@ dummy_parent_func <- function(x) {
2525
#' @return A character string with child output
2626
#'
2727
#' @examples
28-
#' # This function is internal and called by dummy_parent_func
28+
#' # This function is called by dummy_parent_func
2929
#' # It serves as an example of a function that can be hotpatched
30-
#' result <- hotpatchR:::dummy_child_func("example")
30+
#' result <- dummy_child_func("example")
3131
#' print(result)
3232
#'
33-
#' @keywords internal
33+
#' @export
3434
dummy_child_func <- function(x) {
3535
return(paste("I am the BROKEN child. Input:", x))
3636
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ A typical test-hotfix flow looks like this:
7373
```r
7474
library(hotpatchR)
7575

76-
baseline <- hotpatchR:::dummy_parent_func("test")
76+
baseline <- dummy_parent_func("test")
7777
print(baseline)
7878
#> "Parent output -> I am the BROKEN child. Input: test"
7979

@@ -84,14 +84,14 @@ inject_patch(
8484
})
8585
)
8686

87-
patched_result <- hotpatchR:::dummy_parent_func("test")
87+
patched_result <- dummy_parent_func("test")
8888
print(patched_result)
8989
#> "Parent output -> I am the FIXED child! Input: test"
9090

9191

9292
#Eventually, you can reverse the patch to restore the original behavior if needed:
9393
undo_patch(pkg = "hotpatchR", names = "dummy_child_func")
94-
restored_result <- hotpatchR:::dummy_parent_func("test")
94+
restored_result <- dummy_parent_func("test")
9595
print(restored_result)
9696
#> "Parent output -> I am the BROKEN child. Input: test"
9797
```

man/apply_hotfix_file.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dummy_child_func.Rd

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dummy_parent_func.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/inject_patch.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/test_patched_dir.Rd

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)