euston-projections 1.0.2-java → 1.0.3-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.2'
3
+ s.version = '1.0.3'
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']
@@ -26,8 +26,8 @@ Gem::Specification.new do |s|
26
26
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
27
 
28
28
  s.add_dependency 'activesupport', '>= 3.0.10'
29
- s.add_dependency 'euston-eventstore', '~> 1.2.2'
30
- s.add_dependency 'mongoid', '~> 2.1.0'
29
+ s.add_dependency 'euston-eventstore', '~> 1.2.3'
30
+ s.add_dependency 'mongoid', '>= 2.1.0'
31
31
 
32
32
  s.add_development_dependency 'awesome_print', '~> 0.4.0'
33
33
  s.add_development_dependency 'fuubar', '~> 0.0.0'
@@ -7,13 +7,13 @@ module Euston
7
7
  def if_unhandled obj, headers
8
8
  return if obj.already_processed_message? headers.id
9
9
 
10
+ yield
11
+
10
12
  obj.add_to_history headers.id
11
13
 
12
14
  unless headers.source_message.nil? || obj.already_processed_message?(headers.source_message[:headers][:id])
13
15
  obj.add_to_history headers.source_message[:headers][:id]
14
16
  end
15
-
16
- yield
17
17
  end
18
18
 
19
19
  def if_unhandled_or_new document_type, id, headers
@@ -1,30 +1,37 @@
1
1
  module Euston
2
- module Projections
3
- module MongoProjection
4
- extend ActiveSupport::Concern
5
- include Mongoid::Document
2
+ module Projections
3
+ module MongoProjection
4
+ extend ActiveSupport::Concern
5
+ include Mongoid::Document
6
6
 
7
- included do
8
- embeds_many :historical_messages, as: :historical, class_name: 'Euston::Projections::HistoricalMessage'
9
- end
7
+ included do
8
+ embeds_many :historical_messages, as: :historical, class_name: 'Euston::Projections::HistoricalMessage'
9
+ end
10
10
 
11
- def add_to_history message_id
12
- return if already_processed_message? message_id
11
+ module ClassMethods
12
+ def get(mongo_spec)
13
+ where(mongo_spec).first rescue nil
14
+ end
15
+ end
13
16
 
14
- historical_messages << HistoricalMessage.new(message_id: message_id)
15
- end
17
+ module InstanceMethods
18
+ def add_to_history message_id
19
+ return if already_processed_message? message_id
20
+ historical_messages << HistoricalMessage.new(message_id: message_id)
21
+ end
16
22
 
17
- def already_processed_message? message_id
18
- historical_messages.any? { |m| m.message_id == message_id }
19
- end
23
+ def already_processed_message? *message_ids
24
+ (processed_message_ids & message_ids).size == message_ids.size
25
+ end
20
26
 
21
- def processed_message_ids
22
- historical_messages.map { |m| m.message_id }
23
- end
27
+ def processed_message_ids
28
+ historical_messages.map { |m| m.message_id }
29
+ end
24
30
 
25
- def prune_history_older_than time
26
- historical_messages.reject! { |m| m.timestamp < time }
27
- end
31
+ def prune_history_older_than time
32
+ historical_messages.reject! { |m| m.timestamp < time }
28
33
  end
29
34
  end
30
35
  end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  module Euston
2
2
  module Projections
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
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.2
5
+ version: 1.0.3
6
6
  platform: java
7
7
  authors:
8
8
  - Lee Henson
@@ -10,73 +10,72 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-10-24 00:00:00.000000000 +01:00
14
- default_executable:
13
+ date: 2011-10-31 00:00:00.000000000Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: activesupport
18
- version_requirements: &2206 !ruby/object:Gem::Requirement
17
+ version_requirements: &2058 !ruby/object:Gem::Requirement
19
18
  requirements:
20
19
  - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
21
  version: 3.0.10
23
22
  none: false
24
- requirement: *2206
23
+ requirement: *2058
25
24
  prerelease: false
26
25
  type: :runtime
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: euston-eventstore
29
- version_requirements: &2224 !ruby/object:Gem::Requirement
28
+ version_requirements: &2076 !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ~>
32
31
  - !ruby/object:Gem::Version
33
- version: 1.2.2
32
+ version: 1.2.3
34
33
  none: false
35
- requirement: *2224
34
+ requirement: *2076
36
35
  prerelease: false
37
36
  type: :runtime
38
37
  - !ruby/object:Gem::Dependency
39
38
  name: mongoid
40
- version_requirements: &2240 !ruby/object:Gem::Requirement
39
+ version_requirements: &2092 !ruby/object:Gem::Requirement
41
40
  requirements:
42
- - - ~>
41
+ - - ! '>='
43
42
  - !ruby/object:Gem::Version
44
43
  version: 2.1.0
45
44
  none: false
46
- requirement: *2240
45
+ requirement: *2092
47
46
  prerelease: false
48
47
  type: :runtime
49
48
  - !ruby/object:Gem::Dependency
50
49
  name: awesome_print
51
- version_requirements: &2256 !ruby/object:Gem::Requirement
50
+ version_requirements: &2108 !ruby/object:Gem::Requirement
52
51
  requirements:
53
52
  - - ~>
54
53
  - !ruby/object:Gem::Version
55
54
  version: 0.4.0
56
55
  none: false
57
- requirement: *2256
56
+ requirement: *2108
58
57
  prerelease: false
59
58
  type: :development
60
59
  - !ruby/object:Gem::Dependency
61
60
  name: fuubar
62
- version_requirements: &2274 !ruby/object:Gem::Requirement
61
+ version_requirements: &2126 !ruby/object:Gem::Requirement
63
62
  requirements:
64
63
  - - ~>
65
64
  - !ruby/object:Gem::Version
66
65
  version: 0.0.0
67
66
  none: false
68
- requirement: *2274
67
+ requirement: *2126
69
68
  prerelease: false
70
69
  type: :development
71
70
  - !ruby/object:Gem::Dependency
72
71
  name: rspec
73
- version_requirements: &2290 !ruby/object:Gem::Requirement
72
+ version_requirements: &2142 !ruby/object:Gem::Requirement
74
73
  requirements:
75
74
  - - ~>
76
75
  - !ruby/object:Gem::Version
77
76
  version: 2.6.0
78
77
  none: false
79
- requirement: *2290
78
+ requirement: *2142
80
79
  prerelease: false
81
80
  type: :development
82
81
  description: ''
@@ -96,7 +95,6 @@ files:
96
95
  - lib/euston-projections/mongo_projection.rb
97
96
  - lib/euston-projections/mongo_projection_event_handler.rb
98
97
  - lib/euston-projections/version.rb
99
- has_rdoc: true
100
98
  homepage: http://github.com/leemhenson/euston-projections
101
99
  licenses: []
102
100
  post_install_message:
@@ -117,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
115
  none: false
118
116
  requirements: []
119
117
  rubyforge_project:
120
- rubygems_version: 1.5.1
118
+ rubygems_version: 1.8.9
121
119
  signing_key:
122
120
  specification_version: 3
123
121
  summary: Default projection classes for Euston.