Skip to content

Commit

Permalink
rename R package to curies and ConverterR to Converter
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Apr 3, 2024
1 parent a67cc85 commit 4eb3655
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion lib/docs/docs/r.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Initialize a converter, then use it to `compress` URIs to CURIEs, or `expand` CU
```r title="curies_conversion.R"
library(curiesr)

converter <- ConverterR$new()
converter <- Converter$new()

curie <- converter$compress("http://purl.obolibrary.org/obo/DOID_1234")
uri <- converter$expand("doid:1234")
Expand Down
2 changes: 1 addition & 1 deletion r/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: curiesr
Package: curies
Title: Idiomatic conversion between URIs and compact URIs (CURIEs)
Version: 0.1.0
Authors@R: c(
Expand Down
6 changes: 3 additions & 3 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated by roxygen2: do not edit by hand

S3method("$",ConverterR)
S3method("[[",ConverterR)
useDynLib(curiesr, .registration = TRUE)
S3method("$",Converter)
S3method("[[",Converter)
useDynLib(curies, .registration = TRUE)
16 changes: 8 additions & 8 deletions r/R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

#
# This file was created with the following call:
# .Call("wrap__make_curiesr_wrappers", use_symbols = TRUE, package_name = "curiesr")
# .Call("wrap__make_curies_wrappers", use_symbols = TRUE, package_name = "curies")

#' @docType package
#' @usage NULL
#' @useDynLib curiesr, .registration = TRUE
#' @useDynLib curies, .registration = TRUE
NULL

ConverterR <- new.env(parent = emptyenv())
Converter <- new.env(parent = emptyenv())

ConverterR$new <- function() .Call(wrap__ConverterR__new)
Converter$new <- function() .Call(wrap__Converter__new)

ConverterR$compress <- function(uri) .Call(wrap__ConverterR__compress, self, uri)
Converter$compress <- function(uri) .Call(wrap__Converter__compress, self, uri)

ConverterR$expand <- function(curie) .Call(wrap__ConverterR__expand, self, curie)
Converter$expand <- function(curie) .Call(wrap__Converter__expand, self, curie)

#' @export
`$.ConverterR` <- function (self, name) { func <- ConverterR[[name]]; environment(func) <- environment(); func }
`$.Converter` <- function (self, name) { func <- Converter[[name]]; environment(func) <- environment(); func }

#' @export
`[[.ConverterR` <- `$.ConverterR`
`[[.Converter` <- `$.Converter`


# nolint end
2 changes: 1 addition & 1 deletion r/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ After installation, the following should work:

```r
library(curiesr)
converter <- ConverterR$new()
converter <- Converter$new()
curie <- converter$compress("http://purl.obolibrary.org/obo/DOID_1234")
print(curie)
```
8 changes: 4 additions & 4 deletions r/man/curiesr-package.Rd → r/man/curies-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions r/src/Makevars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TARGET_DIR = ./rust/target
LIBDIR = $(TARGET_DIR)/release
STATLIB = $(LIBDIR)/libcuriesr.a
PKG_LIBS = -L$(LIBDIR) -lcuriesr -lssl
STATLIB = $(LIBDIR)/libcuries.a
PKG_LIBS = -L$(LIBDIR) -lcuries -lssl

all: C_clean

Expand Down
4 changes: 2 additions & 2 deletions r/src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ TARGET = $(subst 64,x86_64,$(subst 32,i686,$(WIN)))-pc-windows-gnu

TARGET_DIR = ./rust/target
LIBDIR = $(TARGET_DIR)/$(TARGET)/release
STATLIB = $(LIBDIR)/libcuriesr.a
PKG_LIBS = -L$(LIBDIR) -lcuriesr -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll -lCrypt32 -lSecur32
STATLIB = $(LIBDIR)/libcuries.a
PKG_LIBS = -L$(LIBDIR) -lcuries -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll -lCrypt32 -lSecur32

all: C_clean

Expand Down
2 changes: 1 addition & 1 deletion r/src/curiesr-win.def
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
EXPORTS
R_init_curiesr
R_init_curies
6 changes: 3 additions & 3 deletions r/src/entrypoint.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// We need to forward routine registration from C to Rust
// to avoid the linker removing the static library.

void R_init_curiesr_extendr(void *dll);
void R_init_curies_extendr(void *dll);

void R_init_curiesr(void *dll) {
R_init_curiesr_extendr(dll);
void R_init_curies(void *dll) {
R_init_curies_extendr(dll);
}
4 changes: 2 additions & 2 deletions r/src/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = 'curiesr'
name = 'curies-r'
publish = false
version = '0.3.0'
edition = '2021'
license-file.workspace = true

[lib]
crate-type = [ 'staticlib' ]
name = 'curiesr'
name = 'curies'

[dependencies]
curies.workspace = true
Expand Down
17 changes: 8 additions & 9 deletions r/src/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use extendr_api::prelude::*;

use ::curies::{sources::get_bioregistry_converter, Converter};
use ::curies::{sources::get_bioregistry_converter, Converter as RsConverter};
use tokio::runtime::Runtime;

/// Converter struct for R
/// @export
pub struct ConverterR {
converter: Converter,
pub struct Converter {
converter: RsConverter,
pub name: String,
}

#[extendr]
impl ConverterR {
impl Converter {
fn new() -> Result<Self> {
// Building from empty converter works
// let mut converter = Converter::default();
Expand Down Expand Up @@ -41,16 +41,15 @@ impl ConverterR {
}

/// Initialize converter
fn init_converter() -> Converter {
fn init_converter() -> RsConverter {
let rt = Runtime::new().unwrap();
rt.block_on(async { get_bioregistry_converter().await.unwrap() })
}

// Macro to generate exports. This ensures exported functions are registered with R.
// See corresponding C code in `entrypoint.c`.
// Macro to generate exports. This ensures exported functions are registered with R. See corresponding C code in `entrypoint.c`.
extendr_module! {
mod curiesr;
impl ConverterR;
mod curies;
impl Converter;
// fn hello_world;
}

Expand Down
6 changes: 3 additions & 3 deletions r/tests/test-curies.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
library(testthat)
library(curiesr)
library(curies)

test_that("Create curiesr default converter, compress and expand", {
converter <- ConverterR$new()
test_that("Create curies default converter, compress and expand", {
converter <- Converter$new()
expect_equal(converter$compress("http://purl.obolibrary.org/obo/DOID_1234"), "doid:1234")
expect_equal(converter$expand("doid:1234"), "http://purl.obolibrary.org/obo/DOID_1234")

Expand Down

0 comments on commit 4eb3655

Please sign in to comment.