command_post 0.0.3 → 0.0.4
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 +4 -4
- data/README.md +1 -4
- data/command_post.gemspec +1 -0
- data/lib/command_post/db/postgresql.sql +24 -23
- data/lib/command_post/persistence/persistence.rb +2 -1
- data/lib/command_post/version.rb +1 -1
- data/spec/command_post/persistence/indexing_spec.rb +77 -0
- data/spec/command_post/persistence/scratch.rb +46 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 860fe4cf62e3c2f38fad7c3d5611c276a3ab67af
|
4
|
+
data.tar.gz: d4f67830f1725e227697511b7f127b26aa57598c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5174a62436e5ef7d4b8c735f04c77a3429e3425f375a4030412af550d162f9f798109be82b10f37fb49b2bbb045c4d01c5f6d4c4e3a04e116e5ea4d8ebbfca4
|
7
|
+
data.tar.gz: fd0db270fce1df7f026a71fed32d96b2d2ca1d0f6ee711d3d5e014cf164fe36dd24b6d01399290f1915b971ec9d67207c277b724cc0cc0bbdb599db5c24fa253
|
data/README.md
CHANGED
@@ -236,10 +236,7 @@ Now to persist this thing we would say something like this:
|
|
236
236
|
|
237
237
|
|
238
238
|
|
239
|
-
|
240
|
-
That's all for today. I'll write more soon. I wrote this in one setting so I apologize for any typos.
|
241
|
-
|
242
|
-
More soon. I hope to release this as open source on GitHub sometime before August, 2013.
|
239
|
+
Download the gem from RubyGems at: https://rubygems.org/gems/command_post
|
243
240
|
|
244
241
|
|
245
242
|
|
data/command_post.gemspec
CHANGED
@@ -1,48 +1,49 @@
|
|
1
|
-
--
|
2
|
-
--
|
1
|
+
--DROP TABLE AGGREGATE_EVENTS;
|
2
|
+
--DROP TABLE AGGREGATES;
|
3
3
|
|
4
4
|
|
5
5
|
|
6
|
-
|
6
|
+
CREATE TABLE aggregate_events (
|
7
7
|
|
8
|
-
transaction_id
|
9
|
-
aggregate_id
|
10
|
-
aggregate_type
|
11
|
-
event_description
|
12
|
-
content
|
13
|
-
call_stack
|
14
|
-
user_id
|
15
|
-
transacted
|
8
|
+
transaction_id BIGINT PRIMARY KEY,
|
9
|
+
aggregate_id BIGINT,
|
10
|
+
aggregate_type VARCHAR(100),
|
11
|
+
event_description TEXT,
|
12
|
+
content TEXT,
|
13
|
+
call_stack TEXT,
|
14
|
+
user_id VARCHAR(100) NOT NULL,
|
15
|
+
transacted TIMESTAMP
|
16
16
|
|
17
17
|
) ;
|
18
18
|
|
19
|
-
|
19
|
+
CREATE INDEX aggregate_id_idx ON aggregate_events(aggregate_id,aggregate_type);
|
20
20
|
|
21
21
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
|
25
|
+
CREATE TABLE aggregates (
|
26
26
|
|
27
|
-
aggregate_id
|
28
|
-
aggregate_lookup_value
|
29
|
-
aggregate_type
|
30
|
-
content
|
27
|
+
aggregate_id BIGINT NOT NULL PRIMARY KEY,
|
28
|
+
aggregate_lookup_value VARCHAR(100) NOT NULL,
|
29
|
+
aggregate_type VARCHAR(100) NOT NULL,
|
30
|
+
content TEXT NOT NULL
|
31
31
|
|
32
32
|
) ;
|
33
33
|
|
34
|
-
|
34
|
+
CREATE INDEX aggregate_lookup_idx ON aggregates(aggregate_lookup_value);
|
35
35
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
|
40
|
-
aggregate_id
|
41
|
-
index_field
|
42
|
-
index_value
|
39
|
+
CREATE TABLE aggregate_indexes (
|
40
|
+
aggregate_id BIGINT NOT NULL,
|
41
|
+
index_field VARCHAR(100) NOT NULL,
|
42
|
+
index_value VARCHAR(100) NOT NULL,
|
43
|
+
PRIMARY KEY (aggregate_id,index_field)
|
43
44
|
) ;
|
44
45
|
|
45
|
-
|
46
|
+
|
46
47
|
|
47
48
|
CREATE SEQUENCE aggregate START 1;
|
48
49
|
|
data/lib/command_post/version.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../command_post/require')
|
2
|
+
|
3
|
+
require 'faker'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
class Test100Person < CommandPost::Persistence
|
9
|
+
include CommandPost::Identity
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
end
|
14
|
+
def self.schema
|
15
|
+
fields = Hash.new
|
16
|
+
fields[ :first_name ] = { :required => true, :type => String, :location => :local }
|
17
|
+
fields[ :last_name ] = { :required => true, :type => String, :location => :local }
|
18
|
+
fields[ :ssn ] = { :required => true, :type => String, :location => :local }
|
19
|
+
fields[ :favorite_number ] = { :required => true, :type => Fixnum, :location => :local }
|
20
|
+
fields[ :lookup ] = { :use => :ssn }
|
21
|
+
fields
|
22
|
+
end
|
23
|
+
def self.indexes
|
24
|
+
[:favorite_number]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
describe CommandPost::Identity do
|
31
|
+
it 'should aggregate_ids via index methods' do
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
1000.times do |i|
|
36
|
+
|
37
|
+
|
38
|
+
puts "count = #{i.to_s}"
|
39
|
+
params = Hash.new # like a web request...
|
40
|
+
|
41
|
+
params['first_name'] = Faker::Name.first_name #hash key is a string to mimic a web post/put
|
42
|
+
params['last_name'] = Faker::Name.last_name #hash key is a string to mimic a web post/put
|
43
|
+
params['ssn'] = "%09d" % CommandPost::SequenceGenerator.misc #hash key is a string to mimic a web post/put
|
44
|
+
params['favorite_number'] = rand(20)
|
45
|
+
|
46
|
+
#----------------------------------------------------------------
|
47
|
+
# The code below will eventually be replaced by the
|
48
|
+
# 'handle' method of the CommandXXXXXX class.
|
49
|
+
#----------------------------------------------------------------
|
50
|
+
|
51
|
+
object = Test100Person.load_from_hash Test100Person, params
|
52
|
+
puts "OBJECT IS NIL #{'=' * 80}" if object.nil?
|
53
|
+
event = CommandPost::AggregateEvent.new
|
54
|
+
event.aggregate_id = object.aggregate_id
|
55
|
+
event.object = object
|
56
|
+
event.aggregate_type = Test100Person
|
57
|
+
event.event_description = 'hired'
|
58
|
+
event.user_id = 'test'
|
59
|
+
event.publish
|
60
|
+
|
61
|
+
|
62
|
+
#----------------------------------------------------------------
|
63
|
+
# Retrieve the object by both aggregate_id and aggregate_lookup_value
|
64
|
+
# Both ways should retrieve the same object and the fields of both
|
65
|
+
# should match the original values used to create the object.
|
66
|
+
#----------------------------------------------------------------
|
67
|
+
|
68
|
+
|
69
|
+
saved_person = CommandPost::Aggregate.get_by_aggregate_id Test100Person, event.aggregate_id
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../command_post/require')
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class Test100Person < CommandPost::Persistence
|
8
|
+
include CommandPost::Identity
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
end
|
13
|
+
def self.schema
|
14
|
+
fields = Hash.new
|
15
|
+
fields[ :first_name ] = { :required => true, :type => String, :location => :local }
|
16
|
+
fields[ :last_name ] = { :required => true, :type => String, :location => :local }
|
17
|
+
fields[ :ssn ] = { :required => true, :type => String, :location => :local }
|
18
|
+
fields[ :favorite_number ] = { :required => true, :type => Fixnum, :location => :local }
|
19
|
+
fields[ :lookup ] = { :use => :ssn }
|
20
|
+
fields
|
21
|
+
end
|
22
|
+
def self.indexes
|
23
|
+
[:favorite_number]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
# Test100Person.init_indexes Test100Person.indexes
|
31
|
+
|
32
|
+
|
33
|
+
ids = Test100Person.favorite_number_in([10,11,12])
|
34
|
+
|
35
|
+
puts "count = #{ids.count}"
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_post
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Meirow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: CommandPost
|
42
56
|
email:
|
43
57
|
- joe.meirow@gmail.com
|
@@ -72,9 +86,11 @@ files:
|
|
72
86
|
- spec/command_post/identity/identity_lookup_value_checksum_spec.rb
|
73
87
|
- spec/command_post/identity/identity_lookup_value_field_spec.rb
|
74
88
|
- spec/command_post/persistence/data_validation_spec.rb
|
89
|
+
- spec/command_post/persistence/indexing_spec.rb
|
75
90
|
- spec/command_post/persistence/nested_remote_spec.rb
|
76
91
|
- spec/command_post/persistence/querying_spec.rb
|
77
92
|
- spec/command_post/persistence/schema_validation_spec.rb
|
93
|
+
- spec/command_post/persistence/scratch.rb
|
78
94
|
- spec/command_post/require.rb
|
79
95
|
- spec/spec_helper.rb
|
80
96
|
homepage: http://github.com/jmeirow/command_post
|
@@ -107,8 +123,10 @@ test_files:
|
|
107
123
|
- spec/command_post/identity/identity_lookup_value_checksum_spec.rb
|
108
124
|
- spec/command_post/identity/identity_lookup_value_field_spec.rb
|
109
125
|
- spec/command_post/persistence/data_validation_spec.rb
|
126
|
+
- spec/command_post/persistence/indexing_spec.rb
|
110
127
|
- spec/command_post/persistence/nested_remote_spec.rb
|
111
128
|
- spec/command_post/persistence/querying_spec.rb
|
112
129
|
- spec/command_post/persistence/schema_validation_spec.rb
|
130
|
+
- spec/command_post/persistence/scratch.rb
|
113
131
|
- spec/command_post/require.rb
|
114
132
|
- spec/spec_helper.rb
|