├── .gitignore
├── Cargo.toml
├── README.rst
├── vagga.yaml
├── LICENSE-MIT
├── .travis.yml
├── src
├── lib.rs
├── for_serde.rs
└── for_rustc_serialize.rs
└── LICENSE-APACHE
/.gitignore:
--------------------------------------------------------------------------------
1 | /.vagga
2 | /target
3 | /Cargo.lock
4 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "gron"
3 | description = """
4 | Gron transforms JSON into discrete assignments to make it easier to grep
5 | """
6 | license = "MIT"
7 | readme = "README.rst"
8 | keywords = ["gron", "json"]
9 | homepage = "http://github.com/tailhook/rust-gron"
10 | documentation = "http://tailhook.github.com/rust-gron/"
11 | version = "0.4.0"
12 | authors = ["paul@colomiets.name"]
13 |
14 | [dependencies]
15 | rustc-serialize = "0.3.19"
16 | serde_json = "1.0.0"
17 |
18 | [features]
19 | log_errors = []
20 |
21 | [lib]
22 | name = "gron"
23 | path = "src/lib.rs"
24 |
25 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | =========
2 | Rust-Gron
3 | =========
4 |
5 | :Credits: gron_
6 | :API Documentation: http://tailhook.github.io/rust-gron/
7 | :Format Description: `in gron docs`__
8 |
9 | __ https://github.com/tomnomnom/gron/blob/master/README.mkd
10 | .. _gron: https://github.com/tomnomnom/gron
11 |
12 | Gron transforms JSON into discrete assignments to make it easier to grep for
13 | what you want and see the absolute 'path' to it. It eases the exploration of
14 | APIs that return large blobs of JSON.
15 |
16 | This is a reimplementation of the library in Rust because I need to embed
17 | it into a daemon written in rust.
18 |
19 |
20 |
--------------------------------------------------------------------------------
/vagga.yaml:
--------------------------------------------------------------------------------
1 | commands:
2 |
3 | make: !Command
4 | description: Build gron library
5 | container: ubuntu
6 | run: [cargo, build]
7 |
8 | test: !Command
9 | description: Run unit tests
10 | container: ubuntu
11 | run: [cargo, test]
12 |
13 | cargo: !Command
14 | description: Run any cargo command
15 | container: ubuntu
16 | run: [cargo]
17 |
18 | containers:
19 |
20 | ubuntu:
21 | setup:
22 | - !Ubuntu xenial
23 | - !Install [ca-certificates, build-essential]
24 |
25 | - !TarInstall
26 | url: "https://static.rust-lang.org/dist/rust-1.15.1-x86_64-unknown-linux-gnu.tar.gz"
27 | script: "./install.sh --prefix=/usr \
28 | --components=rustc,rust-std-x86_64-unknown-linux-gnu,cargo"
29 |
30 | environ:
31 | HOME: /work/target
32 |
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 The rust-gron Developers
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: rust
2 | rust:
3 | - stable
4 | - beta
5 | - nightly
6 | sudo: false
7 | script:
8 | - cargo build --verbose
9 | # don't run doc tests because they don't run well for macros
10 | - cargo test --verbose
11 | env:
12 | secure: "p8APQ2B/rHalaFEBamFGyYuIRIpIfiGKOkH206MsjS6oFlhLMRGYcGLOeM3W7sXiJQD7RReR5AFPMbD0Az8Lfnl7K7UnHTrK3Yxjb+eFizqeQqEuGaV3n1EyU7hONuDGaQMNdg0X3SJvDah0Fh1IIjMshHJYcHM9cCe1CSwEShwIitSKOSPkQ5MJ3RYwq114owv0NaTw1yAqKC78qqx2XmJLTt29/nri5oR7fumVobCGoGfGv3e4gSEXzCk4zKhFmWdVZuAcIKxSeNfgcf8n5tpHl+khhWbK3+71TBOh9wo+DlRrEay8WocH5doE6o7Bs/gEz7FWON8EqwZjQCgqXqIZ8pJpodniKxegUa/aOjkVF/+aoOmQZGiNXkhdx70bRJVKepLWEU++s502GAi+TM+mO+Myc+SPfdTjJMfoGuqmg2MvrH8zBrKEZDZjXPgQjrS+/Fhn15m0/Bv76otlkfcmj07UxR93MCmBhLon62+UJCVCLGkaKQ6fbPzvL+nt8Tj/s2VMERiy5JXB9ySezLeU0prEH8zOOq10XNmVT+/7k9T3ngl19t7iFWZwuphIKVYgoNkAjKMqZwcWtzN4J6MOVl1q/MZYSaDAAsmjrlPu86pbTSDpnjIP/G5fls1XljXnxaUeHExec+SrTAk2YdvhOThGJRhZOUWfQPHX8xQ="
13 | after_success: |
14 | [ $TRAVIS_RUST_VERSION = stable ] &&
15 | [ $TRAVIS_BRANCH = master ] &&
16 | [ $TRAVIS_PULL_REQUEST = false ] &&
17 | cargo doc &&
18 | echo "" > target/doc/index.html &&
19 | pip install ghp-import --user &&
20 | ~/.local/bin/ghp-import -n target/doc &&
21 | git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
22 |
--------------------------------------------------------------------------------
/src/lib.rs:
--------------------------------------------------------------------------------
1 | //! Convertor of JSON text into gron format
2 | //!
3 | //! Gron is a representation that is easy to grep. Similarly to JSON
4 | //! it can be easily evaluated with javascript interpreter.
5 | //!
6 | //! * [Original gron](https://github.com/tomnomnom/gron)
7 | //! * [Documentation](https://tailhook.github.io/rust-gron/)
8 | #![warn(missing_docs)]
9 |
10 | extern crate rustc_serialize;
11 | extern crate serde_json;
12 |
13 | mod for_rustc_serialize;
14 | mod for_serde;
15 |
16 | use std::io::{self, Write};
17 |
18 |
19 | /// An (internal) interface to gronify of json like data types
20 | ///
21 | /// You probably should not implement it yourself, it's here just to unify
22 | /// serde and rustc_serialize json structure.
23 | pub trait ToGron {
24 | /// Write gron style representation of `self` to `out` with `prefix` in
25 | /// front of.
26 | ///
27 | /// Returns `()` when write to `out` was successful.
28 | fn to_gron(&self, out: &mut W, prefix: &str) -> io::Result<()>;
29 | }
30 |
31 | /// Converts JSON structure from into gron format.
32 | ///
33 | /// It works both on `serde_json::Value` and on `rustc_serialize::json::Json`
34 | ///
35 | /// # Example
36 | ///
37 | /// ```
38 | /// extern crate gron;
39 | /// extern crate serde_json;
40 | ///
41 | /// use std::io::stdout;
42 | /// use serde_json::value::Value;
43 | /// use serde_json::de;
44 | /// use gron::json_to_gron;
45 | ///
46 | /// # fn main() {
47 | /// let json: Value = de::from_str(r#"{"x": [1,2]}"#).unwrap();
48 | /// json_to_gron(&mut stdout(), "val", &json);
49 | /// // Outputs to stdout:
50 | /// //
51 | /// // val = {}
52 | /// // val.x = []
53 | /// // val.x[0] = 1
54 | /// // val.x[1] = 2
55 | /// # }
56 | ///
57 | /// ```
58 | pub fn json_to_gron(out: &mut W, prefix: &str, json: &T)
59 | -> io::Result<()>
60 | {
61 | json.to_gron(out, prefix)
62 | }
63 |
64 |
65 | #[cfg(test)]
66 | mod test {
67 | use serde_json::de;
68 | use serde_json::value::Value;
69 |
70 | use rustc_serialize::json::Json;
71 |
72 | use ToGron;
73 |
74 | fn assert_equal(json_src: &str, gron: &str) {
75 | let mut serde_buf = Vec::new();
76 | let serde_json = &de::from_str::(json_src).unwrap();
77 | assert_eq!(serde_json.to_gron(&mut serde_buf, "json").is_ok(), true);
78 | assert_eq!(String::from_utf8(serde_buf).unwrap(), gron);
79 |
80 | let mut rustc_serialize_buf = Vec::new();
81 | let rustc_serialize_json = &Json::from_str(json_src).unwrap();
82 | assert_eq!(rustc_serialize_json.to_gron(&mut rustc_serialize_buf, "json").is_ok(), true);
83 | assert_eq!(String::from_utf8(rustc_serialize_buf).unwrap(), gron);
84 | }
85 |
86 | #[test]
87 | fn test_simple() {
88 | assert_equal(r#""x""#, "json = \"x\"\n");
89 | assert_equal(r#"1"#, "json = 1\n");
90 | assert_equal(r#"-1"#, "json = -1\n");
91 | assert_equal(r#"1.5"#, "json = 1.5\n");
92 | assert_equal(r#"null"#, "json = null\n");
93 | assert_equal(r#"true"#, "json = true\n");
94 | }
95 |
96 | #[test]
97 | fn test_map() {
98 | assert_equal(
99 | r#"{"x": 1, "y": 2}"#, "\
100 | json = {}\n\
101 | json.x = 1\n\
102 | json.y = 2\n");
103 | }
104 |
105 | #[test]
106 | fn test_vec() {
107 | assert_equal(
108 | r#"[1, 2, 3]"#, "\
109 | json = []\n\
110 | json[0] = 1\n\
111 | json[1] = 2\n\
112 | json[2] = 3\n\
113 | ");
114 | }
115 |
116 | #[test]
117 | fn test_obj_in_list() {
118 | assert_equal(
119 | r#"[1, {"x": 1, "y": 2}, 3]"#, "\
120 | json = []\n\
121 | json[0] = 1\n\
122 | json[1] = {}\n\
123 | json[1].x = 1\n\
124 | json[1].y = 2\n\
125 | json[2] = 3\n\
126 | ");
127 | }
128 |
129 | #[test]
130 | fn test_list_in_obj() {
131 | assert_equal(
132 | r#"{"a": 1, "x": [7, 8], "y": 2}"#, "\
133 | json = {}\n\
134 | json.a = 1\n\
135 | json.x = []\n\
136 | json.x[0] = 7\n\
137 | json.x[1] = 8\n\
138 | json.y = 2\n\
139 | ");
140 | }
141 | }
142 |
143 |
--------------------------------------------------------------------------------
/src/for_serde.rs:
--------------------------------------------------------------------------------
1 | use std::io::{self, Write};
2 | use std::iter::Enumerate;
3 | use serde_json::map::Iter as MapIter;
4 | use std::slice::Iter as VecIter;
5 |
6 | use serde_json::value::Value;
7 |
8 | use super::ToGron;
9 |
10 | enum StackItem<'a> {
11 | MapIter(MapIter<'a>),
12 | VecIter(Enumerate>),
13 | }
14 |
15 |
16 | impl ToGron for Value {
17 | fn to_gron(&self, out: &mut W, prefix: &str)
18 | -> io::Result<()>
19 | {
20 | use self::StackItem::*;
21 |
22 | let mut stack = Vec::with_capacity(8);
23 | let mut namebuf = String::with_capacity(100);
24 | namebuf.push_str(prefix);
25 | match *self {
26 | Value::Number(ref value) => try!(writeln!(out, "{} = {}", namebuf, value)),
27 | Value::String(ref value) => {
28 | try!(writeln!(out, "{} = {:?}", namebuf, value));
29 | }
30 | Value::Bool(value) => try!(writeln!(out, "{} = {}", namebuf, value)),
31 | Value::Array(ref vec) => {
32 | try!(writeln!(out, "{} = []", namebuf));
33 | stack.push((VecIter(vec.iter().enumerate()), namebuf.len()));
34 | }
35 | Value::Object(ref keys) => {
36 | try!(writeln!(out, "{} = {{}}", namebuf));
37 | stack.push((MapIter(keys.iter()), namebuf.len()));
38 | }
39 | Value::Null => try!(writeln!(out, "{} = null", namebuf)),
40 | }
41 | while stack.len() > 0 {
42 | let (kind, off) = stack.pop().unwrap();
43 | namebuf.truncate(off);
44 | match kind {
45 | MapIter(mut iter) => {
46 | let (key, json) = match iter.next() {
47 | Some((key, json)) => (key, json),
48 | None => continue,
49 | };
50 | stack.push((MapIter(iter), off));
51 | match *json {
52 | Value::Number(ref value) => {
53 | try!(writeln!(out, "{}.{} = {}",
54 | namebuf, key, value));
55 | }
56 | Value::String(ref value) => {
57 | try!(writeln!(out, "{}.{} = {:?}",
58 | namebuf, key, value));
59 | }
60 | Value::Bool(value) => {
61 | try!(writeln!(out, "{}.{} = {}",
62 | namebuf, key, value));
63 | }
64 | Value::Null => {
65 | try!(writeln!(out, "{}.{} = null",
66 | namebuf, key));
67 | }
68 | Value::Array(ref vec) => {
69 | namebuf.push('.');
70 | namebuf.push_str(key);
71 | try!(writeln!(out, "{} = []", namebuf));
72 | stack.push((
73 | VecIter(vec.iter().enumerate()),
74 | namebuf.len()));
75 | }
76 | Value::Object(ref keys) => {
77 | namebuf.push('.');
78 | namebuf.push_str(key);
79 | try!(writeln!(out, "{} = {{}}", namebuf));
80 | stack.push((MapIter(keys.iter()), namebuf.len()));
81 | }
82 | }
83 | }
84 | VecIter(mut iter) => {
85 | let (index, json) = match iter.next() {
86 | Some((index, json)) => (index, json),
87 | None => continue,
88 | };
89 | stack.push((VecIter(iter), off));
90 | match *json {
91 | Value::Number(ref value) => {
92 | try!(writeln!(out, "{}[{}] = {}",
93 | namebuf, index, value));
94 | }
95 | Value::String(ref value) => {
96 | try!(writeln!(out, "{}[{}] = {:?}",
97 | namebuf, index, value));
98 | }
99 | Value::Bool(value) => {
100 | try!(writeln!(out, "{}[{}] = {}",
101 | namebuf, index, value));
102 | }
103 | Value::Null => {
104 | try!(writeln!(out, "{}[{}] = null",
105 | namebuf, index));
106 | }
107 | Value::Array(ref vec) => {
108 | use std::fmt::Write;
109 | write!(&mut namebuf, "[{}]", index).unwrap();
110 | try!(writeln!(out, "{} = []", namebuf));
111 | stack.push((
112 | VecIter(vec.iter().enumerate()),
113 | namebuf.len()));
114 | }
115 | Value::Object(ref keys) => {
116 | use std::fmt::Write;
117 | write!(&mut namebuf, "[{}]", index).unwrap();
118 | try!(writeln!(out, "{} = {{}}", namebuf));
119 | stack.push((MapIter(keys.iter()), namebuf.len()));
120 | }
121 | }
122 | }
123 | }
124 | }
125 | Ok(())
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/src/for_rustc_serialize.rs:
--------------------------------------------------------------------------------
1 | use std::io::{self, Write};
2 | use std::iter::Enumerate;
3 | use std::collections::btree_map::Iter as MapIter;
4 | use std::slice::Iter as VecIter;
5 |
6 | use rustc_serialize::json::Json;
7 |
8 | use super::ToGron;
9 |
10 |
11 | enum StackItem<'a> {
12 | MapIter(MapIter<'a, String, Json>),
13 | VecIter(Enumerate>),
14 | }
15 |
16 |
17 | impl ToGron for Json {
18 | fn to_gron(&self, out: &mut W, prefix: &str)
19 | -> io::Result<()>
20 | {
21 | use self::StackItem::*;
22 |
23 | let mut stack = Vec::with_capacity(8);
24 | let mut namebuf = String::with_capacity(100);
25 | namebuf.push_str(prefix);
26 | match *self {
27 | Json::I64(value) => try!(writeln!(out, "{} = {}", namebuf, value)),
28 | Json::U64(value) => try!(writeln!(out, "{} = {}", namebuf, value)),
29 | Json::F64(value) => try!(writeln!(out, "{} = {}", namebuf, value)),
30 | Json::String(ref value) => {
31 | try!(writeln!(out, "{} = {:?}", namebuf, value));
32 | }
33 | Json::Boolean(value) => try!(writeln!(out, "{} = {}", namebuf, value)),
34 | Json::Array(ref vec) => {
35 | try!(writeln!(out, "{} = []", namebuf));
36 | stack.push((VecIter(vec.iter().enumerate()), namebuf.len()));
37 | }
38 | Json::Object(ref keys) => {
39 | try!(writeln!(out, "{} = {{}}", namebuf));
40 | stack.push((MapIter(keys.iter()), namebuf.len()));
41 | }
42 | Json::Null => try!(writeln!(out, "{} = null", namebuf)),
43 | }
44 | while stack.len() > 0 {
45 | let (kind, off) = stack.pop().unwrap();
46 | namebuf.truncate(off);
47 | match kind {
48 | MapIter(mut iter) => {
49 | let (key, json) = match iter.next() {
50 | Some((key, json)) => (key, json),
51 | None => continue,
52 | };
53 | stack.push((MapIter(iter), off));
54 | match *json {
55 | Json::I64(value) => {
56 | try!(writeln!(out, "{}.{} = {}",
57 | namebuf, key, value));
58 | }
59 | Json::U64(value) => {
60 | try!(writeln!(out, "{}.{} = {}",
61 | namebuf, key, value));
62 | }
63 | Json::F64(value) => {
64 | try!(writeln!(out, "{}.{} = {}",
65 | namebuf, key, value));
66 | }
67 | Json::String(ref value) => {
68 | try!(writeln!(out, "{}.{} = {:?}",
69 | namebuf, key, value));
70 | }
71 | Json::Boolean(value) => {
72 | try!(writeln!(out, "{}.{} = {}",
73 | namebuf, key, value));
74 | }
75 | Json::Null => {
76 | try!(writeln!(out, "{}.{} = null",
77 | namebuf, key));
78 | }
79 | Json::Array(ref vec) => {
80 | namebuf.push('.');
81 | namebuf.push_str(key);
82 | try!(writeln!(out, "{} = []", namebuf));
83 | stack.push((
84 | VecIter(vec.iter().enumerate()),
85 | namebuf.len()));
86 | }
87 | Json::Object(ref keys) => {
88 | namebuf.push('.');
89 | namebuf.push_str(key);
90 | try!(writeln!(out, "{} = {{}}", namebuf));
91 | stack.push((MapIter(keys.iter()), namebuf.len()));
92 | }
93 | }
94 | }
95 | VecIter(mut iter) => {
96 | let (index, json) = match iter.next() {
97 | Some((index, json)) => (index, json),
98 | None => continue,
99 | };
100 | stack.push((VecIter(iter), off));
101 | match *json {
102 | Json::I64(value) => {
103 | try!(writeln!(out, "{}[{}] = {}",
104 | namebuf, index, value));
105 | }
106 | Json::U64(value) => {
107 | try!(writeln!(out, "{}[{}] = {}",
108 | namebuf, index, value));
109 | }
110 | Json::F64(value) => {
111 | try!(writeln!(out, "{}[{}] = {}",
112 | namebuf, index, value));
113 | }
114 | Json::String(ref value) => {
115 | try!(writeln!(out, "{}[{}] = {:?}",
116 | namebuf, index, value));
117 | }
118 | Json::Boolean(value) => {
119 | try!(writeln!(out, "{}[{}] = {}",
120 | namebuf, index, value));
121 | }
122 | Json::Null => {
123 | try!(writeln!(out, "{}[{}] = null",
124 | namebuf, index));
125 | }
126 | Json::Array(ref vec) => {
127 | use std::fmt::Write;
128 | write!(&mut namebuf, "[{}]", index).unwrap();
129 | try!(writeln!(out, "{} = []", namebuf));
130 | stack.push((
131 | VecIter(vec.iter().enumerate()),
132 | namebuf.len()));
133 | }
134 | Json::Object(ref keys) => {
135 | use std::fmt::Write;
136 | write!(&mut namebuf, "[{}]", index).unwrap();
137 | try!(writeln!(out, "{} = {{}}", namebuf));
138 | stack.push((MapIter(keys.iter()), namebuf.len()));
139 | }
140 | }
141 | }
142 | }
143 | }
144 | Ok(())
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/LICENSE-APACHE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------