aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2016-09-30 23:16:19 (UTC)
committerjan <jan@ruken.pw>2016-09-30 23:16:19 (UTC)
commita6b37fa5e1bd505adfae4888896be2a3aa49ec3a (patch)
tree0a381e0533489a78758b1516680e274f5fd82216 /src/main.rs
parent361ea3a80a60bc6595a7a624b6cc5d71ddc8f6fc (diff)
parsen von traits und tags, wir koennen den configkram eigentlich wieder komplett entfernen. klappt so nicht wirklich.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 7d06fe7..ee8c3eb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,15 +16,21 @@ use pre_process::Section;
16mod config; 16mod config;
17use config::Config; 17use config::Config;
18 18
19mod character;
20use character::{Images, Names, Traits, Character};
21
22mod tags;
23mod traits;
24
19fn main() { 25fn main() {
20 let raw_files = env::var("RAW_FILES").unwrap_or("characters".into()); 26 let raw_files = env::var("RAW_FILES").unwrap_or("characters".into());
21 let base_path = Path::new(&raw_files); 27 let base_path = Path::new(&raw_files);
22 28
23 let cfg = Config::from_file("config.yml"); 29 let cfg = Config::from_file("config.yml", vec!["name", "image", "misc", "tags", "traits"]);
24 30
25 let mut sections: Vec<Section> = vec![]; 31 let mut sections: HashMap<String, Section> = HashMap::new();
26 for (name, sec) in &cfg.sections { 32 for (name, sec) in &cfg.sections {
27 sections.push(Section::new(&name, &sec.pattern, sec.groups.clone())); 33 sections.insert(name.clone(), Section::new(&name, &sec.pattern, sec.groups.clone()));
28 } 34 }
29 35
30 for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) { 36 for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) {
@@ -39,11 +45,30 @@ fn main() {
39 45
40 pre_process::split_sections(&buf, &mut sections); 46 pre_process::split_sections(&buf, &mut sections);
41 47
42 let mut char: HashMap<String, HashMap<String, String>> = HashMap::new(); 48 {
43 for s in &sections { 49 let name: &Section = &sections["name".into()];
44 char.insert(s.name.clone(), s.data.clone()); 50 let image: &Section = &sections["image".into()];
51 let misc: &Section = &sections["misc".into()];
52 println!("{:?}", Character {
53 name: Names {
54 romaji: name.data["romaji".into()].clone(),
55 japanese: name.data["japanese".into()].clone(),
56 aliases: name.data["aliases".into()].split(", ").map(|s| s.to_string()).collect(),
57 },
58 image: Images {
59 thumb: image.data["thumb".into()].clone(),
60 full: image.data["full".into()].clone(),
61 },
62 tags: tags::parse(&(&sections["tags".into()] as &Section).data["tags_raw".into()]),
63 traits: Traits {
64 official: traits::parse(&(&sections["traits"] as &Section).data["official_raw".into()]),
65 indexed: traits::parse(&(&sections["traits"] as &Section).data["indexed_raw".into()]),
66 },
67 role: match misc.data["role".into()].len() > 0 {
68 true => Some(misc.data["role".into()].clone()),
69 false => None
70 }
71 });
45 } 72 }
46
47 println!("{:?}", char);
48 } 73 }
49} 74}