Extract commodity type into separate crate

korrat
Jun 23, 2023, 4:18 PM
WS3UUOV3DGSOZSN4V2O6YZDFO3M4NIC6BCYWGGEHFBCV4KZJPQHAC

Dependencies

  • [2] SMBQYFPG Enable access to timestamps for directives
  • [3] NG5QXPZH Extract Account into separate crate
  • [4] QNGOXZL4 Add a basic framework
  • [5] SEEWF7KX Implement metadata on transactions
  • [6] R7S2CWF7 Add type for account segments
  • [7] 2JBFREZG enable additional warnings
  • [8] 4W4CDACX Upgrade dependencies
  • [9] W3MWSSJ7 Add a templating engine for accounts
  • [10] 24CCPM5O Update dependencies
  • [11] ZVTVMOZQ Upgrade dependencies
  • [12] TB2QGHXN Upgrade dependencies
  • [13] R524JUUE Implement metadata & price directives
  • [14] YDK6X6PP add a library of important types for beancount
  • [*] I2P2FTLE add basic parser for german decimals

Change contents

  • edit in common/beancount-types/src/that.rs at line 36
    [5.4722][5.4722:4777](),[5.4777][5.3975:4029](),[5.4029][5.4777:4821](),[5.4777][5.4777:4821](),[5.4874][5.4874:5842]()
    mod commodities {
    use {
    crate::Commodity,
    core::{fmt::Debug, hash::Hash, str::FromStr},
    static_assertions::assert_impl_all,
    test_case::test_case,
    };
    assert_impl_all!(
    Commodity: Copy,
    Debug,
    FromStr,
    Hash,
    Ord,
    TryFrom<&'static str>
    );
    #[test_case("A"; "single letter")]
    #[test_case("USD"; "dollar")]
    #[test_case("EUR"; "euro")]
    #[test_case("MSFT"; "stock")]
    #[test_case("AIRMILE"; "creative")]
    #[test_case("DE.-_3"; "with special characters")]
    fn parse_when_valid(name: &str) {
    let commodity = Commodity::try_from(name).unwrap();
    assert_eq!(commodity.to_string(), name);
    }
    #[test_case("0"; "starting with number")]
    #[test_case("D-"; "ending with dash")]
    #[test_case("E_"; "ending with underscore")]
    #[test_case("X."; "ending with dot")]
    #[test_case("X 3"; "containing space")]
    #[test_case("X\\0"; "containing backslash")]
    fn do_not_parse_when_invalid(name: &str) {
    Commodity::try_from(name).unwrap_err();
    }
    // TODO proptest?
    }
  • replacement in common/beancount-types/src/lib.rs at line 1
    [5.5874][2.840:880]()
    #![warn(clippy::all, clippy::pedantic)]
    [5.5874]
    [2.880]
    #![warn(clippy::all, clippy::nursery, clippy::pedantic)]
  • edit in common/beancount-types/src/lib.rs at line 9
    [3.2176]
    [3.2176]
    pub use beancount_commodity::Commodity;
  • edit in common/beancount-types/src/lib.rs at line 14
    [5.4156][5.4156:4193]()
    pub use crate::commodity::Commodity;
  • edit in common/beancount-types/src/lib.rs at line 37
    [5.5953][5.5953:5968]()
    mod commodity;
  • replacement in common/beancount-types/Cargo.toml at line 26
    [3.2285][3.2285:2336]()
    beancount-account.path = "../../beancount/account"
    [3.2285]
    [3.2336]
    beancount-account.path = "../../beancount/account"
    beancount-commodity.path = "../../beancount/commodity"
  • file addition: commodity (d--r------)
    [3.1]
  • file addition: tests (d--r------)
    [0.1]
  • file addition: basic.rs (---r------)
    [0.24]
    use core::fmt::Debug;
    use core::hash::Hash;
    use core::str::FromStr;
    use beancount_commodity::Commodity;
    use static_assertions::assert_impl_all;
    use test_case::test_case;
    assert_impl_all!(
    Commodity: Copy,
    Debug,
    FromStr,
    Hash,
    Ord,
    TryFrom<&'static str>
    );
    #[test_case("A"; "single letter")]
    #[test_case("USD"; "dollar")]
    #[test_case("EUR"; "euro")]
    #[test_case("MSFT"; "stock")]
    #[test_case("AIRMILE"; "creative")]
    #[test_case("DE.-_3"; "with special characters")]
    fn parse_when_valid(name: &str) {
    let commodity = Commodity::try_from(name).unwrap();
    assert_eq!(commodity.to_string(), name);
    }
    #[test_case("0"; "starting with number")]
    #[test_case("D-"; "ending with dash")]
    #[test_case("E_"; "ending with underscore")]
    #[test_case("X."; "ending with dot")]
    #[test_case("X 3"; "containing space")]
    #[test_case("X\\0"; "containing backslash")]
    fn do_not_parse_when_invalid(name: &str) {
    Commodity::try_from(name).unwrap_err();
    }
    // TODO proptest?
  • file addition: src (d--r------)
    [0.1]
  • file move: commodity.rs (---r------)lib.rs (---r------)
    [0.1067]
    [5.8128]
  • edit in beancount/commodity/src/lib.rs at line 1
    [5.8128]
    [5.4876]
    #![warn(clippy::all, clippy::nursery, clippy::pedantic)]
  • file addition: Cargo.toml (---r------)
    [0.1]
    [package]
    name = "beancount-commodity"
    edition.workspace = true
    publish.workspace = true
    rust-version.workspace = true
    version.workspace = true
    [dependencies]
    # Inherited dependencies
    arrayvec.workspace = true
    delegate.workspace = true
    lazy-regex.workspace = true
    miette.workspace = true
    serde.workspace = true
    snafu.workspace = true
    [dev-dependencies]
    static_assertions.workspace = true
    test-case.workspace = true
  • edit in beancount/account/Cargo.toml at line 3
    [3.1256][3.1256:1291]()
    version = "0.1.0"
    edition = "2021"
  • replacement in beancount/account/Cargo.toml at line 4
    [3.1292][3.1292:1389]()
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    [3.1292]
    [3.1389]
    edition.workspace = true
    publish.workspace = true
    rust-version.workspace = true
    version.workspace = true
  • replacement in beancount/account/Cargo.toml at line 11
    [3.1430][3.1430:1456]()
    delegate.workspace = true
    [3.1430]
    [3.1456]
    delegate.workspace = true
  • replacement in beancount/account/Cargo.toml at line 13
    [3.1484][3.1484:1576]()
    miette.workspace = true
    momo.workspace = true
    serde.workspace = true
    snafu.workspace = true
    [3.1484]
    [3.1576]
    miette.workspace = true
    momo.workspace = true
    serde.workspace = true
    snafu.workspace = true
  • edit in beancount/account/Cargo.toml at line 19
    [3.1596][3.1596:1623]()
    test-case.workspace = true
  • edit in beancount/account/Cargo.toml at line 20
    [3.1658]
    test-case.workspace = true
  • replacement in Cargo.lock at line 205
    [5.2189][5.2189:2207]()
    version = "0.1.0"
    [5.2189]
    [5.2207]
    version = "0.0.0-dev.0"
  • edit in Cargo.lock at line 218
    [5.279]
    [4.15218]
    name = "beancount-commodity"
    version = "0.0.0-dev.0"
    dependencies = [
    "arrayvec",
    "delegate",
    "lazy-regex",
    "miette",
    "serde",
    "snafu",
    "static_assertions",
    "test-case",
    ]
    [[package]]
  • edit in Cargo.lock at line 328
    [5.2353]
    [5.26614]
    "beancount-commodity",