hutch-xamplr 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION.yml +2 -2
- data/examples/random-people-shared-addresses/Makefile +2 -2
- data/examples/random-people-shared-addresses/batch-load-users.rb +2 -5
- data/examples/random-people-shared-addresses/find-mentions.rb +1 -4
- data/examples/random-people-shared-addresses/find-people-by-address.rb +1 -4
- data/examples/random-people-shared-addresses/optimise.rb +1 -4
- data/examples/random-people-shared-addresses/people.rb +0 -15
- data/examples/random-people-shared-addresses/query.rb +1 -4
- data/examples/random-people-shared-addresses/query2.rb +1 -4
- data/examples/random-people-shared-addresses/results.write.BASELINE +298 -0
- data/examples/random-people-shared-addresses/results.write.NEW_ATTR_ENCODING +294 -0
- data/examples/random-people-shared-addresses/settings.rb +3 -0
- data/examples/random-people/batch-load-users.rb +1 -4
- data/examples/random-people/optimise.rb +1 -4
- data/examples/random-people/people.rb +0 -3
- data/examples/random-people/query.rb +1 -5
- data/examples/random-people/query2.rb +1 -4
- data/examples/random-people/settings.rb +3 -0
- data/examples/random-people/what-to-query-on.rb +1 -3
- data/examples/read-testing/Makefile +10 -0
- data/examples/read-testing/load.rb +65 -0
- data/examples/read-testing/read.rb +51 -0
- data/examples/read-testing/results.read.BASELINE +6 -0
- data/examples/read-testing/results.read.FAST +5 -0
- data/examples/read-testing/rrr.rb +87 -0
- data/examples/read-testing/settings.rb +2 -0
- data/examples/read-testing/xampl-gen.rb +36 -0
- data/examples/read-testing/xml/text.xml +8 -0
- data/lib/xamplr.rb +10 -1
- data/lib/xamplr/exceptions.rb +97 -0
- data/lib/xamplr/from-xml-orig.rb +350 -0
- data/lib/xamplr/from-xml.rb +272 -183
- data/lib/xamplr/handwritten/example.rb +0 -58
- data/lib/xamplr/handwritten/hand-example.rb +0 -27
- data/lib/xamplr/handwritten/test-handwritten.rb +0 -37
- data/lib/xamplr/mixins.rb +10 -48
- data/lib/xamplr/persist-to-xml.rb +249 -0
- data/lib/xamplr/persistence.rb +44 -412
- data/lib/xamplr/persistence.rb.more_thread_safe +0 -13
- data/lib/xamplr/persistence.rb.partially_thread_safe +0 -13
- data/lib/xamplr/persister.rb +298 -0
- data/lib/xamplr/{persister → persisters}/caches.rb +0 -0
- data/lib/xamplr/{persister → persisters}/caching.rb +1 -1
- data/lib/xamplr/{persister → persisters}/filesystem.rb +4 -5
- data/lib/xamplr/{persister → persisters}/in-memory.rb +1 -1
- data/lib/xamplr/{persister → persisters}/simple.rb +0 -0
- data/lib/xamplr/{persister → persisters}/tokyo-cabinet.rb +53 -15
- data/lib/xamplr/simpleTemplate/{input-c.r4 → obsolete/input-c.r4} +0 -0
- data/lib/xamplr/simpleTemplate/{play.r6.txt → obsolete/play.r6.txt} +0 -0
- data/lib/xamplr/simpleTemplate/{play_more.r6.txt → obsolete/play_more.r6.txt} +0 -0
- data/lib/xamplr/simpleTemplate/{test001.r5 → obsolete/test001.r5} +0 -0
- data/lib/xamplr/simpleTemplate/{test002.r5 → obsolete/test002.r5} +0 -0
- data/lib/xamplr/simpleTemplate/{test003.r5 → obsolete/test003.r5} +0 -0
- data/lib/xamplr/templates/child_indexed.template +1 -1
- data/lib/xamplr/templates/element_classes.template +1 -1
- data/lib/xamplr/templates/element_data.template +0 -39
- data/lib/xamplr/templates/element_empty.template +0 -40
- data/lib/xamplr/templates/element_mixed.template +0 -41
- data/lib/xamplr/templates/element_simple.template +0 -40
- data/lib/xamplr/test-support/bench.rb +6 -26
- data/lib/xamplr/test-support/test.rb +1 -89
- data/lib/xamplr/visitor.rb +0 -778
- data/lib/xamplr/visitors.rb +573 -0
- data/lib/xamplr/xampl-generator.rb +1 -1
- data/lib/xamplr/xampl-hand-generated.rb +0 -85
- data/lib/xamplr/xampl-module.rb +36 -0
- data/lib/xamplr/xampl-object-internals.rb +6 -0
- data/lib/xamplr/xampl-object.rb +10 -341
- data/lib/xamplr/xampl-persisted-object.rb +122 -0
- data/lib/xamplr/xml-text.rb +117 -0
- metadata +53 -18
- data/lib/xamplr/persister/subversion.rb +0 -61
- data/lib/xamplr/rac.sh +0 -6
- data/lib/xamplr/rac_gen.sh +0 -1
- data/lib/xamplr/templates/child_indexed.template.000 +0 -87
@@ -0,0 +1,122 @@
|
|
1
|
+
module Xampl
|
2
|
+
|
3
|
+
module XamplPersistedObject
|
4
|
+
include XamplObject
|
5
|
+
|
6
|
+
attr_reader :persister
|
7
|
+
attr_accessor :load_needed
|
8
|
+
|
9
|
+
def persist_required
|
10
|
+
return true
|
11
|
+
end
|
12
|
+
|
13
|
+
def accessed
|
14
|
+
raise XamplIsInvalid.new(self) if invalid
|
15
|
+
# TODO -- why do I need to get rid of this line, alternatively, why
|
16
|
+
# is this next line even there? Well, because accessed is now called
|
17
|
+
# differently. But???
|
18
|
+
#raise NoActivePersister unless @persister
|
19
|
+
|
20
|
+
if @load_needed and @persister then
|
21
|
+
raise NoActivePersister.new unless @persister
|
22
|
+
|
23
|
+
if nil == Xampl.persister then
|
24
|
+
#raise UnmanagedChange.new(self)
|
25
|
+
if not @persister.syncing then
|
26
|
+
Xampl.read_only(@persister) do
|
27
|
+
Xampl.lazy_load(self)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
puts "LOAD NEEDED(2): REFUSED (persister: #{@persister.name})"
|
31
|
+
puts " pid: #{self.get_the_index} #{self}"
|
32
|
+
caller(0).each { | trace | puts " #{trace}"}
|
33
|
+
end
|
34
|
+
elsif Xampl.persister != @persister then
|
35
|
+
raise MixedPersisters.new(@persister, self)
|
36
|
+
elsif Xampl.persister == @persister then
|
37
|
+
if not @persister.syncing then
|
38
|
+
Xampl.lazy_load(self)
|
39
|
+
else
|
40
|
+
puts "LOAD NEEDED(3): REFUSED (persister: #{@persister.name})"
|
41
|
+
puts " pid: #{self.get_the_index} #{self}"
|
42
|
+
caller(0).each { | trace | puts " #{trace}"}
|
43
|
+
end
|
44
|
+
else
|
45
|
+
puts "LOAD NEEDED(4): REFUSED (persister: #{@persister.name})"
|
46
|
+
puts " pid: #{self.get_the_index} #{self}"
|
47
|
+
caller(0).each { | trace | puts " #{trace}"}
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts "LOAD NEEDED(5): REFUSED (persister: #{@persister})" if @load_needed
|
51
|
+
puts " pid: #{self.get_the_index} #{self}" if @load_needed
|
52
|
+
caller(0).each { | trace | puts " #{trace}"} if @load_needed
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def changed
|
57
|
+
#puts "CHANGED: is_changed #{@is_changed} xampl #{self}"
|
58
|
+
unless Xampl.persister then
|
59
|
+
raise UnmanagedChange.new(self)
|
60
|
+
end
|
61
|
+
if @persister then
|
62
|
+
if Xampl.persister != @persister then
|
63
|
+
raise UnmanagedChange.new(self)
|
64
|
+
end
|
65
|
+
if @persister.block_changes then
|
66
|
+
raise BlockedChange.new(self)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
unless @is_changed then
|
70
|
+
@is_changed = true
|
71
|
+
if @persister then
|
72
|
+
@persister.has_changed self
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def force_load
|
78
|
+
@load_needed = true
|
79
|
+
@is_changed = false
|
80
|
+
@persister.has_not_changed(self) if @persister
|
81
|
+
self.clear_non_persistent_index_attributes
|
82
|
+
methods = self.methods.grep(/init_.*_as_child/)
|
83
|
+
methods.each do |method_name|
|
84
|
+
self.send(method_name)
|
85
|
+
end
|
86
|
+
@children = []
|
87
|
+
end
|
88
|
+
|
89
|
+
def reset_contents
|
90
|
+
self.clear_non_persistent_index_attributes
|
91
|
+
self.methods.grep(/init_.*_as_child/).each do |method_name|
|
92
|
+
self.send(method_name)
|
93
|
+
end
|
94
|
+
@children = []
|
95
|
+
end
|
96
|
+
|
97
|
+
def introduce_persister(persister)
|
98
|
+
#accessed
|
99
|
+
if @persister and (@persister != persister) then
|
100
|
+
raise AlreadyKnownToPersister.new(self, persister)
|
101
|
+
end
|
102
|
+
@persister = persister
|
103
|
+
return true
|
104
|
+
end
|
105
|
+
|
106
|
+
def init_xampl_object
|
107
|
+
super
|
108
|
+
@persister = nil
|
109
|
+
@load_needed = false
|
110
|
+
if (Xampl.persister and Xampl.persister.automatic) then
|
111
|
+
Xampl.persister.introduce(self)
|
112
|
+
else
|
113
|
+
introduce_persister(nil)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def describe_yourself
|
118
|
+
nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module Xampl
|
2
|
+
|
3
|
+
class XMLText
|
4
|
+
attr_accessor :namespaces, :prefix_ns_map, :ns, :first_text, :text
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@namespaces = []
|
8
|
+
@prefix_ns_map = {}
|
9
|
+
@first_text = nil
|
10
|
+
@text = nil
|
11
|
+
@ns = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def start_element(pp, depth)
|
15
|
+
@namespaces = {}
|
16
|
+
@namespaces[pp.namespace] = pp.namespace
|
17
|
+
|
18
|
+
depth += 1
|
19
|
+
|
20
|
+
if @first_text then
|
21
|
+
@text << "<" << pp.qname
|
22
|
+
|
23
|
+
pp.attributeCount.times do |i|
|
24
|
+
@text << " " << pp.attributeQName(i) << "='" << pp.attributeValue(i) << "'"
|
25
|
+
|
26
|
+
prefix = pp.attributePrefix(i)
|
27
|
+
if prefix then
|
28
|
+
@prefix_ns_map[prefix] = pp.attributeNamespace(i)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
else
|
32
|
+
@first_text = "<" << pp.qname
|
33
|
+
|
34
|
+
pp.attributeCount.times do |i|
|
35
|
+
@first_text << " " << pp.attributeQName(i) << "='" << pp.attributeValue(i) << "'"
|
36
|
+
|
37
|
+
prefix = pp.attributePrefix(i)
|
38
|
+
if prefix then
|
39
|
+
@prefix_ns_map[prefix] = pp.attributeNamespace(i)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
@text = ""
|
43
|
+
end
|
44
|
+
|
45
|
+
prefix = pp.prefix
|
46
|
+
if prefix then
|
47
|
+
@prefix_ns_map[prefix] = pp.namespace
|
48
|
+
end
|
49
|
+
|
50
|
+
if @ns != pp.namespace then
|
51
|
+
@text << " xmlns='" << pp.namespace << "'"
|
52
|
+
end
|
53
|
+
|
54
|
+
@text << ">"
|
55
|
+
|
56
|
+
return depth
|
57
|
+
end
|
58
|
+
|
59
|
+
def end_element(pp, depth)
|
60
|
+
depth -= 1
|
61
|
+
|
62
|
+
@text << "</"
|
63
|
+
@text << pp.prefix << ":" if pp.prefix
|
64
|
+
@text << pp.name << ">"
|
65
|
+
|
66
|
+
return depth
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_s
|
70
|
+
@text
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_xml(xml_printer=nil)
|
74
|
+
@text
|
75
|
+
end
|
76
|
+
|
77
|
+
def build(pp)
|
78
|
+
@namespaces = {}
|
79
|
+
@first_text = nil
|
80
|
+
@text = nil
|
81
|
+
|
82
|
+
depth = start_element(pp, 0)
|
83
|
+
|
84
|
+
while true
|
85
|
+
raise XamplException.new("unexpected end of document") if pp.endDocument?
|
86
|
+
|
87
|
+
case pp.nextEvent
|
88
|
+
when Xampl_PP::START_DOCUMENT
|
89
|
+
raise XamplException.new("unexpected start of document")
|
90
|
+
when Xampl_PP::END_DOCUMENT
|
91
|
+
raise XamplException.new("unexpected end of document")
|
92
|
+
when Xampl_PP::START_ELEMENT
|
93
|
+
depth = start_element(pp, depth)
|
94
|
+
when Xampl_PP::END_ELEMENT
|
95
|
+
depth = end_element(pp, depth)
|
96
|
+
break if depth <= 0
|
97
|
+
when Xampl_PP::TEXT, Xampl_PP::CDATA_SECTION, Xampl_PP::ENTITY_REF
|
98
|
+
@text << pp.text
|
99
|
+
#when Xampl_PP::IGNORABLE_WHITESPACE
|
100
|
+
#when Xampl_PP::PROCESSING_INSTRUCTION
|
101
|
+
#when Xampl_PP::COMMENT
|
102
|
+
#when Xampl_PP::DOCTYPE
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
@namespaces = @namespaces.keys
|
107
|
+
|
108
|
+
@prefix_ns_map.sort.each do |prefix, ns|
|
109
|
+
@first_text << " xmlns:" << prefix << "='" << ns << "'"
|
110
|
+
end
|
111
|
+
@first_text << @text
|
112
|
+
@text = @first_text
|
113
|
+
@first_text = nil
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hutch-xamplr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Hutchison
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04
|
12
|
+
date: 2009-05-04 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: libxml-ruby
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.3
|
34
|
+
version:
|
25
35
|
description:
|
26
36
|
email: hutch@recursive.ca
|
27
37
|
executables: []
|
@@ -46,6 +56,9 @@ files:
|
|
46
56
|
- examples/random-people-shared-addresses/query.rb
|
47
57
|
- examples/random-people-shared-addresses/query2.rb
|
48
58
|
- examples/random-people-shared-addresses/random-names.csv
|
59
|
+
- examples/random-people-shared-addresses/results.write.BASELINE
|
60
|
+
- examples/random-people-shared-addresses/results.write.NEW_ATTR_ENCODING
|
61
|
+
- examples/random-people-shared-addresses/settings.rb
|
49
62
|
- examples/random-people-shared-addresses/what-to-query-on.rb
|
50
63
|
- examples/random-people-shared-addresses/xampl-gen.rb
|
51
64
|
- examples/random-people-shared-addresses/xml/people.xml
|
@@ -57,9 +70,19 @@ files:
|
|
57
70
|
- examples/random-people/query2.rb
|
58
71
|
- examples/random-people/random-names.csv
|
59
72
|
- examples/random-people/rawtc.rb
|
73
|
+
- examples/random-people/settings.rb
|
60
74
|
- examples/random-people/what-to-query-on.rb
|
61
75
|
- examples/random-people/xampl-gen.rb
|
62
76
|
- examples/random-people/xml/people.xml
|
77
|
+
- examples/read-testing/Makefile
|
78
|
+
- examples/read-testing/load.rb
|
79
|
+
- examples/read-testing/read.rb
|
80
|
+
- examples/read-testing/results.read.BASELINE
|
81
|
+
- examples/read-testing/results.read.FAST
|
82
|
+
- examples/read-testing/rrr.rb
|
83
|
+
- examples/read-testing/settings.rb
|
84
|
+
- examples/read-testing/xampl-gen.rb
|
85
|
+
- examples/read-testing/xml/text.xml
|
63
86
|
- examples/tokyo-cabinet-experimental/expt-query.rb
|
64
87
|
- examples/tokyo-cabinet-experimental/expt-query2.rb
|
65
88
|
- examples/tokyo-cabinet-experimental/expt-query3.rb
|
@@ -73,6 +96,8 @@ files:
|
|
73
96
|
- lib/xamplr.rb
|
74
97
|
- lib/xamplr/README-POSSIBLE-PROBLEMS
|
75
98
|
- lib/xamplr/TODO
|
99
|
+
- lib/xamplr/exceptions.rb
|
100
|
+
- lib/xamplr/from-xml-orig.rb
|
76
101
|
- lib/xamplr/from-xml.rb
|
77
102
|
- lib/xamplr/gen-elements.xml
|
78
103
|
- lib/xamplr/gen.elements.xml
|
@@ -86,36 +111,34 @@ files:
|
|
86
111
|
- lib/xamplr/my.gen.elements.xml
|
87
112
|
- lib/xamplr/notifications.rb
|
88
113
|
- lib/xamplr/obsolete/fsdb.rb
|
114
|
+
- lib/xamplr/persist-to-xml.rb
|
89
115
|
- lib/xamplr/persistence.rb
|
90
116
|
- lib/xamplr/persistence.rb.more_thread_safe
|
91
117
|
- lib/xamplr/persistence.rb.partially_thread_safe
|
92
|
-
- lib/xamplr/persister
|
93
|
-
- lib/xamplr/
|
94
|
-
- lib/xamplr/
|
95
|
-
- lib/xamplr/
|
96
|
-
- lib/xamplr/
|
97
|
-
- lib/xamplr/
|
98
|
-
- lib/xamplr/
|
99
|
-
- lib/xamplr/rac.sh
|
100
|
-
- lib/xamplr/rac_gen.sh
|
118
|
+
- lib/xamplr/persister.rb
|
119
|
+
- lib/xamplr/persisters/caches.rb
|
120
|
+
- lib/xamplr/persisters/caching.rb
|
121
|
+
- lib/xamplr/persisters/filesystem.rb
|
122
|
+
- lib/xamplr/persisters/in-memory.rb
|
123
|
+
- lib/xamplr/persisters/simple.rb
|
124
|
+
- lib/xamplr/persisters/tokyo-cabinet.rb
|
101
125
|
- lib/xamplr/simpleTemplate/danger.rx
|
102
|
-
- lib/xamplr/simpleTemplate/input-c.r4
|
126
|
+
- lib/xamplr/simpleTemplate/obsolete/input-c.r4
|
127
|
+
- lib/xamplr/simpleTemplate/obsolete/play.r6.txt
|
128
|
+
- lib/xamplr/simpleTemplate/obsolete/play_more.r6.txt
|
129
|
+
- lib/xamplr/simpleTemplate/obsolete/test001.r5
|
130
|
+
- lib/xamplr/simpleTemplate/obsolete/test002.r5
|
131
|
+
- lib/xamplr/simpleTemplate/obsolete/test003.r5
|
103
132
|
- lib/xamplr/simpleTemplate/old/r6.000.rb
|
104
133
|
- lib/xamplr/simpleTemplate/old/r6.001.rb
|
105
134
|
- lib/xamplr/simpleTemplate/play.r6
|
106
|
-
- lib/xamplr/simpleTemplate/play.r6.txt
|
107
135
|
- lib/xamplr/simpleTemplate/play_more.r6
|
108
|
-
- lib/xamplr/simpleTemplate/play_more.r6.txt
|
109
136
|
- lib/xamplr/simpleTemplate/play_noblanks.r6
|
110
137
|
- lib/xamplr/simpleTemplate/playq.r6
|
111
138
|
- lib/xamplr/simpleTemplate/r6.rb
|
112
139
|
- lib/xamplr/simpleTemplate/simple-template.rb
|
113
|
-
- lib/xamplr/simpleTemplate/test001.r5
|
114
|
-
- lib/xamplr/simpleTemplate/test002.r5
|
115
|
-
- lib/xamplr/simpleTemplate/test003.r5
|
116
140
|
- lib/xamplr/templates/child.template
|
117
141
|
- lib/xamplr/templates/child_indexed.template
|
118
|
-
- lib/xamplr/templates/child_indexed.template.000
|
119
142
|
- lib/xamplr/templates/child_modules.template
|
120
143
|
- lib/xamplr/templates/element_classes.template
|
121
144
|
- lib/xamplr/templates/element_data.template
|
@@ -145,9 +168,14 @@ files:
|
|
145
168
|
- lib/xamplr/to-xml.rb
|
146
169
|
- lib/xamplr/version.rb
|
147
170
|
- lib/xamplr/visitor.rb
|
171
|
+
- lib/xamplr/visitors.rb
|
148
172
|
- lib/xamplr/xampl-generator.rb
|
149
173
|
- lib/xamplr/xampl-hand-generated.rb
|
174
|
+
- lib/xamplr/xampl-module.rb
|
175
|
+
- lib/xamplr/xampl-object-internals.rb
|
150
176
|
- lib/xamplr/xampl-object.rb
|
177
|
+
- lib/xamplr/xampl-persisted-object.rb
|
178
|
+
- lib/xamplr/xml-text.rb
|
151
179
|
- lib/xamplr/xml/document.xml
|
152
180
|
- lib/xamplr/xml/elements.xml
|
153
181
|
- lib/xamplr/xml/elements000.xml
|
@@ -191,6 +219,7 @@ test_files:
|
|
191
219
|
- examples/random-people/query.rb
|
192
220
|
- examples/random-people/query2.rb
|
193
221
|
- examples/random-people/rawtc.rb
|
222
|
+
- examples/random-people/settings.rb
|
194
223
|
- examples/random-people/what-to-query-on.rb
|
195
224
|
- examples/random-people/xampl-gen.rb
|
196
225
|
- examples/random-people-shared-addresses/batch-load-users.rb
|
@@ -200,8 +229,14 @@ test_files:
|
|
200
229
|
- examples/random-people-shared-addresses/people.rb
|
201
230
|
- examples/random-people-shared-addresses/query.rb
|
202
231
|
- examples/random-people-shared-addresses/query2.rb
|
232
|
+
- examples/random-people-shared-addresses/settings.rb
|
203
233
|
- examples/random-people-shared-addresses/what-to-query-on.rb
|
204
234
|
- examples/random-people-shared-addresses/xampl-gen.rb
|
235
|
+
- examples/read-testing/load.rb
|
236
|
+
- examples/read-testing/read.rb
|
237
|
+
- examples/read-testing/rrr.rb
|
238
|
+
- examples/read-testing/settings.rb
|
239
|
+
- examples/read-testing/xampl-gen.rb
|
205
240
|
- examples/tokyo-cabinet-experimental/expt-query.rb
|
206
241
|
- examples/tokyo-cabinet-experimental/expt-query2.rb
|
207
242
|
- examples/tokyo-cabinet-experimental/expt-query3.rb
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Xampl
|
2
|
-
|
3
|
-
require 'xamplr/version'
|
4
|
-
|
5
|
-
require "fileutils"
|
6
|
-
require "xamplr/persister/caching"
|
7
|
-
|
8
|
-
class SubversionPersister < AbstractCachingPersister
|
9
|
-
|
10
|
-
def initialize(name=nil, format=nil, root=File.join(".", "repo"))
|
11
|
-
super(root, name, format)
|
12
|
-
end
|
13
|
-
|
14
|
-
def SubversionPersister.kind
|
15
|
-
:subversion
|
16
|
-
end
|
17
|
-
|
18
|
-
def kind
|
19
|
-
SubversionPersister.kind
|
20
|
-
end
|
21
|
-
|
22
|
-
def version(stream)
|
23
|
-
catch(:refuse_to_version) do
|
24
|
-
Version.new(@repo_name, @repo_root).make(stream)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
def write(xampl)
|
30
|
-
#raise XamplException.new(:no_index_so_no_persist) unless xampl.get_the_index or xampl.ignore_when_no_index
|
31
|
-
raise XamplException.new("no_index_so_no_persist [#{xampl.class.name}]") unless xampl.get_the_index or xampl.ignore_when_no_index
|
32
|
-
return unless xampl.get_the_index
|
33
|
-
|
34
|
-
place = File.join(@root_dir, xampl.class.name.split("::"))
|
35
|
-
|
36
|
-
FileUtils.mkdir_p(place) unless File.exist?(place)
|
37
|
-
|
38
|
-
place = File.join(place, xampl.get_the_index)
|
39
|
-
|
40
|
-
representation = represent(xampl)
|
41
|
-
if representation then
|
42
|
-
File.open(place, "w"){ | out |
|
43
|
-
out.puts representation
|
44
|
-
}
|
45
|
-
@write_count = @write_count + 1
|
46
|
-
end
|
47
|
-
xampl.changes_accepted
|
48
|
-
return true
|
49
|
-
end
|
50
|
-
|
51
|
-
def read_representation(klass, pid)
|
52
|
-
place = File.join(@root_dir, klass.name.split("::"), pid)
|
53
|
-
|
54
|
-
return nil unless File.exist?(place)
|
55
|
-
return File.read(place)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
Xampl.register_persister_kind(SubversionPersister)
|
60
|
-
end
|
61
|
-
|