ruote-couch 2.1.5 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -2,6 +2,11 @@
2
2
  = ruote-couch - CHANGELOG.txt
3
3
 
4
4
 
5
+ == ruote-couch 2.1.7 released 2010/02/15
6
+
7
+ - enabled Ruote::StorageParticipant#query(criteria)
8
+
9
+
5
10
  == ruote-couch 2.1.5 released 2010/01/28
6
11
 
7
12
  - implemented CouchStorage#by_wfid and #by_participant
data/README.rdoc CHANGED
@@ -3,7 +3,27 @@
3
3
 
4
4
  A storage implementation for ruote 2.1.x.
5
5
 
6
- Warning : this is a very naive implementation for now. No optimizations.
6
+ Warning : this is a very naive implementation for now. Not many optimizations...
7
+
8
+
9
+ == running tests
10
+
11
+ assuming you have
12
+
13
+ ruote/
14
+ ruote-couch/
15
+
16
+ * unit tests :
17
+
18
+ get into ruote/ and do
19
+
20
+ ruby test/unit/storage.rb --couch
21
+
22
+ * functional tests :
23
+
24
+ get into ruote/ and do
25
+
26
+ ruby test/functional/test.rb --couch
7
27
 
8
28
 
9
29
  == license
data/Rakefile CHANGED
@@ -33,10 +33,9 @@ CouchDB storage for ruote 2.1 (ruby workflow engine)
33
33
  gem.test_file = 'test/test.rb'
34
34
 
35
35
  gem.add_dependency 'ruote', ">= #{Ruote::Couch::VERSION}"
36
- #gem.add_dependency 'yajl-ruby'
37
- #gem.add_dependency 'json'
38
- gem.add_dependency 'rufus-jig', '>= 0.1.12'
39
- gem.add_development_dependency 'yard', '>= 0'
36
+ gem.add_dependency 'rufus-jig', '>= 0.1.13'
37
+ gem.add_development_dependency 'yard'
38
+ gem.add_development_dependency 'jeweler'
40
39
 
41
40
  # gemspec spec : http://www.rubygems.org/read/chapter/20
42
41
  end
@@ -30,6 +30,9 @@ module Ruote::Couch
30
30
  #
31
31
  # A database corresponds to a Couch database (not a Couch server).
32
32
  #
33
+ # There is one database per ruote document type (msgs, workitems,
34
+ # expressions, ...)
35
+ #
33
36
  class Database
34
37
 
35
38
  attr_reader :type
@@ -130,11 +133,11 @@ module Ruote::Couch
130
133
  #
131
134
  def query_options (opts)
132
135
 
133
- if l = opts[:limit]
134
- "&limit=#{l}"
135
- else
136
- ''
137
- end
136
+ opts = opts.select { |k, v| [ :limit, :skip ].include?(k) && v != nil }
137
+
138
+ s = opts.collect { |k, v| "#{k}=#{v}" }.join('&')
139
+
140
+ s.length > 0 ? "&#{s}" : ''
138
141
  end
139
142
 
140
143
  def query (uri)
@@ -143,6 +146,15 @@ module Ruote::Couch
143
146
 
144
147
  rs['rows'].collect { |e| e['doc'] }
145
148
  end
149
+
150
+ def query_by_post (uri, keys)
151
+
152
+ keys = { 'keys' => keys }
153
+
154
+ rs = @couch.post(uri, keys)
155
+
156
+ rs['rows'].collect { |e| e['doc'] }.uniq
157
+ end
146
158
  end
147
159
 
148
160
  #
@@ -166,6 +178,13 @@ module Ruote::Couch
166
178
  end
167
179
  end
168
180
 
181
+ # Used by WorkitemDatabase#query
182
+ #
183
+ def by_wfid (wfid)
184
+
185
+ get_many(/!#{wfid}$/, {})
186
+ end
187
+
169
188
  protected
170
189
 
171
190
  def design_doc
@@ -215,6 +234,42 @@ module Ruote::Couch
215
234
  "&include_docs=true#{query_options(opts)}")
216
235
  end
217
236
 
237
+ # This method is called by CouchStorage#query
238
+ #
239
+ def query_workitems (criteria)
240
+
241
+ offset = criteria.delete('offset')
242
+ limit = criteria.delete('limit')
243
+
244
+ wfid =
245
+ criteria.delete('wfid')
246
+ pname =
247
+ criteria.delete('participant_name') || criteria.delete('participant')
248
+
249
+ if criteria.empty? && (wfid.nil? ^ pname.nil?)
250
+ return by_participant(pname) if pname
251
+ return by_wfid(wfid) # if wfid
252
+ end
253
+
254
+ return get_many(nil, {}).collect { |hwi| Ruote::Workitem.new(hwi) } \
255
+ if criteria.empty?
256
+
257
+ cr = criteria.collect { |fname, fvalue| { fname => fvalue } }
258
+
259
+ opts = { :skip => offset, :limit => limit }
260
+
261
+ hwis = query_by_post(
262
+ "_design/ruote/_view/by_field?include_docs=true#{query_options(opts)}",
263
+ cr)
264
+
265
+ hwis = hwis.select { |hwi| hwi['fei']['wfid'] == wfid } if wfid
266
+
267
+ hwis = hwis.select { |hwi|
268
+ Ruote::StorageParticipant.matches?(hwi, pname, criteria) }
269
+
270
+ hwis.collect { |hwi| Ruote::Workitem.new(hwi) }
271
+ end
272
+
218
273
  protected
219
274
 
220
275
  def design_doc
@@ -237,11 +292,11 @@ module Ruote::Couch
237
292
 
238
293
  emit(field, null);
239
294
 
240
- var k = {};
241
- k[field] = doc.fields[field]
242
- emit(k, null);
295
+ var entry = {};
296
+ entry[field] = doc.fields[field]
297
+ emit(entry, null);
243
298
  //
244
- // have to use that k trick...
299
+ // have to use that 'entry' trick...
245
300
  // else the field is named 'field'
246
301
  }
247
302
  }
@@ -31,12 +31,23 @@ require 'rufus/jig' # gem install rufus-jig
31
31
  module Ruote
32
32
  module Couch
33
33
 
34
+ #
35
+ # A CouchDB storage mechanism for ruote.
36
+ #
37
+ # The storage merely 'routes' work to Ruote::Couch::Database instances,
38
+ # one per document 'type' (expressions, msgs, schedules, variables, ...)
39
+ #
34
40
  class CouchStorage
35
41
 
36
42
  include Ruote::StorageBase
37
43
 
38
44
  attr_reader :couch
39
45
 
46
+ # Hooks the storage to a CouchDB instance.
47
+ #
48
+ # The main option is 'prefix', which indicate which prefix should be
49
+ # added to all the database names used by this storage.
50
+ #
40
51
  def initialize (host, port, options={})
41
52
 
42
53
  @host = host
@@ -145,6 +156,11 @@ module Couch
145
156
  @dbs['workitems'].by_field(field, value)
146
157
  end
147
158
 
159
+ def query_workitems (criteria)
160
+
161
+ @dbs['workitems'].query_workitems(criteria)
162
+ end
163
+
148
164
  protected
149
165
 
150
166
  def put_configuration
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Ruote
3
3
  module Couch
4
- VERSION = '2.1.5'
4
+ VERSION = '2.1.7'
5
5
  end
6
6
  end
7
7
 
data/ruote-couch.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruote-couch}
8
- s.version = "2.1.5"
8
+ s.version = "2.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux"]
12
- s.date = %q{2010-01-28}
12
+ s.date = %q{2010-02-15}
13
13
  s.description = %q{CouchDB storage for ruote 2.1 (ruby workflow engine)}
14
14
  s.email = %q{jmettraux@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -28,14 +28,8 @@ Gem::Specification.new do |s|
28
28
  "lib/ruote/couch/storage.rb",
29
29
  "lib/ruote/couch/version.rb",
30
30
  "ruote-couch.gemspec",
31
- "test/functional/ft_0_echo.rb",
32
- "test/functional/test.rb",
33
31
  "test/integration_connection.rb",
34
- "test/path_helper.rb",
35
- "test/test.rb",
36
- "test/test_helper.rb",
37
- "test/unit/test.rb",
38
- "test/unit/ut_0_initial.rb"
32
+ "test/test.rb"
39
33
  ]
40
34
  s.homepage = %q{http://github.com/jmettraux/ruote-couch}
41
35
  s.rdoc_options = ["--charset=UTF-8"]
@@ -52,18 +46,21 @@ Gem::Specification.new do |s|
52
46
  s.specification_version = 3
53
47
 
54
48
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
- s.add_runtime_dependency(%q<ruote>, [">= 2.1.5"])
56
- s.add_runtime_dependency(%q<rufus-jig>, [">= 0.1.12"])
49
+ s.add_runtime_dependency(%q<ruote>, [">= 2.1.7"])
50
+ s.add_runtime_dependency(%q<rufus-jig>, [">= 0.1.13"])
57
51
  s.add_development_dependency(%q<yard>, [">= 0"])
52
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
58
53
  else
59
- s.add_dependency(%q<ruote>, [">= 2.1.5"])
60
- s.add_dependency(%q<rufus-jig>, [">= 0.1.12"])
54
+ s.add_dependency(%q<ruote>, [">= 2.1.7"])
55
+ s.add_dependency(%q<rufus-jig>, [">= 0.1.13"])
61
56
  s.add_dependency(%q<yard>, [">= 0"])
57
+ s.add_dependency(%q<jeweler>, [">= 0"])
62
58
  end
63
59
  else
64
- s.add_dependency(%q<ruote>, [">= 2.1.5"])
65
- s.add_dependency(%q<rufus-jig>, [">= 0.1.12"])
60
+ s.add_dependency(%q<ruote>, [">= 2.1.7"])
61
+ s.add_dependency(%q<rufus-jig>, [">= 0.1.13"])
66
62
  s.add_dependency(%q<yard>, [">= 0"])
63
+ s.add_dependency(%q<jeweler>, [">= 0"])
67
64
  end
68
65
  end
69
66
 
data/test/test.rb CHANGED
@@ -1,10 +1,7 @@
1
1
 
2
- #
3
- # testing Ruote-couch
4
- #
5
- # Fri Dec 11 20:10:30 JST 2009
6
- #
7
-
8
- load File.dirname(__FILE__) + '/unit/test.rb'
9
- load File.dirname(__FILE__) + '/functional/test.rb'
2
+ puts %{
3
+ ~~~
4
+ please read the README about how to run ruote-dm tests
5
+ ~~~
6
+ }
10
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruote-couch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-28 00:00:00 +09:00
12
+ date: 2010-02-15 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.1.5
23
+ version: 2.1.7
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rufus-jig
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.12
33
+ version: 0.1.13
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: yard
@@ -42,6 +42,16 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: "0"
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: jeweler
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
45
55
  description: CouchDB storage for ruote 2.1 (ruby workflow engine)
46
56
  email: jmettraux@gmail.com
47
57
  executables: []
@@ -63,14 +73,8 @@ files:
63
73
  - lib/ruote/couch/storage.rb
64
74
  - lib/ruote/couch/version.rb
65
75
  - ruote-couch.gemspec
66
- - test/functional/ft_0_echo.rb
67
- - test/functional/test.rb
68
76
  - test/integration_connection.rb
69
- - test/path_helper.rb
70
77
  - test/test.rb
71
- - test/test_helper.rb
72
- - test/unit/test.rb
73
- - test/unit/ut_0_initial.rb
74
78
  has_rdoc: true
75
79
  homepage: http://github.com/jmettraux/ruote-couch
76
80
  licenses: []
@@ -1,42 +0,0 @@
1
-
2
- #
3
- # testing ruote-couch
4
- #
5
- # Fri Dec 11 22:06:25 JST 2009
6
- #
7
-
8
- require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
9
-
10
- require 'ruote/engine'
11
- require 'ruote/worker'
12
-
13
- require File.join(File.dirname(__FILE__), '..', 'integration_connection.rb')
14
-
15
-
16
- class FtInitialTest < Test::Unit::TestCase
17
-
18
- def test_echo
19
-
20
- #require 'ruote/storage/hash_storage'
21
- #storage = Ruote::HashStorage.new
22
- #require 'ruote/storage/fs_storage'
23
- #storage = Ruote::FsStorage.new('work')
24
-
25
- storage = new_storage(nil)
26
-
27
- engine = Ruote::Engine.new(Ruote::Worker.new(storage))
28
-
29
- engine.context[:noisy] = true
30
-
31
- pdef = Ruote.process_definition :name => 'test' do
32
- echo '* SEEN *'
33
- end
34
-
35
- wfid = engine.launch(pdef)
36
-
37
- engine.wait_for(wfid)
38
-
39
- #storage.purge!
40
- end
41
- end
42
-
@@ -1,11 +0,0 @@
1
-
2
- #
3
- # testing ruote-couch
4
- #
5
- # Fri Dec 11 20:11:39 JST 2009
6
- #
7
-
8
- Dir.glob(File.join(File.dirname(__FILE__), 'ft_*.rb')).sort.each { |t|
9
- require(t)
10
- }
11
-
data/test/path_helper.rb DELETED
@@ -1,16 +0,0 @@
1
-
2
- #
3
- # testing ruote-couch
4
- #
5
- # Thu Dec 10 11:04:02 JST 2009
6
- #
7
-
8
- ruote_lib = File.expand_path(
9
- File.join(File.dirname(__FILE__), *%w[ .. .. ruote lib ]))
10
- ruote_couch_lib = File.expand_path(
11
- File.join(File.dirname(__FILE__), *%w[ .. lib ]))
12
-
13
- [ ruote_lib, ruote_couch_lib ].each do |lib|
14
- $:.unshift(lib) unless $:.include?(lib)
15
- end
16
-
data/test/test_helper.rb DELETED
@@ -1,13 +0,0 @@
1
-
2
- #
3
- # testing ruote-couch
4
- #
5
- # Thu Dec 10 11:09:17 JST 2009
6
- #
7
-
8
- require 'yajl'
9
-
10
- require File.join(File.dirname(__FILE__), 'path_helper')
11
-
12
- require 'test/unit'
13
-
data/test/unit/test.rb DELETED
@@ -1,11 +0,0 @@
1
-
2
- #
3
- # testing ruote-couch
4
- #
5
- # Fri Dec 11 20:12:37 JST 2009
6
- #
7
-
8
- Dir.glob(File.join(File.dirname(__FILE__), 'ut_*.rb')).sort.each { |t|
9
- require(t)
10
- }
11
-
@@ -1,25 +0,0 @@
1
-
2
- #
3
- # testing ruote-couch
4
- #
5
- # Thu Dec 10 11:07:56 JST 2009
6
- #
7
-
8
- require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
9
- require File.join(File.dirname(__FILE__), '..', 'integration_connection.rb')
10
-
11
-
12
- class UtInitialTest < Test::Unit::TestCase
13
-
14
- def test_connect
15
-
16
- storage = new_storage(nil)
17
-
18
- v = storage.get_many('configurations')
19
-
20
- #p v
21
-
22
- assert_equal 1, v.size
23
- end
24
- end
25
-