ruote-dm 2.1.6

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 ADDED
@@ -0,0 +1,6 @@
1
+
2
+ = ruote-dm - CHANGELOG.txt
3
+
4
+
5
+ == ruote-dm 2.1.6 not yet released
6
+
data/CREDITS.txt ADDED
@@ -0,0 +1,19 @@
1
+
2
+ = ruote-dm CREDITS.txt
3
+
4
+ == authors
5
+
6
+ - John Mettraux http://jmettraux.wordpress.com
7
+ - Jordan Ritter (http://github.com/jpr5)
8
+
9
+
10
+ == contributors
11
+
12
+ - asm (many bug reports)
13
+ - Kenneth Kalmer (http://www.opensourcery.co.za/)
14
+
15
+
16
+ == many thanks to
17
+
18
+ - the DataMapper team
19
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+
2
+ Copyright (c) 2001-2009, 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,49 @@
1
+
2
+ = ruote-dm
3
+
4
+ ruote 2.1 extension for DataMapper (dm) persistence
5
+
6
+
7
+ == usage
8
+
9
+ well...
10
+
11
+
12
+ == running tests
13
+
14
+ assuming you have
15
+
16
+ ruote/
17
+ ruote-dm/
18
+
19
+ * unit tests :
20
+
21
+ get into ruote/ and do
22
+
23
+ ruby test/unit/storage.rb --dm
24
+
25
+ * functional tests :
26
+
27
+ get into ruote/ and do
28
+
29
+ ruby test/functional/test.rb --dm
30
+
31
+
32
+ == license
33
+
34
+ MIT
35
+
36
+
37
+ == links
38
+
39
+ http://datamapper.org/
40
+
41
+ http://ruote.rubyforge.org/
42
+ http://github.com/jmettraux/ruote-dm
43
+
44
+
45
+ == feedback
46
+
47
+ mailing list : http://groups.google.com/group/openwferu-users
48
+ irc : irc.freenode.net #ruote
49
+
data/Rakefile ADDED
@@ -0,0 +1,78 @@
1
+
2
+ require 'rubygems'
3
+ require 'rake'
4
+
5
+ require 'lib/ruote/dm/version.rb'
6
+
7
+ #
8
+ # CLEAN
9
+
10
+ require 'rake/clean'
11
+ CLEAN.include('pkg', 'tmp', 'html')
12
+ task :default => [ :clean ]
13
+
14
+
15
+ #
16
+ # GEM
17
+
18
+ require 'jeweler'
19
+
20
+ Jeweler::Tasks.new do |gem|
21
+
22
+ gem.version = Ruote::Dm::VERSION
23
+ gem.name = 'ruote-dm'
24
+ gem.summary = 'datamapper storage for ruote 2.1'
25
+ gem.description = %{
26
+ datamapper storage for ruote 2.1
27
+ }.strip
28
+ gem.email = 'jmettraux@gmail.com'
29
+ gem.homepage = 'http://github.com/jmettraux/ruote-dm'
30
+ gem.authors = [ 'John Mettraux' ]
31
+ gem.rubyforge_project = 'ruote'
32
+
33
+ gem.test_file = 'test/test.rb'
34
+
35
+ gem.add_dependency 'ruote', ">= #{Ruote::Dm::VERSION}"
36
+ gem.add_dependency 'dm-core'
37
+ #gem.add_dependency 'dm-aggregates'
38
+ #gem.add_dependency 'dm-types'
39
+ gem.add_development_dependency 'yard', '>= 0'
40
+
41
+ # gemspec spec : http://www.rubygems.org/read/chapter/20
42
+ end
43
+ Jeweler::GemcutterTasks.new
44
+
45
+
46
+ #
47
+ # DOC
48
+
49
+ begin
50
+
51
+ require 'yard'
52
+
53
+ YARD::Rake::YardocTask.new do |doc|
54
+ doc.options = [
55
+ '-o', 'html/ruote-dm', '--title',
56
+ "ruote-dm #{Ruote::Dm::VERSION}"
57
+ ]
58
+ end
59
+
60
+ rescue LoadError
61
+
62
+ task :yard do
63
+ abort "YARD is not available : sudo gem install yard"
64
+ end
65
+ end
66
+
67
+
68
+ #
69
+ # TO THE WEB
70
+
71
+ task :upload_website => [ :clean, :yard ] do
72
+
73
+ account = 'jmettraux@rubyforge.org'
74
+ webdir = '/var/www/gforge-projects/ruote'
75
+
76
+ sh "rsync -azv -e ssh html/ruote-dm #{account}:#{webdir}/"
77
+ end
78
+
data/TODO.txt ADDED
@@ -0,0 +1,6 @@
1
+
2
+ [ ] storage : control #save result
3
+ [ ] examine indices (participant_name ?)
4
+
5
+ [ ] investigate ct_0_ weakness
6
+
@@ -0,0 +1,228 @@
1
+ #--
2
+ # Copyright (c) 2005-2010, 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 'dm-core'
26
+ require 'ruote/storage/base'
27
+ require 'ruote/dm/version'
28
+
29
+
30
+ module Ruote
31
+ module Dm
32
+
33
+ class Document
34
+ include DataMapper::Resource
35
+
36
+ property :ide, String, :key => true, :length => 2048, :required => true
37
+ property :rev, Integer, :key => true, :required => true
38
+ property :typ, String, :key => true, :required => true
39
+ property :doc, Text, :length => 2**32 - 1, :required => true, :lazy => false
40
+
41
+ property :participant_name, String, :length => 512
42
+ end
43
+
44
+ class DmStorage
45
+
46
+ include Ruote::StorageBase
47
+
48
+ attr_reader :repository
49
+
50
+ def initialize (repository=nil, options={})
51
+
52
+ @options = options
53
+ @repository = repository
54
+
55
+ put_configuration
56
+ end
57
+
58
+ def put (doc, opts={})
59
+
60
+ DataMapper.repository(@repository) do
61
+
62
+ d = Document.first(:ide => doc['_id'], :typ => doc['type'])
63
+
64
+ return Rufus::Json.decode(d.doc) if d && d.rev != doc['_rev']
65
+
66
+ if doc['_rev'].nil?
67
+
68
+ d = Document.new(
69
+ :ide => doc['_id'],
70
+ :rev => 0,
71
+ :typ => doc['type'],
72
+ :doc => Rufus::Json.encode(doc.merge(
73
+ '_rev' => 0, 'put_at' => Ruote.now_to_utc_s)),
74
+ :participant_name => doc['participant_name']
75
+ ).save
76
+
77
+ doc['_rev'] = 0 if opts[:update_rev]
78
+
79
+ else
80
+
81
+ return true unless d
82
+
83
+ d.rev = d.rev + 1
84
+ d.doc = Rufus::Json.encode(doc.merge(
85
+ '_rev' => d.rev, 'put_at' => Ruote.now_to_utc_s))
86
+ d.save
87
+
88
+ doc['_rev'] = d.rev if opts[:update_rev]
89
+ end
90
+
91
+ nil
92
+ end
93
+ end
94
+
95
+ def get (type, key)
96
+
97
+ DataMapper.repository(@repository) do
98
+ d = Document.first(:typ => type, :ide => key)
99
+ d ? Rufus::Json.decode(d.doc) : nil
100
+ end
101
+ end
102
+
103
+ def delete (doc)
104
+
105
+ raise ArgumentError.new('no _rev for doc') unless doc['_rev']
106
+
107
+ DataMapper.repository(@repository) do
108
+
109
+ d = Document.first(
110
+ :typ => doc['type'], :ide => doc['_id'], :rev => doc['_rev'])
111
+
112
+ return true unless d
113
+
114
+ d.destroy!
115
+
116
+ nil
117
+ end
118
+ end
119
+
120
+ def get_many (type, key=nil, opts={})
121
+
122
+ q = { :typ => type }
123
+
124
+ if l = opts[:limit]
125
+ q[:limit] = l
126
+ end
127
+
128
+ if key
129
+ key = if m = key.source.match(/(.+)\$$/)
130
+ "%#{m[1]}"
131
+ elsif m = key.source.match(/^\^(.+)/)
132
+ "#{m[1]}%"
133
+ else
134
+ key
135
+ end
136
+ q[:ide.like] = key
137
+ end
138
+
139
+ DataMapper.repository(@repository) do
140
+ Document.all(q).collect { |d| Rufus::Json.decode(d.doc) }
141
+ end
142
+ end
143
+
144
+ def ids (type)
145
+
146
+ DataMapper.repository(@repository) do
147
+ Document.all(:typ => type).collect { |d| d.ide }
148
+ end
149
+ end
150
+
151
+ def purge!
152
+
153
+ DataMapper.repository(@repository) do
154
+ Document.all.destroy!
155
+ end
156
+ end
157
+
158
+ #def dump (type)
159
+ # @dbs[type].dump
160
+ #end
161
+
162
+ def shutdown
163
+
164
+ #@dbs.values.each { |db| db.shutdown }
165
+ end
166
+
167
+ # Mainly used by ruote's test/unit/ut_17_storage.rb
168
+ #
169
+ def add_type (type)
170
+
171
+ # does nothing, types are differentiated by the 'typ' column
172
+ end
173
+
174
+ # Nukes a db type and reputs it (losing all the documents that were in it).
175
+ #
176
+ def purge_type! (type)
177
+
178
+ DataMapper.repository(@repository) do
179
+ Document.all(:typ => type).destroy!
180
+ end
181
+ end
182
+
183
+ # A provision made for workitems, allow to query them directly by
184
+ # participant name.
185
+ #
186
+ def by_participant (type, participant_name)
187
+
188
+ raise NotImplementedError if type != 'workitems'
189
+
190
+ Document.all(
191
+ :typ => type, :participant_name => participant_name
192
+ ).collect { |d|
193
+ Rufus::Json.decode(d.doc)
194
+ }
195
+ end
196
+
197
+ # Querying workitems by field (warning, goes deep into the JSON structure)
198
+ #
199
+ def by_field (type, field, value=nil)
200
+
201
+ raise NotImplementedError if type != 'workitems'
202
+
203
+ like = [ '%"', field, '":' ]
204
+ like.push(Rufus::Json.encode(value)) if value
205
+ like.push('%')
206
+
207
+ Document.all(:typ => type, :doc.like => like.join).collect { |d|
208
+ Rufus::Json.decode(d.doc)
209
+ }
210
+ end
211
+
212
+ protected
213
+
214
+ # Don't put configuration if it's already in
215
+ #
216
+ # (avoid storages from trashing configuration...)
217
+ #
218
+ def put_configuration
219
+
220
+ return if get('configurations', 'engine')
221
+
222
+ conf = { '_id' => 'engine', 'type' => 'configurations' }.merge(@options)
223
+ put(conf)
224
+ end
225
+ end
226
+ end
227
+ end
228
+
@@ -0,0 +1,7 @@
1
+
2
+ module Ruote
3
+ module Dm
4
+ VERSION = '2.1.6'
5
+ end
6
+ end
7
+
data/lib/ruote-dm.rb ADDED
@@ -0,0 +1,3 @@
1
+
2
+ require 'ruote/dm/storage'
3
+
data/ruote-dm.gemspec ADDED
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ruote-dm}
8
+ s.version = "2.1.6"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["John Mettraux"]
12
+ s.date = %q{2010-02-08}
13
+ s.description = %q{datamapper storage for ruote 2.1}
14
+ s.email = %q{jmettraux@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "CHANGELOG.txt",
21
+ "CREDITS.txt",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "TODO.txt",
26
+ "lib/ruote-dm.rb",
27
+ "lib/ruote/dm/storage.rb",
28
+ "lib/ruote/dm/version.rb",
29
+ "ruote-dm.gemspec",
30
+ "test/integration_connection.rb",
31
+ "test/test.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/jmettraux/ruote-dm}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubyforge_project = %q{ruote}
37
+ s.rubygems_version = %q{1.3.5}
38
+ s.summary = %q{datamapper storage for ruote 2.1}
39
+ s.test_files = [
40
+ "test/test.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<ruote>, [">= 2.1.6"])
49
+ s.add_runtime_dependency(%q<dm-core>, [">= 0"])
50
+ s.add_development_dependency(%q<yard>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<ruote>, [">= 2.1.6"])
53
+ s.add_dependency(%q<dm-core>, [">= 0"])
54
+ s.add_dependency(%q<yard>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<ruote>, [">= 2.1.6"])
58
+ s.add_dependency(%q<dm-core>, [">= 0"])
59
+ s.add_dependency(%q<yard>, [">= 0"])
60
+ end
61
+ end
62
+
@@ -0,0 +1,34 @@
1
+
2
+ #
3
+ # testing ruote-dm
4
+ #
5
+ # Thu Feb 4 13:44:13 JST 2010
6
+ #
7
+
8
+ require 'yajl' rescue require 'json'
9
+ require 'rufus-json'
10
+ Rufus::Json.detect_backend
11
+
12
+ require 'ruote-dm'
13
+
14
+ if ARGV.include?('-l')
15
+ FileUtils.rm('debug.log') rescue nil
16
+ DataMapper::Logger.new('debug.log', :debug)
17
+ elsif ARGV.include?('-ls')
18
+ DataMapper::Logger.new(STDOUT, :debug)
19
+ end
20
+
21
+ DataMapper.setup(:default, 'postgres://localhost/ruote_test')
22
+ #DataMapper.setup(:default, 'sqlite3::memory:')
23
+ #DataMapper.setup(:default, 'sqlite3:ruote_test.db')
24
+
25
+ #DataMapper.repository(:default) do
26
+ # Ruote::Dm::Document.all.destroy!
27
+ # Ruote::Dm::Document.auto_upgrade!
28
+ #end
29
+
30
+ def new_storage (opts)
31
+
32
+ Ruote::Dm::DmStorage.new(:default, opts)
33
+ end
34
+
data/test/test.rb ADDED
@@ -0,0 +1,7 @@
1
+
2
+ puts %{
3
+ ~~~
4
+ please read the README about how to run ruote-dm tests
5
+ ~~~
6
+ }
7
+
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruote-dm
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.6
5
+ platform: ruby
6
+ authors:
7
+ - John Mettraux
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-08 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ruote
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.1.6
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: dm-core
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: datamapper storage for ruote 2.1
46
+ email: jmettraux@gmail.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE.txt
53
+ - README.rdoc
54
+ files:
55
+ - CHANGELOG.txt
56
+ - CREDITS.txt
57
+ - LICENSE.txt
58
+ - README.rdoc
59
+ - Rakefile
60
+ - TODO.txt
61
+ - lib/ruote-dm.rb
62
+ - lib/ruote/dm/storage.rb
63
+ - lib/ruote/dm/version.rb
64
+ - ruote-dm.gemspec
65
+ - test/integration_connection.rb
66
+ - test/test.rb
67
+ has_rdoc: true
68
+ homepage: http://github.com/jmettraux/ruote-dm
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project: ruote
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: datamapper storage for ruote 2.1
95
+ test_files:
96
+ - test/test.rb