summaryrefslogtreecommitdiffstats
path: root/svgbob
diff options
context:
space:
mode:
authorJovansonlee Cesar <ivanceras@gmail.com>2018-05-22 21:27:35 +0800
committerJovansonlee Cesar <ivanceras@gmail.com>2018-05-22 21:27:35 +0800
commitc641d32f82b416a5ad52b9a4e6f4367c556580d5 (patch)
tree4ebb6e0dc05e9c38f50cd1ab45273a12a4247f5e /svgbob
parent977d3d9243f80f2a03559e819897d0615696e1e5 (diff)
Fix tests, remove warnings
Diffstat (limited to 'svgbob')
-rw-r--r--svgbob/Cargo.lock26
-rw-r--r--svgbob/Cargo.toml2
-rw-r--r--svgbob/src/box_drawing.rs2
-rw-r--r--svgbob/src/enhance.rs4
-rw-r--r--svgbob/src/enhance_circles.rs2
-rw-r--r--svgbob/src/lib.rs188
-rw-r--r--svgbob/src/optimizer.rs4
-rw-r--r--svgbob/src/patterns.rs17
8 files changed, 57 insertions, 188 deletions
diff --git a/svgbob/Cargo.lock b/svgbob/Cargo.lock
index ef398c5..7d17391 100644
--- a/svgbob/Cargo.lock
+++ b/svgbob/Cargo.lock
@@ -1,11 +1,11 @@
[[package]]
name = "cc"
-version = "1.0.4"
+version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
-version = "0.1.2"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -26,7 +26,7 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.37"
+version = "0.2.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -42,7 +42,7 @@ name = "log"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -80,14 +80,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "svgbob"
-version = "0.2.6"
+version = "0.2.7"
dependencies = [
"handlebars 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pom 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"svg 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"sys-info 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -95,21 +95,21 @@ name = "sys-info"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-width"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
-"checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0"
-"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
+"checksum cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebb87d1116151416c0cf66a0e3fb6430cccd120fd6300794b4dfaa050ac40ba"
+"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18"
"checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8"
"checksum handlebars 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "937e9d49d65ffb5f70e95710a6c8539addf40200275ad8b6cdba0f0a59d5814d"
-"checksum libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "56aebce561378d99a0bb578f8cb15b6114d2a1814a6c7949bbe646d968bb4fa9"
+"checksum libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)" = "ac8ebf8343a981e2fa97042b14768f02ed3e1d602eac06cae6166df3c8ced206"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
"checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8"
@@ -119,4 +119,4 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum svg 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce4450d6982b758228fa5407db2fc27cefccb013c170ade23c03ec3a643bb72"
"checksum sys-info 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "617f594d3869801871433390254b4a79f2a18176d7f4ad5784fa990bc8c12986"
-"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
+"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
diff --git a/svgbob/Cargo.toml b/svgbob/Cargo.toml
index acfb809..9eadfaa 100644
--- a/svgbob/Cargo.toml
+++ b/svgbob/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "svgbob"
-version = "0.2.6"
+version = "0.2.7"
authors = ["Jovansonlee Cesar <ivanceras@gmail.com>"]
description = "Transform your ascii diagrams into happy little SVG"
repository = "https://github.com/ivanceras/svgbobrus"
diff --git a/svgbob/src/box_drawing.rs b/svgbob/src/box_drawing.rs
index b63df19..5a8e782 100644
--- a/svgbob/src/box_drawing.rs
+++ b/svgbob/src/box_drawing.rs
@@ -4,8 +4,8 @@ use fragments::Block::{A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S,
use fragments::Fragment;
use fragments::{arc, line};
-use properties::Properties;
use properties::PointBlock;
+use properties::Properties;
pub fn box_drawing(ch: &char) -> (Vec<Block>, Vec<Fragment>) {
let a = &PointBlock::block(A);
diff --git a/svgbob/src/enhance.rs b/svgbob/src/enhance.rs
index 08312ed..bba89d0 100644
--- a/svgbob/src/enhance.rs
+++ b/svgbob/src/enhance.rs
@@ -1,7 +1,7 @@
use fragments::Block::{A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y};
+use patterns::FocusChar;
use properties::Location;
use properties::PointBlock;
-use patterns::FocusChar;
use fragments::Fragment;
use fragments::{arc, line};
@@ -25,8 +25,8 @@ impl<'g> Enhance for FocusChar<'g> {
/// based on the surrounding neighbors
/// returns the fragments, consumed location
fn enhance(&self) -> (Vec<Fragment>, Vec<Location>) {
- use fragments::Direction::*;
use fragments;
+ use fragments::Direction::*;
let a = &PointBlock::block(A);
let _b = &PointBlock::block(B);
let c = &PointBlock::block(C);
diff --git a/svgbob/src/enhance_circles.rs b/svgbob/src/enhance_circles.rs
index 2e8aa13..8427a88 100644
--- a/svgbob/src/enhance_circles.rs
+++ b/svgbob/src/enhance_circles.rs
@@ -1,7 +1,7 @@
use fragments::Block::{A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y};
+use patterns::FocusChar;
use properties::Location;
use properties::PointBlock;
-use patterns::FocusChar;
use fragments::Fragment;
use fragments::{arc, line, open_circle};
diff --git a/svgbob/src/lib.rs b/svgbob/src/lib.rs
index 4aaffe5..9ef8b95 100644
--- a/svgbob/src/lib.rs
+++ b/svgbob/src/lib.rs
@@ -37,41 +37,41 @@ extern crate pretty_assertions;
extern crate svg;
extern crate unicode_width;
-use pom::TextInput;
use pom::parser::*;
+use pom::TextInput;
-use svg::Node;
-use svg::node::element::Circle as SvgCircle;
-use svg::node::element::Path as SvgPath;
-use svg::node::element::Line as SvgLine;
-use svg::node::element::Text as SvgText;
-use svg::node::element::Rectangle as SvgRect;
-use svg::node::element::Style;
-use svg::node::element::SVG;
-use svg::node::element::Definitions;
-use svg::node::element::Marker;
-use optimizer::Optimizer;
use self::Feature::Arrow;
use self::Feature::Circle;
use self::Feature::Nothing;
-use self::Stroke::Solid;
use self::Stroke::Dashed;
-use unicode_width::UnicodeWidthStr;
-use unicode_width::UnicodeWidthChar;
+use self::Stroke::Solid;
+use fragments::Direction::{Bottom, BottomLeft, BottomRight, Left, Right, Top, TopLeft, TopRight};
+use optimizer::Optimizer;
use patterns::FocusChar;
use properties::Location;
-use fragments::Direction::{Bottom, BottomLeft, BottomRight, Left, Right, Top, TopLeft, TopRight};
+use svg::node::element::Circle as SvgCircle;
+use svg::node::element::Definitions;
+use svg::node::element::Line as SvgLine;
+use svg::node::element::Marker;
+use svg::node::element::Path as SvgPath;
+use svg::node::element::Rectangle as SvgRect;
+use svg::node::element::Style;
+use svg::node::element::Text as SvgText;
+use svg::node::element::SVG;
+use svg::Node;
+use unicode_width::UnicodeWidthChar;
+use unicode_width::UnicodeWidthStr;
use ArcFlag::{Major, Minor};
mod optimizer;
mod patterns;
-mod fragments;
-mod properties;
mod box_drawing;
mod enhance;
mod enhance_circles;
+mod fragments;
+mod properties;
/// generate an SVG from the ascii text input
///
@@ -1007,7 +1007,7 @@ fn svg_escape(arg: &str) -> String {
#[test]
fn test_escaped_string() {
- let mut input3 = r#"The "qu/i/ck" brown "fox\"s" jumps over the lazy "do|g""#;
+ let input3 = r#"The "qu/i/ck" brown "fox\"s" jumps over the lazy "do|g""#;
let mut raw3 = TextInput::new(input3);
let output3 = line_parse().parse(&mut raw3);
println!("output3: {:?}", output3);
@@ -1036,7 +1036,7 @@ fn test_escaped_string() {
#[test]
fn test_escaped_multiline_string() {
- let mut input3 = r#"The "qu/i/ck brown fox \njumps over the lazy do|g""#;
+ let input3 = r#"The "qu/i/ck brown fox \njumps over the lazy do|g""#;
let mut raw3 = TextInput::new(input3);
let output3 = line_parse().parse(&mut raw3);
println!("output3: {:?}", output3);
@@ -1080,8 +1080,8 @@ fn line_parse() -> pom::parser::Parser<'static, char, Vec<(usize, usize)>> {
#[cfg(test)]
mod test_lib {
use super::Grid;
- use super::Settings;
use super::Loc;
+ use super::Settings;
#[test]
fn test_grid() {
@@ -1089,15 +1089,13 @@ mod test_lib {
println!("{:?}", g.index);
assert_eq!(
g.index,
- vec![
- vec![
- "a".to_string(),
- "统".to_string(),
- "\u{0}".to_string(),
- "ö".to_string(),
- "o͡͡͡".to_string(),
- ],
- ]
+ vec![vec![
+ "a".to_string(),
+ "统".to_string(),
+ "\u{0}".to_string(),
+ "ö".to_string(),
+ "o͡͡͡".to_string(),
+ ]]
);
}
@@ -1215,133 +1213,3 @@ uvwxyz1234
}
}
-
-#[cfg(test)]
-mod benchmark {
- extern crate test;
- use self::test::Bencher;
-
- #[bench]
- fn convert(b: &mut Bencher) {
- b.iter(|| super::to_svg(&get_str()))
- }
-
- fn get_str() -> String {
- r#"
-Svgbob is a diagramming model
-which uses a set of typing characters
-to approximate the desired shape.
-
- .---.
- /-o-/--
- .-/ / /->
- ( * \/
- '-. \
- \ /
- '
-It uses a combination of this characters "`[(/<^.|+v*>\)]'"
-
-It can do basic shapes such as:
- ,
- +------+ .------. .------. /\ ,' `.
- | | | | ( ) / \ .' `.
- +------+ '------' '------' '----' `. ,'
- _______ ________ `.'
- / \ /\ \ \
- / \ / \ ) )
- \ / \ / /_______/
- \_______/ \/
-
- .-----------. . <. .> .
- ( ) ( ) ( )
- '-----+ ,---' `> ' ` <'
- |/
-
-
-Quick logo scribbles
- .---. _
- /-o-/-- .--. | | .--. |\
- .-/ / /-> /--. \ .--(-| .----. //.-.\ | \..-.
- ( * \/ / o )| | | | |-> | (+(-*-)) \(( )
- '-. \ /\ |-// . * | '----' \\'-'/ \ '+'
- \ / \ '+'/ \__/ '--' '-'
- ' '--'
-
-Even unicode box drawing characters are supported
- ┌─┬┐ ╔═╦╗ ╓─╥╖ ╒═╤╕
- ├─┼┤ ╠═╬╣ ╟─╫╢ ╞═╪╡
- └─┴┘ ╚═╩╝ ╙─╨╜ ╘═╧╛
-
-Mindmaps
-
- .--> Alpha
- /
- .----> Initial Release
- Planning -------. / \
- \ / '---> Patch 1
- Initial research \ / \
- \ \ / '--> Patch 2
- \ \ /
- \ \ .-----------> Beta
- \ \ /
- \ .---.
- '------ ( )
- `---'
- / \ \ \
- / \ \ \
- .--' \ \ \
- / \ \ '--- Push backs
- . \ \ \
- /| \ \ '----> Setbacks
- Team __/ . \ \
- /| \ '-----> Reception
- Workload __/ . \
- /| \
- Holiday __/ . '--- Career change
- /
- V
- Bugs
-
-
-It can do complex stuff such as circuit diagrams
-
-
- +10-15V ___0,047R
- *------o------o-|___|-o--o---------o----o-------o
- | | | | | | |
- --- | | .-. | | |
- 470uF ### | | | | 2k2 | | |
- | + | | | | | | .-.
- *------o '--. | '-' .+. | '-'
- | |6 |7 |8 1k | | | |
- GND .------------. | | | |
- | | '+' | |
- | |1 | |/ BC |
- | |------o--| 547 |
- | | | |`> |
- | | ,+. | |
- | | 220R| | o----||-+ IRF9Z34
- | | | | | |+->
- | MC34063 | `+' | ||-+
- | | | | | BYV29 -12V6
- | | '----' o--|<-o----o--X OUT
- | |2 | | |
- | |--| C| | |
- | | GND 30uH C| | --- 470
- | |3 1nF C| | ### uF
- | |-------||--. | | | +
- '------------' | GND | GND
- 5| 4| | |
- | '-------------o-------------o
- | ___ |
- '------/\/\/------------o--|___|-'
- | 1k0
- .-.
- | | 5k6 + 3k3
- | | in Serie
- '-'
- |
- GND
-"#.to_string()
- }
-}
diff --git a/svgbob/src/optimizer.rs b/svgbob/src/optimizer.rs
index a420722..004fd2e 100644
--- a/svgbob/src/optimizer.rs
+++ b/svgbob/src/optimizer.rs
@@ -1,9 +1,9 @@
-use super::Loc;
use super::Element;
-use super::Stroke;
use super::Feature;
+use super::Loc;
use super::Point;
use super::Settings;
+use super::Stroke;
use ArcFlag;
pub struct Optimizer {
diff --git a/svgbob/src/patterns.rs b/svgbob/src/patterns.rs
index 52a6550..e7f6700 100644
--- a/svgbob/src/patterns.rs
+++ b/svgbob/src/patterns.rs
@@ -629,9 +629,10 @@ mod test {
use fragments::Direction::*;
use properties::Location;
- use fragments::Block::{A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X,
- Y};
- use properties::Signal::{Medium, Strong, Weak};
+ //use fragments::Block::{A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X,
+ // Y};
+ use fragments::Block::{O, U, Y};
+ //use properties::Signal::{Medium, Strong, Weak};
#[test]
fn test_adjascent() {
@@ -647,7 +648,7 @@ mod test {
// ._
let g = Grid::from_str(".-", &Settings::separate_lines());
let fc = FocusChar::new(&Loc::new(0, 0), &g);
- let (frags, consumed) = fc.get_fragments();
+ let (frags, _consumed) = fc.get_fragments();
println!("frags: {:?}", frags);
assert!(fc.is_intensified(&O));
assert!(fc.can_be_strong_block(&O));
@@ -658,8 +659,8 @@ mod test {
// ._
let g = Grid::from_str(".-", &Settings::separate_lines());
let fc = FocusChar::new(&Loc::new(0, 0), &g);
- let (frags, consumed) = fc.get_fragments();
- let loc = &Location::go(Right);
+ let (_frags, _consumed) = fc.get_fragments();
+ let _loc = &Location::go(Right);
let go_right = fc.from_location(&Location::go(Right));
let right = fc.right();
let right2 = fc.in_right(2);
@@ -689,7 +690,7 @@ mod test {
let g = Grid::from_str("._", &Settings::separate_lines());
let fc = FocusChar::new(&Loc::new(0, 0), &g);
println!("focus char: {:#?}", fc);
- let (frags, consumed) = fc.get_fragments();
+ let (frags, _consumed) = fc.get_fragments();
println!("frags: {:?}", frags);
assert!(!fc.is_intensified(&U));
assert!(fc.is_intensified(&Y));
@@ -700,7 +701,7 @@ mod test {
let g = Grid::from_str("._", &Settings::separate_lines());
let fc = FocusChar::new(&Loc::new(1, 0), &g);
println!("focus char: {:#?}", fc);
- let (frags, consumed) = fc.get_fragments();
+ let (frags, _consumed) = fc.get_fragments();
println!("frags: {:?}", frags);
assert!(!fc.is_intensified(&Y));
assert!(!fc.is_intensified(&U));