hecks 0.0.8 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hecks +1 -0
- data/lib/cli.rb +28 -0
- data/lib/cli/build.rb +13 -0
- data/lib/cli/{commands/console.rb → console.rb} +0 -0
- data/lib/cli/generate.rb +35 -0
- data/lib/cli/{commands/package.rb → package.rb} +2 -5
- data/lib/cli/test.rb +56 -0
- data/lib/{console/console.rb → console.rb} +1 -2
- data/lib/console/commands.rb +1 -1
- data/lib/hecks.rb +6 -6
- data/lib/packager.rb +2 -0
- data/lib/packager/generate_binary_package.rb +146 -0
- data/lib/packager/generate_lambda_package.rb +26 -0
- data/lib/{cli/commands/generate/templates/binary_package/build/resources → packager/templates}/Gemfile.tt +1 -1
- data/lib/{cli/commands/generate → packager}/templates/binary_package/build/linux-x86_64/lib/app/hello.rb +0 -0
- data/lib/{cli/commands/generate → packager}/templates/binary_package/build/resources/%domain_name%.rb.tt +6 -2
- data/lib/packager/templates/binary_package/build/resources/Dockerfile.tt +14 -0
- data/lib/{cli/commands/generate → packager}/templates/binary_package/build/resources/bundle/config +0 -0
- data/lib/{cli/commands/generate → packager}/templates/binary_package/build/resources/wrapper.tt +0 -0
- data/lib/{cli/commands/generate → packager}/templates/lambda_package/handler.js.tt +0 -0
- data/lib/{cli/commands/generate → packager}/templates/lambda_package/serverless.yml.tt +0 -0
- metadata +45 -94
- data/lib/adapters/adapters.rb +0 -6
- data/lib/adapters/events/events.rb +0 -27
- data/lib/adapters/logger/logger.rb +0 -18
- data/lib/adapters/memory_database/memory_database.rb +0 -18
- data/lib/adapters/resource_server/methods.rb +0 -22
- data/lib/adapters/resource_server/methods/create.rb +0 -49
- data/lib/adapters/resource_server/methods/delete.rb +0 -45
- data/lib/adapters/resource_server/methods/read.rb +0 -44
- data/lib/adapters/resource_server/methods/update.rb +0 -50
- data/lib/adapters/resource_server/resource_server.rb +0 -52
- data/lib/adapters/validator/validator.rb +0 -33
- data/lib/application/application.rb +0 -45
- data/lib/application/commands/commands.rb +0 -5
- data/lib/application/commands/create.rb +0 -52
- data/lib/application/commands/crud_handler.rb +0 -40
- data/lib/application/commands/delete.rb +0 -40
- data/lib/application/commands/runner.rb +0 -48
- data/lib/application/commands/update.rb +0 -41
- data/lib/application/queries/find_by_id.rb +0 -19
- data/lib/application/queries/queries.rb +0 -2
- data/lib/application/queries/query_runner.rb +0 -28
- data/lib/cli/cli.rb +0 -24
- data/lib/cli/commands.rb +0 -5
- data/lib/cli/commands/build.rb +0 -10
- data/lib/cli/commands/generate.rb +0 -26
- data/lib/cli/commands/generate/builder.rb +0 -60
- data/lib/cli/commands/generate/builder/aggregate_command_line_builder.rb +0 -18
- data/lib/cli/commands/generate/builder/reference_command_line_builder.rb +0 -19
- data/lib/cli/commands/generate/builder/value_object_command_line_builder.rb +0 -19
- data/lib/cli/commands/generate/generate_aws_package.rb +0 -17
- data/lib/cli/commands/generate/generate_binary_package.rb +0 -92
- data/lib/cli/commands/generate/generate_domain_object.rb +0 -71
- data/lib/cli/commands/generate/generate_domain_object/assignment_template.rb +0 -36
- data/lib/cli/commands/generate/generate_domain_object/option_formatter.rb +0 -30
- data/lib/cli/commands/generate/generate_lambda_package.rb +0 -20
- data/lib/cli/commands/generate/generate_resource_server.rb +0 -17
- data/lib/cli/commands/generate/new.rb +0 -47
- data/lib/cli/commands/generate/templates/aggregate/lib/domain/%name%/%head_name%.rb.tt +0 -16
- data/lib/cli/commands/generate/templates/aggregate/lib/domain/%name%/%name%.rb.tt +0 -9
- data/lib/cli/commands/generate/templates/aggregate/lib/domain/%name%/repository.rb.tt +0 -40
- data/lib/cli/commands/generate/templates/binary_package/build/resources/Dockerfile.tt +0 -8
- data/lib/cli/commands/generate/templates/domain/%name%.gemspec.tt +0 -12
- data/lib/cli/commands/generate/templates/domain/Version +0 -1
- data/lib/cli/commands/generate/templates/domain/lib/%name%.rb.tt +0 -21
- data/lib/cli/commands/generate/templates/domain/spec/spec_helper.rb.tt +0 -4
- data/lib/cli/commands/generate/templates/reference/lib/domain/%module_name%/%file_name%.rb.tt +0 -25
- data/lib/cli/commands/generate/templates/resource_server/config.ru.tt +0 -8
- data/lib/cli/commands/generate/templates/value_object/lib/domain/%module_name%/%name%.rb.tt +0 -24
- data/lib/cli/commands/test.rb +0 -41
- data/lib/domain_builder/attribute.rb +0 -33
- data/lib/domain_builder/domain.rb +0 -17
- data/lib/domain_builder/domain_builder.rb +0 -35
- data/lib/domain_builder/domain_module.rb +0 -26
- data/lib/domain_builder/domain_object.rb +0 -37
- data/lib/domain_builder/head.rb +0 -6
- data/lib/domain_builder/reference.rb +0 -17
- data/lib/domain_builder/value.rb +0 -6
data/lib/adapters/adapters.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class Events
|
5
|
-
def initialize(listeners: [])
|
6
|
-
@listeners = listeners
|
7
|
-
end
|
8
|
-
|
9
|
-
def send(module_name:, command:)
|
10
|
-
@command = command
|
11
|
-
@module_name = module_name
|
12
|
-
listeners.each do |listener|
|
13
|
-
next unless listener.respond_to?(event_name)
|
14
|
-
listener.public_send(event_name, command)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
attr_reader :listeners, :command, :module_name
|
21
|
-
|
22
|
-
def event_name
|
23
|
-
"#{module_name}_#{command.name}".to_sym
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class Logger
|
5
|
-
def initialize(output: [])
|
6
|
-
@output = output
|
7
|
-
end
|
8
|
-
|
9
|
-
def method_missing(name, *args, &block)
|
10
|
-
@output << {name: name, command: args.first.to_h.to_s}.to_s
|
11
|
-
end
|
12
|
-
|
13
|
-
def respond_to?(name)
|
14
|
-
true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class MemoryDatabase
|
5
|
-
def initialize(domain:)
|
6
|
-
@repositories = domain.repositories
|
7
|
-
end
|
8
|
-
|
9
|
-
def [](module_name)
|
10
|
-
@repositories[module_name]
|
11
|
-
end
|
12
|
-
|
13
|
-
def delete_all
|
14
|
-
@repositories.values.each(&:delete_all)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require_relative 'methods/create'
|
3
|
-
require_relative 'methods/read'
|
4
|
-
require_relative 'methods/update'
|
5
|
-
require_relative 'methods/delete'
|
6
|
-
|
7
|
-
module Hecks
|
8
|
-
module Adapters
|
9
|
-
class ResourceServer
|
10
|
-
class Methods
|
11
|
-
attr_reader :create, :read, :update, :delete
|
12
|
-
|
13
|
-
def initialize(application_adapter:)
|
14
|
-
@create = Create.new(application_adapter: application_adapter)
|
15
|
-
@read = Read.new(application_adapter: application_adapter)
|
16
|
-
@update = Update.new(application_adapter: application_adapter)
|
17
|
-
@delete = Delete.new(application_adapter: application_adapter)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class ResourceServer < Sinatra::Base
|
5
|
-
class Methods
|
6
|
-
class Create
|
7
|
-
attr_reader :result
|
8
|
-
|
9
|
-
def initialize(application_adapter:)
|
10
|
-
@application_adapter = application_adapter
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(body:, module_name:)
|
14
|
-
@body = body.read
|
15
|
-
@module_name = module_name.to_sym
|
16
|
-
run_command
|
17
|
-
build_json
|
18
|
-
self
|
19
|
-
end
|
20
|
-
|
21
|
-
def status
|
22
|
-
return 500 if command_result.errors.count.positive?
|
23
|
-
200
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :application_adapter, :body, :module_name, :command_result
|
29
|
-
|
30
|
-
def build_json
|
31
|
-
@result = JSON.generate(command_result.to_h)
|
32
|
-
end
|
33
|
-
|
34
|
-
def run_command
|
35
|
-
@command_result = application_adapter.call(
|
36
|
-
module_name: module_name,
|
37
|
-
command_name: :create,
|
38
|
-
args: params
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
def params
|
43
|
-
JSON.parse(body, symbolize_names: true)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class ResourceServer < Sinatra::Base
|
5
|
-
class Methods
|
6
|
-
class Delete
|
7
|
-
attr_reader :result
|
8
|
-
|
9
|
-
def initialize(application_adapter:)
|
10
|
-
@application_adapter = application_adapter
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(id:, module_name:)
|
14
|
-
@id = id.to_i
|
15
|
-
@module_name = module_name.to_sym
|
16
|
-
run_command
|
17
|
-
convert_to_json
|
18
|
-
self
|
19
|
-
end
|
20
|
-
|
21
|
-
def status
|
22
|
-
return 500 if command_result.errors.count.positive?
|
23
|
-
200
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :application_adapter, :module_name, :id, :command_result
|
29
|
-
|
30
|
-
def convert_to_json
|
31
|
-
@result = JSON.generate(command_result.to_h)
|
32
|
-
end
|
33
|
-
|
34
|
-
def run_command
|
35
|
-
@command_result = application_adapter.call(
|
36
|
-
module_name: module_name,
|
37
|
-
command_name: :delete,
|
38
|
-
args: { id: id }
|
39
|
-
)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class ResourceServer < Sinatra::Base
|
5
|
-
class Methods
|
6
|
-
class Read
|
7
|
-
attr_reader :result, :status
|
8
|
-
def initialize(application_adapter:)
|
9
|
-
@application_adapter = application_adapter
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(id:, module_name:)
|
13
|
-
@id = id.to_i
|
14
|
-
@module_name = module_name.to_sym
|
15
|
-
run_query
|
16
|
-
convert_to_json
|
17
|
-
self
|
18
|
-
end
|
19
|
-
|
20
|
-
def status
|
21
|
-
return 404 if command_result.nil?
|
22
|
-
200
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
attr_reader :application_adapter, :id, :module_name, :command_result
|
28
|
-
|
29
|
-
def convert_to_json
|
30
|
-
@result = command_result.to_json
|
31
|
-
end
|
32
|
-
|
33
|
-
def run_query
|
34
|
-
@command_result = application_adapter.query(
|
35
|
-
query_name: :find_by_id,
|
36
|
-
module_name: module_name,
|
37
|
-
args: { id: id }
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class ResourceServer < Sinatra::Base
|
5
|
-
class Methods
|
6
|
-
class Update
|
7
|
-
attr_reader :result
|
8
|
-
|
9
|
-
def initialize(application_adapter:)
|
10
|
-
@application_adapter = application_adapter
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(id:, body:, module_name:)
|
14
|
-
@id = id.to_i
|
15
|
-
@body = body.read
|
16
|
-
@module_name = module_name.to_sym
|
17
|
-
run_command
|
18
|
-
convert_to_json
|
19
|
-
self
|
20
|
-
end
|
21
|
-
|
22
|
-
def status
|
23
|
-
return 500 if command_result.errors.count.positive?
|
24
|
-
200
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_accessor :application_adapter, :id, :body, :module_name, :command_result
|
30
|
-
|
31
|
-
def convert_to_json
|
32
|
-
@result = JSON.generate(command_result.to_h)
|
33
|
-
end
|
34
|
-
|
35
|
-
def run_command
|
36
|
-
@command_result = application_adapter.call(
|
37
|
-
module_name: module_name,
|
38
|
-
command_name: :update,
|
39
|
-
args: params
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
def params
|
44
|
-
JSON.parse(body, symbolize_names: true).merge(id: id)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'sinatra'
|
3
|
-
require 'json'
|
4
|
-
require_relative 'methods'
|
5
|
-
|
6
|
-
module Hecks
|
7
|
-
module Adapters
|
8
|
-
class ResourceServer < Sinatra::Base
|
9
|
-
configure do
|
10
|
-
set :raise_errors, true
|
11
|
-
set :show_exceptions, false
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(app: nil, application_adapter:)
|
15
|
-
super(app)
|
16
|
-
@methods = Methods.new(application_adapter: application_adapter)
|
17
|
-
end
|
18
|
-
|
19
|
-
get '/:module_name/:id' do |module_name, id|
|
20
|
-
command = methods.read.call(id: id, module_name: module_name)
|
21
|
-
body command.result
|
22
|
-
status command.status
|
23
|
-
end
|
24
|
-
|
25
|
-
post '/:module_name' do |module_name|
|
26
|
-
command = methods.create.call(body: request.body, module_name: module_name)
|
27
|
-
status command.status
|
28
|
-
body command.result
|
29
|
-
end
|
30
|
-
|
31
|
-
put '/:module_name/:id' do |module_name, id|
|
32
|
-
command = methods.update.call(
|
33
|
-
id: id,
|
34
|
-
body: request.body,
|
35
|
-
module_name: module_name
|
36
|
-
)
|
37
|
-
status command.status
|
38
|
-
body command.result
|
39
|
-
end
|
40
|
-
|
41
|
-
delete '/:module_name/:id' do |module_name, id|
|
42
|
-
command = methods.delete.call(id: id, module_name: module_name)
|
43
|
-
status command.status
|
44
|
-
body command.result
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
attr_reader :methods
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Adapters
|
3
|
-
class Validator
|
4
|
-
attr_reader :errors
|
5
|
-
|
6
|
-
def initialize(command:)
|
7
|
-
@args = command.args
|
8
|
-
@head_spec = command.domain_module.head
|
9
|
-
@errors = {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def call
|
13
|
-
validate
|
14
|
-
return self
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :args, :head_spec
|
20
|
-
|
21
|
-
def validate
|
22
|
-
(missing_attributes).each do |missing_attribute|
|
23
|
-
errors[missing_attribute] = []
|
24
|
-
errors[missing_attribute] << "missing"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def missing_attributes
|
29
|
-
head_spec.attribute_hash.keys - args.keys
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require_relative 'commands/commands'
|
3
|
-
require_relative 'queries/queries'
|
4
|
-
|
5
|
-
module Hecks
|
6
|
-
module Adapters
|
7
|
-
class Application
|
8
|
-
attr_reader :database, :domain_spec, :events_port
|
9
|
-
def initialize(database: nil, listeners: [], domain:)
|
10
|
-
load(domain.spec_path)
|
11
|
-
@domain = domain
|
12
|
-
@database = database.new(domain: @domain) if @database
|
13
|
-
@events_port = Adapters::Events.new(listeners: listeners)
|
14
|
-
@domain_spec = Hecks.specification
|
15
|
-
end
|
16
|
-
|
17
|
-
def call(command_name:, module_name:, args: {})
|
18
|
-
Runner.new(
|
19
|
-
command_name: command_name,
|
20
|
-
module_name: module_name,
|
21
|
-
args: args,
|
22
|
-
application: self
|
23
|
-
).call
|
24
|
-
end
|
25
|
-
|
26
|
-
def [](module_name)
|
27
|
-
CRUDHandler.new(module_name: module_name, application: self)
|
28
|
-
end
|
29
|
-
|
30
|
-
def query(query_name:, module_name:, args: {})
|
31
|
-
QueryRunner.new(
|
32
|
-
module_name: module_name,
|
33
|
-
query_name: query_name,
|
34
|
-
args: args,
|
35
|
-
application: self
|
36
|
-
).call
|
37
|
-
end
|
38
|
-
|
39
|
-
def database
|
40
|
-
return MemoryDatabase.new(domain: @domain) unless @database
|
41
|
-
@database
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Hecks
|
3
|
-
module Adapters
|
4
|
-
class Application
|
5
|
-
module Commands
|
6
|
-
class Create
|
7
|
-
attr_accessor :args, :id, :errors, :repository, :domain_module
|
8
|
-
|
9
|
-
def initialize(args:, repository: , domain_module: )
|
10
|
-
@repository = repository
|
11
|
-
@args = args
|
12
|
-
@errors = {}
|
13
|
-
@validator = Validator
|
14
|
-
@domain_module = domain_module
|
15
|
-
end
|
16
|
-
|
17
|
-
def call
|
18
|
-
validate
|
19
|
-
create
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_h
|
24
|
-
{ errors: errors, id: repository_result, args: args }
|
25
|
-
end
|
26
|
-
|
27
|
-
def name
|
28
|
-
self.class.to_s.split('::').last.underscore
|
29
|
-
end
|
30
|
-
|
31
|
-
def result
|
32
|
-
{ id: id, success: !id.nil?, errors: errors, args: args }
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
attr_reader :repository_result
|
38
|
-
|
39
|
-
def create
|
40
|
-
return if @errors.count.positive?
|
41
|
-
@id = @repository_result = repository.create(args)
|
42
|
-
end
|
43
|
-
|
44
|
-
def validate
|
45
|
-
return if @validator.nil?
|
46
|
-
@errors = @validator.new(command: self).call.errors
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|