ruote-sequel 2.3.0 → 2.3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +10 -0
- data/CREDITS.txt +3 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +15 -13
- data/lib/ruote/sequel/storage.rb +45 -21
- data/lib/ruote/sequel/version.rb +2 -2
- data/ruote-sequel.gemspec +1 -1
- data/test/connection.rb +28 -22
- metadata +6 -6
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
= ruote-sequel - CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== ruote-sequel 2.3.1 not yet released
|
6
|
+
|
7
|
+
|
8
|
+
== ruote-sequel 2.3.0.2 not yet released
|
9
|
+
|
10
|
+
- :asc / :desc fix by Iuri Gagnidze
|
11
|
+
- d[:doc].read if possible, as devised with Geoff Herney in
|
12
|
+
https://groups.google.com/d/topic/openwferu-users/ivLPT4jASVc/discussion
|
13
|
+
|
14
|
+
|
5
15
|
== ruote-sequel 2.3.0 released 2012/09/01
|
6
16
|
|
7
17
|
- switched to "begin_step" model
|
data/CREDITS.txt
CHANGED
@@ -9,11 +9,14 @@
|
|
9
9
|
|
10
10
|
== contributors
|
11
11
|
|
12
|
+
- Iuri Gagnidze - https://github.com/igagnidz
|
13
|
+
- Geoff Herney - https://github.com/gherney
|
12
14
|
- Wesley Moore - https://github.com/wezm
|
13
15
|
|
14
16
|
|
15
17
|
== feedback
|
16
18
|
|
19
|
+
- yzhang - reconnect issue
|
17
20
|
- Chad Albers - https://github.com/neomantic
|
18
21
|
- Eric Smith - issue reporting
|
19
22
|
|
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Copyright (c) 2005-
|
2
|
+
Copyright (c) 2005-2013, John Mettraux, jmettraux@gmail.com
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rubygems'
|
|
5
5
|
|
6
6
|
require 'rake'
|
7
7
|
require 'rake/clean'
|
8
|
-
require '
|
8
|
+
require 'rdoc/task'
|
9
9
|
|
10
10
|
|
11
11
|
#
|
@@ -76,17 +76,19 @@ Rake::RDocTask.new do |rd|
|
|
76
76
|
end
|
77
77
|
|
78
78
|
|
79
|
+
##
|
80
|
+
## upload_rdoc
|
79
81
|
#
|
80
|
-
#
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
#desc %{
|
83
|
+
# upload the rdoc to rubyforge
|
84
|
+
#}
|
85
|
+
#task :upload_rdoc => [ :clean, :rdoc ] do
|
86
|
+
#
|
87
|
+
# account = 'jmettraux@rubyforge.org'
|
88
|
+
# webdir = '/var/www/gforge-projects/ruote'
|
89
|
+
#
|
90
|
+
# sh "rsync -azv -e ssh rdoc/#{GEMSPEC.name}_rdoc #{account}:#{webdir}/"
|
91
|
+
#end
|
92
|
+
#
|
93
|
+
# leverage rdoc.info instead
|
92
94
|
|
data/lib/ruote/sequel/storage.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -197,13 +197,13 @@ module Sequel
|
|
197
197
|
return ds.count if opts[:count]
|
198
198
|
|
199
199
|
ds = ds.order(
|
200
|
-
opts[:descending] ? :ide
|
200
|
+
opts[:descending] ? ::Sequel.desc(:ide) : ::Sequel.asc(:ide), ::Sequel.desc(:rev)
|
201
201
|
).limit(
|
202
202
|
opts[:limit], opts[:skip] || opts[:offset]
|
203
203
|
)
|
204
204
|
|
205
205
|
docs = select_last_revs(ds)
|
206
|
-
docs = docs.collect { |d|
|
206
|
+
docs = docs.collect { |d| decode_doc(d) }
|
207
207
|
|
208
208
|
if keys && keys.first.is_a?(Regexp)
|
209
209
|
docs.select { |doc| keys.find { |key| key.match(doc['_id']) } }
|
@@ -273,7 +273,7 @@ module Sequel
|
|
273
273
|
return docs.count if opts[:count]
|
274
274
|
|
275
275
|
docs = docs.order(
|
276
|
-
:ide
|
276
|
+
::Sequel.asc(:ide), ::Sequel.desc(:rev)
|
277
277
|
).limit(
|
278
278
|
opts[:limit], opts[:offset] || opts[:skip]
|
279
279
|
)
|
@@ -294,13 +294,13 @@ module Sequel
|
|
294
294
|
docs = @sequel[@table].where(
|
295
295
|
:typ => type
|
296
296
|
).filter(
|
297
|
-
|
297
|
+
::Sequel.like(:doc, lk.join)
|
298
298
|
)
|
299
299
|
|
300
300
|
return docs.count if opts[:count]
|
301
301
|
|
302
302
|
docs = docs.order(
|
303
|
-
:ide
|
303
|
+
::Sequel.asc(:ide), ::Sequel.desc(:rev)
|
304
304
|
).limit(
|
305
305
|
opts[:limit], opts[:offset] || opts[:skip]
|
306
306
|
)
|
@@ -322,16 +322,16 @@ module Sequel
|
|
322
322
|
pname =
|
323
323
|
criteria.delete('participant_name') || criteria.delete('participant')
|
324
324
|
|
325
|
-
ds = ds.filter(
|
325
|
+
ds = ds.filter(::Sequel.like(:ide, "%!#{wfid}")) if wfid
|
326
326
|
ds = ds.filter(:participant_name => pname) if pname
|
327
327
|
|
328
328
|
criteria.collect do |k, v|
|
329
|
-
ds = ds.filter(
|
329
|
+
ds = ds.filter(::Sequel.like(:doc, "%\"#{k}\":#{Rufus::Json.encode(v)}%"))
|
330
330
|
end
|
331
331
|
|
332
332
|
return ds.count if count
|
333
333
|
|
334
|
-
ds = ds.order(:ide
|
334
|
+
ds = ds.order(::Sequel.asc(:ide), ::Sequel.desc(:rev)).limit(limit, offset)
|
335
335
|
|
336
336
|
select_last_revs(ds).collect { |d| Ruote::Workitem.from_json(d[:doc]) }
|
337
337
|
end
|
@@ -347,20 +347,45 @@ module Sequel
|
|
347
347
|
|
348
348
|
protected
|
349
349
|
|
350
|
+
def decode_doc(doc)
|
351
|
+
|
352
|
+
return nil if doc.nil?
|
353
|
+
|
354
|
+
doc = doc[:doc]
|
355
|
+
doc = doc.read if doc.respond_to?(:read)
|
356
|
+
|
357
|
+
Rufus::Json.decode(doc)
|
358
|
+
end
|
359
|
+
|
350
360
|
def do_insert(doc, rev, update_rev=false)
|
351
361
|
|
352
362
|
doc = doc.send(
|
353
363
|
update_rev ? :merge! : :merge,
|
354
364
|
{ '_rev' => rev, 'put_at' => Ruote.now_to_utc_s })
|
355
365
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
366
|
+
# Use bound variables
|
367
|
+
# http://sequel.rubyforge.org/rdoc/files/doc/prepared_statements_rdoc.html
|
368
|
+
#
|
369
|
+
# That makes Oracle happy (the doc field might > 4000 characters)
|
370
|
+
#
|
371
|
+
# Thanks Geoff Herney
|
372
|
+
#
|
373
|
+
@sequel[@table].call(
|
374
|
+
:insert, {
|
375
|
+
:ide => (doc['_id'] || ''),
|
376
|
+
:rev => (rev || ''),
|
377
|
+
:typ => (doc['type'] || ''),
|
378
|
+
:doc => (Rufus::Json.encode(doc) || ''),
|
379
|
+
:wfid => (extract_wfid(doc) || ''),
|
380
|
+
:participant_name => (doc['participant_name'] || '')
|
381
|
+
}, {
|
382
|
+
:ide => :$ide,
|
383
|
+
:rev => :$rev,
|
384
|
+
:typ => :$typ,
|
385
|
+
:doc => :$doc,
|
386
|
+
:wfid => :$wfid,
|
387
|
+
:participant_name => :$participant_name
|
388
|
+
})
|
364
389
|
end
|
365
390
|
|
366
391
|
def extract_wfid(doc)
|
@@ -374,7 +399,7 @@ module Sequel
|
|
374
399
|
:typ => type, :ide => key
|
375
400
|
).reverse_order(:rev).first
|
376
401
|
|
377
|
-
|
402
|
+
decode_doc(d)
|
378
403
|
end
|
379
404
|
|
380
405
|
# Weed out older docs (same ide, smaller rev).
|
@@ -410,9 +435,9 @@ module Sequel
|
|
410
435
|
).where(
|
411
436
|
:typ => CACHED_TYPES
|
412
437
|
).order(
|
413
|
-
:ide
|
438
|
+
::Sequel.asc(:ide), ::Sequel.desc(:rev)
|
414
439
|
).each do |d|
|
415
|
-
(cache[d[:typ]] ||= {})[d[:ide]] ||=
|
440
|
+
(cache[d[:typ]] ||= {})[d[:ide]] ||= decode_doc(d)
|
416
441
|
end
|
417
442
|
|
418
443
|
cache['variables']['trackers'] ||=
|
@@ -459,4 +484,3 @@ module Sequel
|
|
459
484
|
end
|
460
485
|
end
|
461
486
|
end
|
462
|
-
|
data/lib/ruote/sequel/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -26,7 +26,7 @@
|
|
26
26
|
module Ruote
|
27
27
|
module Sequel
|
28
28
|
|
29
|
-
VERSION = '2.3.0'
|
29
|
+
VERSION = '2.3.0.2'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/ruote-sequel.gemspec
CHANGED
@@ -26,7 +26,7 @@ Sequel storage for ruote (a workflow engine)
|
|
26
26
|
]
|
27
27
|
|
28
28
|
s.add_runtime_dependency 'sequel'#, '>= 3.31.0'
|
29
|
-
s.add_runtime_dependency 'ruote', ">= #{s.version}"
|
29
|
+
s.add_runtime_dependency 'ruote', ">= #{s.version.to_s.split('.')[0, 3].join('.')}"
|
30
30
|
|
31
31
|
s.add_development_dependency 'rake'
|
32
32
|
s.add_development_dependency 'pg', '0.10.1'
|
data/test/connection.rb
CHANGED
@@ -11,31 +11,37 @@ require 'ruote-sequel'
|
|
11
11
|
|
12
12
|
unless $sequel
|
13
13
|
|
14
|
-
$sequel =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
$sequel =
|
15
|
+
case ENV['RUOTE_STORAGE_DB'] || 'postgres'
|
16
|
+
when 'pg', 'postgres'
|
17
|
+
Sequel.connect('postgres://localhost/ruote_test')
|
18
|
+
when 'my', 'mysql'
|
19
|
+
#Sequel.connect('mysql://root:root@localhost/ruote_test')
|
20
|
+
Sequel.connect('mysql://root@localhost/ruote_test')
|
21
|
+
when 'mysql2'
|
22
|
+
Sequel.connect(
|
23
|
+
'mysql2://root@localhost/ruote_test',
|
24
|
+
:after_connect => proc { |c| c.send(:reconnect=, true) })
|
25
|
+
when /:/
|
26
|
+
Sequel.connect(ENV['RUOTE_STORAGE_DB'])
|
27
|
+
else
|
28
|
+
raise ArgumentError.new("unknown DB: #{ENV['RUOTE_STORAGE_DB'].inspect}")
|
29
|
+
end
|
27
30
|
|
28
31
|
require 'logger'
|
29
32
|
|
30
|
-
logger =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
logger =
|
34
|
+
case dbg = ENV['RUOTE_STORAGE_DEBUG']
|
35
|
+
when 'log'
|
36
|
+
FileUtils.rm("debug_#{$$}.log") rescue nil
|
37
|
+
Logger.new("debug_#{$$}.log")
|
38
|
+
when 'stdout'
|
39
|
+
Logger.new($stdout)
|
40
|
+
when /\.(log|txt)$/
|
41
|
+
Logger.new(dbg)
|
42
|
+
else
|
43
|
+
nil
|
44
|
+
end
|
39
45
|
|
40
46
|
if logger
|
41
47
|
logger.level = Logger::DEBUG
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruote-sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.0
|
4
|
+
version: 2.3.0.2
|
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:
|
12
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|
@@ -103,13 +103,13 @@ files:
|
|
103
103
|
- lib/ruote/sequel/version.rb
|
104
104
|
- lib/ruote/sequel.rb
|
105
105
|
- lib/ruote-sequel.rb
|
106
|
-
- test/connection.rb
|
107
106
|
- test/test.rb
|
107
|
+
- test/connection.rb
|
108
108
|
- ruote-sequel.gemspec
|
109
109
|
- CHANGELOG.txt
|
110
|
-
- CREDITS.txt
|
111
|
-
- LICENSE.txt
|
112
110
|
- TODO.txt
|
111
|
+
- LICENSE.txt
|
112
|
+
- CREDITS.txt
|
113
113
|
homepage: http://ruote.rubyforge.org
|
114
114
|
licenses: []
|
115
115
|
post_install_message:
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project: ruote
|
133
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.23
|
134
134
|
signing_key:
|
135
135
|
specification_version: 3
|
136
136
|
summary: Sequel storage for ruote (a workflow engine)
|