From 26770906408734b72833d806e9fd0154825170c1 Mon Sep 17 00:00:00 2001 From: Vincent Emonet Date: Tue, 14 Nov 2023 11:26:52 +0100 Subject: [PATCH] rename libs and fix npm build workflow --- .../workflows/{artifacts.yml => build.yml} | 4 +- .gitignore | 6 +++ README.md | 6 +-- js/Cargo.toml | 2 +- js/build_package.js | 30 +++++++++++++ js/package.json | 44 +++++++++++++++---- js/src/nanopub.rs | 2 +- lib/Cargo.toml | 2 +- lib/README.md | 2 +- lib/docs/src/00_introduction.md | 4 +- lib/docs/src/01_getting_started.md | 4 +- lib/src/lib.rs | 2 +- lib/src/nanopub.rs | 2 +- lib/tests/nanopub_test.rs | 2 +- python/Cargo.toml | 6 +-- python/README.md | 2 +- python/src/lib.rs | 9 ++-- python/src/nanopub.rs | 8 ++-- python/try.py | 2 +- scripts/docs-build.sh | 2 +- scripts/docs-serve.sh | 2 +- try/Cargo.toml | 2 +- try/src/main.rs | 2 +- 23 files changed, 105 insertions(+), 42 deletions(-) rename .github/workflows/{artifacts.yml => build.yml} (97%) create mode 100644 js/build_package.js diff --git a/.github/workflows/artifacts.yml b/.github/workflows/build.yml similarity index 97% rename from .github/workflows/artifacts.yml rename to .github/workflows/build.yml index 18be2a2..ba48c0f 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/build.yml @@ -69,8 +69,8 @@ jobs: # working-directory: ./js - name: NPM packing run: npm run pack - working-directory: js/pkg - - name: NPM release + working-directory: ./js + - name: NPM upload uses: actions/upload-artifact@v3 with: name: nanopub_rs_npm diff --git a/.gitignore b/.gitignore index 7205682..b872f1d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,12 @@ target/ pkg +# JS +node_modules/ +pkg*/ +package-lock.json +*.lock + # HTML docs generated by mdbook lib/docs/docs diff --git a/README.md b/README.md index fa9e837..673e80b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # 🔬🦀 Nanopub rs -[![Lint and Test](https://github.com/vemonet/nanopub-rs/actions/workflows/test.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/test.yml) [![Build](https://github.com/vemonet/nanopub-rs/actions/workflows/artifacts.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/artifacts.yml) [![Deploy docs to GitHub Pages](https://github.com/vemonet/nanopub-rs/actions/workflows/docs.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/docs.yml) +[![Lint and Test](https://github.com/vemonet/nanopub-rs/actions/workflows/test.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/test.yml) [![Build](https://github.com/vemonet/nanopub-rs/actions/workflows/build.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/build.yml) [![Deploy docs to GitHub Pages](https://github.com/vemonet/nanopub-rs/actions/workflows/docs.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/docs.yml) -A rust toolkit to sign and publish [Nanopublications](https://nanopub.org), with bindings to python and javascript (wasm). +A rust toolkit to sign and publish [Nanopublications](https://nanopub.net), with bindings to python and javascript (wasm). ## Nanopub signing process @@ -88,4 +88,4 @@ https://github.com/Harzu/wasm-rsa https://github.com/frehberg/wasm-sign -Building artefacts for many targets: https://github.com/oxigraph/oxigraph/blob/main/.github/workflows/artifacts.yml +Building artefacts for many targets: https://github.com/oxigraph/oxigraph/blob/main/.github/workflows/build.yml diff --git a/js/Cargo.toml b/js/Cargo.toml index 8b957aa..5f725ec 100644 --- a/js/Cargo.toml +++ b/js/Cargo.toml @@ -15,7 +15,7 @@ crate-type = ["cdylib"] wasm-bindgen = "0.2" js-sys = "0.3" console_error_panic_hook = "0.1" -nanopub_rs = { path = "../lib" } +nanopub = { path = "../lib" } [dev-dependencies] wasm-bindgen-test = "0.3" \ No newline at end of file diff --git a/js/build_package.js b/js/build_package.js new file mode 100644 index 0000000..a1f1cea --- /dev/null +++ b/js/build_package.js @@ -0,0 +1,30 @@ +#! /usr/bin/env node + +// From https://github.com/vemonet/nanopub-rs/blob/main/js/build_package.js +const fs = require("fs"); + +// We copy file to the new directory +fs.mkdirSync("pkg"); +for (const file of fs.readdirSync("./pkg-web")) { + fs.copyFileSync(`./pkg-web/${file}`, `./pkg/${file}`); +} +for (const file of fs.readdirSync("./pkg-node")) { + fs.copyFileSync(`./pkg-node/${file}`, `./pkg/${file}`); +} + +const pkg = JSON.parse(fs.readFileSync("./pkg/package.json")); +pkg.name = "@nanopub/sign"; +pkg.main = "node.js"; +pkg.browser = "web.js"; +pkg.files = ["*.{js,wasm,d.ts}"]; +pkg.homepage = "https://github.com/vemonet/nanopub-rs/tree/main/js"; +pkg.bugs = { + url: "https://github.com/vemonet/nanopub-rs/issues", +}; +pkg.collaborators = undefined; +pkg.repository = { + type: "git", + url: "https://github.com/vemonet/nanopub-rs.git", + directory: "js", +}; +fs.writeFileSync("./pkg/package.json", JSON.stringify(pkg, null, 2)); \ No newline at end of file diff --git a/js/package.json b/js/package.json index 4e95e8c..3a954fd 100644 --- a/js/package.json +++ b/js/package.json @@ -1,11 +1,14 @@ { + "version": "0.1.0", "name": "nanopub-js", + "description": "JavaScript bindings for the Nanopub rust toolkit", + "license": "MIT", + "homepage": "https://github.com/vemonet/nanopub-rs", + "module": "nanopub_js.js", + "types": "nanopub_js.d.ts", "collaborators": [ "Vincent Emonet " ], - "description": "JavaScript bindings for the Nanopub rust toolkit", - "version": "0.1.0", - "license": "MIT", "repository": { "type": "git", "url": "https://github.com/vemonet/nanopub-rs/tree/main/js" @@ -15,10 +18,35 @@ "nanopub_js.js", "nanopub_js.d.ts" ], - "module": "nanopub_js.js", - "homepage": "https://github.com/vemonet/nanopub-rs", - "types": "nanopub_js.d.ts", "sideEffects": [ "./snippets/*" - ] -} \ No newline at end of file + ], + "scripts": { + "fmt": "prettier \"**/*.{ts,tsx,js,cjs,json,md,html}\" --ignore-path .gitignore --write", + "test": "wasm-pack build --debug --target nodejs && mocha", + "build": "rm -rf pkg && wasm-pack build --release --target web --out-name web && mv pkg pkg-web && wasm-pack build --release --target nodejs --out-name node && mv pkg pkg-node && node build_package.js && rm -r pkg-web && rm -r pkg-node", + "release": "npm run build && npm publish ./pkg", + "pack": "npm run build && npm pack ./pkg" + }, + "standard": { + "ignore": [ + "pkg*" + ] + }, + "devDependencies": { + "prettier": "^3.1.0" + }, + "prettier": { + "trailingComma": "none", + "semi": false, + "tabWidth": 2, + "singleQuote": true, + "bracketSpacing": false, + "arrowParens": "avoid", + "useTabs": false, + "printWidth": 120, + "pluginSearchDirs": [ + "." + ] + } +} diff --git a/js/src/nanopub.rs b/js/src/nanopub.rs index 3525cec..900d566 100644 --- a/js/src/nanopub.rs +++ b/js/src/nanopub.rs @@ -1,4 +1,4 @@ -use nanopub_rs::nanopub::Nanopub; +use nanopub::nanopub::Nanopub; use wasm_bindgen::prelude::*; #[wasm_bindgen(js_name = Nanopub)] diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 812a5b3..b93dec5 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "nanopub_rs" +name = "nanopub" version = "0.1.0" authors = ["Vincent Emonet "] license = "MIT" diff --git a/lib/README.md b/lib/README.md index b02955d..a9d921b 100644 --- a/lib/README.md +++ b/lib/README.md @@ -3,7 +3,7 @@ [![Lint and Test](https://github.com/vemonet/nanopub-rs/actions/workflows/test.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/test.yml) [![Deploy docs to GitHub Pages](https://github.com/vemonet/nanopub-rs/actions/workflows/deploy-docs.yml/badge.svg)](https://github.com/vemonet/nanopub-rs/actions/workflows/deploy-docs.yml) -A rust toolkit to sign and publish [Nanopublications](https://nanopub.org). +A rust toolkit to sign and publish [Nanopublications](https://nanopub.net). ## Build diff --git a/lib/docs/src/00_introduction.md b/lib/docs/src/00_introduction.md index ce186d8..058dd95 100644 --- a/lib/docs/src/00_introduction.md +++ b/lib/docs/src/00_introduction.md @@ -1,9 +1,9 @@ # Introduction -The [nanopub_rs crate](https://crates.io/crates/sophia) aims to provide a comprehensive toolkit for working with Nanopublications and RDF in Rust. +The [nanopub crate](https://crates.io/crates/nanopub) aims to provide a comprehensive toolkit for working with Nanopublications and RDF in Rust. RDF is a data model designed to exchange knowledge on the Web in an interoperable way. Each piece of knowledge in RDF (a statement) is represented by a triple, made of three terms. A set of triples forms an RDF graph. Finally, several graphs can be grouped in a collection called a dataset, where each graph is identified by a unique name. ## Code reference -Checkout the [documentation generated from the code](/nanopub-rs/doc/nanopub_rs) +Checkout the [documentation generated from the code](/nanopub-rs/doc/nanopub) diff --git a/lib/docs/src/01_getting_started.md b/lib/docs/src/01_getting_started.md index 98c074f..742f424 100644 --- a/lib/docs/src/01_getting_started.md +++ b/lib/docs/src/01_getting_started.md @@ -1,13 +1,13 @@ # Getting Started -`nanopub_rs` is a toolkit to sign and publish [Nanopublications](https://nanopub.org). +`nanopub` is a toolkit to sign and publish [Nanopublications](https://nanopub.net). ## Usage ```rust use std::fs; -use nanopub_rs::nanopub::Nanopub; +use nanopub::nanopub::Nanopub; let public_key = r#"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo2NYLBcZmpOkjgqLiT7hMxzRaK5KhYYHxxN2gCAMfmOaulAxAzPUNBJLIXjX3yQeIj6rAH4haWNAEUGPdiua/D+Pmu/Hrva3mK29lsWW9ajyZr0e12erDdaBw+3XfxMkKCZkLJjina6mi0W80e7Wa3+dsrypMDVl3CFYVvLsXu4lIMYqI2aVvbKyqCv6hUaWlGUip+2f84LQx/RSZGGwbBjwzKqe/Cs7frCW/lNlvsAkkst+IyFMcekEW875+rnsXP3phcP9Q1Ocu8wbnYYAu5lZPL19YFDSso2Qc5TpkXK3rawDYH36rOX8f0zBzdcbZAPx9btSCgXyqMpP8U4TCwIDAQAB"#; let private_key = r#"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCjY1gsFxmak6SOCouJPuEzHNForkqFhgfHE3aAIAx+Y5q6UDEDM9Q0EksheNffJB4iPq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q2btLIeZhiWjsKIrw71+Q/vIe0YDb1PGf6DsoYhmWBpdHzR9HN+hGjvwlsYny2L9Qbfhgxxmsuf7zeFLpQLijjwKBgH7TD28k8IOk5VKec2CNjKd600OYaA3UfCpP/OhDl/RmVtYoHWDcrBrRvkvEEd2/DZ8qw165Zl7gJs3vK+FTYvYVcfIzGPWA1KU7nkntwewmf3i7V8lT8ZTwVRsmObWU60ySJ8qKuwoBQodki2VX12NpMN1wgWe3qUUlr6gLJU4xAoGAet6nD3QKwk6TTmcGVfSWOzvpaDEzGkXjCLaxLKh9GreM/OE+h5aN2gUoFeQapG5rUwI/7Qq0xiLbRXw+OmfAoV2XKv7iI8DjdIh0F06mlEAwQ/B0CpbqkuuxphIbchtdcz/5ra233r3BMNIqBl3VDDVoJlgHPg9msOTRy13lFqc="#; diff --git a/lib/src/lib.rs b/lib/src/lib.rs index ce0fbad..46f1f45 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -16,7 +16,7 @@ mod namespaces; /// /// ``` /// use std::fs; -/// use nanopub_rs::nanopub::Nanopub; +/// use nanopub::nanopub::Nanopub; /// let private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCjY1gsFxmak6SOCouJPuEzHNForkqFhgfHE3aAIAx+Y5q6UDEDM9Q0EksheNffJB4iPqsAfiFpY0ARQY92K5r8P4+a78eu9reYrb2WxZb1qPJmvR7XZ6sN1oHD7dd/EyQoJmQsmOKdrqaLRbzR7tZrf52yvKkwNWXcIVhW8uxe7iUgxiojZpW9srKoK/qFRpaUZSKn7Z/zgtDH9FJkYbBsGPDMqp78Kzt+sJb+U2W+wCSSy34jIUxx6QRbzvn6uexc/emFw/1DU5y7zBudhgC7mVk8vX1gUNKyjZBzlOmRcretrANgffqs5fx/TMHN1xtkA/H1u1IKBfKoyk/xThMLAgMBAAECggEAECuG0GZA3HF8OaqFgMG+W+agOvH04h4Pqv4cHjYNxnxpFcNV9nEssTKWSOvCwYy7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OmfAoV2XKv7iI8DjdIh0F06mlEAwQ/B0CpbqkuuxphIbchtdcz/5ra233r3BMNIqBl3VDDVoJlgHPg9msOTRy13lFqc="; /// let np_rdf = fs::read_to_string("./tests/resources/simple1-rsa.trig").unwrap(); /// let np = Nanopub::new( diff --git a/lib/src/nanopub.rs b/lib/src/nanopub.rs index aa1fc81..18675e6 100644 --- a/lib/src/nanopub.rs +++ b/lib/src/nanopub.rs @@ -47,7 +47,7 @@ impl Nanopub { /// /// ``` /// use std::fs; - /// use nanopub_rs::nanopub::Nanopub; + /// use nanopub::nanopub::Nanopub; /// let private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCjY1gsFxmak6SOCouJPuEzHNForkqFhgfHE3aAIAx+Y5q6UDEDM9Q0EksheNffJB4iPqsAfiFpY0ARQY92K5r8P4+a78eu9reYrb2WxZb1qPJmvR7XZ6sN1oHD7dd/EyQoJmQsmOKdrqaLRbzR7tZrf52yvKkwNWXcIVhW8uxe7iUgxiojZpW9srKoK/qFRpaUZSKn7Z/zgtDH9FJkYbBsGPDMqp78Kzt+sJb+U2W+wCSSy34jIUxx6QRbzvn6uexc/emFw/1DU5y7zBudhgC7mVk8vX1gUNKyjZBzlOmRcretrANgffqs5fx/TMHN1xtkA/H1u1IKBfKoyk/xThMLAgMBAAECggEAECuG0GZA3HF8OaqFgMG+W+agOvH04h4Pqv4cHjYNxnxpFcNV9nEssTKWSOvCwYy7hrwZBGV3PQzbjFmmrxVFs20+8yCD7KbyKKQZPVC0zf84bj6NTNgvr6DpGtDxINxuGaMjCt7enqhoRyRRuZ0fj2gD3Wqae/Ds8cpDCefkyMg0TvauHSUj244vGq5nt93txUv1Sa+/8tWZ77Dm0s5a3wUYB2IeAMl5WrO2GMvgzwH+zT+4kvNWg5S0Ze4KE+dG3lSIYZjo99h14LcQS9eALC/VBcAJ6pRXaCTT/TULtcLNeOpoc9Fu25f0yTsDt6Ga5ApliYkb7rDhV+OFrw1sYQKBgQDCE9so+dPg7qbp0cV+lbb7rrV43m5s9Klq0riS7u8m71oTwhmvm6gSLfjzqb8GLrmflCK4lKPDSTdwyvd+2SSmOXySw94zr1Pvc7sHdmMRyA7mH3m+zSOOgyCTTKyhDRCNcRIkysoL+DecDhNo4Fumf71tsqDYogfxpAQhn0re8wKBgQDXhMmmT2oXiMnYHhi2k7CJe3HUqkZgmW4W44SWqKHp0V6sjcHm0N0RT5Hz1BFFUd5Y0ZB3JLcah19myD1kKYCj7xz6oVLb8O7LeAZNlb0FsrtD7NU+Hciywo8qESiA7UYDkU6+hsmxaI01DsttMIdG4lSBbEjA7t4IQC5lyr7xiQKBgQCN87YGJ40Y5ZXCSgOZDepz9hqX2KGOIfnUv2HvXsIfiUwqTXs6HbD18xg3KL4myIBOvywSM+4ABYp+foY+Cpcq2btLIeZhiWjsKIrw71+Q/vIe0YDb1PGf6DsoYhmWBpdHzR9HN+hGjvwlsYny2L9Qbfhgxxmsuf7zeFLpQLijjwKBgH7TD28k8IOk5VKec2CNjKd600OYaA3UfCpP/OhDl/RmVtYoHWDcrBrRvkvEEd2/DZ8qw165Zl7gJs3vK+FTYvYVcfIzGPWA1KU7nkntwewmf3i7V8lT8ZTwVRsmObWU60ySJ8qKuwoBQodki2VX12NpMN1wgWe3qUUlr6gLJU4xAoGAet6nD3QKwk6TTmcGVfSWOzvpaDEzGkXjCLaxLKh9GreM/OE+h5aN2gUoFeQapG5rUwI/7Qq0xiLbRXw+OmfAoV2XKv7iI8DjdIh0F06mlEAwQ/B0CpbqkuuxphIbchtdcz/5ra233r3BMNIqBl3VDDVoJlgHPg9msOTRy13lFqc="; /// let np_rdf = fs::read_to_string("./tests/resources/simple1-rsa.trig").unwrap(); /// let np = Nanopub::new( diff --git a/lib/tests/nanopub_test.rs b/lib/tests/nanopub_test.rs index 7acc0cb..a8c06ff 100644 --- a/lib/tests/nanopub_test.rs +++ b/lib/tests/nanopub_test.rs @@ -1,4 +1,4 @@ -use nanopub_rs::nanopub::Nanopub; +use nanopub::nanopub::Nanopub; use std::fs; pub const ORCID: &str = "http://orcid.org/0000-0002-1267-0234"; diff --git a/python/Cargo.toml b/python/Cargo.toml index d5497ff..21901c5 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "nanopub_rs_py" +name = "nanopub-py" description = "Python bindings for the Nanopub rust toolkit" repository = "https://github.com/vemonet/nanopub-rs/tree/main/python" homepage = "https://github.com/vemonet/nanopub-rs" @@ -7,11 +7,11 @@ version = "0.1.0" edition = "2018" [lib] -name = "nanopub_rs_py" +name = "nanopub_rs" crate-type = ["cdylib"] [dependencies] -nanopub_rs = { path = "../lib" } +nanopub = { path = "../lib" } [dependencies.pyo3] version = "0.17.1" diff --git a/python/README.md b/python/README.md index d5fe284..80a983f 100644 --- a/python/README.md +++ b/python/README.md @@ -21,7 +21,7 @@ maturin develop Try the python lib by running `python try.py`: ```python -from nanopub_py import Nanopub +from nanopub_rs import Nanopub np = Nanopub(rdf="tiii") print(np.get_rdf()) ``` diff --git a/python/src/lib.rs b/python/src/lib.rs index 90b6fb2..17428f5 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -15,14 +15,13 @@ use pyo3::prelude::*; /// Nanopub Python bindings #[pymodule] -// fn nanopub_py(_py: Python<'_>, module: &PyModule) -> PyResult<()> { -fn nanopub_py(_py: Python<'_>, module: &PyModule) -> PyResult<()> { - module.add("__package__", "nanopub_py")?; +// fn nanopub_rs(_py: Python<'_>, module: &PyModule) -> PyResult<()> { +fn nanopub_rs(_py: Python<'_>, module: &PyModule) -> PyResult<()> { + module.add("__package__", "nanopub_rs")?; module.add("__version__", env!("CARGO_PKG_VERSION"))?; module.add("__author__", env!("CARGO_PKG_AUTHORS").replace(':', "\n"))?; - module.add_class::() + module.add_class::() - // module.add_class::()?; // io::add_to_module(module) } diff --git a/python/src/nanopub.rs b/python/src/nanopub.rs index a759b80..71cd9fb 100644 --- a/python/src/nanopub.rs +++ b/python/src/nanopub.rs @@ -1,15 +1,15 @@ -use nanopub_rs::nanopub::Nanopub; +use nanopub::nanopub::Nanopub; use pyo3::prelude::*; -#[pyclass(name = "Nanopub", module = "nanopub_py")] +#[pyclass(name = "Nanopub", module = "nanopub_rs")] #[pyo3(text_signature = "(rdf, private_key, orcid, server_url=None, publish=False)")] // #[derive(Clone)] -pub struct PyNanopub { +pub struct NanopubPy { np: Nanopub, } #[pymethods] -impl PyNanopub { +impl NanopubPy { #[new] fn new( rdf: &str, diff --git a/python/try.py b/python/try.py index c4d7dd5..07ddce9 100644 --- a/python/try.py +++ b/python/try.py @@ -1,4 +1,4 @@ -from nanopub_py import Nanopub +from nanopub_rs import Nanopub rdf_str = """@prefix : . @prefix drugbank: . diff --git a/scripts/docs-build.sh b/scripts/docs-build.sh index ce1dc36..c7543b8 100755 --- a/scripts/docs-build.sh +++ b/scripts/docs-build.sh @@ -6,7 +6,7 @@ rm -rf target/doc mdbook build -cargo doc --workspace --no-deps --exclude try-nanopub-rs --exclude nanopub-js --exclude nanopub_py --target-dir target/doc +cargo doc --workspace --no-deps --exclude try-nanopub-rs --exclude nanopub-js --exclude nanopub_rs --target-dir target/doc echo "📖 Docs generated in the target/doc folder" diff --git a/scripts/docs-serve.sh b/scripts/docs-serve.sh index 8ec7752..283a664 100755 --- a/scripts/docs-serve.sh +++ b/scripts/docs-serve.sh @@ -6,7 +6,7 @@ rm -rf target/doc mdbook build --open -cargo doc --open --workspace --no-deps --exclude try-nanopub-rs --exclude nanopub-js --exclude nanopub_py --target-dir target/doc +cargo doc --open --workspace --no-deps --exclude try-nanopub-rs --exclude nanopub-js --exclude nanopub_rs --target-dir target/doc echo "📖 Docs generated in the target/doc folder" diff --git a/try/Cargo.toml b/try/Cargo.toml index 93dbd56..a216370 100644 --- a/try/Cargo.toml +++ b/try/Cargo.toml @@ -18,7 +18,7 @@ keywords = ["RDF", "nanopublications"] [dependencies] -nanopub_rs = { path = "../lib" } +nanopub = { path = "../lib" } # sophia = "0.7.2" # regex = "1" diff --git a/try/src/main.rs b/try/src/main.rs index d05cd9c..82f6ab9 100644 --- a/try/src/main.rs +++ b/try/src/main.rs @@ -1,4 +1,4 @@ -use nanopub_rs::nanopub::Nanopub; +use nanopub::nanopub::Nanopub; fn main() { // http://purl.org/np/RA5IWUwPmx_chibRuDOMfby6Sz8I0n76xnB3BiAm6ZP74