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.
This commit is contained in:
Brian Grinstead 2016-12-16 18:43:47 -08:00 committed by GitHub
parent 38e8c49223
commit 9b8257a725
5 changed files with 41 additions and 1 deletions

View file

@ -2,5 +2,5 @@ language: rust
script: script:
- cargo build --verbose - cargo build --verbose
- cargo test --verbose - cargo test --verbose
- cargo build --verbose -p datomish-cli - cargo test --verbose -p datomish-query-parser
- cargo test --verbose -p datomish-cli - 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>"] authors = ["Richard Newman <rnewman@twinql.com>", "Nicholas Alexander <nalexander@mozilla.com>"]
[dependencies] [dependencies]
[dependencies.datomish-query-parser]
path = "query-parser"
[dev-dependencies] [dev-dependencies]
[dev-dependencies.datomish-cli] [dev-dependencies.datomish-cli]

3
query-parser/Cargo.toml Normal file
View file

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

24
query-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-query-parser");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(String::from("datomish-query-parser"), get_name());
}
}

View file

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