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:
parent
38e8c49223
commit
9b8257a725
5 changed files with 41 additions and 1 deletions
|
@ -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
|
|
@ -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
3
query-parser/Cargo.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[package]
|
||||||
|
name = "datomish-query-parser"
|
||||||
|
version = "0.0.1"
|
24
query-parser/src/lib.rs
Normal file
24
query-parser/src/lib.rs
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
11
src/lib.rs
11
src/lib.rs
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue