Skip to content

Commit

Permalink
Merge pull request #61 from KWB-R/dev
Browse files Browse the repository at this point in the history
Prepare release v0.1.3
  • Loading branch information
mrustl authored Sep 17, 2019
2 parents 0ac3694 + b0fbfbc commit 7134b69
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 41 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: kwb.pkgbuild
Title: R package for standardised development at KWB
Version: 0.1.1
Version: 0.1.2
Authors@R:
c(person(given = "Michael",
family = "Rustler",
Expand Down
23 changes: 2 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
# MIT License

Copyright (c) 2018 Kompetenzzentrum Wasser Berlin gGmbH (KWB)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
YEAR: 2018-2019
COPYRIGHT HOLDER: Kompetenzzentrum Wasser Berlin gGmbH (KWB)
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2018 Kompetenzzentrum Wasser Berlin gGmbH (KWB)
Copyright (c) 2018-2019 Kompetenzzentrum Wasser Berlin gGmbH (KWB)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 11 additions & 9 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
* current development version
# [kwb.pkgbuild 0.1.2](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.2) <small>2019-09-17</small>

* Fixed MIT LICENSE creation for CRAN (#60)

# [kwb.pkgbuild 0.1.1](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.1) <small>2019-09-06</small>

* use .md instead of .Rmd due to changed workflow in pkgdown v1.4 (see: [r-lib/pkgdown#1136](https://github.com/r-lib/pkgdown/issues/1136))
* Use .md instead of .Rmd due to changed workflow in pkgdown v1.4 (see: [r-lib/pkgdown#1136](https://github.com/r-lib/pkgdown/issues/1136))

# [kwb.pkgbuild 0.1.0](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.0) <small>2019-09-04</small>

* improved use in case of an existing R package (by reading information from
* Improved use in case of an existing R package (by reading information from
DESCRIPTION file with function `kwb.pkgbuild::read_description`)

* improved documentation generation (closes #6)
* Improved documentation generation (closes #6)

+ changed `README.Rmd` to `index.Rmd` (used by `pkgdown::build_home`) and added
+ Changed `README.Rmd` to `index.Rmd` (used by `pkgdown::build_home`) and added
"Installation" chapter

+ added "Installation" chapter in `README.md` for Github repo site
+ Added "Installation" chapter in `README.md` for Github repo site

* automatically convert package title to Title Case with `tools::toTitleCase()`
* Automatically convert package title to Title Case with `tools::toTitleCase()`

* added a `NEWS.md` file to track changes to the package.
* Added a `NEWS.md` file to track changes to the package.

* see http://style.tidyverse.org/news.html for writing a good `NEWS.md`
* See http://style.tidyverse.org/news.html for writing a good `NEWS.md`


33 changes: 25 additions & 8 deletions R/use_mit_license.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,46 @@
#' @importFrom usethis use_mit_license
#' @importFrom stringr str_detect
#' @importFrom fs file_copy
#' @importFrom kwb.utils catAndRun
#' @export
use_mit_license <- function(
copyright_holder = list(name = kwb_string(), start_year = NULL)
)
{
cat("Creating KWB MIT LICENSE file....\n")
usethis::use_mit_license(name = copyright_holder$name)
kwb.utils::catAndRun("Creating KWB MIT LICENSE/LICENSE.md files",
expr = {
usethis::use_mit_license(name = copyright_holder$name)})


copyright_years <- ifelse(!is.null(copyright_holder$start_year),
sprintf("%s-%s", as.character(copyright_holder$start_year),
format(Sys.Date(), format = "%Y")),
format(Sys.Date(), format = "%Y"))

if (! is.null(copyright_holder$start_year)) {

kwb.utils::catAndRun("Modifying start year in MIT LICENSE (CRAN version)",
expr = {
writeLines(text = sprintf("YEAR: %s\nCOPYRIGHT HOLDER: %s",
copyright_years,
copyright_holder$name),
con = "LICENSE")
})

kwb.utils::catAndRun("Modifying start year in MIT LICENSE.md",
expr = {
lic_txt <- readLines("LICENSE.md")
index <- stringr::str_detect(lic_txt,pattern = "^Copyright\\s+\\(c\\)")

lic_txt[index] <- sprintf(
"Copyright (c) %s-%s %s",
as.character(copyright_holder$start_year),
format(Sys.Date(), format = "%Y"),
"Copyright (c) %s %s",
copyright_years,
copyright_holder$name
)

writeLines(lic_txt, "LICENSE.md")
writeLines(lic_txt, "LICENSE.md")})


}

fs::file_copy("LICENSE.md", "LICENSE", overwrite = TRUE)
cat("Creating MIT LICENSE file....done.\n")
}
11 changes: 10 additions & 1 deletion tests/testthat/test-function-use_mit_license.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
# This test file has been generated by kwb.test::create_test_files()
#

test_that("use_mit_license() works", {
test_that("use_mit_license() works with defaults", {
withr::with_dir(create_pkg_temp(), {
usethis::proj_set(getwd())
kwb.pkgbuild::use_description()
kwb.pkgbuild:::use_mit_license()})
})


test_that("use_mit_license() works with defined start_year", {
withr::with_dir(create_pkg_temp(), {
usethis::proj_set(getwd())
kwb.pkgbuild::use_description()
cph <- list(name = kwb.pkgbuild:::kwb_string(), start_year = 2018)
kwb.pkgbuild:::use_mit_license(copyright_holder = cph)})
})

0 comments on commit 7134b69

Please sign in to comment.