Skip to content

Commit

Permalink
release v0.0.0.9002 added print.polite and is.polite
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Perepolkin committed Jul 28, 2018
1 parent 34ad64f commit 03bc355
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 18 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: polite
Version: 0.0.0.9001
Version: 0.0.0.9002
Title: Be nice on the web
Description: Be responsible when scraping data from APIs or websites. Remember to itroduce yourself, ask for permission and stay well mannered while you do what you came for.
Authors@R: person("Dmytro", "Perepolkin", email = "[email protected]", role = c("aut", "cre"))
Expand All @@ -12,6 +12,7 @@ BugReports: https://github.com/dmi3kno/polite/issues
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.0.1
Imports:
crayon,
httr,
magrittr,
memoise,
Expand Down
8 changes: 7 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Generated by roxygen2: do not edit by hand

S3method(print,polite)
export("%>%")
export("%||%")
export(bow)
export(is.polite)
export(nod)
export(scrape)
importFrom(crayon,blue)
importFrom(crayon,bold)
importFrom(crayon,green)
importFrom(crayon,red)
importFrom(crayon,yellow)
importFrom(httr,GET)
importFrom(httr,add_headers)
importFrom(httr,config)
Expand Down
15 changes: 0 additions & 15 deletions NEWS

This file was deleted.

18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# polite 0.0.0.9002 (Release date: 2018-07-29)

* Added a `NEWS.md` file to track changes to the package.
* Added custom print method for `polite session` using `crayon`
* `bow` and `nod` now warn if the current path is not permitted to be scraped
* `polite` has gotten a sticker! `png` is stored in `data-raw`


# polite v0.0.0.9001 (Release date: 2018-07-27)

* Implemented bow(), nod() and scrape()
* Added documentation and examples
* Updated README to include examples


# polite v0.0.0.9000 (Release date: 2018-07-23)

* Polite is born!
20 changes: 20 additions & 0 deletions R/bow.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' session <- bow(host)
#' session
#' }
#' @rdname bow
#' @importFrom urltools domain path suffix_extract url_parse
#' @importFrom robotstxt robotstxt
#' @importFrom httr handle config add_headers
Expand Down Expand Up @@ -71,3 +72,22 @@ bow <- function(url,
self
}

#' @param x object of class `polite session`
#' @param ... other parameters passed to methods
#' @importFrom crayon yellow bold blue green red
#' @export
print.polite <- function(x, ...) {
cat(yellow$bold("<polite session> "), x$url, "\n", sep = "")
cat(blue(" ", "User-agent: "), x$user_agent, "\n", sep = "")
cat(blue(" ", "robots.txt: "), nrow(x$robotstxt$permissions), " rules are defined for ",length(x$robotstxt$bots), " bots\n", sep = "")
if(is_scrapable(x)){
cat(green(" ", "The path is scrapable for this user-agent\n"), sep="")
} else {
cat(red(" ", "The path is not scrapable for this user-agent\n"), sep="")
}
}

#' @param x object of class `polite session`
#' @rdname bow
#' @export
is.polite <- function(x) inherits(x, "polite")
1 change: 0 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#' @name null-coalesce
#' @rdname nullcoalesce
#' @keywords internal
#' @export
#' @usage lhs \%||\% rhs
"%||%" <- function(lhs, rhs) {
if (!is.null(lhs) && length(lhs) > 0) lhs else rhs
Expand Down
Binary file added data-raw/sticker_med.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions man/bow.Rd

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

0 comments on commit 03bc355

Please sign in to comment.