Skip to content

Commit

Permalink
Get build working with updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
zmbush committed Oct 3, 2019
1 parent 57e2703 commit bfdc3a6
Show file tree
Hide file tree
Showing 8 changed files with 684 additions and 355 deletions.
922 changes: 624 additions & 298 deletions Cargo.lock

Large diffs are not rendered by default.

29 changes: 17 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@ doc = false
[dependencies]
# Both
budgetronlib = { path = "budgetronlib" }
serde = "1.0.15"
serde_json = "1.0.4"
serde = "1.0.101"
serde_json = "1.0.40"

# Library
csv = "1.0.0-beta.5"
data_store = { path = "data_store" }
log = "0.3.8"
regex = "0.2.2"
csv = "1.1.1"
data_store = { path = "data_store", optional = true }
log = "0.4.8"
regex = "1.3.1"
serde_derive = "1.0.101"

# Binary
clap = "2.26.2"
env_logger = "0.4.3"
iron = "0.5.1"
mount = "0.3.0"
staticfile = "0.4.0"
toml = "0.4.5"
clap = "2.33.0"
env_logger = "0.7.0"
iron = "0.6.1"
mount = "0.4.0"
staticfile = "0.5.0"
toml = "0.5.3"

[workspace]

[features]
default = []

db = ["data_store"]
2 changes: 1 addition & 1 deletion bin/rustup
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

rustup override set 1.37.0
rustup override set 1.38.0
rustup component add clippy
rustup component add rust-src
rustup component add rustfmt
Expand Down
10 changes: 5 additions & 5 deletions budgetronlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
authors = ["Zach Bush <[email protected]>"]

[dependencies]
chrono = "*"
serde = "*"
serde_derive = "*"
toml = "*"
csv = "1.0.0-beta.5"
chrono = "0.4.9"
serde = "1.0.101"
serde_derive = "1.0.101"
toml = "0.5.3"
csv = "1.1.1"
11 changes: 9 additions & 2 deletions src/bin/budgetron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use budgetron::loading;
use budgetron::processing::{collate_all, Collator, ConfiguredProcessors};
use budgetron::reporting::{ConfiguredReports, Database, List, Reporter};
use budgetron::reporting::{ConfiguredReports, List, Reporter};
use budgetronlib::config;
use clap::{App, Arg};
use iron::prelude::*;
Expand All @@ -19,8 +19,11 @@ use serde::Serialize;
use std::borrow::Cow;
use std::path::Path;

#[cfg(feature = "db")]
use budgetron::reporting::Database;

fn main() {
env_logger::init().expect("Unable to set up env_logger");
env_logger::init();

let matches = App::new("Collator")
.version(env!("CARGO_PKG_VERSION"))
Expand Down Expand Up @@ -74,8 +77,12 @@ fn main() {
.iter()
.map(|t| Cow::Borrowed(t))
.collect::<Vec<_>>();
#[cfg(feature = "db")]
let transaction_list = (List, Database).report(cow_transactions.into_iter());

#[cfg(not(feature = "db"))]
let transaction_list = List.report(cow_transactions.into_iter());

if matches.is_present("serve") {
let mut mount = Mount::new();
mount.mount("/", staticfile::Static::new(Path::new("web/static")));
Expand Down
61 changes: 25 additions & 36 deletions src/loading/money.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use serde::de::{self, Deserialize, Deserializer, Visitor};
use serde::ser::{Serialize, Serializer};
use serde_json;
use std::convert::TryInto;
use std::fmt;
use std::iter;
use std::ops;
Expand Down Expand Up @@ -163,32 +164,27 @@ impl<'de> Visitor<'de> for MoneyVisitor {
formatter.write_str("a valid money amount")
}

fn visit_i8<E>(self, value: i8) -> Result<Money, E>
fn visit_i64<E>(self, value: i64) -> Result<Money, E>
where
E: de::Error,
{
Ok(Money::from_i64(i64::from(value)))
Ok(Money::from_i64(value))
}

fn visit_i32<E>(self, value: i32) -> Result<Money, E>
fn visit_u32<E>(self, value: u32) -> Result<Money, E>
where
E: de::Error,
{
Ok(Money::from_i64(i64::from(value)))
}

fn visit_i64<E>(self, value: i64) -> Result<Money, E>
where
E: de::Error,
{
Ok(Money::from_i64(value))
}

fn visit_f32<E>(self, value: f32) -> Result<Money, E>
fn visit_u64<E>(self, value: u64) -> Result<Money, E>
where
E: de::Error,
{
Ok(Money::from_f64(f64::from(value)))
Ok(Money::from_i64(
value.try_into().map_err(|_| E::custom("Too much money!"))?,
))
}

fn visit_f64<E>(self, value: f64) -> Result<Money, E>
Expand All @@ -198,7 +194,7 @@ impl<'de> Visitor<'de> for MoneyVisitor {
Ok(Money::from_f64(value))
}

fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Money, E>
fn visit_str<E>(self, v: &str) -> Result<Money, E>
where
E: de::Error,
{
Expand All @@ -212,28 +208,14 @@ impl<'de> Visitor<'de> for MoneyVisitor {

self.visit_f64(parsed)
}

fn visit_str<E>(self, v: &str) -> Result<Money, E>
where
E: de::Error,
{
self.visit_borrowed_str(v)
}

fn visit_string<E>(self, v: String) -> Result<Money, E>
where
E: de::Error,
{
self.visit_borrowed_str(&v)
}
}

impl<'de> Deserialize<'de> for Money {
fn deserialize<D>(deserializer: D) -> Result<Money, D::Error>
where
D: Deserializer<'de>,
{
deserializer.deserialize_str(MoneyVisitor)
deserializer.deserialize_any(MoneyVisitor)
}
}

Expand Down Expand Up @@ -283,7 +265,7 @@ mod tests {
#[test]
fn $name() {
$(
let money_str = format!(r#""{}""#, $s);
let money_str = format!(r#"{}"#, $s);
let parsed_money: Money = serde_json::from_str(&money_str).unwrap();
assert_eq!(parsed_money, Money::from_f64($o));
)+
Expand All @@ -293,16 +275,23 @@ mod tests {

test_conversion!(
parse_complex_numbers,
"($100.0)" => -100.0,
"$100.0" => 100.0,
"-$100.0" => -100.0
);
r#""($100.0)""# => -100.0,
r#""$100.0""# => 100.0,
r#""-$100.0""# => -100.0
);

test_conversion!(
parse_simpler_numbers,
"$150.0" => 150.0,
"-125.50" => -125.50
);
r#""$150.0""# => 150.0,
r#""-125.50""# => -125.50
);

test_conversion!(
plain_numbers,
"100" => 100.0,
"100.0" => 100.0,
"0" => 0.0
);
}

impl fmt::Display for Money {
Expand Down
2 changes: 1 addition & 1 deletion src/loading/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::loading::logix;
use crate::loading::mint;
use budgetronlib::error::{BResult, BudgetError};
use csv::Reader;
use log::{info, log};
use log::info;
use serde::de::DeserializeOwned;
use std::cmp::min;
use std::fmt::Display;
Expand Down
2 changes: 2 additions & 0 deletions src/reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mod by_timeframe;
mod cashflow;
mod categories;
mod config;
#[cfg(feature = "db")]
mod database;
mod excluding_tags;
mod income_expense_ratio;
Expand All @@ -87,6 +88,7 @@ pub use crate::reporting::by_timeframe::ByTimeframeReport;
pub use crate::reporting::cashflow::Cashflow;
pub use crate::reporting::categories::Categories;
pub use crate::reporting::config::ConfiguredReports;
#[cfg(feature = "db")]
pub use crate::reporting::database::Database;
pub use crate::reporting::excluding_tags::ExcludingTags;
pub use crate::reporting::income_expense_ratio::IncomeExpenseRatio;
Expand Down

0 comments on commit bfdc3a6

Please sign in to comment.