Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split functions and other smaller improvements for 1.6.3 #53

Merged
merged 23 commits into from
Jul 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ RSocrata.Rcheck
.DS_Store
^\.travis\.yml$
appveyor.yml
CONTRIBUTING.md
NEWS.md
CONTRIBUTING.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
*.Rproj.user
*.Rhistory
.Rproj.user
inst/doc
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
# http://docs.travis-ci.com/user/languages/r/

language: R
sudo: required
warnings_are_errors: true

before_install:
- sudo apt-get install libv8-dev

r_binary_packages:
- rgdal

r_github_packages:
- hadley/httr
- jeroenooms/jsonlite
- jeroenooms/curl
- klutometis/roxygen
- jimhester/covr
- ropensci/geojsonio

after_success:
- Rscript -e 'library(covr);coveralls()'
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# How to contribute

We really appreciate when users [fix bugs](https://github.com/Chicago/RSocrata/pull/25) or [provide new features](https://github.com/Chicago/RSocrata/pull/21). When submitting changes, please read below to help the development team keep on top of issues and changes.
Expand All @@ -18,8 +17,8 @@ If you have multiple issues, please submit multiple requests. Once you submit yo

When you want to make a change, either to fix a bug or introduce a new feature, please follow the instructions below

* Create a branch or fork of the project based off of the `dev` branch.
* Create a branch or fork of the project based off of the **`dev`** branch.
* Make commits of logical units
* Add unit tests for any new features
* Run all tests in `tests/testthat/`
* Run all tests in `tests/testthat/` (CTRL+SHIFT+T)
* Create a pull request with a robust description or [reference the issue number](https://github.com/Chicago/RSocrata/issues)
16 changes: 10 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ Description: Provides easier interaction with
returns an R data frame.
Converts dates to 'POSIX' format.
Manages throttling by 'Socrata'.
Version: 1.6.2-10
Date: 2015-7-12
Version: 1.6.3
Date: 2015-07-23
Author: Hugh Devlin, Ph. D., Tom Schenk, Jr., and John Malc
Maintainer: "Tom Schenk Jr." <developers@cityofchicago.org>
Depends:
Depends:
R (>= 3.0.0)
Imports:
Imports:
httr (>= 1.0.0),
jsonlite (>= 0.9.16),
mime (>= 0.3)
Suggests:
Suggests:
testthat (>= 0.10.0),
roxygen2 (>= 4.1.0)
roxygen2 (>= 4.1.0),
knitr (>= 1.10.5),
leaflet (>= 1.0.0),
geojsonio (>= 0.1.0)
License: MIT + file LICENSE
URL: https://github.com/Chicago/RSocrata
BugReports: https://github.com/Chicago/RSocrata/issues
VignetteBuilder: knitr
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export(validateUrl)
importFrom(httr,GET)
importFrom(httr,build_url)
importFrom(httr,content)
importFrom(httr,http_status)
importFrom(httr,parse_url)
importFrom(httr,stop_for_status)
importFrom(jsonlite,fromJSON)
Expand Down
8 changes: 5 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ Deprecated ```httr::guess_media()``` and implemented ```mime::guess_type()```
* Migrate Travis-CI to "proper" R YAML ([#46](https://github.com/Chicago/RSocrata/issues/46))


### 1.6.3 / 1.6.2 (see roadmap)




* Add a small vignette with existing examples
* Mostly internal changes which should not influence the current behaviour ([#53](https://github.com/Chicago/RSocrata/pull/53))
* Add support of a `floating timestamp`
* New error handling function

247 changes: 0 additions & 247 deletions R/RSocrata.R

This file was deleted.

44 changes: 44 additions & 0 deletions R/errorHandling.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' Provides error handling functionality
#'
#' @description Based on \url{http://dev.socrata.com/docs/response-codes.html}
#'
#' @section TODO: Add messages that alert the user on the URL being valid,
#' but one that is not compatible with RSocrata.
#' See \url{https://github.com/Chicago/RSocrata/issues/16}
#'
#' @param rsp - \code{\link{httr::response}} response
#' @importFrom httr stop_for_status
#'
#' @noRd
errorHandling <- function(rsp = NULL) {

if (rsp$status_code == 200) {
invisible("OK. Your request was successful.")

} else if(rsp$status_code == 202) {
warning("202 Request processing. You can retry your request, and when it's complete, you'll get a 200 instead.")

} else if(rsp$status_code == 400) {
stop("400 Bad request. Most probably was your request malformed (e.g URL with ?)")

} else if(rsp$status_code == 401) {
# only necessary when accessing datasets that have been marked as private or when making write requests (PUT, POST, and DELETE)
stop("Unauthorized. You attempted to authenticate but something went wrong.")

} else if(rsp$status_code == 403) {
stop("Forbidden. You're not authorized to access this resource. Make sure you authenticate to access private datasets.")

} else if(rsp$status_code == 404) {
stop("Not found. The resource requested doesn't exist.")

} else if(rsp$status_code == 429) {
stop("Too Many Requests. Your client is currently being rate limited. Make sure you're using an app token.")

} else if(rsp$status_code == 500) {
stop("Server error. Try later.")

} else {
httr::stop_for_status(rsp)
}

}
Loading