From 9b8257a725680c148e14ab7df52fd47d622136f3 Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Fri, 16 Dec 2016 18:43:47 -0800 Subject: [PATCH] Create a new crate for the query parser. Fixes #138. r=rnewman Starting to work out the project layout for sub-crates. The crate inside query-parser/ is "datomish-query-parser" and the core code in src/ depends on it. --- .travis.yml | 2 +- Cargo.toml | 2 ++ query-parser/Cargo.toml | 3 +++ query-parser/src/lib.rs | 24 ++++++++++++++++++++++++ src/lib.rs | 11 +++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 query-parser/Cargo.toml create mode 100644 query-parser/src/lib.rs diff --git a/.travis.yml b/.travis.yml index 9ed6b679..23396e14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,5 @@ language: rust script: - cargo build --verbose - cargo test --verbose - - cargo build --verbose -p datomish-cli + - cargo test --verbose -p datomish-query-parser - cargo test --verbose -p datomish-cli \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index ef843bb3..b0ec7ca3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,8 @@ version = "0.4.0" authors = ["Richard Newman ", "Nicholas Alexander "] [dependencies] +[dependencies.datomish-query-parser] + path = "query-parser" [dev-dependencies] [dev-dependencies.datomish-cli] diff --git a/query-parser/Cargo.toml b/query-parser/Cargo.toml new file mode 100644 index 00000000..a17d9c6c --- /dev/null +++ b/query-parser/Cargo.toml @@ -0,0 +1,3 @@ +[package] +name = "datomish-query-parser" +version = "0.0.1" \ No newline at end of file diff --git a/query-parser/src/lib.rs b/query-parser/src/lib.rs new file mode 100644 index 00000000..952491a8 --- /dev/null +++ b/query-parser/src/lib.rs @@ -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-query-parser"); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + assert_eq!(String::from("datomish-query-parser"), get_name()); + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 6f682720..2c4086f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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_query_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_query_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-query-parser"), get_parser_name()); + } } \ No newline at end of file