Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*.exe

# Generated by Cargo
/target/
Cargo.lock

# Visual Studio
Expand Down
41 changes: 29 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,31 @@ addons:
- libdw-dev
- binutils-dev # optional: only required for the --verify flag of coveralls

rust:
- nightly
matrix:
include:
- rust: stable
env:
- CRATE="derive"
- rust: stable
env:
- CRATE="elastic/examples/account_sample"
- rust: stable
env:
- CRATE="elastic"

- rust: nightly
env:
- CRATE="derive"
- rust: nightly
env:
- CRATE="elastic/examples/account_sample"
- rust: nightly
env:
- CRATE="benches/rust/elastic"
- rust: nightly
env:
- CRATE="elastic"
- DOC_UPLOAD=true

env:
global:
Expand All @@ -22,14 +45,8 @@ before_script:

script:
- |
cd $CRATE &&
travis-cargo test &&
cd examples/account_sample &&
travis-cargo test &&
cd ../../benches/rust/elastic &&
travis-cargo --only nightly build &&
cd ../elastic-raw &&
travis-cargo --only nightly build &&
cd ../../../ &&
travis-cargo doc
after_success:
- travis-cargo doc-upload
travis-cargo --only nightly bench &&
travis-cargo --only nightly doc &&
if [ $DOC_UPLOAD ]; then travis-cargo --only nightly doc-upload; fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Add `elastic` and `json_str` to your `Cargo.toml`:
elastic = "*"

# Optional
elastic_derive = "*"
serde_json = "*"
json_str = "*"
```
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ install:
- cargo -vV
build: false
test_script:
- ps: cd elastic
- cargo test --verbose --no-default-features
4 changes: 2 additions & 2 deletions benches/rust/elastic-raw/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.bk
perf.*
/target/
/obj/
target/
obj/
2 changes: 1 addition & 1 deletion benches/rust/elastic-raw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Ashley Mannix <ashleymannix@live.com.au>"]
[dependencies]
json_str = { version = "*", features = ["nightly"]}

elastic = { version = "*", path = "../../../", features = ["nightly"] }
elastic = { version = "*", path = "../../../elastic" }

lazy_static = "*"
time = "*"
Expand Down
4 changes: 2 additions & 2 deletions benches/rust/elastic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.bk
perf.*
/target/
/obj/
target/
obj/
2 changes: 1 addition & 1 deletion benches/rust/elastic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ serde = "*"
serde_derive = "*"
json_str = { version = "*", features = ["nightly"]}

elastic = { version = "*", path = "../../../", features = ["nightly"] }
elastic = { version = "*", path = "../../../elastic" }

lazy_static = "*"
time = "*"
Expand Down
4 changes: 4 additions & 0 deletions derive/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.bk
perf.*
target/
obj/
13 changes: 13 additions & 0 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "elastic_derive"
version = "0.1.0"
authors = ["Ashley Mannix <ashleymannix@live.com.au>"]

[lib]
name = "elastic_derive"
proc-macro = true

[dependencies]
elastic_types_derive_internals = "~0.1.0"
syn = { version = "~0.11.0", features = ["aster", "visit", "parsing", "full"] }
quote = "~0.3.0"
46 changes: 46 additions & 0 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! Elasticsearch Codegen
//!
//! Compile-time code generation for Elasticsearch type implementations.
//! This crate provides custom `derive` attributes for data types in the [`elastic`](https://github.com/elastic-rs/elastic) crate.
//!
//! # Links
//! - [Github](https://github.com/elastic-rs/elastic)

extern crate proc_macro;

extern crate syn;
#[macro_use]
extern crate quote;
extern crate elastic_types_derive_internals as internals;

use internals::{elastic_type, date_format};

#[proc_macro_derive(ElasticType, attributes(elastic))]
pub fn derive_elastic_type(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let mut expanded = quote::Tokens::new();
let ast = syn::parse_macro_input(&input.to_string()).unwrap();

match elastic_type::expand_derive(quote!(::elastic::types), &ast) {
Ok(genned) => {
expanded.append_all(genned);

expanded.to_string().parse().unwrap()
},
Err(e) => panic!("{}", e)
}
}

#[proc_macro_derive(ElasticDateFormat, attributes(elastic))]
pub fn derive_date_format(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let mut expanded = quote::Tokens::new();
let ast = syn::parse_macro_input(&input.to_string()).unwrap();

match date_format::expand_derive(quote!(::elastic::types), &ast) {
Ok(genned) => {
expanded.append_all(genned);

expanded.to_string().parse().unwrap()
},
Err(e) => panic!("{}", e)
}
}
4 changes: 4 additions & 0 deletions elastic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.bk
perf.*
target/
obj/
11 changes: 3 additions & 8 deletions Cargo.toml → elastic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
[package]
name = "elastic"
version = "0.8.0"
version = "0.9.0"
authors = ["Ashley Mannix <ashleymannix@live.com.au>"]
license = "Apache-2.0"
description = "A client for the Elasticsearch REST API."
documentation = "https://docs.rs/elastic/"
repository = "https://github.com/elastic-rs/elastic"

[features]
nightly = [
"elastic_types/nightly"
]

[dependencies]
error-chain = "~0.7.0"
serde = "~0.9.0"
Expand All @@ -21,9 +16,9 @@ reqwest = "~0.4.0"
elastic_reqwest = "~0.4.0"
elastic_requests = "~0.1.7"
elastic_responses = "~0.5.0"
elastic_types = "~0.11.1"
elastic_types = "~0.13.0"

[dev-dependencies]
json_str = "^0.*"
serde_derive = "~0.9.0"
elastic_types_derive = { version = "~0.12.0", features = ["elastic"] }
elastic_derive = { version = "*", path = "../derive" }
4 changes: 4 additions & 0 deletions elastic/examples/account_sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.bk
perf.*
target/
obj/
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ name = "account-sample"
version = "0.1.0"
authors = ["Ashley Mannix <ashleymannix@live.com.au>"]

[features]
nightly = [
"elastic/nightly"
]

[dependencies]
elastic = { version = "*", path = "../../" }
elastic_types_derive = { version = "*", features = ["elastic"]}
elastic_derive = { version = "*", path = "../../../derive" }

quick-error = "*"
serde = "0.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate elastic_types_derive;
extern crate elastic_derive;
#[macro_use]
extern crate json_str;
#[macro_use]
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/typed.rs → elastic/examples/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#[macro_use]
extern crate json_str;
#[macro_use]
extern crate elastic_types_derive;
extern crate elastic_derive;
#[macro_use]
extern crate serde_derive;
extern crate serde;
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs → elastic/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl ResponseBuilder {
/// # #[macro_use]
/// # extern crate serde_derive;
/// # #[macro_use]
/// # extern crate elastic_types_derive;
/// # extern crate elastic_derive;
/// # extern crate elastic;
/// # use elastic::prelude::*;
/// # fn main() {
Expand Down
File renamed without changes.
File renamed without changes.
Loading