Skip to content

Commit

Permalink
Merge branch 'main' into renovate/configure
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianGoeb authored Oct 3, 2023
2 parents 1033264 + f03a17a commit 79365ff
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
5 changes: 1 addition & 4 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: stable
override: true
components: rustfmt, clippy, llvm-tools-preview

Expand All @@ -30,6 +30,3 @@ runs:
target/
key: cargo-repo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo-binstall
shell: bash
run: cargo install cargo-binstall
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
uses: ./.github/actions/setup

- name: Install more cargo tools
run: echo yes | cargo binstall cargo-llvm-cov cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov,cargo-nextest

# test
- name: Run tests and generate coverage
Expand Down
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ async-std = { version = "1", features = [ "attributes" ] }
futures = "0.3.28"
csv = "1.2.1"
tempfile = "3.5.0"
itertools = "0.11.0"
16 changes: 10 additions & 6 deletions src/file/csv.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use itertools::intersperse;

use crate::model;
use csv::StringRecord;
use std::{error::Error, path::Path};
Expand All @@ -9,12 +11,14 @@ impl From<&model::Note> for StringRecord {
value.word.to_owned(),
value.stem.to_owned(),
value.lang.to_owned(),
value
.usages
.iter()
.map(|usage| format!("<p>\n{}\n</p>", usage))
.intersperse("\n".to_owned())
.collect(),
intersperse(
value
.usages
.iter()
.map(|usage| format!("<p>\n{}\n</p>", usage)),
"\n".to_owned(),
)
.collect(),
])
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(iter_intersperse)]

use std::error;
pub mod cli;
mod db;
Expand Down Expand Up @@ -38,6 +36,8 @@ mod tests {

use crate::{cli, export_to_csv};

use itertools::intersperse;

#[async_std::test]
async fn should_export_words_and_usage_to_csv() -> Result<(), Box<dyn error::Error>> {
let csvfile = tempfile::NamedTempFile::new()?;
Expand All @@ -51,11 +51,11 @@ mod tests {

// should output csv
let contents = fs::read_to_string(csvfile.path())?;
let row_1: String = contents
.lines()
.take(3) // multiline contents
.intersperse("\n")
.collect::<String>();
let row_1: String = intersperse(
contents.lines().take(3), // multiline contents
"\n",
)
.collect::<String>();
assert_eq!(
row_1,
"de:verwendet,verwendet,verwenden,de,\"<p>
Expand Down

0 comments on commit 79365ff

Please sign in to comment.