ruote-sequel 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.txt +8 -0
- data/CREDITS.txt +15 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +75 -0
- data/Rakefile +92 -0
- data/TODO.txt +3 -0
- data/lib/ruote/sequel/storage.rb +360 -0
- data/lib/ruote/sequel/version.rb +8 -0
- data/lib/ruote/sequel.rb +3 -0
- data/lib/ruote-sequel.rb +3 -0
- data/ruote-sequel.gemspec +33 -0
- data/test/functional_connection.rb +44 -0
- data/test/test.rb +7 -0
- metadata +150 -0
data/CHANGELOG.txt
ADDED
data/CREDITS.txt
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
THE SOFTWARE.
|
21
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
= ruote-sequel
|
3
|
+
|
4
|
+
Sequel storage implementation for ruote >= 2.2.0
|
5
|
+
|
6
|
+
|
7
|
+
== usage
|
8
|
+
|
9
|
+
This is how a ruote engine is setup with a ruote-dm storage (postgres) and a worker :
|
10
|
+
|
11
|
+
require 'rubygems'
|
12
|
+
require 'json' # gem install json
|
13
|
+
require 'ruote'
|
14
|
+
require 'ruote-sequel' # gem install ruote-sequel
|
15
|
+
|
16
|
+
sequel = Sequel.connect('postgres://localhost/ruote_test')
|
17
|
+
#sequel = Sequel.connect('mysql://root:root@localhost/ruote_test')
|
18
|
+
|
19
|
+
engine = Ruote::Engine.new(
|
20
|
+
Ruote::Worker.new(
|
21
|
+
Ruote::Sequel::Storage.new(sequel)))
|
22
|
+
|
23
|
+
# ...
|
24
|
+
|
25
|
+
To create the tables in the database :
|
26
|
+
|
27
|
+
Ruote::Sequel.create_table($sequel, :re_create => true)
|
28
|
+
|
29
|
+
|
30
|
+
Tested with sequel 3.20.0, with the postgresql (pg 0.10.1) adapter.
|
31
|
+
|
32
|
+
|
33
|
+
== running tests
|
34
|
+
|
35
|
+
assuming you have
|
36
|
+
|
37
|
+
ruote/
|
38
|
+
ruote-sequel/
|
39
|
+
|
40
|
+
* unit tests :
|
41
|
+
|
42
|
+
get into ruote/ and do
|
43
|
+
|
44
|
+
ruby test/unit/storage.rb -- --sequel
|
45
|
+
|
46
|
+
* functional tests :
|
47
|
+
|
48
|
+
get into ruote/ and do
|
49
|
+
|
50
|
+
ruby test/functional/test.rb -- --sequel
|
51
|
+
|
52
|
+
|
53
|
+
== known issues
|
54
|
+
|
55
|
+
none
|
56
|
+
|
57
|
+
|
58
|
+
== license
|
59
|
+
|
60
|
+
MIT
|
61
|
+
|
62
|
+
|
63
|
+
== links
|
64
|
+
|
65
|
+
http://sequel.rubyforge.org/
|
66
|
+
|
67
|
+
http://ruote.rubyforge.org/
|
68
|
+
http://github.com/jmettraux/ruote-sequel
|
69
|
+
|
70
|
+
|
71
|
+
== feedback
|
72
|
+
|
73
|
+
mailing list : http://groups.google.com/group/openwferu-users
|
74
|
+
irc : irc.freenode.net #ruote
|
75
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
$:.unshift('.') # 1.9.2
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/clean'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
|
11
|
+
#
|
12
|
+
# clean
|
13
|
+
|
14
|
+
CLEAN.include('pkg', 'rdoc')
|
15
|
+
|
16
|
+
|
17
|
+
#
|
18
|
+
# test / spec
|
19
|
+
|
20
|
+
task :test do
|
21
|
+
|
22
|
+
puts
|
23
|
+
puts "to test ruote-sequel, head to your ruote/ dir and run"
|
24
|
+
puts
|
25
|
+
puts " ruby test/test.rb -- --sequel"
|
26
|
+
puts
|
27
|
+
puts "but first, make sure your ruote-sequel/test/functional_connection.rb"
|
28
|
+
puts "is set correctly."
|
29
|
+
puts
|
30
|
+
end
|
31
|
+
|
32
|
+
task :default => [ :test ]
|
33
|
+
|
34
|
+
|
35
|
+
#
|
36
|
+
# gem
|
37
|
+
|
38
|
+
GEMSPEC_FILE = Dir['*.gemspec'].first
|
39
|
+
GEMSPEC = eval(File.read(GEMSPEC_FILE))
|
40
|
+
GEMSPEC.validate
|
41
|
+
|
42
|
+
|
43
|
+
desc %{
|
44
|
+
builds the gem and places it in pkg/
|
45
|
+
}
|
46
|
+
task :build do
|
47
|
+
|
48
|
+
sh "gem build #{GEMSPEC_FILE}"
|
49
|
+
sh "mkdir pkg" rescue nil
|
50
|
+
sh "mv #{GEMSPEC.name}-#{GEMSPEC.version}.gem pkg/"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc %{
|
54
|
+
builds the gem and pushes it to rubygems.org
|
55
|
+
}
|
56
|
+
task :push => :build do
|
57
|
+
|
58
|
+
sh "gem push pkg/#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
#
|
63
|
+
# rdoc
|
64
|
+
#
|
65
|
+
# make sure to have rdoc 2.5.x to run that
|
66
|
+
|
67
|
+
Rake::RDocTask.new do |rd|
|
68
|
+
|
69
|
+
rd.main = 'README.rdoc'
|
70
|
+
rd.rdoc_dir = 'rdoc'
|
71
|
+
|
72
|
+
rd.rdoc_files.include(
|
73
|
+
'README.rdoc', 'CHANGELOG.txt', 'CREDITS.txt', 'lib/**/*.rb')
|
74
|
+
|
75
|
+
rd.title = "#{GEMSPEC.name} #{GEMSPEC.version}"
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
#
|
80
|
+
# upload_rdoc
|
81
|
+
|
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
|
+
|
data/TODO.txt
ADDED
@@ -0,0 +1,360 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'sequel'
|
26
|
+
require 'ruote/storage/base'
|
27
|
+
require 'ruote/sequel/version'
|
28
|
+
|
29
|
+
|
30
|
+
module Ruote
|
31
|
+
module Sequel
|
32
|
+
|
33
|
+
# Creates the 'documents' table necessary for this storage.
|
34
|
+
#
|
35
|
+
# If re_create is set to true, it will destroy any previous 'documents'
|
36
|
+
# table and create it.
|
37
|
+
#
|
38
|
+
def self.create_table(sequel, re_create=false)
|
39
|
+
|
40
|
+
m = re_create ? :create_table! : :create_table
|
41
|
+
|
42
|
+
sequel.send(m, :documents) do
|
43
|
+
String :ide, :size => 255, :null => false
|
44
|
+
Integer :rev, :null => false
|
45
|
+
String :typ, :size => 55, :null => false
|
46
|
+
String :doc, :text => true, :null => false
|
47
|
+
String :wfid, :size => 255, :index => true
|
48
|
+
String :participant_name, :size => 512
|
49
|
+
primary_key [ :ide, :rev, :typ ]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# A Sequel storage implementation for ruote >= 2.2.0.
|
55
|
+
#
|
56
|
+
# require 'rubygems'
|
57
|
+
# require 'json' # gem install json
|
58
|
+
# require 'ruote'
|
59
|
+
# require 'ruote-sequel' # gem install ruote-sequel
|
60
|
+
#
|
61
|
+
# sequel = Sequel.connect('postgres://localhost/ruote_test')
|
62
|
+
# #sequel = Sequel.connect('mysql://root:root@localhost/ruote_test')
|
63
|
+
#
|
64
|
+
# opts = { 'remote_definition_allowed' => true }
|
65
|
+
#
|
66
|
+
# engine = Ruote::Engine.new(
|
67
|
+
# Ruote::Worker.new(
|
68
|
+
# Ruote::Sequel::Storage.new(sequel, opts)))
|
69
|
+
#
|
70
|
+
# # ...
|
71
|
+
#
|
72
|
+
class Storage
|
73
|
+
|
74
|
+
include Ruote::StorageBase
|
75
|
+
|
76
|
+
# The underlying Sequel::Database instance
|
77
|
+
#
|
78
|
+
attr_reader :sequel
|
79
|
+
|
80
|
+
def initialize(sequel, options={})
|
81
|
+
|
82
|
+
@sequel = sequel
|
83
|
+
@options = options
|
84
|
+
|
85
|
+
put_configuration
|
86
|
+
end
|
87
|
+
|
88
|
+
def put_msg(action, options)
|
89
|
+
|
90
|
+
# put_msg is a unique action, no need for all the complexity of put
|
91
|
+
|
92
|
+
do_insert(prepare_msg_doc(action, options), 1)
|
93
|
+
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
|
97
|
+
def put_schedule(flavour, owner_fei, s, msg)
|
98
|
+
|
99
|
+
# put_schedule is a unique action, no need for all the complexity of put
|
100
|
+
|
101
|
+
doc = prepare_schedule_doc(flavour, owner_fei, s, msg)
|
102
|
+
|
103
|
+
return nil unless doc
|
104
|
+
|
105
|
+
do_insert(doc, 1)
|
106
|
+
|
107
|
+
doc['_id']
|
108
|
+
end
|
109
|
+
|
110
|
+
def put(doc, opts={})
|
111
|
+
|
112
|
+
if doc['_rev']
|
113
|
+
|
114
|
+
d = get(doc['type'], doc['_id'])
|
115
|
+
|
116
|
+
return true unless d
|
117
|
+
return d if d['_rev'] != doc['_rev']
|
118
|
+
# failures
|
119
|
+
end
|
120
|
+
|
121
|
+
nrev = doc['_rev'].to_i + 1
|
122
|
+
|
123
|
+
begin
|
124
|
+
|
125
|
+
do_insert(doc, nrev)
|
126
|
+
|
127
|
+
rescue ::Sequel::DatabaseError => de
|
128
|
+
|
129
|
+
return (get(doc['type'], doc['_id']) || true)
|
130
|
+
# failure
|
131
|
+
end
|
132
|
+
|
133
|
+
@sequel[:documents].where(
|
134
|
+
:typ => doc['type'], :ide => doc['_id']
|
135
|
+
).filter { rev < nrev }.delete
|
136
|
+
|
137
|
+
doc['_rev'] = nrev if opts[:update_rev]
|
138
|
+
|
139
|
+
nil
|
140
|
+
# success
|
141
|
+
end
|
142
|
+
|
143
|
+
def get(type, key)
|
144
|
+
|
145
|
+
d = do_get(type, key)
|
146
|
+
|
147
|
+
d ? Rufus::Json.decode(d[:doc]) : nil
|
148
|
+
end
|
149
|
+
|
150
|
+
def delete(doc)
|
151
|
+
|
152
|
+
raise ArgumentError.new('no _rev for doc') unless doc['_rev']
|
153
|
+
|
154
|
+
count = do_delete(doc)
|
155
|
+
|
156
|
+
return (get(doc['type'], doc['_id']) || true) if count != 1
|
157
|
+
# failure
|
158
|
+
|
159
|
+
nil
|
160
|
+
# success
|
161
|
+
end
|
162
|
+
|
163
|
+
def get_many(type, key=nil, opts={})
|
164
|
+
|
165
|
+
ds = @sequel[:documents].where(:typ => type)
|
166
|
+
|
167
|
+
keys = key ? Array(key) : nil
|
168
|
+
ds = ds.filter(:wfid => keys) if keys && keys.first.is_a?(String)
|
169
|
+
|
170
|
+
return ds.all.size if opts[:count]
|
171
|
+
|
172
|
+
ds = ds.order(
|
173
|
+
*(opts[:descending] ? [ :ide.desc, :rev.desc ] : [ :ide.asc, :rev.asc ])
|
174
|
+
)
|
175
|
+
|
176
|
+
ds = ds.limit(opts[:limit], opts[:skip])
|
177
|
+
|
178
|
+
docs = ds.all
|
179
|
+
docs = select_last_revs(docs, opts[:descending])
|
180
|
+
docs = docs.collect { |d| Rufus::Json.decode(d[:doc]) }
|
181
|
+
|
182
|
+
keys && keys.first.is_a?(Regexp) ?
|
183
|
+
docs.select { |doc| keys.find { |key| key.match(doc['_id']) } } :
|
184
|
+
docs
|
185
|
+
|
186
|
+
# (pass on the dataset.filter(:wfid => /regexp/) for now
|
187
|
+
# since we have potentially multiple keys)
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns all the ids of the documents of a given type.
|
191
|
+
#
|
192
|
+
def ids(type)
|
193
|
+
|
194
|
+
@sequel[:documents].where(:typ => type).collect { |d| d[:ide] }.uniq.sort
|
195
|
+
end
|
196
|
+
|
197
|
+
# Nukes all the documents in this storage.
|
198
|
+
#
|
199
|
+
def purge!
|
200
|
+
|
201
|
+
@sequel[:documents].delete
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns a string representation the current content of the storage for
|
205
|
+
# a given type.
|
206
|
+
#
|
207
|
+
def dump(type)
|
208
|
+
|
209
|
+
"=== #{type} ===\n" +
|
210
|
+
get_many(type).map { |h| " #{h['_id']} => #{h.inspect}" }.join("\n")
|
211
|
+
end
|
212
|
+
|
213
|
+
# Calls #disconnect on the db. According to Sequel's doc, it closes
|
214
|
+
# all the idle connections in the pool (not the active ones).
|
215
|
+
#
|
216
|
+
def shutdown
|
217
|
+
|
218
|
+
@sequel.disconnect
|
219
|
+
end
|
220
|
+
|
221
|
+
# Grrr... I should sort the mess between close and shutdown...
|
222
|
+
# Tests vs production :-(
|
223
|
+
#
|
224
|
+
def close
|
225
|
+
|
226
|
+
@sequel.disconnect
|
227
|
+
end
|
228
|
+
|
229
|
+
# Mainly used by ruote's test/unit/ut_17_storage.rb
|
230
|
+
#
|
231
|
+
def add_type(type)
|
232
|
+
|
233
|
+
# does nothing, types are differentiated by the 'typ' column
|
234
|
+
end
|
235
|
+
|
236
|
+
# Nukes a db type and reputs it (losing all the documents that were in it).
|
237
|
+
#
|
238
|
+
def purge_type!(type)
|
239
|
+
|
240
|
+
@sequel[:documents].where(:typ => type).delete
|
241
|
+
end
|
242
|
+
|
243
|
+
# A provision made for workitems, allow to query them directly by
|
244
|
+
# participant name.
|
245
|
+
#
|
246
|
+
def by_participant(type, participant_name, opts)
|
247
|
+
|
248
|
+
raise NotImplementedError if type != 'workitems'
|
249
|
+
|
250
|
+
docs = @sequel[:documents].where(
|
251
|
+
:typ => type, :participant_name => participant_name)
|
252
|
+
|
253
|
+
select_last_revs(docs).collect { |d| Rufus::Json.decode(d[:doc]) }
|
254
|
+
end
|
255
|
+
|
256
|
+
# Querying workitems by field (warning, goes deep into the JSON structure)
|
257
|
+
#
|
258
|
+
def by_field(type, field, value=nil)
|
259
|
+
|
260
|
+
raise NotImplementedError if type != 'workitems'
|
261
|
+
|
262
|
+
lk = [ '%"', field, '":' ]
|
263
|
+
lk.push(Rufus::Json.encode(value)) if value
|
264
|
+
lk.push('%')
|
265
|
+
|
266
|
+
docs = @sequel[:documents].where(:typ => type).filter(:doc.like(lk.join))
|
267
|
+
|
268
|
+
select_last_revs(docs).collect { |d| Rufus::Json.decode(d[:doc]) }
|
269
|
+
end
|
270
|
+
|
271
|
+
def query_workitems(criteria)
|
272
|
+
|
273
|
+
ds = @sequel[:documents].where(:typ => 'workitems')
|
274
|
+
|
275
|
+
return select_last_revs(ds.all).size if criteria['count']
|
276
|
+
|
277
|
+
limit = criteria.delete('limit')
|
278
|
+
offset = criteria.delete('offset')
|
279
|
+
|
280
|
+
ds = ds.limit(limit, offset)
|
281
|
+
|
282
|
+
wfid =
|
283
|
+
criteria.delete('wfid')
|
284
|
+
pname =
|
285
|
+
criteria.delete('participant_name') || criteria.delete('participant')
|
286
|
+
|
287
|
+
ds = ds.filter(:ide.like("%!#{wfid}")) if wfid
|
288
|
+
ds = ds.filter(:participant_name => pname) if pname
|
289
|
+
|
290
|
+
criteria.collect do |k, v|
|
291
|
+
ds = ds.filter(:doc.like("%\"#{k}\":#{Rufus::Json.encode(v)}%"))
|
292
|
+
end
|
293
|
+
|
294
|
+
select_last_revs(ds.all).collect { |d|
|
295
|
+
Ruote::Workitem.new(Rufus::Json.decode(d[:doc]))
|
296
|
+
}
|
297
|
+
end
|
298
|
+
|
299
|
+
protected
|
300
|
+
|
301
|
+
def do_delete(doc)
|
302
|
+
|
303
|
+
@sequel[:documents].where(
|
304
|
+
:ide => doc['_id'], :typ => doc['type'], :rev => doc['_rev'].to_i
|
305
|
+
).delete
|
306
|
+
end
|
307
|
+
|
308
|
+
def do_insert(doc, rev)
|
309
|
+
|
310
|
+
@sequel[:documents].insert(
|
311
|
+
:ide => doc['_id'],
|
312
|
+
:rev => rev,
|
313
|
+
:typ => doc['type'],
|
314
|
+
:doc => Rufus::Json.encode(doc.merge(
|
315
|
+
'_rev' => rev,
|
316
|
+
'put_at' => Ruote.now_to_utc_s)),
|
317
|
+
:wfid => extract_wfid(doc),
|
318
|
+
:participant_name => doc['participant_name']
|
319
|
+
)
|
320
|
+
end
|
321
|
+
|
322
|
+
def extract_wfid(doc)
|
323
|
+
|
324
|
+
doc['wfid'] || (doc['fei'] ? doc['fei']['wfid'] : nil)
|
325
|
+
end
|
326
|
+
|
327
|
+
def do_get(type, key)
|
328
|
+
|
329
|
+
@sequel[:documents].where(
|
330
|
+
:typ => type, :ide => key
|
331
|
+
).reverse_order(:rev).first
|
332
|
+
end
|
333
|
+
|
334
|
+
# Don't put configuration if it's already in
|
335
|
+
#
|
336
|
+
# (avoid storages from trashing configuration...)
|
337
|
+
#
|
338
|
+
def put_configuration
|
339
|
+
|
340
|
+
return if get('configurations', 'engine')
|
341
|
+
|
342
|
+
conf = { '_id' => 'engine', 'type' => 'configurations' }.merge(@options)
|
343
|
+
put(conf)
|
344
|
+
end
|
345
|
+
|
346
|
+
def select_last_revs(docs, reverse=false)
|
347
|
+
|
348
|
+
docs = docs.inject({}) { |h, doc|
|
349
|
+
h[doc[:ide]] = doc
|
350
|
+
h
|
351
|
+
}.values.sort_by { |h|
|
352
|
+
h[:ide]
|
353
|
+
}
|
354
|
+
|
355
|
+
reverse ? docs.reverse : docs
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
data/lib/ruote/sequel.rb
ADDED
data/lib/ruote-sequel.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
|
5
|
+
s.name = 'ruote-sequel'
|
6
|
+
s.version = File.read('lib/ruote/sequel/version.rb').match(/VERSION = '([^']+)'/)[1]
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = [ 'John Mettraux' ]
|
9
|
+
s.email = [ 'jmettraux@gmail.com' ]
|
10
|
+
s.homepage = 'http://ruote.rubyforge.org'
|
11
|
+
s.rubyforge_project = 'ruote'
|
12
|
+
s.summary = 'Sequel storage for ruote (a workflow engine)'
|
13
|
+
s.description = %q{
|
14
|
+
Sequel storage for ruote (a workflow engine)
|
15
|
+
}
|
16
|
+
|
17
|
+
#s.files = `git ls-files`.split("\n")
|
18
|
+
s.files = Dir[
|
19
|
+
'Rakefile',
|
20
|
+
'lib/**/*.rb', 'spec/**/*.rb', 'test/**/*.rb',
|
21
|
+
'*.gemspec', '*.txt', '*.rdoc', '*.md'
|
22
|
+
]
|
23
|
+
|
24
|
+
s.add_runtime_dependency 'sequel', '3.20.0'
|
25
|
+
s.add_runtime_dependency 'ruote', ">= #{s.version}"
|
26
|
+
|
27
|
+
s.add_development_dependency 'rake'
|
28
|
+
s.add_development_dependency 'pg', '0.10.1'
|
29
|
+
s.add_development_dependency 'mysql', '2.8.1'
|
30
|
+
|
31
|
+
s.require_path = 'lib'
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote-sequel
|
4
|
+
#
|
5
|
+
# Thu Feb 10 11:14:56 JST 2011
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'yajl' rescue require 'json'
|
9
|
+
require 'rufus-json'
|
10
|
+
Rufus::Json.detect_backend
|
11
|
+
|
12
|
+
require 'ruote-sequel'
|
13
|
+
|
14
|
+
unless $sequel
|
15
|
+
|
16
|
+
$sequel = Sequel.connect('postgres://localhost/ruote_test')
|
17
|
+
#$sequel = Sequel.connect('mysql://root:root@localhost/ruote_test')
|
18
|
+
|
19
|
+
Ruote::Sequel.create_table($sequel, true)
|
20
|
+
# true forces re_create of 'documents' table
|
21
|
+
|
22
|
+
require 'logger'
|
23
|
+
|
24
|
+
logger = nil
|
25
|
+
|
26
|
+
if ARGV.include?('-l') || ARGV.include?('--l')
|
27
|
+
FileUtils.rm('debug.log') rescue nil
|
28
|
+
logger = Logger.new('debug.log')
|
29
|
+
elsif ARGV.include?('-ls') || ARGV.include?('--ls')
|
30
|
+
logger = Logger.new($stdout)
|
31
|
+
end
|
32
|
+
|
33
|
+
if logger
|
34
|
+
logger.level = Logger::DEBUG
|
35
|
+
$sequel.loggers << logger
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def new_storage (opts)
|
41
|
+
|
42
|
+
Ruote::Sequel::Storage.new($sequel, opts)
|
43
|
+
end
|
44
|
+
|
data/test/test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruote-sequel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 2.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- John Mettraux
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-03-01 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: sequel
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 20
|
31
|
+
- 0
|
32
|
+
version: 3.20.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: ruote
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
- 2
|
46
|
+
- 0
|
47
|
+
version: 2.2.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rake
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: pg
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - "="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
- 10
|
74
|
+
- 1
|
75
|
+
version: 0.10.1
|
76
|
+
type: :development
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mysql
|
80
|
+
prerelease: false
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - "="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 2
|
88
|
+
- 8
|
89
|
+
- 1
|
90
|
+
version: 2.8.1
|
91
|
+
type: :development
|
92
|
+
version_requirements: *id005
|
93
|
+
description: "\n\
|
94
|
+
Sequel storage for ruote (a workflow engine)\n"
|
95
|
+
email:
|
96
|
+
- jmettraux@gmail.com
|
97
|
+
executables: []
|
98
|
+
|
99
|
+
extensions: []
|
100
|
+
|
101
|
+
extra_rdoc_files: []
|
102
|
+
|
103
|
+
files:
|
104
|
+
- Rakefile
|
105
|
+
- lib/ruote/sequel/storage.rb
|
106
|
+
- lib/ruote/sequel/version.rb
|
107
|
+
- lib/ruote/sequel.rb
|
108
|
+
- lib/ruote-sequel.rb
|
109
|
+
- test/functional_connection.rb
|
110
|
+
- test/test.rb
|
111
|
+
- ruote-sequel.gemspec
|
112
|
+
- CHANGELOG.txt
|
113
|
+
- CREDITS.txt
|
114
|
+
- LICENSE.txt
|
115
|
+
- TODO.txt
|
116
|
+
- README.rdoc
|
117
|
+
has_rdoc: true
|
118
|
+
homepage: http://ruote.rubyforge.org
|
119
|
+
licenses: []
|
120
|
+
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
142
|
+
requirements: []
|
143
|
+
|
144
|
+
rubyforge_project: ruote
|
145
|
+
rubygems_version: 1.3.7
|
146
|
+
signing_key:
|
147
|
+
specification_version: 3
|
148
|
+
summary: Sequel storage for ruote (a workflow engine)
|
149
|
+
test_files: []
|
150
|
+
|