Skip to content

Commit b065080

Browse files
MarcAntoine-Arnaudscholtzan
authored andcommitted
Fix formatting, publish and add Travis CI
* rename to rdf library * upate description formatting * release 0.1.1 * syntax * add travis configuration * format code using cargo-fmt * update travis build * fix syntaxes from clippy informations * fix clone and format * updte rust syntax * update syntax * update indentation * defines UnsignedLong type * wrote logn type as integer value * release 0.1.2 * update formatting * update turtle formatter for lexical number representation * bump to 0.1.3 * fix turtle format for bool with type * bump to 0.1.4 * Update links * force to install clippy * add more tested rust versions * format code * fix format * format * minor syntax fix
1 parent 880c173 commit b065080

27 files changed

+4138
-3730
lines changed

.travis.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
language: rust
3+
4+
rust:
5+
- 1.23.0
6+
- 1.24.0
7+
- 1.25.0
8+
- 1.26.0
9+
- 1.27.0
10+
- 1.28.0
11+
- stable
12+
- beta
13+
- nightly
14+
15+
matrix:
16+
allow_failures:
17+
- rust: nightly
18+
include:
19+
# Rustfmt
20+
- env: RUSTFMT_VERSION="0.4.1"
21+
rust: nightly-2018-04-01
22+
install:
23+
- rustup component add rustfmt-preview
24+
- cargo install rustfmt-nightly --force --version $RUSTFMT_VERSION || echo "rustfmt already installed"
25+
before_script:
26+
- cargo-fmt fmt -- --version
27+
script:
28+
- cargo fmt -- --write-mode=diff
29+
30+
# Clippy
31+
- env: CLIPPY_VERSION="0.0.191"
32+
rust: nightly-2018-04-01
33+
install:
34+
- travis_wait cargo install clippy --force --version $CLIPPY_VERSION || echo "clippy already installed"
35+
script:
36+
# Fail if clippy output contains "error:" or "warning:"
37+
- cargo clippy 2>&1 | tee ./clippy.out && ! grep -qe "error:\|warning:" ./clippy.out
38+
39+
# Test coverage (with Tarpaulin)
40+
- env: TARPAULIN_VERSION="0.5.6"
41+
rust: stable
42+
# To avoid "Error: EPERM: operation not permitted" error (see https://github.com/valery-barysok/session-file-store/issues/58)
43+
sudo: true
44+
install:
45+
- curl -sL https://github.com/xd009642/tarpaulin/releases/download/$TARPAULIN_VERSION/cargo-tarpaulin-$TARPAULIN_VERSION-travis.tar.gz | tar xvz -C $HOME/.cargo/bin
46+
script:
47+
- cargo tarpaulin --verbose > ./tarpaulin.out
48+
49+
# Fetch coverage percentage (integer)
50+
- COVERAGE=$(cat ./tarpaulin.out | awk -F '.' '/coverage/ { print $1 }')
51+
- echo COVERAGE=${COVERAGE}
52+
53+
# Print uncoverted lines
54+
- 'echo "UNCOVERED LINES" && grep "hits: 0" ./tarpaulin.out'
55+
56+
# Exit 1, if coverage is less than 89%
57+
- if [ $COVERAGE -lt 89 ]; then exit 0; fi
58+
59+
cache:
60+
cargo: true
61+
before_cache:
62+
# Travis can't cache files that are not readable by "others"
63+
- chmod -R a+r $HOME/.cargo
64+
65+
script:
66+
- cargo test
67+
68+
addons:
69+
apt:
70+
packages:
71+
- libssl-dev # Required for tarpaulin

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
[package]
2-
name = "rdf-rs"
3-
version = "0.1.0"
4-
authors = ["Anna Scholtz <[email protected]>"]
2+
name = "rdf"
3+
version = "0.1.4"
4+
authors = ["Anna Scholtz <[email protected]>", "Marc-Antoine Arnaud <[email protected]>"]
5+
description = """
6+
rdf is a library for the Resource Description Framework (RDF) and SPARQL implemented in Rust.
7+
"""
8+
license = "MIT"
9+
repository = "https://github.com/scholtzan/rdf-rs"
10+
documentation = "https://docs.rs/rdf"
511

612
[dependencies]

README.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,20 @@
22

33
> Note: This project is work in progress and currently not stable.
44
5-
`rdf-rs` is a library for the [Resource Description Framework](https://www.w3.org/RDF/) (RDF) and [SPARQL](https://www.w3.org/TR/rdf-sparql-query/) implemented in Rust.
5+
`rdf` is a library for the [Resource Description Framework](https://www.w3.org/RDF/) (RDF) and [SPARQL](https://www.w3.org/TR/rdf-sparql-query/) implemented in Rust.
66

77
This project is a way for me to learn Rust and combine it with my interests in semantic web technologies.
88

9-
## Usage
10-
11-
A comprehensive documentation of the API is available [**here**](https://scholtzan.github.io/rdf-rs/doc/rdf_rs/index.html).
12-
13-
### Installation
14-
15-
To use `rdf-rs`, add this to `Cargo.toml`:
16-
17-
```toml
18-
[dependencies.rdf-rs]
19-
git = "https://github.com/scholtzan/rdf-rs"
20-
```
21-
229

2310
### Basic Examples
2411

2512

2613
RDF triples can be stored and represented in a graph.
2714

2815
```rust
29-
use rdf_rs::graph::Graph;
30-
use rdf_rs::uri::Uri;
31-
use rdf_rs::triple::Triple;
16+
use rdf::graph::Graph;
17+
use rdf::uri::Uri;
18+
use rdf::triple::Triple;
3219

3320
let mut graph = Graph::new(None);
3421
let subject = graph.create_blank_node();
@@ -42,11 +29,11 @@ graph.add_triple(&triple);
4229
RDF graphs can be serialized to a supported format.
4330

4431
```rust
45-
use rdf_rs::writer::n_triples_writer::NTriplesWriter;
46-
use rdf_rs::writer::rdf_writer::RdfWriter;
47-
use rdf_rs::graph::Graph;
48-
use rdf_rs::uri::Uri;
49-
use rdf_rs::triple::Triple;
32+
use rdf::writer::n_triples_writer::NTriplesWriter;
33+
use rdf::writer::rdf_writer::RdfWriter;
34+
use rdf::graph::Graph;
35+
use rdf::uri::Uri;
36+
use rdf::triple::Triple;
5037

5138
let writer = NTriplesWriter::new();
5239

@@ -64,9 +51,9 @@ assert_eq!(writer.write_to_string(&graph).unwrap(),
6451
RDF syntax can also be parsed and transformed into an RDF graph.
6552

6653
```rust
67-
use rdf_rs::reader::turtle_parser::TurtleParser;
68-
use rdf_rs::reader::rdf_parser::RdfParser;
69-
use rdf_rs::uri::Uri;
54+
use rdf::reader::turtle_parser::TurtleParser;
55+
use rdf::reader::rdf_parser::RdfParser;
56+
use rdf::uri::Uri;
7057

7158
let input = "@base <http://example.org/> .
7259
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

src/error.rs

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,62 @@
1-
use std::fmt;
2-
use std::error::Error as StdError;
31
use reader::input_reader::InputChars;
2+
use std::error::Error as StdError;
3+
use std::fmt;
44

55
/// Different types of errors that can occur.
66
#[derive(Debug)]
77
pub enum ErrorType {
8-
/// RDF writer produces invalid RDF (e.g. if invalid node types are provided).
9-
InvalidWriterOutput,
8+
/// RDF writer produces invalid RDF (e.g. if invalid node types are provided).
9+
InvalidWriterOutput,
1010

11-
/// RDF lexer reads invalid RDF (e.g. non-closing string).
12-
InvalidReaderInput,
11+
/// RDF lexer reads invalid RDF (e.g. non-closing string).
12+
InvalidReaderInput,
1313

14-
/// RDF reader reads an invalid token (e.g. invalid node type).
15-
InvalidToken,
14+
/// RDF reader reads an invalid token (e.g. invalid node type).
15+
InvalidToken,
1616

17-
/// RDF reader reaches the end of the input and stores the characters that were read last.
18-
EndOfInput(InputChars),
17+
/// RDF reader reaches the end of the input and stores the characters that were read last.
18+
EndOfInput(InputChars),
1919

20-
/// Input reader encounters invalid byte encoding.
21-
InvalidByteEncoding,
20+
/// Input reader encounters invalid byte encoding.
21+
InvalidByteEncoding,
2222

23-
/// Incorrect namespace.
24-
InvalidNamespace
23+
/// Incorrect namespace.
24+
InvalidNamespace,
2525
}
2626

27-
2827
/// An error related to the rdf-rs module.
2928
#[derive(Debug)]
3029
pub struct Error {
31-
error_type: ErrorType,
32-
error: Box<StdError>
30+
error_type: ErrorType,
31+
error: Box<StdError>,
3332
}
3433

35-
3634
impl Error {
37-
/// Constructor of `Error`.
38-
pub fn new<E>(error_type: ErrorType, error: E) -> Error
39-
where E: Into<Box<StdError>> {
40-
Error {
41-
error_type: error_type,
42-
error: error.into()
35+
/// Constructor of `Error`.
36+
pub fn new<E>(error_type: ErrorType, error: E) -> Error
37+
where
38+
E: Into<Box<StdError>>,
39+
{
40+
Error {
41+
error_type,
42+
error: error.into(),
43+
}
4344
}
44-
}
4545

46-
/// Returns the type of the error.
47-
pub fn error_type(&self) -> &ErrorType {
48-
&self.error_type
49-
}
46+
/// Returns the type of the error.
47+
pub fn error_type(&self) -> &ErrorType {
48+
&self.error_type
49+
}
5050
}
5151

52-
5352
impl fmt::Display for Error {
54-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
55-
self.error.fmt(f)
56-
}
53+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54+
self.error.fmt(f)
55+
}
5756
}
5857

59-
6058
impl StdError for Error {
61-
fn description(&self) -> &str {
62-
self.error.description()
63-
}
64-
}
59+
fn description(&self) -> &str {
60+
self.error.description()
61+
}
62+
}

0 commit comments

Comments
 (0)