evt-command_line-component_generator 0.1.0.4 → 0.1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 288adb0fe6d35eaceb3c654e90d78a8c86211db8
4
- data.tar.gz: 9b1b3facfee14332a6988caa40ded04bf7667c28
3
+ metadata.gz: d924f5e873050831b6d2008643baf44a7b97ee12
4
+ data.tar.gz: 6e48f29d1a333f07f3e4d3f8d1db82a3b30fa061
5
5
  SHA512:
6
- metadata.gz: 253f2dd34f668c398993f6d4d1f87899874bc8a9767ad43ece493a39bcd2bbfa42a28a20b9dfe4050c00383b0f80e5ac533bd814847a7f43d798801499668d2b
7
- data.tar.gz: 7ef2014758ebee7b8f2a533d8b21acf0c06b48a1ec7dec9db2a1f0362968d3586271d3927aa4560a366ff28ba80dc5e7a74ddf0191ce45d059beb7a724810319
6
+ metadata.gz: 76b91cac6f658adaf4f32c42ce1e250244fe4449804dc5c8a755fca5f1561243fce75ae4cf1046571db1807f58df41b32efa7e5c2d3078252adcc5731900ed80
7
+ data.tar.gz: e5da2c0d8d49defffa308ff3c8493101162eef1e6d9afa3d5207a0e4f2b232665bd968818d44e4a1395c2f8e6fcf981a5ddd7f2d7f2f638c86f33befab9c820b
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.name = '<%= component_name %>'
4
+ s.version = '0.0.0'
5
+ s.summary = ' '
6
+ s.description = ' '
7
+
8
+ s.authors = ['email@domain.com']
9
+ s.homepage = 'http://domain.com'
10
+ s.licenses = ['TODO']
11
+
12
+ s.require_paths = ['lib']
13
+ s.files = Dir.glob('{lib}/**/*')
14
+ s.platform = Gem::Platform::RUBY
15
+ s.required_ruby_version = '>= 2.4'
16
+
17
+ s.add_runtime_dependency 'eventide-postgres'
18
+
19
+ s.add_development_dependency 'test_bench'
20
+ end
data/source/Gemfile.tt ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec name: '<%= component_name %>'
4
+
5
+ gem 'evt-component_host'
data/source/init.rb.tt ADDED
@@ -0,0 +1,3 @@
1
+ require_relative 'load_path'
2
+
3
+ require '<%= component_name %>'
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Removing gems directory..."
4
+ rm -rf gems
5
+ echo "Removing .bundle directory..."
6
+ rm -rf .bundle
7
+ echo "Removing Gemfile.lock file..."
8
+ rm -f Gemfile.lock
9
+ echo
10
+
11
+ set -e
12
+
13
+ echo "Installing gems to ./gems"
14
+ echo '= = ='
15
+
16
+ cmd="bundle install --standalone --path=./gems"
17
+
18
+ echo $cmd
19
+ ($cmd)
20
+
21
+ echo '- - -'
22
+ echo '(done)'
23
+ echo
@@ -0,0 +1,11 @@
1
+ require 'eventide/postgres'
2
+
3
+ # require '<%= component_name %>/messages/commands/...'
4
+ # require '<%= component_name %>/messages/events/...'
5
+
6
+ require '<%= component_name %>/<%= entity_name %>'
7
+ require '<%= component_name %>/projection'
8
+ require '<%= component_name %>/store'
9
+
10
+ require '<%= component_name %>/handlers/commands'
11
+ require '<%= component_name %>/handlers/events'
@@ -0,0 +1,11 @@
1
+ module <%= component_constant_name %>
2
+ class <%= entity_constant_name %>
3
+ include Schema::DataStructure
4
+
5
+ attribute :id, String
6
+
7
+ # TODO Implement attributes
8
+ # TODO Implement entity logic, predicates, mutations, calculations, etc?
9
+ # Note: This class's methods should pertain to its attributes
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'clock/controls'
2
+ require 'identifier/uuid/controls'
3
+
4
+ require '<%= component_name %>/controls/id'
5
+ require '<%= component_name %>/controls/time'
6
+ require '<%= component_name %>/controls/version'
7
+
8
+ require '<%= component_name %>/controls/<%= entity_name %>'
9
+
10
+ # require '<%= component_name %>/controls/commands/...'
11
+
12
+ # require '<%= component_name %>/controls/events/...'
@@ -0,0 +1,36 @@
1
+ module <%= component_constant_name %>
2
+ module Controls
3
+ module <%= entity_constant_name %>
4
+ def self.example
5
+ <%= entity_name %> = <%= component_constant_name %>::<%= entity_constant_name %>.build
6
+
7
+ <%= entity_name %>.id = self.id
8
+ <%= entity_name %>.something_happened_time = Time::Effective::Raw.example
9
+
10
+ <%= entity_name %>
11
+ end
12
+
13
+ def self.id
14
+ ID.example(increment: id_increment)
15
+ end
16
+
17
+ def self.id_increment
18
+ 1111
19
+ end
20
+
21
+ module New
22
+ def self.example
23
+ <%= component_constant_name %>::<%= entity_constant_name %>.build
24
+ end
25
+ end
26
+
27
+ module Identified
28
+ def self.example
29
+ <%= entity_name %> = New.example
30
+ <%= entity_name %>.id = <%= entity_constant_name %>.id
31
+ <%= entity_name %>
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module <%= component_constant_name %>
2
+ module Controls
3
+ ID = Identifier::UUID::Controls::Incrementing
4
+ end
5
+ end
@@ -0,0 +1,62 @@
1
+ module <%= component_constant_name %>
2
+ module Controls
3
+ module Time
4
+ def self.example(time=nil)
5
+ time ||= Raw.example
6
+ ISO8601.example(time)
7
+ end
8
+
9
+ module Raw
10
+ def self.example
11
+ Clock::Controls::Time::Raw.example
12
+ end
13
+ end
14
+
15
+ module ISO8601
16
+ def self.example(time=nil)
17
+ Clock::Controls::Time::ISO8601.example(time)
18
+ end
19
+
20
+ def self.precision
21
+ 3
22
+ end
23
+ end
24
+
25
+ module Processed
26
+ def self.example(time=nil, offset_milliseconds: nil)
27
+ offset_milliseconds ||= self.offset_milliseconds
28
+ Clock::Controls::Time::Offset.example(offset_milliseconds, time: time, precision: ISO8601.precision)
29
+ end
30
+
31
+ module Raw
32
+ def self.example(time=nil, offset_milliseconds: nil)
33
+ offset_milliseconds ||= Processed.offset_milliseconds
34
+ Clock::Controls::Time::Offset::Raw.example(offset_milliseconds, time: time, precision: ISO8601.precision)
35
+ end
36
+ end
37
+
38
+ def self.offset_milliseconds
39
+ 11
40
+ end
41
+ end
42
+
43
+ module Effective
44
+ def self.example(time=nil, offset_milliseconds: nil)
45
+ offset_milliseconds ||= self.offset_milliseconds
46
+ Clock::Controls::Time::Offset.example(offset_milliseconds, time: time, precision: ISO8601.precision)
47
+ end
48
+
49
+ module Raw
50
+ def self.example(time=nil, offset_milliseconds: nil)
51
+ offset_milliseconds ||= Processed.offset_milliseconds
52
+ Clock::Controls::Time::Offset::Raw.example(offset_milliseconds, time: time, precision: ISO8601.precision)
53
+ end
54
+ end
55
+
56
+ def self.offset_milliseconds
57
+ 1
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,9 @@
1
+ module <%= component_constant_name %>
2
+ module Controls
3
+ module Version
4
+ def self.example
5
+ 1
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ module <%= component_constant_name %>
2
+ module Handlers
3
+ class Commands
4
+ include Messaging::Handle
5
+ include Messaging::StreamName
6
+ include Log::Dependency
7
+ include Messages::Commands
8
+ include Messages::Events
9
+
10
+ dependency :write, Messaging::Postgres::Write
11
+ dependency :clock, Clock::UTC
12
+ dependency :store, Store
13
+
14
+ def configure
15
+ Messaging::Postgres::Write.configure(self)
16
+ Clock::UTC.configure(self)
17
+ Store.configure(self)
18
+ end
19
+
20
+ category :<%= entity_name %>
21
+
22
+ # TODO Implement command handler block
23
+ # eg:
24
+ # handle DoSomething do |do_something|
25
+ # <%= entity_name %>_id = do_something.<%= entity_name %>_id
26
+
27
+ # <%= entity_name %>, version = store.fetch(<%= entity_name %>_id, include: :version)
28
+
29
+ # if <%= entity_name %>.something_happened?
30
+ # logger.info(tag: :ignored) { "Command ignored (Command: #{do_something.message_type}, <%= entity_constant_name %> ID: #{<%= entity_name %>_id})" }
31
+ # return
32
+ # end
33
+
34
+ # something_happened = SomethingHappened.follow(do_something)
35
+
36
+ # something_happened.processed_time = clock.iso8601
37
+
38
+ # stream_name = stream_name(<%= entity_name %>_id)
39
+
40
+ # write.(something_happened, stream_name, expected_version: version)
41
+ # end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ module <%= component_constant_name %>
2
+ module Handlers
3
+ class Events
4
+ include Messaging::Handle
5
+ include Messaging::StreamName
6
+ include Log::Dependency
7
+ include Messages::Commands
8
+ include Messages::Events
9
+
10
+ # TODO Implement event handler blocks
11
+ # Note: Delete this file if not handling events
12
+
13
+ # handle SomethingHappened do |something_happened|
14
+ # end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ module <%= component_constant_name %>
2
+ class Projection
3
+ include EntityProjection
4
+ include Messages::Events
5
+
6
+ entity_name :<%= entity_name %>
7
+
8
+ # TODO Implement event projection blocks
9
+ # eg:
10
+ # apply SomethingHappened do |something_happened|
11
+ # SetAttributes.(<%= entity_name %>, something_happened, copy: [
12
+ # { :<%= entity_name %>_id => :id }
13
+ # ])
14
+
15
+ # something_happened_time = Clock.parse(something_happened.time)
16
+
17
+ # <%= entity_name %>.something_happened_time = something_happened_time
18
+ # end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ module <%= component_constant_name %>
2
+ class Store
3
+ include EntityStore
4
+
5
+ category :<%= entity_name %>
6
+ entity <%= entity_constant_name %>
7
+ projection Projection
8
+ reader MessageStore::Postgres::Read
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ bundler_standalone_loader = 'gems/bundler/setup'
2
+
3
+ begin
4
+ require_relative bundler_standalone_loader
5
+ rescue LoadError
6
+ puts "WARNING: Standalone bundle loader is not at #{bundler_standalone_loader}. Using Bundler to load gems."
7
+ require "bundler/setup"
8
+ Bundler.require
9
+ end
10
+
11
+ lib_dir = File.expand_path('../lib', __FILE__)
12
+ $LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
13
+
14
+ libraries_dir = ENV['LIBRARIES_HOME']
15
+ unless libraries_dir.nil?
16
+ libraries_dir = File.expand_path(libraries_dir)
17
+ $LOAD_PATH.unshift libraries_dir unless $LOAD_PATH.include?(libraries_dir)
18
+ end
@@ -0,0 +1,7 @@
1
+ {
2
+ "dbname": "message_store",
3
+ "host": "localhost",
4
+ "hostaddr": "127.0.0.1",
5
+ "port": 5432,
6
+ "user": "message_store"
7
+ }
data/source/test.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ruby test/automated.rb
@@ -0,0 +1,8 @@
1
+ require_relative './test_init'
2
+
3
+ require 'test_bench/cli'
4
+
5
+ TestBench::CLI.(
6
+ exclude_pattern: '/_|sketch|(_init\.rb|_tests\.rb)\z',
7
+ tests_directory: 'test/automated'
8
+ ) or exit 1
@@ -0,0 +1 @@
1
+ require_relative '../test_init'
@@ -0,0 +1,13 @@
1
+ require_relative './automated_init'
2
+
3
+ context "Database Connection" do
4
+ session = MessageStore::Postgres::Session.build
5
+
6
+ refute(session.connected?)
7
+
8
+ test "Connects on first use" do
9
+ refute proc { session.execute('SELECT 1;') } do
10
+ raises_error?
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ require_relative '../test_init'
2
+
3
+ ENV['LOG_LEVEL'] = 'data'
@@ -0,0 +1,14 @@
1
+ ENV['CONSOLE_DEVICE'] ||= 'stdout'
2
+ ENV['LOG_LEVEL'] ||= '_min'
3
+
4
+ puts RUBY_DESCRIPTION
5
+
6
+ require_relative '../init.rb'
7
+
8
+ require 'test_bench'; TestBench.activate
9
+
10
+ require 'pp'
11
+
12
+ require '<%= component_name %>/controls'
13
+
14
+ include <%= component_constant_name %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-command_line-component_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.4
4
+ version: 0.1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
@@ -63,6 +63,29 @@ files:
63
63
  - lib/command_line/component_generator.rb
64
64
  - lib/command_line/component_generator/commands/component.rb
65
65
  - lib/command_line/component_generator/interface.rb
66
+ - source/%component_name%.gemspec.tt
67
+ - source/Gemfile.tt
68
+ - source/init.rb.tt
69
+ - source/install-gems.sh
70
+ - source/lib/%component_name%.rb.tt
71
+ - source/lib/%component_name%/%entity_name%.rb.tt
72
+ - source/lib/%component_name%/controls.rb.tt
73
+ - source/lib/%component_name%/controls/%entity_name%.rb.tt
74
+ - source/lib/%component_name%/controls/id.rb.tt
75
+ - source/lib/%component_name%/controls/time.rb.tt
76
+ - source/lib/%component_name%/controls/version.rb.tt
77
+ - source/lib/%component_name%/handlers/commands.rb.tt
78
+ - source/lib/%component_name%/handlers/events.rb.tt
79
+ - source/lib/%component_name%/projection.rb.tt
80
+ - source/lib/%component_name%/store.rb.tt
81
+ - source/load_path.rb
82
+ - source/settings/message_store_postgres.json.example
83
+ - source/test.sh
84
+ - source/test/automated.rb
85
+ - source/test/automated/automated_init.rb
86
+ - source/test/automated/database_connection.rb
87
+ - source/test/interactive/interactive_init.rb
88
+ - source/test/test_init.rb.tt
66
89
  homepage: https://github.com/eventide-project/command-line-component-generator
67
90
  licenses:
68
91
  - MIT