Skip to content

Commit

Permalink
Removed website processing (for now) and added new screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
pomettini committed Jul 29, 2019
1 parent 9adb407 commit 0e128d8
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "golden_frieza"
version = "0.1.0"
version = "0.2.0"
authors = ["Giorgio Pomettini <giorgio.pomettini@gmail.com>"]

[dependencies]
Expand All @@ -9,4 +9,4 @@ iui = { git = "https://github.com/rust-native-ui/libui-rs.git" }
reqwest = ">=0.9.9"
ammonia = ">=2.0.0"
regex = ">=1"
color-convert = ">=0.1.0"
color-convert = ">=0.1.0"
Binary file modified resources/.DS_Store
Binary file not shown.
Binary file added resources/test/image_file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/bin/golden-frieza.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use std::fs::File;
use std::path::Path;
use std::rc::Rc;

// TODO: Load file
// TODO: Load website
// TODO: Support multiple languages

Expand Down Expand Up @@ -76,7 +75,7 @@ fn main() {
website_hbox.set_padded(&ui, true);

// Add to the input panel
input_vbox.append(&ui, website_hbox.clone(), LayoutStrategy::Compact);
// input_vbox.append(&ui, website_hbox.clone(), LayoutStrategy::Compact);
input_vbox.append(&ui, load_file_button.clone(), LayoutStrategy::Compact);
input_vbox.append(&ui, clear_textarea_button.clone(), LayoutStrategy::Compact);
input_vbox.append(&ui, entry.clone(), LayoutStrategy::Stretchy);
Expand Down
12 changes: 2 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ use std::io::prelude::*;
use std::iter::FromIterator;
use std::path::Path;

// Build with CXXFLAGS=-stdlib=libc++ cargo run
// TODO: Find the way to add this to the build script

type RGB = [f32; 3];

#[derive(Default)]
Expand All @@ -25,7 +22,7 @@ pub struct DisplayColors {

impl DisplayColors {
pub fn load_dictionary(path: &Path) -> DisplayColors {
let mut reader = Reader::from_path(path).unwrap();
let mut reader = Reader::from_path(path).expect("Cannot load Color dictionary");
let mut dictionary: HashMap<String, RGB> = HashMap::new();

for record in reader.deserialize() {
Expand Down Expand Up @@ -66,7 +63,7 @@ pub struct Color {
pub matches: usize,
}

#[derive(Default, PartialEq)]
#[derive(Default, Debug, PartialEq)]
pub struct Document {
pub content: String,
}
Expand All @@ -79,8 +76,6 @@ impl Document {
}

pub fn from_file(path: &Path) -> Option<Document> {
// TODO: Handle only text files

let mut file = File::open(&path).expect("File not found");
let mut contents = String::new();

Expand Down Expand Up @@ -189,6 +184,3 @@ pub fn calculate_percentages(

result
}

#[cfg(test)]
mod tests;
12 changes: 10 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ fn test_process_file() {
INIT_COLOR_DICTIONARY!(colors, dictionary);

let document = Document::from_file(Path::new("resources/test/sample_file.txt"));
// TODO: Check if file is valid
colors.count_occurences(&document.unwrap());
colors.count_occurences(&document.expect("Text file cannot be parsed"));

let mut result: HashMap<String, usize> = HashMap::new();
result.insert(String::from("Black"), 1);
Expand All @@ -258,6 +257,15 @@ fn test_process_file() {
assert_eq!(colors.occurrences, result);
}

#[test]
fn test_process_non_text_file() {
INIT_COLOR_DICTIONARY!(colors, dictionary);

let document = Document::from_file(Path::new("resources/test/image_file.png"));

assert_eq!(document, None);
}

#[test]
fn test_process_website() {
INIT_COLOR_DICTIONARY!(colors, dictionary);
Expand Down

0 comments on commit 0e128d8

Please sign in to comment.