Skip to content

Commit

Permalink
feat(can_connected_steps): add inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Feb 27, 2024
1 parent c517ef5 commit d1318bd
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def step(*args, **kwargs)
# @param kwargs [Hash{Symbol => Object}]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `not` from `not_step` has a similar precedence as Ruby's `!`.
# @note `not_step` is a rought equivalent of `!step`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def not_step(*args, **kwargs)
previous_expression = steps.expression

Expand Down Expand Up @@ -71,6 +75,10 @@ def not_step(*args, **kwargs)
# @param kwargs [Hash{Symbol => Object}]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `and` from `and_step` has a similar precedence as Ruby's `&&`.
# @note `and_step` is a rought equivalent of `&& step`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def and_step(*args, **kwargs)
previous_expression = steps.expression

Expand All @@ -94,6 +102,11 @@ def and_step(*args, **kwargs)
# @param kwargs [Hash{Symbol => Object}]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `and` from `and_step` has a similar precedence as Ruby's `&&`.
# @note `not` from `and_not_step` has a similar precedence as Ruby's `!`.
# @note `and_not_step` is a rought equivalent of `&& !step`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def and_not_step(*args, **kwargs)
previous_expression = steps.expression

Expand All @@ -119,6 +132,10 @@ def and_not_step(*args, **kwargs)
# @param kwargs [Hash{Symbol => Object}]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `or` from `or_step` has a similar precedence as Ruby's `||`.
# @note `or_step` is a rought equivalent of `|| step`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
# @internal
# NOTE: Decomposing of the `and` expression is needed to make its priority higher.
#
Expand Down Expand Up @@ -155,6 +172,11 @@ def or_step(*args, **kwargs)
# @param kwargs [Hash{Symbol => Object}]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `or` from `or_not_step` has a similar precedence as Ruby's `||`.
# @note `not` from `or_not_step` has a similar precedence as Ruby's `!`.
# @note `or_not_step` is a rought equivalent of `|| !step`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
# @internal
# NOTE: Decomposing of the `and` expression is needed to make its priority higher.
#
Expand Down Expand Up @@ -192,6 +214,10 @@ def or_not_step(*args, **kwargs)
# @param block [Proc, nil]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `group` has a similar precedence as Ruby's `()`.
# @note `group` is a rought equivalent of `()`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def group(&block)
previous_expression = steps.expression

Expand Down Expand Up @@ -220,6 +246,11 @@ def group(&block)
# @param block [Proc, nil]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `not` from `not_group` has a similar precedence as Ruby's `!`.
# @note `group` from `not_group` has a similar precedence as Ruby's `()`.
# @note `not_group` is a rought equivalent of `!()`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def not_group(&block)
previous_expression = steps.expression

Expand Down Expand Up @@ -252,6 +283,11 @@ def not_group(&block)
# @param block [Proc, nil]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `and` from `and_group` has a similar precedence as Ruby's `&&`.
# @note `group` from `and_group` has a similar precedence as Ruby's `()`.
# @note `not_group` is a rought equivalent of `&& ()`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def and_group(&block)
previous_expression = steps.expression

Expand All @@ -278,6 +314,12 @@ def and_group(&block)
# @param block [Proc, nil]
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
#
# @note `and` from `and_not_group` has a similar precedence as Ruby's `&&`.
# @note `not` from `and_not_group` has a similar precedence as Ruby's `!`.
# @note `group` from `and_not_group` has a similar precedence as Ruby's `()`.
# @note `and_not_group` is a rought equivalent of `&& !()`.
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def and_not_group(&block)
previous_expression = steps.expression

Expand Down Expand Up @@ -309,6 +351,11 @@ def and_not_group(&block)
# @internal
# NOTE: Decomposing of the `and` expression is needed to make its priority higher.
#
# @note `or` from `or_group` has a similar precedence as Ruby's `||`.
# @note `group` from `or_group` has a similar precedence as Ruby's `()`.
# @note `or_group` is a rought equivalent of `|| ()`
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def or_group(&block)
previous_expression = steps.expression

Expand Down Expand Up @@ -348,6 +395,12 @@ def or_group(&block)
# @internal
# NOTE: Decomposing of the `and` expression is needed to make its priority higher.
#
# @note `or` from `or_not_group` has a similar precedence as Ruby's `||`.
# @note `not` from `or_not_group` has a similar precedence as Ruby's `!`.
# @note `group` from `or_not_group` has a similar precedence as Ruby's `()`.
# @note `or_not_group` is a rought equivalent of `|| !()`
# @see https://ruby-doc.org/core-2.7.1/doc/syntax/precedence_rdoc.html
#
def or_not_group(&block)
previous_expression = steps.expression

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def with_organizer(organizer)
# @return [String]
#
def inspect
"#{left_expression.inspect} and #{right_expression.inspect}"
"#{left_expression.inspect} && #{right_expression.inspect}"
end

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def with_organizer(organizer)
# @return [String]
#
def inspect
"not #{expression.inspect}"
"!#{expression.inspect}"
end

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def with_organizer(organizer)
# @return [String]
#
def inspect
"#{left_expression.inspect} or #{right_expression.inspect}"
"#{left_expression.inspect} || #{right_expression.inspect}"
end

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def bar

describe "#inspect" do
it "returns inspect representation" do
expect(expression.inspect).to eq("#{left_sub_expression.inspect} and #{right_sub_expression.inspect}")
expect(expression.inspect).to eq("#{left_sub_expression.inspect} && #{right_sub_expression.inspect}")
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def foo

describe "#inspect" do
it "returns inspect representation" do
expect(expression.inspect).to eq("not #{sub_expression.inspect}")
expect(expression.inspect).to eq("!#{sub_expression.inspect}")
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def bar

describe "#inspect" do
it "returns inspect representation" do
expect(expression.inspect).to eq("#{left_sub_expression.inspect} or #{right_sub_expression.inspect}")
expect(expression.inspect).to eq("#{left_sub_expression.inspect} || #{right_sub_expression.inspect}")
end
end

Expand Down

0 comments on commit d1318bd

Please sign in to comment.