diff --git a/.gitignore b/.gitignore index bdcfb9f..8807532 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ -target/ -TAGS -doc/ +/target/ +/doc/ +/Cargo.lock +*~ +*.swp diff --git a/.travis.yml b/.travis.yml index 0593e64..d21e35b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,16 @@ +language: rust env: global: - secure: OQR++Fdd4QL2qSCTChrWHyBQDwWAfcbupveh+c7EEZO6Gb+8OMEQLKX50rr9MzLvr64BTbFBS9yJEBAcyQUxQFJRM0qfJlT6dkkm2Kfp+FagIOQmz9f7PQhf/NNPyR0RxxkpEkd4OeQUy8bcPq0xhBV9WzviZo8fh7WLoeejfaU= -before_install: - - wget http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz - - tar xf rust-nightly-x86_64-unknown-linux-gnu.tar.gz -install: - - sudo ./rust-nightly-x86_64-unknown-linux-gnu/install.sh - - rustc -v +os: + - osx + - linux script: - - make examples - - make check -after_script: - - curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh + - cargo build + - cargo test + - cargo doc +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + cd target/doc && + (curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh) diff --git a/Cargo.toml b/Cargo.toml index a22b6ef..d58ff7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,11 @@ [package] -name = "rust-smtp" -version = "0.0.1" +name = "smtp" +version = "0.0.1-pre" #readme = "README.md" -authors = [ "Alexis Mousset " ] +authors = ["Alexis Mousset "] #tags = ["smtp", "email", "library"] -[[lib]] +[lib] name = "smtpcommon" -path = "src/smtpcommon/lib.rs" - -#[[lib]] -#name = "smtpc" -#path = "src/smtpc/lib.rs" - +path = "src/lib.rs" diff --git a/README.md b/README.md index f34f0e6..9b1d632 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,15 @@ Rust SMTP library .. image:: https://travis-ci.org/amousset/rust-smtp.png?branch=master :target: https://travis-ci.org/amousset/rust-smtp -This library implements an SMTP client, and maybe later a simple SMTP server. +This library implements an SMTP library and a simple client. Rust versions ------------- -This library is designed for Rust 0.11.0-nightly (master). +This library is designed for Rust 0.13.0-nightly (master). Install ------- +------- Use Cargo to build this library. diff --git a/src/smtpcommon/lib.rs b/src/lib.rs similarity index 83% rename from src/smtpcommon/lib.rs rename to src/lib.rs index 6c17c6d..0041f71 100644 --- a/src/smtpcommon/lib.rs +++ b/src/lib.rs @@ -27,7 +27,7 @@ //! //! ## Usage //! -//! ```rust +//! ```tmp //! extern crate smtp; //! use std::io::net::tcp::TcpStream; //! use smtp::client::SmtpClient; @@ -46,9 +46,9 @@ #![crate_type = "dylib"] #![desc = "Rust SMTP library"] -#![comment = "Simple and modern SMTP library"] +#![comment = "Simple SMTP client and library"] #![license = "MIT/ASL2"] -#![doc(html_root_url = "http://amousset.github.io/rust-smtp/smtpcommon/")] +#![doc(html_root_url = "http://www.rust-ci.org/amousset/rust-smtp/doc")] #![feature(macro_rules)] #![feature(phase)] @@ -59,8 +59,15 @@ #![deny(unnecessary_typecast)] #![deny(unused_result)] -pub mod common; -pub mod command; -pub mod extension; -pub mod response; -pub mod transaction; +#![feature(phase)] #[phase(plugin, link)] extern crate log; + +pub mod smtpcommon; +//pub mod smtpc; + +//pub mod client; +//pub mod connecter; +//pub mod common; +//pub mod command; +//pub mod extension; +//pub mod response; +//pub mod transaction; diff --git a/src/smtpc/lib.rs b/src/smtpc/lib.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/smtpcommon/command.rs b/src/smtpcommon/command.rs index 2ae100a..328b9c8 100644 --- a/src/smtpcommon/command.rs +++ b/src/smtpcommon/command.rs @@ -80,7 +80,7 @@ impl Show for SmtpCommand { #[cfg(test)] mod test { - use command; + use smtpcommon::command; #[test] fn test_command_fmt() { diff --git a/src/smtpcommon/common.rs b/src/smtpcommon/common.rs index 16e7a43..cc5f22e 100644 --- a/src/smtpcommon/common.rs +++ b/src/smtpcommon/common.rs @@ -28,7 +28,7 @@ pub static CRLF: &'static str = "\r\n"; /// Adds quotes to emails if needed pub fn quote_email_address(address: String) -> String { match address.len() { - 0..1 => format!("<{:s}>", address), + 0 ... 1 => format!("<{:s}>", address), _ => match (address.as_slice().slice_to(1), address.as_slice().slice_from(address.len() - 1)) { ("<", ">") => address, _ => format!("<{:s}>", address) @@ -39,7 +39,7 @@ pub fn quote_email_address(address: String) -> String { /// Removes quotes from emails if needed pub fn unquote_email_address(address: String) -> String { match address.len() { - 0..1 => address, + 0 ... 1 => address, _ => match (address.as_slice().slice_to(1), address.as_slice().slice_from(address.len() - 1)) { ("<", ">") => address.as_slice().slice(1, address.len() - 1).to_string(), _ => address @@ -60,7 +60,7 @@ pub fn remove_trailing_crlf(string: String) -> String { /// Returns the first word of a string, or the string if it contains no space pub fn get_first_word(string: String) -> String { - string.as_slice().split_str(CRLF).next().unwrap().splitn(' ', 1).next().unwrap().to_string() + string.as_slice().split_str(CRLF).next().unwrap().splitn(1, ' ').next().unwrap().to_string() } #[cfg(test)] diff --git a/src/smtpcommon/extension.rs b/src/smtpcommon/extension.rs index f872c63..ef88bc4 100644 --- a/src/smtpcommon/extension.rs +++ b/src/smtpcommon/extension.rs @@ -43,14 +43,14 @@ impl Show for SmtpExtension { impl FromStr for SmtpExtension { fn from_str(s: &str) -> Option { - let splitted : Vec<&str> = s.splitn(' ', 1).collect(); + let splitted : Vec<&str> = s.splitn(1, ' ').collect(); match splitted.len() { - 1 => match *splitted.get(0) { + 1 => match splitted[0] { "8BITMIME" => Some(EightBitMime), "SMTPUTF8" => Some(SmtpUtfEight), _ => None }, - 2 => match (*splitted.get(0), from_str::(*splitted.get(1))) { + 2 => match (splitted[0], from_str::(splitted[1])) { ("SIZE", Some(size)) => Some(Size(size)), _ => None }, @@ -74,8 +74,8 @@ impl SmtpExtension { #[cfg(test)] mod test { - use extension; - use extension::SmtpExtension; + use smtpcommon::extension; + use smtpcommon::extension::SmtpExtension; #[test] fn test_extension_same_extension_as() { diff --git a/src/smtpcommon/mod.rs b/src/smtpcommon/mod.rs new file mode 100644 index 0000000..5f2cea6 --- /dev/null +++ b/src/smtpcommon/mod.rs @@ -0,0 +1,7 @@ +//! SMTP library + +pub mod common; +pub mod command; +pub mod extension; +pub mod response; +pub mod transaction; diff --git a/src/smtpcommon/response.rs b/src/smtpcommon/response.rs index bfc3b78..6262b8a 100644 --- a/src/smtpcommon/response.rs +++ b/src/smtpcommon/response.rs @@ -9,9 +9,11 @@ //! SMTP responses, contaiing a mandatory return code, and an optional text message +//extern crate common; + use std::from_str::FromStr; use std::fmt::{Show, Formatter, Result}; -use common::remove_trailing_crlf; +use smtpcommon::common::remove_trailing_crlf; use std::result; /// Contains an SMTP reply, with separed code and message @@ -84,7 +86,7 @@ impl SmtpResponse { #[cfg(test)] mod test { - use response::SmtpResponse; + use smtpcommon::response::SmtpResponse; #[test] fn test_response_fmt() { diff --git a/src/smtpcommon/transaction.rs b/src/smtpcommon/transaction.rs index 503011c..9ba949d 100644 --- a/src/smtpcommon/transaction.rs +++ b/src/smtpcommon/transaction.rs @@ -11,8 +11,8 @@ use std::fmt; use std::fmt::{Show, Formatter}; -use command; -use command::SmtpCommand; +use smtpcommon::command; +use smtpcommon::command::SmtpCommand; /// Contains the state of the current transaction #[deriving(PartialEq,Eq,Clone)] @@ -102,7 +102,7 @@ impl TransactionState { #[cfg(test)] mod test { - use command; + use smtpcommon::command; #[test] fn test_transaction_state_is_command_possible() {