From cedaa8b8c914d7672a1708ebfaf2e78dc4c3a19a Mon Sep 17 00:00:00 2001 From: Juan Gomez Date: Mon, 30 Sep 2024 10:27:07 -0400 Subject: [PATCH] Rename dnf to interrupted --- README.md | 4 +- lib/lite/command/internals/executable.rb | 14 +++---- spec/lite/command/base_spec.rb | 50 ++++++++++++------------ 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index d8340b8..6f4963a 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ command.context.result #=> 8 #### States State represents the state of the executable code. Once `execute` -is ran, it will always `complete` or `dnf` if a fault is thrown by a +is ran, it will always `complete` or `interrupted` if a fault is thrown by a child command. - `pending` @@ -103,7 +103,7 @@ child command. - Command objects actively executing code. - `complete` - Command objects that executed to completion. -- `dnf` +- `interrupted` - Command objects that could NOT be executed to completion. This could be as a result of a fault/exception on the object itself or one of its children. diff --git a/lib/lite/command/internals/executable.rb b/lib/lite/command/internals/executable.rb index 555d298..5503519 100644 --- a/lib/lite/command/internals/executable.rb +++ b/lib/lite/command/internals/executable.rb @@ -4,10 +4,10 @@ module Lite module Command STATES = [ - PENDING = "pending", - EXECUTING = "executing", - COMPLETE = "complete", - DNF = "dnf" + PENDING = "pending", + EXECUTING = "executing", + COMPLETE = "complete", + INTERRUPTED = "interrupted" ].freeze module Internals @@ -35,14 +35,14 @@ def state end def executed? - dnf? || complete? + complete? || interrupted? end STATES.each do |s| # eg: executing? define_method(:"#{s}?") { state == s } - # eg: dnf! + # eg: interrupted! define_method(:"#{s}!") { @state = s } end @@ -57,7 +57,7 @@ def before_execution end def after_execution - fault? ? dnf! : complete! + fault? ? interrupted! : complete! on_after_execution stop_monotonic_time append_execution_result diff --git a/spec/lite/command/base_spec.rb b/spec/lite/command/base_spec.rb index 1544715..f82ca82 100644 --- a/spec/lite/command/base_spec.rb +++ b/spec/lite/command/base_spec.rb @@ -70,9 +70,9 @@ expect { command_instance.execute! }.to raise_error(NoopCommand::Noop, "[!] command stopped due to noop") end - it "returns a dnf state" do - expect(command).to be_dnf - expect(command.state).to eq(Lite::Command::DNF) + it "returns a interrupted state" do + expect(command).to be_interrupted + expect(command.state).to eq(Lite::Command::INTERRUPTED) end end @@ -98,9 +98,9 @@ expect { command_instance.execute! }.to raise_error(InvalidCommand::Invalid, "[!] command stopped due to invalid") end - it "returns a dnf state" do - expect(command).to be_dnf - expect(command.state).to eq(Lite::Command::DNF) + it "returns a interrupted state" do + expect(command).to be_interrupted + expect(command.state).to eq(Lite::Command::INTERRUPTED) end end @@ -126,9 +126,9 @@ expect { command_instance.execute! }.to raise_error(FailureCommand::Failure, "[!] command stopped due to failure") end - it "returns a dnf state" do - expect(command).to be_dnf - expect(command.state).to eq(Lite::Command::DNF) + it "returns a interrupted state" do + expect(command).to be_interrupted + expect(command.state).to eq(Lite::Command::INTERRUPTED) end end @@ -154,9 +154,9 @@ expect { command_instance.execute! }.to raise_error(ErrorCommand::Error, "[!] command stopped due to error") end - it "returns a dnf state" do - expect(command).to be_dnf - expect(command.state).to eq(Lite::Command::DNF) + it "returns a interrupted state" do + expect(command).to be_interrupted + expect(command.state).to eq(Lite::Command::INTERRUPTED) end end @@ -186,9 +186,9 @@ expect { command_instance.execute! }.to raise_error(ThrownCommand::Noop, "[!] command stopped due to child noop") end - it "returns a dnf state" do - expect(command).to be_dnf - expect(command.state).to eq(Lite::Command::DNF) + it "returns a interrupted state" do + expect(command).to be_interrupted + expect(command.state).to eq(Lite::Command::INTERRUPTED) end end @@ -214,9 +214,9 @@ command end - it "returns a dnf state" do - expect(command).to be_dnf - expect(command.state).to eq(Lite::Command::DNF) + it "returns a interrupted state" do + expect(command).to be_interrupted + expect(command.state).to eq(Lite::Command::INTERRUPTED) end end @@ -370,7 +370,7 @@ cid: "018c2b95-b764-7615-a924-cc5b910ed1e5", command: "NoopCommand", outcome: "noop", - state: "dnf", + state: "interrupted", status: "noop", reason: "[!] command stopped due to noop", caused_by: 1, @@ -390,7 +390,7 @@ cid: "018c2b95-b764-7615-a924-cc5b910ed1e5", command: "InvalidCommand", outcome: "invalid", - state: "dnf", + state: "interrupted", status: "invalid", reason: "[!] command stopped due to invalid", caused_by: 1, @@ -410,7 +410,7 @@ cid: "018c2b95-b764-7615-a924-cc5b910ed1e5", command: "FailureCommand", outcome: "failure", - state: "dnf", + state: "interrupted", status: "failure", reason: "[!] command stopped due to failure", caused_by: 1, @@ -430,7 +430,7 @@ cid: "018c2b95-b764-7615-a924-cc5b910ed1e5", command: "ErrorCommand", outcome: "error", - state: "dnf", + state: "interrupted", status: "error", reason: "[!] command stopped due to error", caused_by: 1, @@ -450,7 +450,7 @@ cid: "018c2b95-b764-7615-a924-cc5b910ed1e5", command: "ExceptionCommand", outcome: "error", - state: "dnf", + state: "interrupted", status: "error", reason: "[RuntimeError] [!] command stopped due to exception", caused_by: 1, @@ -469,8 +469,8 @@ index: 1, cid: "018c2b95-b764-7615-a924-cc5b910ed1e5", command: "ThrownCommand", - outcome: "dnf", - state: "dnf", + outcome: "interrupted", + state: "interrupted", status: "noop", reason: "[!] command stopped due to child noop", caused_by: 5,