Skip to content

Commit

Permalink
feat(configs): extract Inspect config
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Jun 30, 2024
1 parent 2f4f654 commit 1b58f69
Show file tree
Hide file tree
Showing 24 changed files with 201 additions and 86 deletions.
2 changes: 2 additions & 0 deletions lib/convenient_service/service/configs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require_relative "configs/essential"

require_relative "configs/inspect"
require_relative "configs/standard"

require_relative "configs/aliases"
4 changes: 4 additions & 0 deletions lib/convenient_service/service/configs/aliases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ module ConvenientService
module Standard
Config = ::ConvenientService::Service::Configs::Standard
end

module Inspect
Config = ::ConvenientService::Service::Configs::Inspect
end
end
20 changes: 0 additions & 20 deletions lib/convenient_service/service/configs/essential.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ module Essential
concerns do
use ConvenientService::Plugins::Common::HasInternals::Concern

use ConvenientService::Plugins::Service::HasInspect::Concern

use ConvenientService::Plugins::Common::HasConstructor::Concern
use ConvenientService::Plugins::Common::HasConstructorWithoutInitialize::Concern

Expand Down Expand Up @@ -92,8 +90,6 @@ class self::Result
concerns do
use ConvenientService::Plugins::Common::HasInternals::Concern

use ConvenientService::Plugins::Result::HasInspect::Concern

use ConvenientService::Plugins::Common::HasConstructor::Concern
use ConvenientService::Plugins::Common::HasConstructorWithoutInitialize::Concern

Expand All @@ -108,35 +104,21 @@ class self::Result

class self::Data
include Core

concerns do
use ConvenientService::Plugins::Data::HasInspect::Concern
end
end

class self::Message
include Core

concerns do
use ConvenientService::Plugins::Message::HasInspect::Concern
end
end

class self::Code
include Core

concerns do
use ConvenientService::Plugins::Code::HasInspect::Concern
end
end

class self::Status
include Core

concerns do
use ConvenientService::Plugins::Common::HasInternals::Concern

use ConvenientService::Plugins::Status::HasInspect::Concern
end

class self::Internals
Expand Down Expand Up @@ -168,8 +150,6 @@ class self::Step
use ConvenientService::Plugins::Step::CanBeCompleted::Concern

use ConvenientService::Plugins::Step::CanBeMethodStep::Concern

use ConvenientService::Plugins::Step::HasInspect::Concern
end

##
Expand Down
57 changes: 57 additions & 0 deletions lib/convenient_service/service/configs/inspect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# frozen_string_literal: true

module ConvenientService
module Service
module Configs
module Inspect
include Support::Concern

# rubocop:disable Lint/ConstantDefinitionInBlock
included do
include Configs::Essential

concerns do
use ConvenientService::Plugins::Service::HasInspect::Concern
end

class self::Result
concerns do
use ConvenientService::Plugins::Result::HasInspect::Concern
end

class self::Data
concerns do
use ConvenientService::Plugins::Data::HasInspect::Concern
end
end

class self::Message
concerns do
use ConvenientService::Plugins::Message::HasInspect::Concern
end
end

class self::Code
concerns do
use ConvenientService::Plugins::Code::HasInspect::Concern
end
end

class self::Status
concerns do
use ConvenientService::Plugins::Status::HasInspect::Concern
end
end
end

class self::Step
concerns do
use ConvenientService::Plugins::Step::HasInspect::Concern
end
end
end
# rubocop:enable Lint/ConstantDefinitionInBlock
end
end
end
end
1 change: 1 addition & 0 deletions lib/convenient_service/service/configs/standard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module Standard
# rubocop:disable Lint/ConstantDefinitionInBlock
included do
include Configs::Essential
include Configs::Inspect

concerns do
use ConvenientService::Plugins::Common::CachesConstructorArguments::Concern
Expand Down
1 change: 1 addition & 0 deletions lib/convenient_service/service/configs/standard/v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module V1
# rubocop:disable Lint/ConstantDefinitionInBlock
included do
include Configs::Essential
include Configs::Inspect

concerns do
use ConvenientService::Plugins::Common::CachesConstructorArguments::Concern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
[
ConvenientService::Service::Plugins::CanHaveStubbedResults::Concern,
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Plugins::Common::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasResult::Concern,
Expand All @@ -42,6 +41,7 @@
ConvenientService::Service::Plugins::CanHaveSteps::Concern,
ConvenientService::Service::Plugins::CanHaveConnectedSteps::Concern,
ConvenientService::Service::Plugins::CanHaveFallbacks::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::CachesConstructorArguments::Concern,
ConvenientService::Common::Plugins::CanBeCopied::Concern,
ConvenientService::Service::Plugins::CanRecalculateResult::Concern,
Expand Down Expand Up @@ -250,11 +250,11 @@
let(:concerns) do
[
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Common::Plugins::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanHaveStep::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasJSendResultDuckShortSyntax::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanRecalculateResult::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasNegatedResult::Concern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
[
ConvenientService::Service::Plugins::CanHaveStubbedResults::Concern,
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Plugins::Common::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasResult::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Concern,
ConvenientService::Service::Plugins::CanHaveSteps::Concern,
ConvenientService::Service::Plugins::CanHaveSequentialSteps::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::CachesConstructorArguments::Concern,
ConvenientService::Common::Plugins::CanBeCopied::Concern,
ConvenientService::Service::Plugins::CanRecalculateResult::Concern,
Expand Down Expand Up @@ -188,11 +188,11 @@
let(:concerns) do
[
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Common::Plugins::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanHaveStep::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasJSendResultDuckShortSyntax::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanRecalculateResult::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanBeFromException::Concern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
[
ConvenientService::Service::Plugins::CanHaveStubbedResults::Concern,
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Plugins::Common::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasResult::Concern,
Expand All @@ -42,6 +41,7 @@
ConvenientService::Service::Plugins::CanHaveSteps::Concern,
ConvenientService::Service::Plugins::CanHaveConnectedSteps::Concern,
ConvenientService::Service::Plugins::CanHaveFallbacks::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::CachesConstructorArguments::Concern,
ConvenientService::Common::Plugins::CanBeCopied::Concern,
ConvenientService::Service::Plugins::CanRecalculateResult::Concern,
Expand Down Expand Up @@ -252,11 +252,11 @@
let(:concerns) do
[
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Common::Plugins::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanHaveStep::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasJSendResultDuckShortSyntax::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanRecalculateResult::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasNegatedResult::Concern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
[
ConvenientService::Service::Plugins::CanHaveStubbedResults::Concern,
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Plugins::Common::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasResult::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Concern,
ConvenientService::Service::Plugins::CanHaveSteps::Concern,
ConvenientService::Service::Plugins::CanHaveSequentialSteps::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::CachesConstructorArguments::Concern,
ConvenientService::Common::Plugins::CanBeCopied::Concern,
ConvenientService::Service::Plugins::CanRecalculateResult::Concern,
Expand Down Expand Up @@ -190,11 +190,11 @@
let(:concerns) do
[
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Common::Plugins::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanHaveStep::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasJSendResultDuckShortSyntax::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanRecalculateResult::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::CanBeFromException::Concern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
# rubocop:disable RSpec/DescribeClass
RSpec.describe "convenient_service/service/configs/aliases", type: :standard do
specify { expect(ConvenientService::Standard::Config).to eq(ConvenientService::Service::Configs::Standard) }
specify { expect(ConvenientService::Inspect::Config).to eq(ConvenientService::Service::Configs::Inspect) }
end
# rubocop:enable RSpec/DescribeClass
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
# https://github.com/marian13/convenient_service/discussions/43
#
it "applies its `included` block only once" do
expect(service_class.concerns.to_a.size).to eq(12)
expect(service_class.concerns.to_a.size).to eq(11)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
# https://github.com/marian13/convenient_service/discussions/43
#
it "applies its `included` block only once" do
expect(service_class.concerns.to_a.size).to eq(12)
expect(service_class.concerns.to_a.size).to eq(11)
end
end
end
Expand Down
51 changes: 2 additions & 49 deletions spec/lib/convenient_service/service/configs/essential_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
let(:concerns) do
[
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Plugins::Common::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasResult::Concern,
Expand Down Expand Up @@ -92,7 +91,6 @@
let(:concerns) do
[
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasInspect::Concern,
ConvenientService::Common::Plugins::HasConstructor::Concern,
ConvenientService::Common::Plugins::HasConstructorWithoutInitialize::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Concern,
Expand All @@ -117,54 +115,11 @@
end
end

example_group "service result data" do
example_group "concerns" do
let(:concerns) do
[
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::Plugins::HasInspect::Concern
]
end

it "sets service result data concerns" do
expect(service_class::Result::Data.concerns.to_a).to eq(concerns)
end
end
end

example_group "service result message" do
example_group "concerns" do
let(:concerns) do
[
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins::HasInspect::Concern
]
end

it "sets service result message concerns" do
expect(service_class::Result::Message.concerns.to_a).to eq(concerns)
end
end
end

example_group "service result code" do
example_group "concerns" do
let(:concerns) do
[
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code::Plugins::HasInspect::Concern
]
end

it "sets service result code concerns" do
expect(service_class::Result::Code.concerns.to_a).to eq(concerns)
end
end
end

example_group "service result status" do
example_group "concerns" do
let(:concerns) do
[
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status::Plugins::HasInspect::Concern
ConvenientService::Common::Plugins::HasInternals::Concern
]
end

Expand Down Expand Up @@ -210,9 +165,7 @@
ConvenientService::Common::Plugins::HasInternals::Concern,
ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::HasResult::Concern,
ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeCompleted::Concern,
ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeMethodStep::Concern,

ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::HasInspect::Concern
ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeMethodStep::Concern
]
end

Expand Down
Loading

0 comments on commit 1b58f69

Please sign in to comment.