seam 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/lib/seam.rb +0 -1
- data/lib/seam/effort.rb +7 -0
- data/lib/seam/in_memory.rb +13 -0
- data/lib/seam/persistence.rb +29 -9
- data/lib/seam/version.rb +1 -1
- data/lib/seam/worker.rb +3 -2
- data/seam.gemspec +0 -1
- data/spec/seam/effort_spec.rb +5 -5
- data/spec/seam/flow_spec.rb +1 -1
- data/spec/seam/worker_spec.rb +2 -1
- data/spec/spec_helper.rb +0 -7
- metadata +6 -22
- data/lib/seam/mongo_db.rb +0 -12
data/.gitignore
CHANGED
data/lib/seam.rb
CHANGED
data/lib/seam/effort.rb
CHANGED
@@ -3,6 +3,7 @@ module Seam
|
|
3
3
|
attr_accessor :completed_steps
|
4
4
|
attr_accessor :created_at
|
5
5
|
attr_accessor :complete
|
6
|
+
attr_accessor :completed_at
|
6
7
|
attr_accessor :id
|
7
8
|
attr_accessor :next_execute_at
|
8
9
|
attr_accessor :next_step
|
@@ -31,6 +32,7 @@ module Seam
|
|
31
32
|
effort.history = document['history'].map { |x| HashWithIndifferentAccess.new x }
|
32
33
|
effort.completed_steps = document['completed_steps']
|
33
34
|
effort.complete = document['complete']
|
35
|
+
effort.completed_at = document['completed_at']
|
34
36
|
effort
|
35
37
|
end
|
36
38
|
|
@@ -60,6 +62,7 @@ module Seam
|
|
60
62
|
id: self.id,
|
61
63
|
created_at: self.created_at,
|
62
64
|
completed_steps: self.completed_steps,
|
65
|
+
completed_at: self.completed_at,
|
63
66
|
next_execute_at: self.next_execute_at,
|
64
67
|
next_step: self.next_step,
|
65
68
|
flow: self.flow,
|
@@ -68,5 +71,9 @@ module Seam
|
|
68
71
|
complete: self.complete,
|
69
72
|
}
|
70
73
|
end
|
74
|
+
|
75
|
+
def clone
|
76
|
+
Seam::Effort.parse HashWithIndifferentAccess.new(self.to_hash)
|
77
|
+
end
|
71
78
|
end
|
72
79
|
end
|
data/lib/seam/persistence.rb
CHANGED
@@ -1,24 +1,44 @@
|
|
1
1
|
module Seam
|
2
2
|
module Persistence
|
3
3
|
def self.find_by_effort_id effort_id
|
4
|
-
|
5
|
-
return nil unless
|
6
|
-
|
4
|
+
effort = Seam::InMemory.records.select { |x| x.id == effort_id }.first
|
5
|
+
return nil unless effort
|
6
|
+
effort.clone
|
7
|
+
#document = Seam::MongoDb.collection.find( { id: effort_id } ).first
|
8
|
+
#return nil unless document
|
9
|
+
#Seam::Effort.parse document
|
7
10
|
end
|
8
11
|
|
9
12
|
def self.find_all_pending_executions_by_step step
|
10
|
-
Seam::
|
11
|
-
.
|
12
|
-
.map { |x|
|
13
|
+
Seam::InMemory.records
|
14
|
+
.select { |x| x.next_step == step && x.next_execute_at <= Time.now }
|
15
|
+
.map { |x| x.clone }
|
16
|
+
#Seam::MongoDb.collection
|
17
|
+
#.find( { next_step: step, next_execute_at: { '$lte' => Time.now } } )
|
18
|
+
#.map { |x| Seam::Effort.parse x }
|
13
19
|
end
|
14
20
|
|
15
21
|
def self.save effort
|
16
|
-
|
17
|
-
|
22
|
+
old_record = find_by_effort_id effort.id
|
23
|
+
if old_record
|
24
|
+
Seam::InMemory.records = Seam::InMemory.records.select { |x| x.id != effort.id }.to_a
|
25
|
+
end
|
26
|
+
create effort
|
27
|
+
#Seam::MongoDb.collection.find( { id: effort.id } )
|
28
|
+
# .update("$set" => effort.to_hash)
|
18
29
|
end
|
19
30
|
|
20
31
|
def self.create effort
|
21
|
-
Seam::
|
32
|
+
Seam::InMemory.records = [Seam::InMemory.records, effort].flatten
|
33
|
+
#Seam::MongoDb.collection.insert(effort.to_hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.all
|
37
|
+
Seam::InMemory.records.to_a
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.destroy
|
41
|
+
Seam::InMemory.records = []
|
22
42
|
end
|
23
43
|
end
|
24
44
|
end
|
data/lib/seam/version.rb
CHANGED
data/lib/seam/worker.rb
CHANGED
data/seam.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency "json"
|
22
22
|
spec.add_runtime_dependency "activesupport", "~> 3.2"
|
23
23
|
spec.add_runtime_dependency "i18n"
|
24
|
-
spec.add_runtime_dependency "moped"
|
25
24
|
spec.add_runtime_dependency "json"
|
26
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
26
|
spec.add_development_dependency "rake"
|
data/spec/seam/effort_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe Seam::Effort do
|
4
4
|
before do
|
5
|
-
|
5
|
+
Seam::Persistence.destroy
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:flow) do
|
@@ -15,14 +15,14 @@ describe Seam::Effort do
|
|
15
15
|
describe "updating an effort" do
|
16
16
|
it "should not create another document in the collection" do
|
17
17
|
first_effort = flow.start
|
18
|
-
|
18
|
+
Seam::Persistence.all.count.must_equal 1
|
19
19
|
first_effort.save
|
20
|
-
|
20
|
+
Seam::Persistence.all.count.must_equal 1
|
21
21
|
|
22
22
|
second_effort = flow.start
|
23
|
-
|
23
|
+
Seam::Persistence.all.count.must_equal 2
|
24
24
|
second_effort.save
|
25
|
-
|
25
|
+
Seam::Persistence.all.count.must_equal 2
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should update the information" do
|
data/spec/seam/flow_spec.rb
CHANGED
data/spec/seam/worker_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe "worker" do
|
4
4
|
|
5
5
|
before do
|
6
|
-
|
6
|
+
Seam::Persistence.destroy
|
7
7
|
end
|
8
8
|
|
9
9
|
after do
|
@@ -271,6 +271,7 @@ describe "worker" do
|
|
271
271
|
effort.data['hit 3'].must_equal 1
|
272
272
|
|
273
273
|
effort.complete?.must_equal true
|
274
|
+
#effort.completed_at.must_equal Time.now
|
274
275
|
|
275
276
|
# FUTURE WAVES
|
276
277
|
send_postcard_if_necessary_worker.execute_all
|
data/spec/spec_helper.rb
CHANGED
@@ -6,10 +6,3 @@ require 'subtle'
|
|
6
6
|
require 'timecop'
|
7
7
|
require 'contrast'
|
8
8
|
require 'mocha/setup'
|
9
|
-
|
10
|
-
def test_moped_session
|
11
|
-
session = Moped::Session.new([ "127.0.0.1:27017" ])
|
12
|
-
session.use "seam_test"
|
13
|
-
end
|
14
|
-
|
15
|
-
Seam::MongoDb.set_collection test_moped_session['efforts']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -59,22 +59,6 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: moped
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
63
|
name: json
|
80
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -218,7 +202,7 @@ files:
|
|
218
202
|
- lib/seam.rb
|
219
203
|
- lib/seam/effort.rb
|
220
204
|
- lib/seam/flow.rb
|
221
|
-
- lib/seam/
|
205
|
+
- lib/seam/in_memory.rb
|
222
206
|
- lib/seam/persistence.rb
|
223
207
|
- lib/seam/step.rb
|
224
208
|
- lib/seam/version.rb
|
@@ -243,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
227
|
version: '0'
|
244
228
|
segments:
|
245
229
|
- 0
|
246
|
-
hash:
|
230
|
+
hash: -1708529221048095917
|
247
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
232
|
none: false
|
249
233
|
requirements:
|
@@ -252,10 +236,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
252
236
|
version: '0'
|
253
237
|
segments:
|
254
238
|
- 0
|
255
|
-
hash:
|
239
|
+
hash: -1708529221048095917
|
256
240
|
requirements: []
|
257
241
|
rubyforge_project:
|
258
|
-
rubygems_version: 1.8.
|
242
|
+
rubygems_version: 1.8.24
|
259
243
|
signing_key:
|
260
244
|
specification_version: 3
|
261
245
|
summary: Simple workflows
|