Skip to content

Commit

Permalink
re-factor bulletin functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestguevarra committed Aug 19, 2024
1 parent abe5a7e commit 6ff11c9
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 42 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ export(eq_build_url)
export(eq_data)
export(eq_get_bulletin)
export(eq_get_bulletin_urls)
export(eq_get_bulletin_urls_)
export(eq_get_bulletins)
export(eq_get_table)
export(eq_process_bulletins)
export(eq_process_table)
importFrom(dplyr,across)
importFrom(dplyr,bind_rows)
importFrom(dplyr,everything)
importFrom(dplyr,mutate)
Expand All @@ -19,7 +21,9 @@ importFrom(rlang,.data)
importFrom(rvest,html_table)
importFrom(rvest,session)
importFrom(stringr,str_detect)
importFrom(stringr,str_remove)
importFrom(stringr,str_remove_all)
importFrom(stringr,str_replace)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_to_title)
importFrom(tibble,tibble)
10 changes: 7 additions & 3 deletions R/eq_get_bulletin_urls.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' @examples
#' eq_get_bulletin_urls()
#'
#' @rdname eq_get_bulletin
#' @rdname eq_get_bulletin_urls
#' @export
#'

Expand All @@ -46,13 +46,17 @@ eq_get_bulletin_urls <- function(.url = "https://earthquake.phivolcs.dost.gov.ph
## Retrieve URLs ----
lapply(
X = urls,
FUN = eq_get_links_
FUN = eq_get_bulletin_urls_
) |>
unlist()
}

#'
#' @rdname eq_get_bulletin_urls
#' @export
#'

eq_get_links_ <- function(.url) {
eq_get_bulletin_urls_ <- function(.url) {
## Detect year and month from URL ----
.year <- stringr::str_extract(string = .url, pattern = "[0-9]{4}") |>
as.integer()
Expand Down
2 changes: 1 addition & 1 deletion R/eq_get_bulletins.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ eq_get_bulletin <- function(.url) {
}

#'
#' @rdname eq_get
#' @rdname eq_get_bulletin
#' @export
#'

Expand Down
2 changes: 2 additions & 0 deletions R/lindol-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#' @importFrom httr config
#' @importFrom rlang .data
#' @importFrom dplyr mutate relocate rename_with bind_rows select everything
#' across
#' @importFrom stringr str_to_title str_remove_all str_replace_all str_detect
#' str_remove str_replace
#' @importFrom rvest session html_table
#' @importFrom tibble tibble
#'
Expand Down
5 changes: 1 addition & 4 deletions man/eq_get.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 6 additions & 34 deletions man/eq_get_bulletin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions man/eq_get_bulletin_urls.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ reference:
- title: Get
contents:
- eq_get_table
- eq_get_bulletin_url
- eq_get_bulletin

- title: Process
contents:
- eq_process_table
- eq_process_bulettin

- title: Data
contents:
Expand Down

0 comments on commit 6ff11c9

Please sign in to comment.