Skip to content

Commit

Permalink
Rename domain_name input to name
Browse files Browse the repository at this point in the history
  • Loading branch information
azimux committed Mar 28, 2024
1 parent 3b6ae15 commit fb20b2d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
GIT
remote: foobara
revision: f97443e06569b022bae15c2b8c1b0c136fc3edf0
revision: 6815a111940fd393e6aa76f69622f5701cf38a4f
branch: main
specs:
foobara (0.0.1)

GIT
remote: https://github.com/foobara/files-generator.git
revision: 8e9439014484892bb49a1d720399d924f853baea
revision: 9c9c49a095adde08985cef2e8a5ff8037ad1ead9
specs:
foobara-files-generator (0.1.0)

Expand All @@ -27,7 +27,7 @@ GIT

GIT
remote: https://github.com/foobara/util.git
revision: b2e2e9c04d866b26c21b6e223bc359c76fcea0f8
revision: 7580a2d7530a6449238b0b1315f27cfee3ed6983
specs:
foobara-util (0.1.0)

Expand Down
6 changes: 3 additions & 3 deletions spec/foobara/generators/generate_domain_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
RSpec.describe Foobara::Generators::DomainGenerator::GenerateDomain do
let(:domain_name) { "SomeOrg::SomeDomain" }
let(:name) { "SomeOrg::SomeDomain" }

let(:inputs) do
{
domain_name:,
name:,
description: "whatever"
}
end
Expand All @@ -22,7 +22,7 @@
context "with all options" do
let(:inputs) do
{
domain_name: "SomeDomain",
name: "SomeDomain",
description: "whatever",
organization_name: "SomeOrg",
full_module_name: "SomeOrg::SomeDomain"
Expand Down
4 changes: 2 additions & 2 deletions spec/foobara/generators/write_domain_to_disk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
end
let(:domain_config) do
{
domain_name:,
name:,
description: "whatever"
}
end
let(:domain_name) { "SomeOrg::SomeDomain" }
let(:name) { "SomeOrg::SomeDomain" }
let(:output_directory) { "#{__dir__}/../../../tmp/domain_test_suite_output" }

before do
Expand Down
12 changes: 6 additions & 6 deletions src/domain_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Generators
module DomainGenerator
class DomainConfig < Foobara::Model
attributes do
domain_name :string, :required
name :string, :required
description :string, :allow_nil
organization_name :string, :allow_nil
full_module_name :string
Expand All @@ -16,26 +16,26 @@ class DomainConfig < Foobara::Model
def initialize(attributes = nil, options = {})
full_module_name = attributes[:full_module_name]
module_path = full_module_name&.split("::")
domain_name = attributes[:domain_name]
name = attributes[:name]
description = attributes[:description]
organization_name = attributes[:organization_name]

if organization_name.nil? && full_module_name.nil?
full_module_name = domain_name
full_module_name = name
module_path = full_module_name.split("::")

*organization_parts, domain_name = module_path
*organization_parts, name = module_path

unless organization_parts.empty?
organization_name = organization_parts.join("::")
end
end

full_module_name ||= [*organization_name, *domain_name].compact.join("::")
full_module_name ||= [*organization_name, *name].compact.join("::")

super(
{
domain_name:,
name:,
description:,
organization_name:,
full_module_name:
Expand Down

0 comments on commit fb20b2d

Please sign in to comment.