evt-event_source-postgres 0.15.0.0 → 0.15.1.0

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: eba580b41148c557fc11aea85e67c6f1b1028929
4
- data.tar.gz: 11a79b1f83208c3378609f527f245d6728cf3e37
3
+ metadata.gz: 0c2d9019e483b7567f36685a5e031f73b8381d74
4
+ data.tar.gz: 0a22f4e4bd5bb38f7697462153b489d065271f28
5
5
  SHA512:
6
- metadata.gz: ddfc4f1204bb81cf5ac65b8930e8f15eb034c4135b3c35dd8e79b4c7100e1fcb07cfca07fb5669e6f9118e0c10842f5da81d3e7d962e0fd3189b3b70a1429630
7
- data.tar.gz: d85e104ecf8dd27fe46247355b4a1bb35fd3fdcfeee5fc2cc480342f02c52d6d0d1021d8bfa4d96665e66b4270a7ac6a06a9ad153be33f70b9d2e4c58238fbae
6
+ metadata.gz: 4b5c1060202100f580779fa96cc8e9c23372ff1721f290bd5edbb090bcc70eee9a9758d10f3985b4b81146a629b54e067a8c463a0cb4bf5e240ba971340ac9e3
7
+ data.tar.gz: de1e5d80500b9bd50298341a54f62604a833fe3e5c9f53f51bc211210d66bb68dfacbe0d08fcde6d4e990fb1f251bc26b30a8f24313b7b858d3ac6fb80c1935b
@@ -1,7 +1,34 @@
1
+ # module EventSource
2
+ # module Postgres
3
+ # module Controls
4
+ # Category = EventSource::Controls::Category
5
+ # end
6
+ # end
7
+ # end
8
+
9
+
1
10
  module EventSource
2
11
  module Postgres
3
12
  module Controls
4
- Category = EventSource::Controls::Category
13
+ module Category
14
+ def self.example(category: nil, randomize_category: nil)
15
+ if randomize_category.nil?
16
+ if !category.nil?
17
+ randomize_category = false
18
+ end
19
+ end
20
+
21
+ randomize_category = true if randomize_category.nil?
22
+
23
+ category ||= 'test'
24
+
25
+ if randomize_category
26
+ category = "#{category}#{SecureRandom.hex(16)}XX"
27
+ end
28
+
29
+ category
30
+ end
31
+ end
5
32
  end
6
33
  end
7
34
  end
@@ -1,7 +1,22 @@
1
+ # module EventSource
2
+ # module Postgres
3
+ # module Controls
4
+ # StreamName = EventSource::Controls::StreamName
5
+ # end
6
+ # end
7
+ # end
8
+
1
9
  module EventSource
2
10
  module Postgres
3
11
  module Controls
4
- StreamName = EventSource::Controls::StreamName
12
+ module StreamName
13
+ def self.example(category: nil, id: nil, type: nil, types: nil, randomize_category: nil)
14
+ category ||= Category.example(category: category, randomize_category: randomize_category)
15
+ id ||= Identifier::UUID.random
16
+
17
+ EventSource::Postgres::StreamName.stream_name(category, id, type: type, types: types)
18
+ end
19
+ end
5
20
  end
6
21
  end
7
22
  end
@@ -5,7 +5,7 @@ module EventSource
5
5
  include EventSource::Read::Iterator
6
6
 
7
7
  def last_position
8
- unless EventSource::StreamName.category?(stream_name)
8
+ unless EventSource::Postgres::StreamName.category?(stream_name)
9
9
  batch.last.position
10
10
  else
11
11
  batch.last.global_position
@@ -0,0 +1,52 @@
1
+ module EventSource
2
+ module Postgres
3
+ module StreamName
4
+ def self.stream_name(category_name, id=nil, type: nil, types: nil)
5
+ types = Array(types)
6
+ types.unshift(type) unless type.nil?
7
+
8
+ type_list = nil
9
+ type_list = types.join('+') unless types.empty?
10
+
11
+ stream_name = category_name
12
+ stream_name = "#{stream_name}:#{type_list}" unless type_list.nil?
13
+ stream_name = "#{stream_name}-#{id}" unless id.nil?
14
+
15
+ stream_name
16
+ end
17
+
18
+ def self.get_id(stream_name)
19
+ id = stream_name.partition('-').last
20
+ id.empty? ? nil : id
21
+ end
22
+
23
+ def self.get_category(stream_name)
24
+ stream_name.split('-').first
25
+ end
26
+
27
+ def self.category?(stream_name)
28
+ !stream_name.include?('-')
29
+ end
30
+
31
+ def self.get_type_list(stream_name)
32
+ type = stream_name.split(':').last.split('-').first
33
+
34
+ return nil if stream_name.start_with?(type)
35
+
36
+ type
37
+ end
38
+
39
+ def self.get_types(stream_name)
40
+ type_list = get_type_list(stream_name)
41
+
42
+ return [] if type_list.nil?
43
+
44
+ type_list.split('+')
45
+ end
46
+
47
+ def self.get_entity_name(stream_name)
48
+ get_category(stream_name).split(':').first
49
+ end
50
+ end
51
+ end
52
+ end
@@ -12,6 +12,8 @@ require 'event_source/postgres/log'
12
12
  require 'event_source/postgres/settings'
13
13
  require 'event_source/postgres/session'
14
14
 
15
+ require 'event_source/postgres/stream_name'
16
+
15
17
  require 'event_source/postgres/put'
16
18
  require 'event_source/postgres/write'
17
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-event_source-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0.0
4
+ version: 0.15.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-04 00:00:00.000000000 Z
11
+ date: 2017-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-event_source
@@ -117,6 +117,7 @@ files:
117
117
  - lib/event_source/postgres/read/iterator.rb
118
118
  - lib/event_source/postgres/session.rb
119
119
  - lib/event_source/postgres/settings.rb
120
+ - lib/event_source/postgres/stream_name.rb
120
121
  - lib/event_source/postgres/write.rb
121
122
  homepage: https://github.com/eventide-project/event-source-postgres
122
123
  licenses: