Skip to content

Commit

Permalink
Merge pull request #1707 from restonslacker/bug/onAttach_Packaged_check
Browse files Browse the repository at this point in the history
Closes #1706, library(data.table) fails if "Packaged" field is not pr…
  • Loading branch information
arunsrinivasan committed May 20, 2016
2 parents 552fbe8 + 159a4b5 commit d9cf539
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@

59. 55. Added `+.IDate` method so that IDate + integer doesn't revert to `Date`, [#1528](https://github.com/Rdatatable/data.table/issues/1528); thanks @MichaelChirico for FR&PR.

60. Fixed test in `onAttach()` for when `Packaged` field is missing from `DESCRIPTION`, [#1706](https://github.com/Rdatatable/data.table/issues/1706); thanks @restonslacker for BR&PR.

#### NOTES

1. Updated error message on invalid joins to reflect the new `on=` syntax, [#1368](https://github.com/Rdatatable/data.table/issues/1368). Thanks @MichaelChirico.
Expand Down
29 changes: 19 additions & 10 deletions R/onAttach.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
.onAttach <- function(libname, pkgname) {
# Runs when attached to search() path such as by library() or require()
if (interactive()) {
v = packageVersion("data.table")
d = read.dcf(system.file("DESCRIPTION", package="data.table"))[,"Packaged"]
dev = as.integer(v[1,3])%%2 == 1 # version number odd
packageStartupMessage("data.table ", v, if(dev) paste0(" IN DEVELOPMENT built ", d))
if (dev && (Sys.Date() - as.Date(d))>28) packageStartupMessage("**********\nThis development version of data.table was built more than 4 weeks ago. Please update.\n**********")
packageStartupMessage('For help type ?data.table or https://github.com/Rdatatable/data.table/wiki')
packageStartupMessage('The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way')
# Runs when attached to search() path such as by library() or require()
if (interactive()) {
v = packageVersion("data.table")
d = read.dcf(system.file("DESCRIPTION", package="data.table"), fields = c("Packaged", "Built"))
if(is.na(d[1])){
if(is.na(d[2])){
return() #neither field exists
} else{
d = unlist(strsplit(d[2], split="; "))[3]
}
} else {
d = d[1]
}

dev = as.integer(v[1,3])%%2 == 1 # version number odd
packageStartupMessage("data.table ", v, if(dev) paste0(" IN DEVELOPMENT built ", d))
if (dev && (Sys.Date() - as.Date(d))>28) packageStartupMessage("**********\nThis development version of data.table was built more than 4 weeks ago. Please update.\n**********")
packageStartupMessage('For help type ?data.table or https://github.com/Rdatatable/data.table/wiki')
packageStartupMessage('The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way')
}
}

0 comments on commit d9cf539

Please sign in to comment.