├── .gitignore ├── .travis.yml ├── examples └── simple_job.rs ├── Cargo.toml ├── LICENSE-MIT ├── CONTRIBUTING.md ├── README.md ├── src └── lib.rs └── LICENSE-APACHE /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | rust: 3 | - stable 4 | script: 5 | - cargo build 6 | - cargo test 7 | - cargo doc 8 | -------------------------------------------------------------------------------- /examples/simple_job.rs: -------------------------------------------------------------------------------- 1 | extern crate job_scheduler; 2 | 3 | use job_scheduler::{Job, JobScheduler}; 4 | use std::time::Duration; 5 | 6 | fn main() { 7 | let mut sched = JobScheduler::new(); 8 | 9 | sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || { 10 | println!("I get executed every 10 seconds!"); 11 | })); 12 | 13 | loop { 14 | sched.tick(); 15 | 16 | std::thread::sleep(Duration::from_millis(500)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "job_scheduler" 3 | version = "1.2.1" 4 | authors = ["Lori Holden "] 5 | description = "A simple cron-like job scheduling library for Rust." 6 | 7 | documentation = "https://docs.rs/job_scheduler/" 8 | repository = "https://github.com/lholden/job_scheduler" 9 | 10 | license = "MIT/Apache-2.0" 11 | 12 | readme = "README.md" 13 | keywords = ["cron", "crontab", "scheduler", "job"] 14 | 15 | categories = ["date-and-time"] 16 | 17 | [dependencies] 18 | cron = "~0.6" 19 | chrono = "~0.4" 20 | uuid = { version = "0.8", features = ["v4"] } 21 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Lori Holden 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to JobScheduler 2 | 3 | We welcome contribution from everyone. Here are the guidelines if you are 4 | thinking of helping us: 5 | 6 | ## Contributions 7 | 8 | Contributions to JobScheduler should be made in the form of GitHub pull 9 | requests. Each pull request will be reviewed and either landed in the main 10 | tree or given feedback for changes that would be required. All contributions 11 | should follow this format. 12 | 13 | Should you wish to work on an issue, please claim it first by commenting on 14 | the GitHub issue that you want to work on it. This is to prevent duplicated 15 | efforts from contributors on the same issue. 16 | 17 | Unless you explicitly state otherwise, any contribution intentionally 18 | submitted for inclusion in JobScheduler by you, as defined in the Apache-2.0 19 | license, shall be dual licensed as MIT/Apache-2.0, without any additional 20 | terms or conditions. 21 | 22 | ## Pull Request Checklist 23 | 24 | - Branch from the master branch and, if needed, rebase to the current master 25 | branch before submitting your pull request. If it doesn't merge cleanly with 26 | master you may be asked to rebase your changes. 27 | 28 | - Commits should be as small as possible, while ensuring that each commit is 29 | correct independently (i.e., each commit should compile and pass tests). 30 | 31 | - If your patch is not getting reviewed or you need a specific person to review 32 | it, you can @-reply a reviewer asking for a review in the pull request or a 33 | comment. 34 | 35 | - Add tests relevant to the fixed bug or new feature. 36 | 37 | ## Conduct 38 | 39 | We follow the [Rust Code of Conduct](https://www.rust-lang.org/conduct.html). 40 | For escalation or moderation issues, please contact Lori (git at loriholden dot 41 | com) instead of the Rust moderation team. 42 | 43 | ## Communication 44 | 45 | Beyond opening tickets on the 46 | [job_scheduler](https://github.com/lholden/job_scheduler) project, I can be 47 | found as `lholden` on [`irc.mozilla.org`](https://wiki.mozilla.org/IRC) and I 48 | frequent the `#rust` channel. 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **NO LONGER MAINTAINED** 2 | 3 | The project I created this crate for is no longer in use, so I haven't really had the time to keep on top of keeping things up to date. I recommend looking at other options if you need the functionality this project provides. 4 | 5 | [If someone would like to take over the project, please let me know.](https://github.com/lholden/job_scheduler/discussions/30) 6 | 7 | # JobScheduler 8 | [![](https://docs.rs/job_scheduler/badge.svg)](https://docs.rs/job_scheduler) [![](https://img.shields.io/crates/v/job_scheduler.svg)](https://crates.io/crates/job_scheduler) [![](https://travis-ci.org/lholden/job_scheduler.svg?branch=master)](https://travis-ci.org/lholden/job_scheduler) 9 | 10 | A simple cron-like job scheduling library for Rust. 11 | 12 | ## Usage 13 | 14 | Please see the [Documentation](https://docs.rs/job_scheduler/) for more details. 15 | 16 | Be sure to add the job_scheduler crate to your `Cargo.toml`: 17 | 18 | ```toml 19 | [dependencies] 20 | job_scheduler = "*" 21 | ``` 22 | 23 | Creating a schedule for a job is done using the `FromStr` impl for the 24 | `Schedule` type of the [cron](https://github.com/zslayton/cron) library. 25 | 26 | The scheduling format is as follows: 27 | 28 | ```text 29 | sec min hour day of month month day of week year 30 | * * * * * * * 31 | ``` 32 | 33 | Time is specified for `UTC` and not your local timezone. Note that the year may 34 | be omitted. 35 | 36 | Comma separated values such as `5,8,10` represent more than one time value. So 37 | for example, a schedule of `0 2,14,26 * * * *` would execute on the 2nd, 14th, 38 | and 26th minute of every hour. 39 | 40 | Ranges can be specified with a dash. A schedule of `0 0 * 5-10 * *` would 41 | execute once per hour but only on day 5 through 10 of the month. 42 | 43 | Day of the week can be specified as an abbreviation or the full name. A 44 | schedule of `0 0 6 * * Sun,Sat` would execute at 6am on Sunday and Saturday. 45 | 46 | A simple usage example: 47 | 48 | ```rust 49 | extern crate job_scheduler; 50 | use job_scheduler::{JobScheduler, Job}; 51 | use std::time::Duration; 52 | 53 | fn main() { 54 | let mut sched = JobScheduler::new(); 55 | 56 | sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || { 57 | println!("I get executed every 10 seconds!"); 58 | })); 59 | 60 | loop { 61 | sched.tick(); 62 | 63 | std::thread::sleep(Duration::from_millis(500)); 64 | } 65 | } 66 | ``` 67 | 68 | ## Similar Libraries 69 | 70 | * [cron](https://github.com/zslayton/cron) the cron expression parser we use. 71 | * [schedule-rs](https://github.com/mehcode/schedule-rs) is a similar rust library that implements it's own cron expression parser. 72 | 73 | ## License 74 | 75 | JobScheduler is licensed under either of 76 | 77 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or 78 | http://www.apache.org/licenses/LICENSE-2.0) 79 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or 80 | http://opensource.org/licenses/MIT) 81 | 82 | ## Contributing 83 | 84 | Unless you explicitly state otherwise, any contribution intentionally submitted 85 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall 86 | be dual licensed as above, without any additional terms or conditions. 87 | 88 | Please see the [CONTRIBUTING](CONTRIBUTING.md) file for more information. 89 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # JobScheduler 2 | //! 3 | //! A simple cron-like job scheduling library for Rust. 4 | //! 5 | //! ## Usage 6 | //! 7 | //! Be sure to add the job_scheduler crate to your `Cargo.toml`: 8 | //! 9 | //! ```toml 10 | //! [dependencies] 11 | //! job_scheduler = "*" 12 | //! ``` 13 | //! 14 | //! Creating a schedule for a job is done using the `FromStr` impl for the 15 | //! `Schedule` type of the [cron](https://github.com/zslayton/cron) library. 16 | //! 17 | //! The scheduling format is as follows: 18 | //! 19 | //! ```text 20 | //! sec min hour day of month month day of week year 21 | //! * * * * * * * 22 | //! ``` 23 | //! 24 | //! Note that the year may be omitted. 25 | //! 26 | //! Comma separated values such as `5,8,10` represent more than one time 27 | //! value. So for example, a schedule of `0 2,14,26 * * * *` would execute 28 | //! on the 2nd, 14th, and 26th minute of every hour. 29 | //! 30 | //! Ranges can be specified with a dash. A schedule of `0 0 * 5-10 * *` 31 | //! would execute once per hour but only on day 5 through 10 of the month. 32 | //! 33 | //! Day of the week can be specified as an abbreviation or the full name. 34 | //! A schedule of `0 0 6 * * Sun,Sat` would execute at 6am on Sunday and 35 | //! Saturday. 36 | //! 37 | //! A simple usage example: 38 | //! 39 | //! ```rust,ignore 40 | //! extern crate job_scheduler; 41 | //! use job_scheduler::{JobScheduler, Job}; 42 | //! use std::time::Duration; 43 | //! 44 | //! fn main() { 45 | //! let mut sched = JobScheduler::new(); 46 | //! 47 | //! sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || { 48 | //! println!("I get executed every 10 seconds!"); 49 | //! })); 50 | //! 51 | //! loop { 52 | //! sched.tick(); 53 | //! 54 | //! std::thread::sleep(Duration::from_millis(500)); 55 | //! } 56 | //! } 57 | //! ``` 58 | 59 | extern crate chrono; 60 | extern crate cron; 61 | extern crate uuid; 62 | 63 | use chrono::{offset, DateTime, Duration, Utc}; 64 | pub use cron::Schedule; 65 | pub use uuid::Uuid; 66 | 67 | /// A schedulable `Job`. 68 | pub struct Job<'a> { 69 | schedule: Schedule, 70 | run: Box<(FnMut() -> ()) + 'a>, 71 | last_tick: Option>, 72 | limit_missed_runs: usize, 73 | job_id: Uuid, 74 | } 75 | 76 | impl<'a> Job<'a> { 77 | /// Create a new job. 78 | /// 79 | /// ```rust,ignore 80 | /// // Run at second 0 of the 15th minute of the 6th, 8th, and 10th hour 81 | /// // of any day in March and June that is a Friday of the year 2017. 82 | /// let s: Schedule = "0 15 6,8,10 * Mar,Jun Fri 2017".into().unwrap(); 83 | /// Job::new(s, || println!("I have a complex schedule...") ); 84 | /// ``` 85 | pub fn new(schedule: Schedule, run: T) -> Job<'a> 86 | where 87 | T: 'a, 88 | T: FnMut() -> (), 89 | { 90 | Job { 91 | schedule, 92 | run: Box::new(run), 93 | last_tick: None, 94 | limit_missed_runs: 1, 95 | job_id: Uuid::new_v4(), 96 | } 97 | } 98 | 99 | fn tick(&mut self) { 100 | let now = Utc::now(); 101 | if self.last_tick.is_none() { 102 | self.last_tick = Some(now); 103 | return; 104 | } 105 | if self.limit_missed_runs > 0 { 106 | for event in self 107 | .schedule 108 | .after(&self.last_tick.unwrap()) 109 | .take(self.limit_missed_runs) 110 | { 111 | if event > now { 112 | break; 113 | } 114 | (self.run)(); 115 | } 116 | } else { 117 | for event in self.schedule.after(&self.last_tick.unwrap()) { 118 | if event > now { 119 | break; 120 | } 121 | (self.run)(); 122 | } 123 | } 124 | 125 | self.last_tick = Some(now); 126 | } 127 | 128 | /// Set the limit for missed jobs in the case of delayed runs. Setting to 0 means unlimited. 129 | /// 130 | /// ```rust,ignore 131 | /// let mut job = Job::new("0/1 * * * * *".parse().unwrap(), || { 132 | /// println!("I get executed every 1 seconds!"); 133 | /// }); 134 | /// job.limit_missed_runs(99); 135 | /// ``` 136 | pub fn limit_missed_runs(&mut self, limit: usize) { 137 | self.limit_missed_runs = limit; 138 | } 139 | 140 | /// Set last tick to force re-running of missed runs. 141 | /// 142 | /// ```rust,ignore 143 | /// let mut job = Job::new("0/1 * * * * *".parse().unwrap(), || { 144 | /// println!("I get executed every 1 seconds!"); 145 | /// }); 146 | /// job.last_tick(Some(Utc::now())); 147 | /// ``` 148 | pub fn last_tick(&mut self, last_tick: Option>) { 149 | self.last_tick = last_tick; 150 | } 151 | } 152 | 153 | #[derive(Default)] 154 | /// The JobScheduler contains and executes the scheduled jobs. 155 | pub struct JobScheduler<'a> { 156 | jobs: Vec>, 157 | } 158 | 159 | impl<'a> JobScheduler<'a> { 160 | /// Create a new `JobScheduler`. 161 | pub fn new() -> JobScheduler<'a> { 162 | JobScheduler { jobs: Vec::new() } 163 | } 164 | 165 | /// Add a job to the `JobScheduler` 166 | /// 167 | /// ```rust,ignore 168 | /// let mut sched = JobScheduler::new(); 169 | /// sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || { 170 | /// println!("I get executed every 10 seconds!"); 171 | /// })); 172 | /// ``` 173 | pub fn add(&mut self, job: Job<'a>) -> Uuid { 174 | let job_id = job.job_id; 175 | self.jobs.push(job); 176 | 177 | job_id 178 | } 179 | 180 | /// Remove a job from the `JobScheduler` 181 | /// 182 | /// ```rust,ignore 183 | /// let mut sched = JobScheduler::new(); 184 | /// let job_id = sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || { 185 | /// println!("I get executed every 10 seconds!"); 186 | /// })); 187 | /// sched.remove(job_id); 188 | /// ``` 189 | pub fn remove(&mut self, job_id: Uuid) -> bool { 190 | let mut found_index = None; 191 | for (i, job) in self.jobs.iter().enumerate() { 192 | if job.job_id == job_id { 193 | found_index = Some(i); 194 | break; 195 | } 196 | } 197 | 198 | if found_index.is_some() { 199 | self.jobs.remove(found_index.unwrap()); 200 | } 201 | 202 | found_index.is_some() 203 | } 204 | 205 | /// The `tick` method increments time for the JobScheduler and executes 206 | /// any pending jobs. It is recommended to sleep for at least 500 207 | /// milliseconds between invocations of this method. 208 | /// 209 | /// ```rust,ignore 210 | /// loop { 211 | /// sched.tick(); 212 | /// std::thread::sleep(Duration::from_millis(500)); 213 | /// } 214 | /// ``` 215 | pub fn tick(&mut self) { 216 | for mut job in &mut self.jobs { 217 | job.tick(); 218 | } 219 | } 220 | 221 | /// The `time_till_next_job` method returns the duration till the next job 222 | /// is supposed to run. This can be used to sleep until then without waking 223 | /// up at a fixed interval.AsMut 224 | /// 225 | /// ```rust, ignore 226 | /// loop { 227 | /// sched.tick(); 228 | /// std::thread::sleep(sched.time_till_next_job()); 229 | /// } 230 | /// ``` 231 | pub fn time_till_next_job(&self) -> std::time::Duration { 232 | if self.jobs.is_empty() { 233 | // Take a guess if there are no jobs. 234 | return std::time::Duration::from_millis(500); 235 | } 236 | let mut duration = Duration::zero(); 237 | let now = Utc::now(); 238 | for job in self.jobs.iter() { 239 | for event in job.schedule.upcoming(offset::Utc).take(1) { 240 | let d = event - now; 241 | if duration.is_zero() || d < duration { 242 | duration = d; 243 | } 244 | } 245 | } 246 | duration.to_std().unwrap() 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /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 2017 Lori Holden 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 | --------------------------------------------------------------------------------