hecks-domain 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/hecks/domain/commands/generate.rb +98 -0
- data/lib/hecks/domain/commands.rb +1 -0
- data/lib/hecks/domain/generators/domain.rb +21 -0
- data/lib/hecks/domain/generators/domain_files.rb +28 -0
- data/lib/hecks/domain/generators/entity.rb +30 -0
- data/lib/hecks/domain/generators/operation.rb +32 -0
- data/lib/hecks/domain/generators/root.rb +30 -0
- data/lib/hecks/domain/generators/spec.rb +30 -0
- data/lib/hecks/domain/generators/value_object.rb +30 -0
- data/lib/hecks/domain/generators.rb +7 -0
- data/lib/hecks/domain/parser/aggregate.rb +44 -0
- data/lib/hecks/domain/parser/domain_object.rb +123 -0
- data/lib/hecks/domain/parser/entity_field.rb +55 -0
- data/lib/hecks/domain/parser/fields.rb +16 -0
- data/lib/hecks/domain/parser/list_field.rb +13 -0
- data/lib/hecks/domain/parser/operation.rb +15 -0
- data/lib/hecks/domain/parser/reference_field.rb +12 -0
- data/lib/hecks/domain/parser/spec_helper.rb +0 -0
- data/lib/hecks/domain/parser/value_field.rb +48 -0
- data/lib/hecks/domain/parser.rb +95 -0
- data/lib/hecks/domain/support/string.rb +9 -0
- data/lib/hecks/domain/support.rb +1 -0
- data/lib/hecks/domain/templates/%domain_name%.gemspec.tt +12 -0
- data/lib/hecks/domain/templates/%folder_name%/Domainfile.tt +9 -0
- data/lib/hecks/domain/templates/%folder_name%/events/command_will_run.rb.tt +11 -0
- data/lib/hecks/domain/templates/%folder_name%/spec/spec_helper.rb.tt +1 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/commands.rb.tt +11 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/events.rb.tt +11 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories/build.rb.tt +37 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories.rb.tt +11 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/invariants.rb.tt +11 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/queries.rb.tt +11 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/repository.rb.tt +68 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/subscribers.rb.tt +11 -0
- data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%.rb.tt +34 -0
- data/lib/hecks/domain/templates/lib/%domain_name%.rb.tt +9 -0
- data/lib/hecks/domain/templates/lib/support/commands/command_loader.rb +18 -0
- data/lib/hecks/domain/templates/lib/support/commands/command_runner.rb +17 -0
- data/lib/hecks/domain/templates/lib/support/commands.rb +2 -0
- data/lib/hecks/domain/templates/lib/support/domain_object.rb +25 -0
- data/lib/hecks/domain/templates/lib/support/events/domain_event.rb +14 -0
- data/lib/hecks/domain/templates/lib/support/events/domain_event_publisher.rb +34 -0
- data/lib/hecks/domain/templates/lib/support/events.rb +14 -0
- data/lib/hecks/domain/templates/lib/support/factories/factory_loader.rb +21 -0
- data/lib/hecks/domain/templates/lib/support/factories.rb +1 -0
- data/lib/hecks/domain/templates/lib/support/invariants/invariant_loader.rb +24 -0
- data/lib/hecks/domain/templates/lib/support/queries/query_loader.rb +18 -0
- data/lib/hecks/domain/templates/lib/support/queries.rb +1 -0
- data/lib/hecks/domain/templates/lib/support/repositories/repository_loader.rb +32 -0
- data/lib/hecks/domain/templates/lib/support/root.rb +27 -0
- data/lib/hecks/domain/templates/lib/support/support/string.rb +9 -0
- data/lib/hecks/domain/templates/lib/support.rb +11 -0
- data/lib/hecks/domain/templates/operation/%aggregate_name%/%domain_object_name%/commands/%operation_name%.rb.tt +21 -0
- data/lib/hecks/domain/templates/root/%aggregate_name%/root.rb.tt +14 -0
- data/lib/hecks/domain/templates/spec/%aggregate_name%/%root_name%_spec.rb.tt +12 -0
- data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories/build.rb.tt +37 -0
- data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories.rb.tt +11 -0
- data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%.rb.tt +34 -0
- data/lib/hecks/domain/top_level_methods.rb +3 -0
- data/lib/hecks/domain.rb +22 -0
- metadata +101 -59
- data/lib/adapters/adapters.rb +0 -2
- data/lib/adapters/resource_server/cli/cli.rb +0 -1
- data/lib/adapters/resource_server/cli/generate_resource_server.rb +0 -25
- data/lib/adapters/resource_server/cli/templates/resource_server/config.ru.tt +0 -8
- data/lib/adapters/resource_server/resource_server.rb +0 -1
- data/lib/adapters/sql_database/cli/cli.rb +0 -3
- data/lib/adapters/sql_database/cli/generate_domain_migrations.rb +0 -33
- data/lib/adapters/sql_database/cli/generate_sql_database.rb +0 -35
- data/lib/adapters/sql_database/cli/migration_builder.rb +0 -51
- data/lib/adapters/sql_database/cli/templates/migration.rb.tt +0 -14
- data/lib/adapters/sql_database/cli/templates/repository.rb.tt +0 -24
- data/lib/adapters/sql_database/cli/templates/sql_database/Gemfile +0 -10
- data/lib/adapters/sql_database/cli/templates/sql_database/Rakefile +0 -15
- data/lib/adapters/sql_database/commands/read/fetch_references.rb +0 -58
- data/lib/adapters/sql_database/commands/update/delete_references.rb +0 -45
- data/lib/adapters/sql_database/commands/update/link_to_references.rb +0 -45
- data/lib/adapters/sql_database/sql_database.rb +0 -1
- data/lib/cli/builder/aggregate_command_line_builder.rb +0 -22
- data/lib/cli/builder/builder.rb +0 -3
- data/lib/cli/builder/reference_command_line_builder.rb +0 -23
- data/lib/cli/builder/value_object_command_line_builder.rb +0 -23
- data/lib/cli/cli.rb +0 -8
- data/lib/cli/command_builder.rb +0 -59
- data/lib/cli/domain_object/assignment_template.rb +0 -43
- data/lib/cli/domain_object/option_formatter.rb +0 -36
- data/lib/cli/generate_domain_object.rb +0 -71
- data/lib/cli/new.rb +0 -50
- data/lib/cli/templates/aggregate/lib/domain/%name%/%head_name%.rb.tt +0 -16
- data/lib/cli/templates/aggregate/lib/domain/%name%/%name%.rb.tt +0 -9
- data/lib/cli/templates/aggregate/lib/domain/%name%/repository.rb.tt +0 -41
- data/lib/cli/templates/domain/%name%.gemspec.tt +0 -12
- data/lib/cli/templates/domain/Version +0 -1
- data/lib/cli/templates/domain/lib/%name%.rb.tt +0 -21
- data/lib/cli/templates/domain/spec/spec_helper.rb.tt +0 -4
- data/lib/cli/templates/reference/lib/domain/%module_name%/%file_name%.rb.tt +0 -25
- data/lib/cli/templates/value_object/lib/domain/%module_name%/%name%.rb.tt +0 -24
- data/lib/domain_builder/attribute.rb +0 -60
- data/lib/domain_builder/domain.rb +0 -19
- data/lib/domain_builder/domain_builder.rb +0 -37
- data/lib/domain_builder/domain_module.rb +0 -28
- data/lib/domain_builder/domain_object.rb +0 -43
- data/lib/domain_builder/head.rb +0 -8
- data/lib/domain_builder/reference.rb +0 -19
- data/lib/domain_builder/value.rb +0 -8
- data/lib/hecks-domain.rb +0 -7
@@ -1,19 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
class DomainBuilder
|
4
|
-
class Domain
|
5
|
-
attr_reader :domain_modules, :name
|
6
|
-
def initialize(name:)
|
7
|
-
@name = name
|
8
|
-
@domain_modules = {}
|
9
|
-
end
|
10
|
-
|
11
|
-
def module(name, &block)
|
12
|
-
result = DomainModule.new(name: name)
|
13
|
-
@domain_modules[name.to_sym] = result
|
14
|
-
yield(result)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require_relative 'attribute'
|
2
|
-
require_relative 'domain'
|
3
|
-
require_relative 'domain_module'
|
4
|
-
require_relative 'domain_object'
|
5
|
-
require_relative 'value'
|
6
|
-
require_relative 'head'
|
7
|
-
require_relative 'reference'
|
8
|
-
|
9
|
-
module Hecks
|
10
|
-
module Domain
|
11
|
-
class DomainBuilder
|
12
|
-
Types = { string: 'String', integer: 'Integer', currency: 'Currency'}
|
13
|
-
|
14
|
-
attr_accessor :domain, :specification, :name
|
15
|
-
|
16
|
-
def initialize(domain_name:, &block)
|
17
|
-
@name = domain_name
|
18
|
-
@domain = Domain.new(name: domain_name)
|
19
|
-
block.yield(@domain)
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
def domain_modules
|
24
|
-
@domain.domain_modules
|
25
|
-
end
|
26
|
-
|
27
|
-
def [](module_name)
|
28
|
-
domain_modules[module_name]
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def self.build(domain_name, &block)
|
33
|
-
new(domain_name: domain_name, &block)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
class DomainBuilder
|
4
|
-
class DomainModule
|
5
|
-
attr_reader :objects, :name, :references
|
6
|
-
|
7
|
-
def initialize(name:)
|
8
|
-
@name = name
|
9
|
-
@objects = []
|
10
|
-
@references = []
|
11
|
-
end
|
12
|
-
|
13
|
-
def head(name=nil)
|
14
|
-
return (@objects << Head.new(name: name)).last if name
|
15
|
-
objects.find{ |o| o.is_a?(Head) }
|
16
|
-
end
|
17
|
-
|
18
|
-
def value(name)
|
19
|
-
(@objects << Value.new(name: name)).last
|
20
|
-
end
|
21
|
-
|
22
|
-
def reference(name)
|
23
|
-
(@references << Reference.new(name)).last
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
class DomainBuilder
|
4
|
-
class DomainObject
|
5
|
-
attr_reader :name, :attributes
|
6
|
-
|
7
|
-
def initialize(name:)
|
8
|
-
@name = name
|
9
|
-
end
|
10
|
-
|
11
|
-
def attributes(*values)
|
12
|
-
return @attributes if @attributes
|
13
|
-
@attributes = values.map { |value| Hecks::Domain::DomainBuilder::Attribute.new(value) }
|
14
|
-
end
|
15
|
-
|
16
|
-
def attribute_hash
|
17
|
-
attributes.map do |attribute|
|
18
|
-
[attribute.name.to_sym, type_with_domain_module(attribute)]
|
19
|
-
end.to_h
|
20
|
-
end
|
21
|
-
|
22
|
-
def attribute_string
|
23
|
-
attributes.map do |attribute|
|
24
|
-
[attribute.name, type_with_domain_module(attribute)].join(':')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def references
|
29
|
-
@attributes.reject(&:primitive?)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def type_with_domain_module(attribute)
|
35
|
-
type = DomainBuilder::Types.values.include?(attribute.type) ? "Value" : attribute.type
|
36
|
-
type = '[' + type + ']' if attribute.list?
|
37
|
-
return type unless attribute.domain_module
|
38
|
-
[attribute.domain_module, type].join("::")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/domain_builder/head.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
class DomainBuilder
|
4
|
-
class Reference
|
5
|
-
def initialize(reference)
|
6
|
-
@reference = reference
|
7
|
-
end
|
8
|
-
|
9
|
-
def referenced_entity
|
10
|
-
@reference.split("::").map(&:camelcase).join("::")
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
@reference.split("::").last.camelcase + "Reference"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/domain_builder/value.rb
DELETED