command_post 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e017af18ee1497964678d7476ff8923328d115f1
4
- data.tar.gz: b1e3e62ddb8333b3ae2af14cb119f03613211f6e
3
+ metadata.gz: 860fe4cf62e3c2f38fad7c3d5611c276a3ab67af
4
+ data.tar.gz: d4f67830f1725e227697511b7f127b26aa57598c
5
5
  SHA512:
6
- metadata.gz: 678251e4d7116fd089a225ab83cd9a4eddcf513305624a998ec68eb1ec8c1578a7a890b492cb1b29a80ee866c379fd98d850f2a658dde249e2b374b03226bab7
7
- data.tar.gz: 4a2490595d96353e8e674e50a47ce93e40c6b612fe97c434f34311caa7c5b7a2abd547b35c48ccb95009c3e4255ca55f5c62d8651382a100bd5c57c8bf1ba9d7
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
@@ -18,4 +18,5 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
  spec.add_development_dependency "bundler", "~> 1.3"
20
20
  spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "mocha"
21
22
  end
@@ -1,48 +1,49 @@
1
- --drop table aggregate_events;
2
- --drop table aggregates;
1
+ --DROP TABLE AGGREGATE_EVENTS;
2
+ --DROP TABLE AGGREGATES;
3
3
 
4
4
 
5
5
 
6
- create table aggregate_events (
6
+ CREATE TABLE aggregate_events (
7
7
 
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
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
- create index aggregate_id_idx on aggregate_events(aggregate_id,aggregate_type);
19
+ CREATE INDEX aggregate_id_idx ON aggregate_events(aggregate_id,aggregate_type);
20
20
 
21
21
 
22
22
 
23
23
 
24
24
 
25
- create table aggregates (
25
+ CREATE TABLE aggregates (
26
26
 
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
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
- create index aggregate_lookup_idx on aggregates(aggregate_lookup_value);
34
+ CREATE INDEX aggregate_lookup_idx ON aggregates(aggregate_lookup_value);
35
35
 
36
36
 
37
37
 
38
38
 
39
- create table aggregate_index (
40
- aggregate_id bigint not null,
41
- index_field varchar(100) not null,
42
- index_value varchar(100) not null,
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
- create index aggregate_index on aggregates(aggregate_lookup_value);
46
+
46
47
 
47
48
  CREATE SEQUENCE aggregate START 1;
48
49
 
@@ -104,7 +104,8 @@ module CommandPost
104
104
  begin
105
105
  super
106
106
  rescue Exception => e
107
- raise e.message
107
+ puts "DEBUG: PRINTING BACKTRACE #{'=' * 80}"
108
+ puts e.backtrace
108
109
  end
109
110
  end
110
111
  end
@@ -1,3 +1,3 @@
1
1
  module CommandPost
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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.3
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-22 00:00:00.000000000 Z
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