evt-event_source 0.18.2.1 → 0.19.0.0

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: 4bdd6bac404bf5f1c0931fb2913688d4325abad2
4
- data.tar.gz: df32dea81012d80b66a4e7ac30bd0da990b9459c
3
+ metadata.gz: d2023c4a4fded3ae97318f828482cfa3a1984560
4
+ data.tar.gz: '07874a76c0b95e1bc4f7a7da7a3404e5738a7556'
5
5
  SHA512:
6
- metadata.gz: abefbc527a28696c7a36e5a789978137c33f72d5df872ef257339d5b38c84af1e2e84fba604f374768b4ed930a840456ca6da23fca12a34cf20e6431a3f8a8d0
7
- data.tar.gz: e2bd805e94970393b74f00ba0996840c3963eb4eb8993fcd04ca3134223ac81c82ebcdf431cedea76f0cb086be4d041caa965ed38e8c1bc20202d3c59aa6fa6d
6
+ metadata.gz: d6c814ec4314887fb5a92b42d5588aa49cf22fe6434b5e9e89318bee444fb948eac1a1285da114d63f9a3d05840d418e4bc7fe6ff7b55fcdbc578f249ce1a393
7
+ data.tar.gz: 6e84704a70a50dc4a4d854e9d2266d4b8394b4b4f0e94867a9c603293088520f9e61e7a665bf6bf0cab3debc0d7a1126c1de58b44fb6c1e6a7687ab5852b3b44
@@ -1,10 +1,14 @@
1
1
  module EventSource
2
2
  module Controls
3
3
  module StreamName
4
- def self.example(category: nil, id: nil, randomize_category: nil)
4
+ def self.example(category: nil, id: nil, type: nil, randomize_category: nil)
5
5
  category ||= Category.example(category: category, randomize_category: randomize_category)
6
6
  id ||= Identifier::UUID.random
7
7
 
8
+ unless type.nil?
9
+ category = "#{category}:#{type}"
10
+ end
11
+
8
12
  "#{category}-#{id}"
9
13
  end
10
14
  end
@@ -2,30 +2,23 @@ module EventSource
2
2
  class Stream
3
3
  initializer :name
4
4
 
5
- def self.get_type(name)
6
- subtype = name.split(':').last.split('-').first
7
-
8
- if name.start_with?(subtype)
9
- return :stream
10
- else
11
- return subtype.to_sym
12
- end
13
- end
14
-
15
- def self.canonize(stream)
16
- return stream if stream.is_a? self
17
-
18
- new stream
5
+ def self.build(subject)
6
+ return subject if subject.is_a? self
7
+ new(subject)
19
8
  end
20
9
 
21
- def type
22
- @type ||= self.class.get_type(name)
10
+ def id
11
+ @id ||= StreamName.get_id(name)
23
12
  end
24
13
 
25
14
  def category
26
15
  @category ||= StreamName.get_category(name)
27
16
  end
28
17
 
18
+ def type
19
+ @type ||= StreamName.get_type(name)
20
+ end
21
+
29
22
  def category?
30
23
  @is_category ||= !name.include?('-')
31
24
  end
@@ -1,9 +1,11 @@
1
1
  module EventSource
2
2
  module StreamName
3
- extend self
3
+ def self.stream_name(category_name, id=nil, type: nil)
4
+ stream_name = category_name
5
+ stream_name = "#{stream_name}:#{type}" unless type.nil?
6
+ stream_name = "#{stream_name}-#{id}" unless id.nil?
4
7
 
5
- def stream_name(category_name, id)
6
- "#{category_name}-#{id}"
8
+ stream_name
7
9
  end
8
10
 
9
11
  def self.get_id(stream_name)
@@ -14,5 +16,13 @@ module EventSource
14
16
  def self.get_category(stream_name)
15
17
  stream_name.split('-')[0]
16
18
  end
19
+
20
+ def self.get_type(name)
21
+ type = name.split(':').last.split('-').first
22
+
23
+ return nil if name.start_with?(type)
24
+
25
+ type
26
+ end
17
27
  end
18
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-event_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.2.1
4
+ version: 0.19.0.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-01-20 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-casing