euston-projections 1.0.1-java → 1.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'euston-projections'
3
- s.version = '1.0.1'
3
+ s.version = '1.0.2'
4
4
  s.platform = RUBY_PLATFORM.to_s == 'java' ? 'java' : Gem::Platform::RUBY
5
5
  s.authors = ['Lee Henson', 'Guy Boertje']
6
6
  s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  Rakefile
15
15
  euston-projections.gemspec
16
16
  lib/euston-projections.rb
17
+ lib/euston-projections/historical_message.rb
17
18
  lib/euston-projections/idempotence.rb
18
19
  lib/euston-projections/mongo_projection.rb
19
20
  lib/euston-projections/mongo_projection_event_handler.rb
@@ -0,0 +1,12 @@
1
+ module Euston
2
+ module Projections
3
+ class HistoricalMessage
4
+ include Mongoid::Document
5
+
6
+ field :message_id
7
+ field :timestamp, type: Float, default: ->{ Time.now.to_f }
8
+
9
+ embedded_in :historical, polymorphic: true
10
+ end
11
+ end
12
+ end
@@ -5,23 +5,25 @@ module Euston
5
5
  include Mongoid::Document
6
6
 
7
7
  included do
8
- field :_history, :type => Hash, :default => {}
8
+ embeds_many :historical_messages, as: :historical, class_name: 'Euston::Projections::HistoricalMessage'
9
9
  end
10
10
 
11
11
  def add_to_history message_id
12
- _history[message_id] = Time.now.to_f unless already_processed_message? message_id
12
+ return if already_processed_message? message_id
13
+
14
+ historical_messages << HistoricalMessage.new(message_id: message_id)
13
15
  end
14
16
 
15
17
  def already_processed_message? message_id
16
- _history.has_key? message_id
18
+ historical_messages.any? { |m| m.message_id == message_id }
17
19
  end
18
20
 
19
21
  def processed_message_ids
20
- _history.keys
22
+ historical_messages.map { |m| m.message_id }
21
23
  end
22
24
 
23
25
  def prune_history_older_than time
24
- _history.reject! { |id, timestamp| timestamp < time }
26
+ historical_messages.reject! { |m| m.timestamp < time }
25
27
  end
26
28
  end
27
29
  end
@@ -1,5 +1,5 @@
1
1
  module Euston
2
2
  module Projections
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require 'mongoid'
2
2
 
3
3
  require 'euston-projections/idempotence'
4
+ require 'euston-projections/historical_message'
4
5
  require 'euston-projections/mongo_projection'
5
6
  require 'euston-projections/mongo_projection_event_handler'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: euston-projections
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: java
7
7
  authors:
8
8
  - Lee Henson
@@ -10,73 +10,73 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-10-18 00:00:00.000000000 +01:00
13
+ date: 2011-10-24 00:00:00.000000000 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- version_requirements: &2230 !ruby/object:Gem::Requirement
18
+ version_requirements: &2206 !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.10
23
23
  none: false
24
- requirement: *2230
24
+ requirement: *2206
25
25
  prerelease: false
26
26
  type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: euston-eventstore
29
- version_requirements: &2248 !ruby/object:Gem::Requirement
29
+ version_requirements: &2224 !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.2.2
34
34
  none: false
35
- requirement: *2248
35
+ requirement: *2224
36
36
  prerelease: false
37
37
  type: :runtime
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: mongoid
40
- version_requirements: &2264 !ruby/object:Gem::Requirement
40
+ version_requirements: &2240 !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
44
  version: 2.1.0
45
45
  none: false
46
- requirement: *2264
46
+ requirement: *2240
47
47
  prerelease: false
48
48
  type: :runtime
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: awesome_print
51
- version_requirements: &2280 !ruby/object:Gem::Requirement
51
+ version_requirements: &2256 !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: 0.4.0
56
56
  none: false
57
- requirement: *2280
57
+ requirement: *2256
58
58
  prerelease: false
59
59
  type: :development
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: fuubar
62
- version_requirements: &2298 !ruby/object:Gem::Requirement
62
+ version_requirements: &2274 !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ~>
65
65
  - !ruby/object:Gem::Version
66
66
  version: 0.0.0
67
67
  none: false
68
- requirement: *2298
68
+ requirement: *2274
69
69
  prerelease: false
70
70
  type: :development
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rspec
73
- version_requirements: &2314 !ruby/object:Gem::Requirement
73
+ version_requirements: &2290 !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 2.6.0
78
78
  none: false
79
- requirement: *2314
79
+ requirement: *2290
80
80
  prerelease: false
81
81
  type: :development
82
82
  description: ''
@@ -91,6 +91,7 @@ files:
91
91
  - Rakefile
92
92
  - euston-projections.gemspec
93
93
  - lib/euston-projections.rb
94
+ - lib/euston-projections/historical_message.rb
94
95
  - lib/euston-projections/idempotence.rb
95
96
  - lib/euston-projections/mongo_projection.rb
96
97
  - lib/euston-projections/mongo_projection_event_handler.rb