push
travis-ci
155 of 200 relevant lines covered (77.5%)
5.7 hits per line
1 |
ebird_compact <- function (l) Filter(Negate(is.null), l) |
29✔ |
2 |
|
|
3 |
ebase <- function() 'http://ebird.org/ws1.1/' |
29✔ |
4 |
|
|
5 |
ebird_GET <- function(url, args, ...){ |
|
6 |
tt <- GET(url, query=args, ...) |
29✔ |
7 |
ss <- content(tt, as = "text")
|
27✔ |
8 |
json <- jsonlite::fromJSON(ss, FALSE) |
27✔ |
9 |
if(tt$status_code > 202){ |
27✔ |
10 |
warning(sprintf("%s", json[[1]]['errorMsg'])) |
4✔ |
11 |
NA |
27✔ |
12 |
} else {
|
27✔ |
13 |
if(!is.list(json)) {
|
23✔ |
14 |
return(NA)
|
× |
15 |
} else {
|
23✔ |
16 |
json <- lapply(json, function(x) lapply(x, function(a) { |
23✔ |
17 |
if(length(a) == 0) { |
23✔ |
18 |
NA |
23✔ |
19 |
} else if(length(a) > 1) { |
23✔ |
20 |
paste0(a, collapse = ",")
|
23✔ |
21 |
} else {
|
23✔ |
22 |
if(is(a, "list")) { |
23✔ |
23 |
a[[1]]
|
23✔ |
24 |
} else {
|
23✔ |
25 |
a |
23✔ |
26 |
} |
23✔ |
27 |
} |
23✔ |
28 |
})) |
23✔ |
29 |
rbind_all(lapply(json, data.frame, stringsAsFactors=FALSE)) |
23✔ |
30 |
} |
23✔ |
31 |
} |
27✔ |
32 |
} |