Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit 2a08930

Browse files
committed
Fix #9
1 parent e4cc518 commit 2a08930

8 files changed

Lines changed: 56 additions & 2 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
^README.Rmd
77
^CONDUCT\.md$
88
^README_cache$
9+
^\.lintr$

.lintr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
linters: with_defaults(line_length_linter(120), object_usage_linter = NULL, closed_curly_linter = NULL, open_curly_linter = NULL, spaces_left_parentheses_linter = NULL, camel_case_linter = NULL)
2+
exclusions: list()
3+
exclude: "# Exclude Linting"
4+
exclude_start: "# Begin Exclude Linting"
5+
exclude_end: "# End Exclude Linting"

DESCRIPTION

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: WikidataQueryServiceR
22
Title: API Client Library for 'Wikidata Query Service'
3-
Version: 0.2.0.9000
4-
Date: 2017-04-28
3+
Version: 1.0.0
4+
Date: 2017-08-05
55
Authors@R: c(
66
person("Mikhail", "Popov", email = "mikhail@wikimedia.org",
77
role = c("aut", "cre"), comment = "@bearloga on Twitter"),
@@ -16,6 +16,9 @@ Imports:
1616
dplyr (>= 0.5.0),
1717
jsonlite (>= 1.2),
1818
WikipediR (>= 1.5.0)
19+
Suggests:
20+
testthat,
21+
lintr
1922
URL: https://github.com/bearloga/WikidataQueryServiceR
2023
BugReports: https://github.com/bearloga/WikidataQueryServiceR/issues
2124
License: MIT + file LICENSE

R/wdqs.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#' by Navino Evans
1919
#' - _[Learning SPARQL](http://www.learningsparql.com/)_ by Bob DuCharme
2020
#' - [WDQS User Manual](https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual)
21+
#' - [Quick intro to WDQS & SPARQL](https://github.com/bearloga/wmf/blob/master/presentations/talks/Cascadia\%20R\%20Conference\%202017/presentation.md#wikidata-query-service-wdqs)
22+
#' from [my Cascadia R Conference 2017 talk](https://github.com/bearloga/wmf/tree/master/presentations/talks/Cascadia\%20R\%20Conference\%202017)
2123
#' @aliases WDQS
2224
#' @docType package
2325
#' @name WDQSR-package

man/WDQSR-package.Rd

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

tests/testthat.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library(testthat)
2+
library(WikidataQueryServiceR)
3+
4+
test_check("WikidataQueryServiceR")

tests/testthat/test-query.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
context("Querying")
2+
3+
query <- "SELECT DISTINCT
4+
?softwareVersion ?publicationDate
5+
WHERE {
6+
BIND(wd:Q206904 AS ?R)
7+
?R p:P348 [
8+
ps:P348 ?softwareVersion;
9+
pq:P577 ?publicationDate
10+
] .
11+
}"
12+
13+
suppressMessages({
14+
simple_results <- query_wikidata(query, format = "simple")
15+
smart_results <- query_wikidata(query, format = "smart")
16+
})
17+
18+
test_that("data", {
19+
expect_s3_class(simple_results, "data.frame")
20+
expect_s3_class(smart_results, "data.frame")
21+
expect_equal(names(simple_results), c("softwareVersion", "publicationDate"))
22+
expect_equal(names(smart_results), c("softwareVersion", "publicationDate"))
23+
})
24+
25+
test_that("date formatting", {
26+
expect_s3_class(smart_results$publicationDate, "POSIXct")
27+
})
28+
29+
test_that("simple ~= smart", {
30+
expect_equal(nrow(simple_results), nrow(smart_results))
31+
})

tests/testthat/test-syntax.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if (requireNamespace("lintr", quietly = TRUE)) {
2+
context("Lints")
3+
test_that("package style", {
4+
lintr::expect_lint_free()
5+
})
6+
}

0 commit comments

Comments
 (0)