Create a sample crate for the parser

This commit is contained in:
Brian Grinstead 2016-12-16 16:49:07 -08:00
parent 38e8c49223
commit a5fa08e748
5 changed files with 41 additions and 1 deletions

View file

@ -2,5 +2,5 @@ language: rust
script:
- cargo build --verbose
- cargo test --verbose
- cargo build --verbose -p datomish-cli
- cargo test --verbose -p datomish-parser
- cargo test --verbose -p datomish-cli

View file

@ -4,6 +4,8 @@ version = "0.4.0"
authors = ["Richard Newman <rnewman@twinql.com>", "Nicholas Alexander <nalexander@mozilla.com>"]
[dependencies]
[dependencies.datomish-parser]
path = "parser"
[dev-dependencies]
[dev-dependencies.datomish-cli]

3
parser/Cargo.toml Normal file
View file

@ -0,0 +1,3 @@
[package]
name = "datomish-parser"
version = "0.0.1"

24
parser/src/lib.rs Normal file
View file

@ -0,0 +1,24 @@
// Copyright 2016 Mozilla
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// This file is just a stub
pub fn get_name() -> String {
return String::from("datomish-parser");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(String::from("datomish-parser"), get_name());
}
}

View file

@ -8,11 +8,17 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
extern crate datomish_parser;
pub fn get_name() -> String {
return String::from("datomish");
}
// Just an example of using a dependency
pub fn get_parser_name() -> String {
return datomish_parser::get_name();
}
pub fn add_two(a: i32) -> i32 {
a + 2
}
@ -25,4 +31,9 @@ mod tests {
fn it_works() {
assert_eq!(4, add_two(2));
}
#[test]
fn can_import_parser() {
assert_eq!(String::from("datomish-parser"), get_parser_name());
}
}