Browse Source

src_knowledgeC and get_app_info

master
boB Rudis 4 years ago
parent
commit
433ee06ce7
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 3
      NAMESPACE
  2. 50
      R/get-app-info.R
  3. 2
      R/mactheknife-package.R
  4. 8
      R/src-knowledgeC.R
  5. 55
      README.md
  6. 14
      man/get_app_info.Rd
  7. 15
      man/src_knowledgeC.Rd

3
NAMESPACE

@ -5,12 +5,14 @@ export(applescript)
export(check_notarization)
export(check_sig)
export(find_dsstore)
export(get_app_info)
export(kernel_state)
export(logger)
export(read_dsstore)
export(read_plist)
export(resolve_alias)
export(software_update_history)
export(src_knowledgeC)
export(sw_vers)
export(system_profile)
import(reticulate)
@ -19,6 +21,7 @@ import(sys)
import(xml2)
importFrom(anytime,anytime)
importFrom(dplyr,case_when)
importFrom(dplyr,src_sqlite)
importFrom(purrr,"%>%")
importFrom(purrr,flatten_chr)
importFrom(purrr,map_chr)

50
R/get-app-info.R

@ -0,0 +1,50 @@
#' Retrieve iTunes info about a give app (via bundle id)
#'
#' @param bundle_id an app bundle id
#' @export
get_app_info <- function(bundle_id) {
bundle_id <- bundle_id[1]
if (grepl("^com\\.apple\\.", bundle_id)) {
tibble(
app = bundle_id,
name = stringi::stri_trans_totitle(sub("^com\\.apple\\.", "", bundle_id)),
category = "Apple"
)
} else {
httr::GET(
url = "https://itunes.apple.com/lookup",
query = list(
bundleId = bundle_id
)
) -> res
httr::stop_for_status(res)
out <- jsonlite::fromJSON(httr::content(res, as = "text"))
if (length(out$resultCount)) {
tibble(
app = bundle_id,
name = out$results$trackName,
category = out$results$primaryGenreName
)
} else {
tibble(
app = bundle_id,
name = NA_character_,
category = NA_character_
)
}
}
}

2
R/mactheknife-package.R

@ -8,7 +8,7 @@
#' @author Bob Rudis (bob@@rud.is)
#' @import reticulate sys xml2
#' @importFrom purrr map_df %>% flatten_chr set_names map_chr safely map_lgl
#' @importFrom dplyr case_when
#' @importFrom dplyr case_when src_sqlite
#' @importFrom anytime anytime
#' @importFrom stats complete.cases
#' @importFrom utils compareVersion download.file read.fwf type.convert

8
R/src-knowledgeC.R

@ -0,0 +1,8 @@
#' Source the `knowledgeC.db` on the local system
#'
#' @param knowledgeC_location location of the `knowledgeC.db` file (defaults to "`~/Library/Application Support/Knowledge/knowledgeC.db`")
#' @export
src_knowledgeC <- function(knowledgeC_location = "~/Library/Application Support/Knowledge/knowledgeC.db") {
dplyr::src_sqlite(knowledgeC_location)
}

55
README.md

@ -40,6 +40,8 @@ The following functions are implemented:
- `check_sig`: Check application signature/notarization information
- `find_dsstore`: Find and optionally remove .DS\_Store files on a
locally-accessible filesystem
- `get_app_info`: Retrieve iTunes info about a give app (via bundle
id)
- `kernel_state`: Retrieve kernel state information
- `logger`: Log a message to the macOS logging system (searchable from
Console.app)
@ -47,6 +49,7 @@ The following functions are implemented:
- `read_plist`: Read a macOS property list file
- `resolve_alias`: Resolve macOS Alias Files to POSIX path strings
- `software_update_history`: Retrieve Software Update history
- `src_knowledgeC`: Source the ‘knowledgeC.db’ on the local system
- `sw_vers`: Retrieve macOS Operating System Version Information
- `system_profile`: Report system hardware and software configuration
@ -81,7 +84,7 @@ packageVersion("mactheknife")
``` r
kernel_state()
## # A tibble: 1,294 x 2
## # A tibble: 1,321 x 2
## setting value
## <chr> <chr>
## 1 user.cs_path /usr/bin:/bin:/usr/sbin:/sbin
@ -94,7 +97,7 @@ kernel_state()
## 8 user.line_max 2048
## 9 user.re_dup_max 255
## 10 user.posix2_version 200112
## # … with 1,284 more rows
## # … with 1,311 more rows
```
### `.DS_Store` example
@ -171,7 +174,8 @@ list.files(
lapply(read_dsstore) -> x
str(x)
## List of 10
## List of 22
## $ : chr [1:9] "2018-asx-200" "2019-factset" "2019-ftse250" "2019-germany" ...
## $ : chr [1:4] "figures" "python" "R" "support"
## $ : chr [1:4] "data" "figures" "python" "R"
## $ : chr(0)
@ -181,6 +185,17 @@ str(x)
## $ : chr(0)
## $ : chr(0)
## $ : chr(0)
## $ : chr(0)
## $ : chr "data"
## $ : chr(0)
## $ : chr "data"
## $ : chr [1:2] "data" "working-final_files"
## $ : chr "hars"
## $ : chr "data"
## $ : chr "R"
## $ : chr [1:2] "data" "working-final_files"
## $ : chr "figure-html"
## $ : chr "data"
## $ : chr(0)
```
@ -188,7 +203,7 @@ str(x)
``` r
software_update_history()
## # A tibble: 203 x 6
## # A tibble: 321 x 6
## displayName displayVersion date packageIdentifiers processName contentType
## <chr> <chr> <dttm> <list> <chr> <chr>
## 1 XProtectPlistConfigData 2103 2019-06-03 22:18:20 <chr [2]> softwareupdated config-data
@ -201,7 +216,7 @@ software_update_history()
## 8 MindNode 6.0.3 2019-06-06 00:50:26 <chr [1]> appstoreagent <NA>
## 9 Tweetbot 3.3 2019-06-06 00:50:56 <chr [1]> appstoreagent <NA>
## 10 Microsoft Excel <NA> 2019-06-06 00:52:53 <chr [1]> installer <NA>
## # … with 193 more rows
## # … with 311 more rows
```
### macOS Version Info (short)
@ -209,9 +224,9 @@ software_update_history()
``` r
sw_vers()
## # A tibble: 1 x 6
## ProductName ProductVersion BuildVersion ProductFullName Hardware KernelVersion
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 Mac OS X 10.15 19A546d macOS Catalina (10.15) x86_64 19.0.0
## ProductName ProductVersion BuildVersion ProductFullName Hardware KernelVersion
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 Mac OS X 10.15.1 19B86a macOS Catalina (10.15.1) x86_64 19.0.0
```
### Applescript
@ -226,7 +241,9 @@ return "artist=" & r_artist & "\ntrack=" & r_name
')
print(res)
## [1] "artist=NICO Touches the Walls" "track=Hologram"
## character(0)
## attr(,"status")
## [1] 1
```
### App info
@ -240,27 +257,27 @@ check_sig("/Applications/RSwitch.app") %>%
## 1 Executable /Applications/RSwitch.app/Contents/MacOS/RSwitch
## 2 Identifier is.rud.bob.RSwitch
## 3 Format app bundle with Mach-O thin (x86_64)
## 4 CodeDirectory v 20500 size=1342 flags=0x10000(runtime) hashes=33+5 location=embedded
## 4 CodeDirectory v 20500 size=2142 flags=0x10000(runtime) hashes=58+5 location=embedded
## 5 VersionPlatform 1
## 6 VersionMin 658944
## 7 VersionSDK 659200
## 8 Hash type sha256 size=32
## 9 CandidateCDHash sha256 efa512a9daabfb9402af8a91697f008b89ffa81e
## 10 CandidateCDHashFull sha256 efa512a9daabfb9402af8a91697f008b89ffa81ea014452821e39a5365d80fe6
## 9 CandidateCDHash sha256 28de5b33fe3eebcbfae885a4dddfa751e28a4e43
## 10 CandidateCDHashFull sha256 28de5b33fe3eebcbfae885a4dddfa751e28a4e43425a7cc02f4268c544c6ff98
## 11 Hash choices sha256
## 12 CMSDigest efa512a9daabfb9402af8a91697f008b89ffa81ea014452821e39a5365d80fe6
## 12 CMSDigest 28de5b33fe3eebcbfae885a4dddfa751e28a4e43425a7cc02f4268c544c6ff98
## 13 CMSDigestType 2
## 14 Page size 4096
## 15 CDHash efa512a9daabfb9402af8a91697f008b89ffa81e
## 16 Signature size 8968
## 15 CDHash 28de5b33fe3eebcbfae885a4dddfa751e28a4e43
## 16 Signature size 8967
## 17 Authority Developer ID Application: Bob Rudis (CBY22P58G8)
## 18 Authority Developer ID Certification Authority
## 19 Authority Apple Root CA
## 20 Timestamp Sep 1, 2019 at 08:46:41
## 20 Timestamp Sep 21, 2019 at 08:44:46
## 21 Info.plist entries 26
## 22 TeamIdentifier CBY22P58G8
## 23 Runtime Version 10.15.0
## 24 Sealed Resources version 2 rules=13 files=26
## 24 Sealed Resources version 2 rules=13 files=32
## 25 Internal requirements count 1 size=212
check_notarization("/Applications/RSwitch.app")
@ -277,8 +294,8 @@ check_notarization("/Applications/RSwitch.app")
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
| R | 19 | 0.95 | 329 | 0.91 | 103 | 0.72 | 149 | 0.73 |
| Rmd | 1 | 0.05 | 33 | 0.09 | 40 | 0.28 | 54 | 0.27 |
| R | 21 | 0.95 | 373 | 0.92 | 119 | 0.75 | 157 | 0.74 |
| Rmd | 1 | 0.05 | 33 | 0.08 | 40 | 0.25 | 54 | 0.26 |
## Code of Conduct

14
man/get_app_info.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get-app-info.R
\name{get_app_info}
\alias{get_app_info}
\title{Retrieve iTunes info about a give app (via bundle id)}
\usage{
get_app_info(bundle_id)
}
\arguments{
\item{bundle_id}{an app bundle id}
}
\description{
Retrieve iTunes info about a give app (via bundle id)
}

15
man/src_knowledgeC.Rd

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/src-knowledgeC.R
\name{src_knowledgeC}
\alias{src_knowledgeC}
\title{Source the `knowledgeC.db` on the local system}
\usage{
src_knowledgeC(knowledgeC_location = "~/Library/Application Support/Knowledge/knowledgeC.db")
}
\arguments{
\item{knowledgeC_location}{location of the `knowledgeC.db` file (defaults to "`~/Library/Application Support/Knowledge/knowledgeC.db`")}
}
\description{
Source the `knowledgeC.db` on the local system
}
Loading…
Cancel
Save