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.
Files changed (107) hide show
  1. checksums.yaml +5 -5
  2. data/lib/hecks/domain/commands/generate.rb +98 -0
  3. data/lib/hecks/domain/commands.rb +1 -0
  4. data/lib/hecks/domain/generators/domain.rb +21 -0
  5. data/lib/hecks/domain/generators/domain_files.rb +28 -0
  6. data/lib/hecks/domain/generators/entity.rb +30 -0
  7. data/lib/hecks/domain/generators/operation.rb +32 -0
  8. data/lib/hecks/domain/generators/root.rb +30 -0
  9. data/lib/hecks/domain/generators/spec.rb +30 -0
  10. data/lib/hecks/domain/generators/value_object.rb +30 -0
  11. data/lib/hecks/domain/generators.rb +7 -0
  12. data/lib/hecks/domain/parser/aggregate.rb +44 -0
  13. data/lib/hecks/domain/parser/domain_object.rb +123 -0
  14. data/lib/hecks/domain/parser/entity_field.rb +55 -0
  15. data/lib/hecks/domain/parser/fields.rb +16 -0
  16. data/lib/hecks/domain/parser/list_field.rb +13 -0
  17. data/lib/hecks/domain/parser/operation.rb +15 -0
  18. data/lib/hecks/domain/parser/reference_field.rb +12 -0
  19. data/lib/hecks/domain/parser/spec_helper.rb +0 -0
  20. data/lib/hecks/domain/parser/value_field.rb +48 -0
  21. data/lib/hecks/domain/parser.rb +95 -0
  22. data/lib/hecks/domain/support/string.rb +9 -0
  23. data/lib/hecks/domain/support.rb +1 -0
  24. data/lib/hecks/domain/templates/%domain_name%.gemspec.tt +12 -0
  25. data/lib/hecks/domain/templates/%folder_name%/Domainfile.tt +9 -0
  26. data/lib/hecks/domain/templates/%folder_name%/events/command_will_run.rb.tt +11 -0
  27. data/lib/hecks/domain/templates/%folder_name%/spec/spec_helper.rb.tt +1 -0
  28. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/commands.rb.tt +11 -0
  29. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/events.rb.tt +11 -0
  30. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories/build.rb.tt +37 -0
  31. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories.rb.tt +11 -0
  32. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/invariants.rb.tt +11 -0
  33. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/queries.rb.tt +11 -0
  34. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/repository.rb.tt +68 -0
  35. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/subscribers.rb.tt +11 -0
  36. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%.rb.tt +34 -0
  37. data/lib/hecks/domain/templates/lib/%domain_name%.rb.tt +9 -0
  38. data/lib/hecks/domain/templates/lib/support/commands/command_loader.rb +18 -0
  39. data/lib/hecks/domain/templates/lib/support/commands/command_runner.rb +17 -0
  40. data/lib/hecks/domain/templates/lib/support/commands.rb +2 -0
  41. data/lib/hecks/domain/templates/lib/support/domain_object.rb +25 -0
  42. data/lib/hecks/domain/templates/lib/support/events/domain_event.rb +14 -0
  43. data/lib/hecks/domain/templates/lib/support/events/domain_event_publisher.rb +34 -0
  44. data/lib/hecks/domain/templates/lib/support/events.rb +14 -0
  45. data/lib/hecks/domain/templates/lib/support/factories/factory_loader.rb +21 -0
  46. data/lib/hecks/domain/templates/lib/support/factories.rb +1 -0
  47. data/lib/hecks/domain/templates/lib/support/invariants/invariant_loader.rb +24 -0
  48. data/lib/hecks/domain/templates/lib/support/queries/query_loader.rb +18 -0
  49. data/lib/hecks/domain/templates/lib/support/queries.rb +1 -0
  50. data/lib/hecks/domain/templates/lib/support/repositories/repository_loader.rb +32 -0
  51. data/lib/hecks/domain/templates/lib/support/root.rb +27 -0
  52. data/lib/hecks/domain/templates/lib/support/support/string.rb +9 -0
  53. data/lib/hecks/domain/templates/lib/support.rb +11 -0
  54. data/lib/hecks/domain/templates/operation/%aggregate_name%/%domain_object_name%/commands/%operation_name%.rb.tt +21 -0
  55. data/lib/hecks/domain/templates/root/%aggregate_name%/root.rb.tt +14 -0
  56. data/lib/hecks/domain/templates/spec/%aggregate_name%/%root_name%_spec.rb.tt +12 -0
  57. data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories/build.rb.tt +37 -0
  58. data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories.rb.tt +11 -0
  59. data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%.rb.tt +34 -0
  60. data/lib/hecks/domain/top_level_methods.rb +3 -0
  61. data/lib/hecks/domain.rb +22 -0
  62. metadata +101 -59
  63. data/lib/adapters/adapters.rb +0 -2
  64. data/lib/adapters/resource_server/cli/cli.rb +0 -1
  65. data/lib/adapters/resource_server/cli/generate_resource_server.rb +0 -25
  66. data/lib/adapters/resource_server/cli/templates/resource_server/config.ru.tt +0 -8
  67. data/lib/adapters/resource_server/resource_server.rb +0 -1
  68. data/lib/adapters/sql_database/cli/cli.rb +0 -3
  69. data/lib/adapters/sql_database/cli/generate_domain_migrations.rb +0 -33
  70. data/lib/adapters/sql_database/cli/generate_sql_database.rb +0 -35
  71. data/lib/adapters/sql_database/cli/migration_builder.rb +0 -51
  72. data/lib/adapters/sql_database/cli/templates/migration.rb.tt +0 -14
  73. data/lib/adapters/sql_database/cli/templates/repository.rb.tt +0 -24
  74. data/lib/adapters/sql_database/cli/templates/sql_database/Gemfile +0 -10
  75. data/lib/adapters/sql_database/cli/templates/sql_database/Rakefile +0 -15
  76. data/lib/adapters/sql_database/commands/read/fetch_references.rb +0 -58
  77. data/lib/adapters/sql_database/commands/update/delete_references.rb +0 -45
  78. data/lib/adapters/sql_database/commands/update/link_to_references.rb +0 -45
  79. data/lib/adapters/sql_database/sql_database.rb +0 -1
  80. data/lib/cli/builder/aggregate_command_line_builder.rb +0 -22
  81. data/lib/cli/builder/builder.rb +0 -3
  82. data/lib/cli/builder/reference_command_line_builder.rb +0 -23
  83. data/lib/cli/builder/value_object_command_line_builder.rb +0 -23
  84. data/lib/cli/cli.rb +0 -8
  85. data/lib/cli/command_builder.rb +0 -59
  86. data/lib/cli/domain_object/assignment_template.rb +0 -43
  87. data/lib/cli/domain_object/option_formatter.rb +0 -36
  88. data/lib/cli/generate_domain_object.rb +0 -71
  89. data/lib/cli/new.rb +0 -50
  90. data/lib/cli/templates/aggregate/lib/domain/%name%/%head_name%.rb.tt +0 -16
  91. data/lib/cli/templates/aggregate/lib/domain/%name%/%name%.rb.tt +0 -9
  92. data/lib/cli/templates/aggregate/lib/domain/%name%/repository.rb.tt +0 -41
  93. data/lib/cli/templates/domain/%name%.gemspec.tt +0 -12
  94. data/lib/cli/templates/domain/Version +0 -1
  95. data/lib/cli/templates/domain/lib/%name%.rb.tt +0 -21
  96. data/lib/cli/templates/domain/spec/spec_helper.rb.tt +0 -4
  97. data/lib/cli/templates/reference/lib/domain/%module_name%/%file_name%.rb.tt +0 -25
  98. data/lib/cli/templates/value_object/lib/domain/%module_name%/%name%.rb.tt +0 -24
  99. data/lib/domain_builder/attribute.rb +0 -60
  100. data/lib/domain_builder/domain.rb +0 -19
  101. data/lib/domain_builder/domain_builder.rb +0 -37
  102. data/lib/domain_builder/domain_module.rb +0 -28
  103. data/lib/domain_builder/domain_object.rb +0 -43
  104. data/lib/domain_builder/head.rb +0 -8
  105. data/lib/domain_builder/reference.rb +0 -19
  106. data/lib/domain_builder/value.rb +0 -8
  107. 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,11 @@
1
+ Dir[File.dirname(__FILE__) + '/factories/*.rb'].each {|file| require_relative file }
2
+ module <%= domain.name %>
3
+ module Domain
4
+ module <%= aggregate.name %>
5
+ class <%= domain_object.name %>
6
+ module Factories
7
+ end
8
+ end
9
+ end
10
+ end
11
+ 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
@@ -0,0 +1,3 @@
1
+ def domain(name, &block)
2
+ HecksDomain.parser(name, &block)
3
+ end
@@ -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.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Chris Young
7
+ - Hecks Domain Developer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-11 00:00:00.000000000 Z
11
+ date: 2019-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: hecks-adatpers-sql-database
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
- description: Make the Domain the center of your programming world
28
- email: chris@example.com
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/adapters/adapters.rb
34
- - lib/adapters/resource_server/cli/cli.rb
35
- - lib/adapters/resource_server/cli/generate_resource_server.rb
36
- - lib/adapters/resource_server/cli/templates/resource_server/config.ru.tt
37
- - lib/adapters/resource_server/resource_server.rb
38
- - lib/adapters/sql_database/cli/cli.rb
39
- - lib/adapters/sql_database/cli/generate_domain_migrations.rb
40
- - lib/adapters/sql_database/cli/generate_sql_database.rb
41
- - lib/adapters/sql_database/cli/migration_builder.rb
42
- - lib/adapters/sql_database/cli/templates/migration.rb.tt
43
- - lib/adapters/sql_database/cli/templates/repository.rb.tt
44
- - lib/adapters/sql_database/cli/templates/sql_database/Gemfile
45
- - lib/adapters/sql_database/cli/templates/sql_database/Rakefile
46
- - lib/adapters/sql_database/commands/read/fetch_references.rb
47
- - lib/adapters/sql_database/commands/update/delete_references.rb
48
- - lib/adapters/sql_database/commands/update/link_to_references.rb
49
- - lib/adapters/sql_database/sql_database.rb
50
- - lib/cli/builder/aggregate_command_line_builder.rb
51
- - lib/cli/builder/builder.rb
52
- - lib/cli/builder/reference_command_line_builder.rb
53
- - lib/cli/builder/value_object_command_line_builder.rb
54
- - lib/cli/cli.rb
55
- - lib/cli/command_builder.rb
56
- - lib/cli/domain_object/assignment_template.rb
57
- - lib/cli/domain_object/option_formatter.rb
58
- - lib/cli/generate_domain_object.rb
59
- - lib/cli/new.rb
60
- - lib/cli/templates/aggregate/lib/domain/%name%/%head_name%.rb.tt
61
- - lib/cli/templates/aggregate/lib/domain/%name%/%name%.rb.tt
62
- - lib/cli/templates/aggregate/lib/domain/%name%/repository.rb.tt
63
- - lib/cli/templates/domain/%name%.gemspec.tt
64
- - lib/cli/templates/domain/Version
65
- - lib/cli/templates/domain/lib/%name%.rb.tt
66
- - lib/cli/templates/domain/spec/spec_helper.rb.tt
67
- - lib/cli/templates/reference/lib/domain/%module_name%/%file_name%.rb.tt
68
- - lib/cli/templates/value_object/lib/domain/%module_name%/%name%.rb.tt
69
- - lib/domain_builder/attribute.rb
70
- - lib/domain_builder/domain.rb
71
- - lib/domain_builder/domain_builder.rb
72
- - lib/domain_builder/domain_module.rb
73
- - lib/domain_builder/domain_object.rb
74
- - lib/domain_builder/head.rb
75
- - lib/domain_builder/reference.rb
76
- - lib/domain_builder/value.rb
77
- - lib/hecks-domain.rb
78
- homepage: https://github.com/chrisyoung/hecks-domain
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
- rubyforge_project:
98
- rubygems_version: 2.6.10
140
+ rubygems_version: 3.0.3
99
141
  signing_key:
100
142
  specification_version: 4
101
- summary: DDD and Hexagonal Code Generators
143
+ summary: 3DSL
102
144
  test_files: []
@@ -1,2 +0,0 @@
1
- require_relative 'sql_database/sql_database'
2
- require_relative 'resource_server/resource_server'
@@ -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,8 +0,0 @@
1
- require_relative "lib/<%= domain %>.rb"
2
- require 'hecks'
3
-
4
- run Hecks::Adapters::ResourceServer.new(
5
- application_adapter: Hecks::Application.new(
6
- domain: <%= domain.camelize %>
7
- )
8
- )
@@ -1 +0,0 @@
1
- require_relative 'cli/cli'
@@ -1,3 +0,0 @@
1
- require_relative 'generate_domain_migrations'
2
- require_relative 'generate_sql_database'
3
- require_relative 'migration_builder'
@@ -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,10 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'hecks', path: '../../../../..'
4
- gem 'thor'
5
- gem 'pry'
6
- gem 'rspec'
7
- gem 'mysql2'
8
- gem 'sequel'
9
- gem 'simplecov'
10
- gem 'pizza_builder', path: '../../'
@@ -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