Skip to content

Commit

Permalink
Rename dnf to interrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
drexed committed Sep 30, 2024
1 parent fab3c6b commit cedaa8b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions lib/lite/command/internals/executable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
50 changes: 25 additions & 25 deletions spec/lite/command/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit cedaa8b

Please sign in to comment.