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
@@ -0,0 +1,21 @@
|
|
1
|
+
module <%= @domain_object.aggregate.domain.name %>
|
2
|
+
module Domain
|
3
|
+
module <%= aggregate.name%>
|
4
|
+
class <%= domain_object.name %>
|
5
|
+
module Commands
|
6
|
+
class <%= operation.name %>
|
7
|
+
attr_reader :root, :args
|
8
|
+
|
9
|
+
def initialize(root, args={})
|
10
|
+
@root = root
|
11
|
+
@args = args
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '<%= root.name.to_s.underscore %>'
|
2
|
+
<% root.aggregate.domain_objects.each do |domain_object| -%>
|
3
|
+
<% next if domain_object.is_a?(HecksDomain::Parser::Root) -%>
|
4
|
+
require_relative '<%= domain_object.name.to_s.underscore %>'
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
module <%= domain.name %>
|
8
|
+
module Domain
|
9
|
+
module <%= aggregate.name %>
|
10
|
+
class Root < <%= root.name %>
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe <%= "#{domain.name}::Domain::#{aggregate.name}::#{root.name}" %> do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
<% root.operations_get.each do |operation| -%>
|
7
|
+
describe '#<%= operation.name.to_s.underscore %>' do
|
8
|
+
xit 'should behave' do
|
9
|
+
end
|
10
|
+
end
|
11
|
+
<% end -%>
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module <%= @domain.name %>
|
2
|
+
module Domain
|
3
|
+
module <%= @aggregate.name%>
|
4
|
+
class <%= @domain_object.name %>
|
5
|
+
module Factories
|
6
|
+
# Recursively build domain objects. Used in the domain as the primary
|
7
|
+
# factory. The results of #build can be passed to any other build
|
8
|
+
# factory in the domain. Takes a hash, or a list of hashes. If a list
|
9
|
+
# is given, it will return a list of the instantiated objects
|
10
|
+
class Build
|
11
|
+
def self.factory(args=nil)
|
12
|
+
return args if args.nil?
|
13
|
+
return args unless args.is_a?(Hash)
|
14
|
+
|
15
|
+
[args].flatten.map do |domain_object_args|
|
16
|
+
new_domain_object(domain_object_args)
|
17
|
+
end.tap do |result|
|
18
|
+
return result.first unless args.is_a?(Array)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.new_domain_object(args)
|
23
|
+
<%= @domain_object.name %>.new(
|
24
|
+
args.merge(
|
25
|
+
<% @domain_object.fields.each do |field| -%>
|
26
|
+
<% next unless (field.respond_to?(:module_name) && field.module_name) -%>
|
27
|
+
<%= field.name.to_s%>: <%= field.module_name.is_a?(Hash) ? 'Domain::' + field.module_name.to_a.join('::').to_s : field.module_name.to_s %>.build(args[:<%= field.name.to_s%>]),
|
28
|
+
<% end -%>
|
29
|
+
)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module <%= domain.name %>
|
2
|
+
module Domain
|
3
|
+
module <%= aggregate.name %>
|
4
|
+
class <%= domain_object.name %>
|
5
|
+
<%= 'include Support::Root' if domain_object.is_a?(HecksDomain::Parser::Root) %>
|
6
|
+
include Support::DomainObject
|
7
|
+
|
8
|
+
attr_reader <%= domain_object.public_accessors %>
|
9
|
+
|
10
|
+
def initialize(<%= domain_object.initializer_attributes %>)
|
11
|
+
<% domain_object.fields.each do |field| -%>
|
12
|
+
<%= "@#{field.name} = #{field.initial_state}" %>
|
13
|
+
<% end -%>
|
14
|
+
end
|
15
|
+
<% domain_object.boolean_accessors.each do |field| -%>
|
16
|
+
|
17
|
+
def <%= field.name %>?
|
18
|
+
@<%= field.name %>
|
19
|
+
end
|
20
|
+
<% end -%>
|
21
|
+
<% domain_object.list_accessors.each do |field| -%>
|
22
|
+
|
23
|
+
def <%= field.name %>
|
24
|
+
@<%= field.name %>.clone.freeze
|
25
|
+
end
|
26
|
+
<% end -%>
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_writer <%= domain_object.private_accessors %>
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/hecks/domain.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'singleton'
|
3
|
+
require 'erubis'
|
4
|
+
require 'thor'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
require_relative 'domain/top_level_methods'
|
8
|
+
require_relative 'domain/support'
|
9
|
+
require_relative 'domain/parser'
|
10
|
+
require_relative 'domain/generators'
|
11
|
+
require_relative 'domain/commands'
|
12
|
+
|
13
|
+
class HecksDomain
|
14
|
+
attr_reader :domain
|
15
|
+
def initialize(name, &block)
|
16
|
+
@domain = Parser.new(name, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parser(name, &block)
|
20
|
+
new name, &block
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,81 +1,124 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hecks-domain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Hecks Domain Developer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: colorize
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
|
28
|
-
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: erubis
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.20'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.20'
|
55
|
+
description: A Domain Specific Language for generating Domain Driven Designs
|
56
|
+
email: dev@hecks_domain.com
|
29
57
|
executables: []
|
30
58
|
extensions: []
|
31
59
|
extra_rdoc_files: []
|
32
60
|
files:
|
33
|
-
- lib/
|
34
|
-
- lib/
|
35
|
-
- lib/
|
36
|
-
- lib/
|
37
|
-
- lib/
|
38
|
-
- lib/
|
39
|
-
- lib/
|
40
|
-
- lib/
|
41
|
-
- lib/
|
42
|
-
- lib/
|
43
|
-
- lib/
|
44
|
-
- lib/
|
45
|
-
- lib/
|
46
|
-
- lib/
|
47
|
-
- lib/
|
48
|
-
- lib/
|
49
|
-
- lib/
|
50
|
-
- lib/
|
51
|
-
- lib/
|
52
|
-
- lib/
|
53
|
-
- lib/
|
54
|
-
- lib/
|
55
|
-
- lib/
|
56
|
-
- lib/
|
57
|
-
- lib/
|
58
|
-
- lib/
|
59
|
-
- lib/
|
60
|
-
- lib/
|
61
|
-
- lib/
|
62
|
-
- lib/
|
63
|
-
- lib/
|
64
|
-
- lib/
|
65
|
-
- lib/
|
66
|
-
- lib/
|
67
|
-
- lib/
|
68
|
-
- lib/
|
69
|
-
- lib/
|
70
|
-
- lib/
|
71
|
-
- lib/
|
72
|
-
- lib/
|
73
|
-
- lib/
|
74
|
-
- lib/
|
75
|
-
- lib/
|
76
|
-
- lib/
|
77
|
-
- lib/hecks
|
78
|
-
|
61
|
+
- lib/hecks/domain.rb
|
62
|
+
- lib/hecks/domain/commands.rb
|
63
|
+
- lib/hecks/domain/commands/generate.rb
|
64
|
+
- lib/hecks/domain/generators.rb
|
65
|
+
- lib/hecks/domain/generators/domain.rb
|
66
|
+
- lib/hecks/domain/generators/domain_files.rb
|
67
|
+
- lib/hecks/domain/generators/entity.rb
|
68
|
+
- lib/hecks/domain/generators/operation.rb
|
69
|
+
- lib/hecks/domain/generators/root.rb
|
70
|
+
- lib/hecks/domain/generators/spec.rb
|
71
|
+
- lib/hecks/domain/generators/value_object.rb
|
72
|
+
- lib/hecks/domain/parser.rb
|
73
|
+
- lib/hecks/domain/parser/aggregate.rb
|
74
|
+
- lib/hecks/domain/parser/domain_object.rb
|
75
|
+
- lib/hecks/domain/parser/entity_field.rb
|
76
|
+
- lib/hecks/domain/parser/fields.rb
|
77
|
+
- lib/hecks/domain/parser/list_field.rb
|
78
|
+
- lib/hecks/domain/parser/operation.rb
|
79
|
+
- lib/hecks/domain/parser/reference_field.rb
|
80
|
+
- lib/hecks/domain/parser/spec_helper.rb
|
81
|
+
- lib/hecks/domain/parser/value_field.rb
|
82
|
+
- lib/hecks/domain/support.rb
|
83
|
+
- lib/hecks/domain/support/string.rb
|
84
|
+
- lib/hecks/domain/templates/%domain_name%.gemspec.tt
|
85
|
+
- lib/hecks/domain/templates/%folder_name%/Domainfile.tt
|
86
|
+
- lib/hecks/domain/templates/%folder_name%/events/command_will_run.rb.tt
|
87
|
+
- lib/hecks/domain/templates/%folder_name%/spec/spec_helper.rb.tt
|
88
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%.rb.tt
|
89
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/commands.rb.tt
|
90
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/events.rb.tt
|
91
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories.rb.tt
|
92
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories/build.rb.tt
|
93
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/invariants.rb.tt
|
94
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/queries.rb.tt
|
95
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/repository.rb.tt
|
96
|
+
- lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/subscribers.rb.tt
|
97
|
+
- lib/hecks/domain/templates/lib/%domain_name%.rb.tt
|
98
|
+
- lib/hecks/domain/templates/lib/support.rb
|
99
|
+
- lib/hecks/domain/templates/lib/support/commands.rb
|
100
|
+
- lib/hecks/domain/templates/lib/support/commands/command_loader.rb
|
101
|
+
- lib/hecks/domain/templates/lib/support/commands/command_runner.rb
|
102
|
+
- lib/hecks/domain/templates/lib/support/domain_object.rb
|
103
|
+
- lib/hecks/domain/templates/lib/support/events.rb
|
104
|
+
- lib/hecks/domain/templates/lib/support/events/domain_event.rb
|
105
|
+
- lib/hecks/domain/templates/lib/support/events/domain_event_publisher.rb
|
106
|
+
- lib/hecks/domain/templates/lib/support/factories.rb
|
107
|
+
- lib/hecks/domain/templates/lib/support/factories/factory_loader.rb
|
108
|
+
- lib/hecks/domain/templates/lib/support/invariants/invariant_loader.rb
|
109
|
+
- lib/hecks/domain/templates/lib/support/queries.rb
|
110
|
+
- lib/hecks/domain/templates/lib/support/queries/query_loader.rb
|
111
|
+
- lib/hecks/domain/templates/lib/support/repositories/repository_loader.rb
|
112
|
+
- lib/hecks/domain/templates/lib/support/root.rb
|
113
|
+
- lib/hecks/domain/templates/lib/support/support/string.rb
|
114
|
+
- lib/hecks/domain/templates/operation/%aggregate_name%/%domain_object_name%/commands/%operation_name%.rb.tt
|
115
|
+
- lib/hecks/domain/templates/root/%aggregate_name%/root.rb.tt
|
116
|
+
- lib/hecks/domain/templates/spec/%aggregate_name%/%root_name%_spec.rb.tt
|
117
|
+
- lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%.rb.tt
|
118
|
+
- lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories.rb.tt
|
119
|
+
- lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories/build.rb.tt
|
120
|
+
- lib/hecks/domain/top_level_methods.rb
|
121
|
+
homepage: http://www.example.com
|
79
122
|
licenses:
|
80
123
|
- MIT
|
81
124
|
metadata: {}
|
@@ -94,9 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
137
|
- !ruby/object:Gem::Version
|
95
138
|
version: '0'
|
96
139
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.6.10
|
140
|
+
rubygems_version: 3.0.3
|
99
141
|
signing_key:
|
100
142
|
specification_version: 4
|
101
|
-
summary:
|
143
|
+
summary: 3DSL
|
102
144
|
test_files: []
|
data/lib/adapters/adapters.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative 'generate_resource_server'
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
module Adapters
|
4
|
-
module ResourceServer
|
5
|
-
module CLI
|
6
|
-
class GenerateResourceServer < Thor::Group
|
7
|
-
include Thor::Actions
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
File.dirname(__FILE__) + '/templates/'
|
11
|
-
end
|
12
|
-
|
13
|
-
def create_aggregate_folder
|
14
|
-
directory('resource_server', '.')
|
15
|
-
end
|
16
|
-
|
17
|
-
def domain
|
18
|
-
File.basename(Dir.getwd)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require_relative 'cli/cli'
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
module Adapters
|
4
|
-
class SQLDatabase
|
5
|
-
module CLI
|
6
|
-
class GenerateDomainMigrations < Thor::Group
|
7
|
-
include Thor::Actions
|
8
|
-
attr_writer :migration_builder
|
9
|
-
|
10
|
-
def load_domain_spec
|
11
|
-
load('../../Domain')
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.source_root
|
15
|
-
File.dirname(__FILE__) + '/templates/'
|
16
|
-
end
|
17
|
-
|
18
|
-
def create_migration_file
|
19
|
-
@migration_builder = MigrationBuilder.new(self, DOMAIN)
|
20
|
-
@migration_builder.call
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def migration_builder
|
26
|
-
@migration_builder
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
module Adapters
|
4
|
-
class SQLDatabase
|
5
|
-
module CLI
|
6
|
-
class GenerateSQLDatabase < Thor::Group
|
7
|
-
include Thor::Actions
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
File.dirname(__FILE__) + '/templates/'
|
11
|
-
end
|
12
|
-
|
13
|
-
def create_sql_database_folder
|
14
|
-
directory('sql_database', './adapters/sql_database')
|
15
|
-
end
|
16
|
-
|
17
|
-
def bundle
|
18
|
-
run 'bundle'
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def class_name
|
24
|
-
@class_name
|
25
|
-
end
|
26
|
-
|
27
|
-
def domain_module_name
|
28
|
-
DOMAIN.name.camelize
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
module Adapters
|
4
|
-
class SQLDatabase
|
5
|
-
module CLI
|
6
|
-
class MigrationBuilder
|
7
|
-
def initialize(generator, specification)
|
8
|
-
@generator = generator
|
9
|
-
@schema = Hecks::Adapters::SQLDatabase::Schema.factory(specification)
|
10
|
-
end
|
11
|
-
|
12
|
-
def call
|
13
|
-
generate_migrations
|
14
|
-
self
|
15
|
-
end
|
16
|
-
|
17
|
-
def table_name
|
18
|
-
@table.name
|
19
|
-
end
|
20
|
-
|
21
|
-
def columns
|
22
|
-
@table.columns
|
23
|
-
end
|
24
|
-
|
25
|
-
def tables
|
26
|
-
@schema.tables
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_reader :generator
|
32
|
-
|
33
|
-
def file_name(index, object)
|
34
|
-
"#{index}_create_#{table_name}.rb"
|
35
|
-
end
|
36
|
-
|
37
|
-
def generate_migrations
|
38
|
-
tables.each.with_index(1) do |table, index|
|
39
|
-
@table = table
|
40
|
-
@generator.template(
|
41
|
-
"migration.rb.tt",
|
42
|
-
"db/migrate/" + file_name(index, table)
|
43
|
-
)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Sequel.migration do
|
2
|
-
up do
|
3
|
-
create_table(:<%= migration_builder.table_name %>) do
|
4
|
-
primary_key :id
|
5
|
-
<%- migration_builder.columns.each do |column| -%>
|
6
|
-
<%= column.type.camelcase %> :<%= column.name.to_sym %>, :null=>false
|
7
|
-
<%- end -%>
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
down do
|
12
|
-
drop_table(:<%= migration_builder.table_name %>)
|
13
|
-
end
|
14
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module <%= domain_module_name %>
|
2
|
-
module Adapters
|
3
|
-
class SQLDatabase
|
4
|
-
module Repositories
|
5
|
-
class <%= class_name %>
|
6
|
-
def self.create attributes = {}
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.update id, attributes
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.read id
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.delete id
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.delete_all
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
namespace :db do
|
2
|
-
desc "Run migrations"
|
3
|
-
task :migrate, [:version] do |t, args|
|
4
|
-
require "sequel"
|
5
|
-
Sequel.extension :migration
|
6
|
-
db = Sequel.connect(ENV.fetch("DATABASE_URL"))
|
7
|
-
if args[:version]
|
8
|
-
puts "Migrating to version #{args[:version]}"
|
9
|
-
Sequel::Migrator.run(db, "db/migrate", target: args[:version].to_i)
|
10
|
-
else
|
11
|
-
puts "Migrating to latest"
|
12
|
-
Sequel::Migrator.run(db, "db/migrate")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Domain
|
3
|
-
module Adapters
|
4
|
-
class SQLDatabase
|
5
|
-
module Commands
|
6
|
-
class Read
|
7
|
-
class FetchReferences
|
8
|
-
attr_reader :reference_map
|
9
|
-
def initialize(read_command)
|
10
|
-
@head = read_command.head
|
11
|
-
@reference_map = {}
|
12
|
-
@entity = read_command.entity
|
13
|
-
@table = read_command.table
|
14
|
-
@id = read_command.id
|
15
|
-
end
|
16
|
-
|
17
|
-
def call
|
18
|
-
@head.references.each do |reference|
|
19
|
-
fetch_reference(reference)
|
20
|
-
fetch_references(reference)
|
21
|
-
end
|
22
|
-
self
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def fetch_reference(reference)
|
28
|
-
return if reference.list?
|
29
|
-
column = Column.factory(reference)
|
30
|
-
value = DB[column.to_table_name].first(id: @entity[column.to_foreign_key])
|
31
|
-
|
32
|
-
@entity.delete(column.to_foreign_key)
|
33
|
-
value.delete(:id)
|
34
|
-
@reference_map[column.name.to_sym] = value
|
35
|
-
end
|
36
|
-
|
37
|
-
def fetch_references(reference)
|
38
|
-
return unless reference.list?
|
39
|
-
|
40
|
-
where_clause = {}
|
41
|
-
where_clause[@table.to_foreign_key.to_sym] = @id
|
42
|
-
column = Column.factory(reference)
|
43
|
-
|
44
|
-
@reference_map[column.name.to_sym] ||= []
|
45
|
-
|
46
|
-
DB[JoinTable(@table, reference).name.to_sym].where(where_clause).map do |record|
|
47
|
-
value_object = DB[column.to_table_name].first(id: record[column.to_foreign_key])
|
48
|
-
value_object.delete(:id)
|
49
|
-
@reference_map[column.name.to_sym] << value_object
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|