Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/benshi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ async fn serve(voice: &Arc<Voice>) -> u8 {
}
};
// What the store holds of the list is what the first round decides
// against, so a daemon recognises before it reads the list again.
let recogniser = match listing::kept(&store.lock().expect("nothing has used the store yet")) {
Ok(recogniser) => recogniser,
// against, so a daemon recognizes before it reads the list again.
let recognizer = match listing::kept(&store.lock().expect("nothing has used the store yet")) {
Ok(recognizer) => recognizer,
Err(unread) => {
voice.say(format_args!(
"{} cannot be used: {unread}",
Expand All @@ -384,7 +384,7 @@ async fn serve(voice: &Arc<Voice>) -> u8 {
let running = benshi_daemon::run(
|| MprisWatcher::connect(SystemClock::new(), SOURCE_DEADLINE),
listener,
recogniser,
recognizer,
store,
SystemTime::now,
POLL_INTERVAL,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn did_not_answer(socket: &Path) -> anyhow::Error {
#[cfg(test)]
mod tests {
#[test]
fn a_request_that_cannot_be_written_says_what_the_serialiser_said() {
fn a_request_that_cannot_be_written_says_what_the_serializer_said() {
// A map keyed by a pair is one JSON cannot spell.
let unwritable = std::collections::BTreeMap::from([((1, 2), 3)]);
let cause = serde_json::to_vec(&unwritable).expect_err("JSON has no such key");
Expand Down
20 changes: 10 additions & 10 deletions crates/cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async fn login(
// Nothing typed was shown, the end of the line included.
writeln!(err).context("prompt could not be printed")?;
let token = match typed.context("token could not be read")? {
Typed::Cancelled => bail!("login cancelled"),
Typed::Canceled => bail!("login canceled"),
Typed::Line(line) => line.secret().trim().to_owned(),
};
if token.is_empty() {
Expand Down Expand Up @@ -531,7 +531,7 @@ mod tests {
use benshi_daemon::ipc::{Server, bind};
use benshi_daemon::listing::Wakes;
use benshi_daemon::protocol::{Request, Response};
use benshi_daemon::recognition::{Decided, Decision, Recogniser};
use benshi_daemon::recognition::{Decided, Decision, Recognizer};
use benshi_daemon::secrets;
use benshi_daemon::supervisor::TaskError;
use socket2::{Domain, SockAddr, Socket, Type};
Expand Down Expand Up @@ -834,7 +834,7 @@ mod tests {
/// round would.
fn has_decided(&self, name: &str) {
let path = RawPath::from_bytes(name.as_bytes().to_vec());
let (parsed, answer) = Recogniser::empty().decide(&path);
let (parsed, answer) = Recognizer::empty().decide(&path);

self.decided.record(Decision {
player: PlayerId(PLAYER.to_owned()),
Expand Down Expand Up @@ -1028,7 +1028,7 @@ mod tests {

/// One answer as the daemon writes it: a line, newline included.
fn line_of(answer: &Response) -> Vec<u8> {
let mut line = serde_json::to_vec(answer).expect("serialise");
let mut line = serde_json::to_vec(answer).expect("serialize");
line.push(b'\n');

line
Expand Down Expand Up @@ -1306,7 +1306,7 @@ mod tests {
assert_eq!(outcome, ExitCode::SUCCESS, "stderr said {complained:?}");
assert!(shown.contains(PLAYER), "{shown}");
assert!(shown.contains("\"Show Title\""), "{shown}");
assert!(shown.contains("unrecognised"), "{shown}");
assert!(shown.contains("unrecognized"), "{shown}");
assert!(complained.is_empty(), "{complained}");
}

Expand Down Expand Up @@ -2124,7 +2124,7 @@ mod tests {
// nothing on the one it was written for.
assert!(
!shown.contains("more than it can replay"),
"a recording of a declared source apologised for an undeclared one: {shown:?}"
"a recording of a declared source apologized for an undeclared one: {shown:?}"
);
assert_eq!(caught.snapshots, vec![a_reading(0)]);
let text = std::fs::read_to_string(&output).expect("a trace was written");
Expand Down Expand Up @@ -2173,7 +2173,7 @@ mod tests {
// carry the caveat, or the caveat says nothing when it does appear.
assert!(
!shown.contains(ENDED_EARLY),
"a complete recording apologised for ending early: {shown:?}"
"a complete recording apologized for ending early: {shown:?}"
);
assert!(
shown.contains(&output.display().to_string()),
Expand Down Expand Up @@ -2451,19 +2451,19 @@ mod tests {
}

#[tokio::test]
async fn a_login_cancelled_at_the_prompt_is_no_login() {
async fn a_login_canceled_at_the_prompt_is_no_login() {
let daemon = Daemon::logging_in(Logins::default());

let (outcome, shown, complained) = timeout(
PATIENCE,
go_typing(Command::Login, &daemon.socket, Typed::Cancelled),
go_typing(Command::Login, &daemon.socket, Typed::Canceled),
)
.await
.expect("the client ended");

assert_eq!(outcome, ExitCode::FAILURE);
assert!(shown.is_empty(), "{shown}");
assert_eq!(complained, format!("{ASKED}benshi: login cancelled\n"));
assert_eq!(complained, format!("{ASKED}benshi: login canceled\n"));
assert!(daemon.accounts.asked().is_empty());
}

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ mod tests {

#[test]
fn a_command_that_does_not_exist_is_refused() {
assert!(Cli::try_parse_from(["benshi", "recognise"]).is_err());
assert!(Cli::try_parse_from(["benshi", "recognize"]).is_err());
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/src/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Typed {
/// before the end. A token is what a prompt reads, so it is held as one.
Line(Token),
/// Ctrl-C or Ctrl-D, at a terminal.
Cancelled,
Canceled,
}

/// Read one line from `input`, which a terminal does not show.
Expand Down Expand Up @@ -74,7 +74,7 @@ fn line(input: BorrowedFd<'_>, at_a_terminal: bool) -> io::Result<Typed> {
match byte[0] {
b'\n' => break,
b'\r' if at_a_terminal => break,
CTRL_C | CTRL_D if at_a_terminal => return Ok(Typed::Cancelled),
CTRL_C | CTRL_D if at_a_terminal => return Ok(Typed::Canceled),
key if at_a_terminal && BACKSPACE.contains(&key) => {
line.pop();
}
Expand Down Expand Up @@ -254,7 +254,7 @@ mod tests {
let terminal = Terminal::new();
let modes = terminal.modes();

assert_eq!(terminal.typing(b"part of a token\x03"), Typed::Cancelled);
assert_eq!(terminal.typing(b"part of a token\x03"), Typed::Canceled);
assert_eq!(terminal.modes(), modes, "the terminal was not put back");
}

Expand All @@ -263,7 +263,7 @@ mod tests {
let terminal = Terminal::new();
let modes = terminal.modes();

assert_eq!(terminal.typing(b"\x04"), Typed::Cancelled);
assert_eq!(terminal.typing(b"\x04"), Typed::Canceled);
assert_eq!(terminal.modes(), modes, "the terminal was not put back");
}

Expand Down
60 changes: 30 additions & 30 deletions crates/cli/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::time::{Duration, UNIX_EPOCH};

use benshi_core::encoding::{Confidence, decode};
use benshi_core::policy::Policy;
use benshi_core::recognise::parse::{Episode, Parsed};
use benshi_core::recognize::parse::{Episode, Parsed};
use benshi_core::{Capabilities, Known, MediaRef, PlayState};
use benshi_daemon::bus::BusEvent;
use benshi_daemon::protocol::{DecidedBy, Explanation, Outcome, SourceListing};
Expand All @@ -23,7 +23,7 @@ use humantime::format_rfc3339_seconds;
/// What is shown for a source that cannot name what it opened.
///
/// A source that publishes no location gives recognition nothing but what the
/// page or window calls itself. That is a different problem from recognising a
/// page or window calls itself. That is a different problem from recognizing a
/// filename, and a user deciding whether to allow such a source has to be told
/// which one they are getting.
const TITLE_ONLY: &str = "title only";
Expand Down Expand Up @@ -189,16 +189,16 @@ pub fn explanation(of: &Explanation) -> String {

/// What recognition answered, as the lines below the parse.
///
/// Each line ends in a newline, and a match takes two: what it was recognised
/// Each line ends in a newline, and a match takes two: what it was recognized
/// as, and the stage that decided.
fn answer(of: &Outcome) -> String {
match of {
Outcome::Recognised {
Outcome::Recognized {
title,
episode,
stage,
} => format!(
"recognised: \"{title}\", {}\nstage: {}\n",
"recognized: \"{title}\", {}\nstage: {}\n",
episode_words(*episode),
decided_by(stage)
),
Expand All @@ -209,11 +209,11 @@ fn answer(of: &Outcome) -> String {
.collect();
format!("ambiguous: {}\n", quoted.join(", "))
}
Outcome::Unrecognised { best: Some(score) } => {
format!("unrecognised: closest candidate scored {score:.2}\n")
Outcome::Unrecognized { best: Some(score) } => {
format!("unrecognized: closest candidate scored {score:.2}\n")
}
Outcome::Unrecognised { best: None } => {
"unrecognised: nothing to score against\n".to_owned()
Outcome::Unrecognized { best: None } => {
"unrecognized: nothing to score against\n".to_owned()
}
}
}
Expand Down Expand Up @@ -345,14 +345,14 @@ mod tests {
use benshi_core::clock::Timestamp;
use benshi_core::path::RawPath;
use benshi_core::policy::Policy;
use benshi_core::recognise::altname::Assignment;
use benshi_core::recognise::parse::Episode;
use benshi_core::recognize::altname::Assignment;
use benshi_core::recognize::parse::Episode;
use benshi_core::{
AppName, Capabilities, Known, MediaRef, PlayState, PlayerId, PlayerSnapshot, ShowId,
};
use benshi_daemon::bus::BusEvent;
use benshi_daemon::protocol::{DecidedBy, Explanation, Outcome, SourceListing};
use benshi_daemon::recognition::Recogniser;
use benshi_daemon::recognition::Recognizer;
// The reason a failure carries comes from here in the daemon, so the tests
// that check how one reads take it from here too rather than writing one.
use benshi_detect::WatchError;
Expand Down Expand Up @@ -638,7 +638,7 @@ mod tests {
/// the daemon would have decided about.
fn explained(path: &[u8], outcome: Outcome) -> Explanation {
let path = RawPath::from_bytes(path.to_vec());
let (spelled, _refused) = Recogniser::empty().decide(&path);
let (spelled, _refused) = Recognizer::empty().decide(&path);

Explanation {
player: PlayerId("mpv".to_owned()),
Expand All @@ -650,7 +650,7 @@ mod tests {

/// A match of this title by this stage, at episode three.
fn found(title: &str, stage: DecidedBy) -> Outcome {
Outcome::Recognised {
Outcome::Recognized {
title: title.to_owned(),
episode: Episode::Only(3),
stage,
Expand Down Expand Up @@ -678,7 +678,7 @@ mod tests {
fn an_explanation_names_the_player_and_the_file_first() {
let shown = explanation(&explained(
b"/anime/[Group] Show Title - 03.mkv",
Outcome::Unrecognised { best: None },
Outcome::Unrecognized { best: None },
));

let first = shown.lines().next().expect("a first line");
Expand All @@ -696,7 +696,7 @@ mod tests {
// the parser cut out of the title.
let shown = explanation(&explained(
b"[Group] Show Title S02E03 [1080p].mkv",
Outcome::Unrecognised { best: None },
Outcome::Unrecognized { best: None },
));

let spelled = line_of(&shown, "spelled:");
Expand All @@ -710,7 +710,7 @@ mod tests {
fn a_name_that_spelled_no_title_says_so() {
let shown = explanation(&explained(
b"/anime/ep 03.mkv",
Outcome::Unrecognised { best: None },
Outcome::Unrecognized { best: None },
));

let spelled = line_of(&shown, "spelled:");
Expand All @@ -726,7 +726,7 @@ mod tests {
// whether the guess was right.
let shown = explanation(&explained(
SHIFT_JIS_NAME,
Outcome::Unrecognised { best: None },
Outcome::Unrecognized { best: None },
));

assert!(shown.contains("ソレッタ"), "the name was not read: {shown}");
Expand Down Expand Up @@ -757,7 +757,7 @@ mod tests {
));

assert!(
line_of(&shown, "recognised:").contains("Kaguya-sama: Love is War -Ultra Romantic-"),
line_of(&shown, "recognized:").contains("Kaguya-sama: Love is War -Ultra Romantic-"),
"{shown}"
);
let stage = line_of(&shown, "stage:");
Expand Down Expand Up @@ -835,22 +835,22 @@ mod tests {
// absence says the list is.
let close = explanation(&explained(
b"Some Other Show - 03.mkv",
Outcome::Unrecognised { best: Some(0.4) },
Outcome::Unrecognized { best: Some(0.4) },
));
let nothing = explanation(&explained(
b"Some Other Show - 03.mkv",
Outcome::Unrecognised { best: None },
Outcome::Unrecognized { best: None },
));

assert_eq!(
line_of(&close, "unrecognised:"),
"unrecognised: closest candidate scored 0.40"
line_of(&close, "unrecognized:"),
"unrecognized: closest candidate scored 0.40"
);
let unscored = line_of(&nothing, "unrecognised:");
let unscored = line_of(&nothing, "unrecognized:");
assert!(unscored.contains("nothing"), "{unscored}");
assert!(
!unscored.contains("0.00"),
"an absence rendered as a score of nought: {unscored}"
"an absence rendered as a score of zero: {unscored}"
);
}

Expand All @@ -867,18 +867,18 @@ mod tests {
for (episode, words) in cases {
let shown = explanation(&explained(
b"[Group] Show Title - 03.mkv",
Outcome::Recognised {
Outcome::Recognized {
title: "Show Title".to_owned(),
episode,
stage: DecidedBy::Key,
},
));

let recognised = line_of(&shown, "recognised:");
assert!(recognised.contains(words), "{recognised}");
let recognized = line_of(&shown, "recognized:");
assert!(recognized.contains(words), "{recognized}");
assert!(
!recognised.contains("episode 0"),
"an absence rendered as a number: {recognised}"
!recognized.contains("episode 0"),
"an absence rendered as a number: {recognized}"
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/tests/the_client_sees_what_the_daemon_does.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use benshi_daemon::bus::{BusEvent, EventBus};
use benshi_daemon::detection::{Detection, Seen, Wiring};
use benshi_daemon::ipc::{Server, bind};
use benshi_daemon::listing::Wakes;
use benshi_daemon::recognition::{Current, Decided, Recogniser};
use benshi_daemon::recognition::{Current, Decided, Recognizer};
use benshi_detect::{PlayerWatcher, PollOutcome, SourceInfo, WatchError};
use benshi_store::Store;
use tempfile::TempDir;
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Daemon {
bus: Arc::clone(&bus),
policy: Arc::clone(&policy),
seen: seen.clone(),
recogniser: Current::new(Recogniser::empty()),
recognizer: Current::new(Recognizer::empty()),
wakes: Wakes::new(),
decided: decided.clone(),
store: Arc::new(Mutex::new(store)),
Expand Down Expand Up @@ -240,7 +240,7 @@ async fn why_explains_the_reading_a_round_decided() {
assert!(shown.contains(PLAYER), "{shown}");
assert!(shown.contains("/anime/ep 03.mkv"), "{shown}");
assert!(shown.contains("episode 3"), "{shown}");
assert!(shown.contains("unrecognised"), "{shown}");
assert!(shown.contains("unrecognized"), "{shown}");
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workspace = true
# direct runtime dependency, `regex` without its Unicode tables, which brings
# `aho-corasick`, `memchr`, `regex-automata` and `regex-syntax` with it. All of
# them are Rust, so nothing C arrives and this crate stays free of platform
# code. MPL-2.0, the only non-permissive licence in the graph; section 3.3
# code. MPL-2.0, the only non-permissive license in the graph; section 3.3
# permits a Larger Work under other terms, so benshi stays MIT.
anitomy-ng = "1.0.10"
chardetng = "1.0.0"
Expand Down
Loading
Loading