xamplr 1.9.13 → 1.9.14
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/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/lib/xamplr/TODO +1 -1
- data/lib/xamplr/exceptions.rb +47 -1
- data/lib/xamplr/from-xml.rb +128 -191
- data/lib/xamplr/from-xml.rb.libxml +463 -0
- data/lib/xamplr/from-xml.rb.nokogiri +437 -0
- data/lib/xamplr/persist-to-xml.rb +3 -21
- data/lib/xamplr/persistence.rb +151 -57
- data/lib/xamplr/persister.rb +13 -28
- data/lib/xamplr/persisters/dumb.rb +1 -1
- data/lib/xamplr/persisters/filesystem.rb +2 -1
- data/lib/xamplr/persisters/in-memory.rb +1 -0
- data/lib/xamplr/persisters/{mongo.rb → mongo.rb.cannot-use} +0 -0
- data/lib/xamplr/persisters/redis.rb +449 -0
- data/lib/xamplr/persisters/simple.rb +1 -1
- data/lib/xamplr/persisters/tokyo-cabinet.rb +4 -2
- data/lib/xamplr/tests/.gitignore +1 -0
- data/lib/xamplr/tests/redis/Makefile +3 -0
- data/lib/xamplr/tests/redis/author.rb +19 -0
- data/lib/xamplr/tests/redis/project-generator.rb +31 -0
- data/lib/xamplr/tests/redis/redis_spec.rb +727 -0
- data/lib/xamplr/tests/redis/spec.opts +1 -0
- data/lib/xamplr/tests/redis/spec_helper.rb +48 -0
- data/lib/xamplr/tests/redis/testing-db/.gitignore +3 -0
- data/lib/xamplr/tests/redis/testing-db/Makefile +5 -0
- data/lib/xamplr/tests/redis/testing-db/unit-testing.redis.conf +332 -0
- data/lib/xamplr/tests/redis/xml/redis-test.xml +8 -0
- data/lib/xamplr/visitors.rb +51 -51
- data/lib/xamplr/xampl-object.rb +20 -5
- data/lib/xamplr/xampl-persisted-object.rb +15 -58
- data/xamplr.gemspec +20 -6
- metadata +23 -9
data/lib/xamplr/xampl-object.rb
CHANGED
@@ -40,21 +40,32 @@ module Xampl
|
|
40
40
|
def invalid
|
41
41
|
return kind_of?(InvalidXampl)
|
42
42
|
end
|
43
|
+
alias invalid? invalid
|
43
44
|
|
44
45
|
def changes_accepted
|
45
46
|
ResetIsChanged.new.start(self)
|
46
47
|
end
|
47
48
|
|
48
49
|
def changed
|
49
|
-
unless Xampl.persister
|
50
|
-
raise UnmanagedChange.new(self)
|
51
|
-
end
|
50
|
+
raise UnmanagedChange.new(self) unless Xampl.persister
|
52
51
|
unless @is_changed then
|
53
52
|
@is_changed = true
|
54
|
-
|
53
|
+
if nil != @parents
|
54
|
+
@parents.each do |parent|
|
55
|
+
parent.changed
|
56
|
+
end
|
57
|
+
end
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
61
|
+
# def changed?
|
62
|
+
# @is_changed
|
63
|
+
# end
|
64
|
+
|
65
|
+
def dirty?
|
66
|
+
@is_changed
|
67
|
+
end
|
68
|
+
|
58
69
|
def accessed
|
59
70
|
raise XamplIsInvalid.new(self) if invalid
|
60
71
|
end
|
@@ -134,7 +145,11 @@ module Xampl
|
|
134
145
|
def to_s
|
135
146
|
if self.persisted? then
|
136
147
|
persister_name = self.persister ? "#{ self.persister.name }/" : ''
|
137
|
-
|
148
|
+
if @load_needed then
|
149
|
+
"<<#{ self.class.name } #{ self.object_id } [#{ self.persister ? self.persister.name : 'no-persister' }/#{ self.get_the_index }] NOT LOADED>>"
|
150
|
+
else
|
151
|
+
"<<#{ self.class.name } #{ self.object_id } [#{ self.persister ? self.persister.name : 'no-persister' }/#{ self.get_the_index }]#{ @is_changed ? ' DIRTY' : ''}>>"
|
152
|
+
end
|
138
153
|
elsif self.indexed_by then
|
139
154
|
"<<#{ self.class.name } #{ self.object_id } [#{ self.get_the_index }]>>"
|
140
155
|
else
|
@@ -12,54 +12,16 @@ module Xampl
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def accessed
|
15
|
-
raise XamplIsInvalid.new(self) if invalid
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#raise UnmanagedChange.new(self)
|
26
|
-
if not @persister.syncing then
|
27
|
-
Xampl.read_only(@persister) do
|
28
|
-
Xampl.lazy_load(self)
|
29
|
-
end
|
30
|
-
else
|
31
|
-
puts "LOAD NEEDED(2): REFUSED (persister: #{@persister.name})"
|
32
|
-
puts " pid: #{self.get_the_index} #{self}"
|
33
|
-
caller(0).each { | trace | puts " #{trace}"}
|
34
|
-
end
|
35
|
-
elsif Xampl.persister != @persister then
|
36
|
-
raise MixedPersisters.new(@persister, self)
|
37
|
-
elsif Xampl.persister == @persister then
|
38
|
-
if not @persister.syncing then
|
39
|
-
Xampl.read_only(@persister) do
|
40
|
-
Xampl.lazy_load(self)
|
41
|
-
end
|
42
|
-
else
|
43
|
-
puts "LOAD NEEDED(3): BAD IDEA, but load anyway (persister: #{@persister.name})"
|
44
|
-
puts " #{self.class.name}"
|
45
|
-
puts " pid: #{self.get_the_index}"
|
46
|
-
Xampl.read_only(@persister) do
|
47
|
-
Xampl.lazy_load(self)
|
48
|
-
end
|
49
|
-
# puts "LOAD NEEDED(3): REFUSED (persister: #{@persister.name})"
|
50
|
-
# puts " #{self.class.name}"
|
51
|
-
# puts " pid: #{self.get_the_index}"
|
52
|
-
# caller(0).each { | trace | puts " #{trace}"}
|
53
|
-
end
|
54
|
-
else
|
55
|
-
puts "LOAD NEEDED(4): REFUSED (persister: #{@persister.name})"
|
56
|
-
puts " pid: #{self.get_the_index} #{self}"
|
57
|
-
caller(0).each { | trace | puts " #{trace}"}
|
58
|
-
end
|
59
|
-
else
|
60
|
-
puts "LOAD NEEDED(5): REFUSED (persister: #{@persister})" if @load_needed
|
61
|
-
puts " pid: #{self.get_the_index} #{self}" if @load_needed
|
62
|
-
caller(0).each { | trace | puts " #{trace}"} if @load_needed
|
15
|
+
raise XamplIsInvalid.new(self) if invalid #need this error to be more prominent
|
16
|
+
return unless @load_needed
|
17
|
+
|
18
|
+
# raise XamplIsInvalid.new(self) if invalid
|
19
|
+
raise NoActivePersister.new unless @persister
|
20
|
+
raise XamplException(:load_blocked_because_persister_is_syncing,
|
21
|
+
"often happens when you are describing a xampl object using a different persisted xampl object that hasn't been loaded yet") if @persister.syncing
|
22
|
+
|
23
|
+
Xampl.read_only(@persister) do
|
24
|
+
Xampl.lazy_load(self)
|
63
25
|
end
|
64
26
|
end
|
65
27
|
|
@@ -68,18 +30,13 @@ module Xampl
|
|
68
30
|
end
|
69
31
|
|
70
32
|
def changed
|
71
|
-
|
72
|
-
|
73
|
-
raise UnmanagedChange.new(self)
|
74
|
-
end
|
33
|
+
raise UnmanagedChange.new(self) unless Xampl.persister
|
34
|
+
|
75
35
|
if @persister then
|
76
|
-
if Xampl.persister != @persister
|
77
|
-
|
78
|
-
end
|
79
|
-
if @persister.block_changes then
|
80
|
-
raise BlockedChange.new(self)
|
81
|
-
end
|
36
|
+
raise UnmanagedChange.new(self) if Xampl.persister != @persister
|
37
|
+
raise BlockedChange.new(self) if @persister.block_changes
|
82
38
|
end
|
39
|
+
|
83
40
|
unless @is_changed then
|
84
41
|
@is_changed = true
|
85
42
|
if @persister then
|
data/xamplr.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{xamplr}
|
8
|
-
s.version = "1.9.
|
8
|
+
s.version = "1.9.14"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bob Hutchison"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-02}
|
13
13
|
s.description = %q{xamplr is the ruby version of xampl.}
|
14
14
|
s.email = %q{hutch@recursive.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -36,6 +36,8 @@ Gem::Specification.new do |s|
|
|
36
36
|
"lib/xamplr/exceptions.rb",
|
37
37
|
"lib/xamplr/from-xml-orig.rb",
|
38
38
|
"lib/xamplr/from-xml.rb",
|
39
|
+
"lib/xamplr/from-xml.rb.libxml",
|
40
|
+
"lib/xamplr/from-xml.rb.nokogiri",
|
39
41
|
"lib/xamplr/indexed-array.rb",
|
40
42
|
"lib/xamplr/iterator.rb",
|
41
43
|
"lib/xamplr/mixins.rb",
|
@@ -48,7 +50,8 @@ Gem::Specification.new do |s|
|
|
48
50
|
"lib/xamplr/persisters/dumb.rb",
|
49
51
|
"lib/xamplr/persisters/filesystem.rb",
|
50
52
|
"lib/xamplr/persisters/in-memory.rb",
|
51
|
-
"lib/xamplr/persisters/mongo.rb",
|
53
|
+
"lib/xamplr/persisters/mongo.rb.cannot-use",
|
54
|
+
"lib/xamplr/persisters/redis.rb",
|
52
55
|
"lib/xamplr/persisters/simple.rb",
|
53
56
|
"lib/xamplr/persisters/tokyo-cabinet.rb",
|
54
57
|
"lib/xamplr/persisters/tokyo-cabinet.rb.1-DB",
|
@@ -72,6 +75,17 @@ Gem::Specification.new do |s|
|
|
72
75
|
"lib/xamplr/test-support/test-names.rb",
|
73
76
|
"lib/xamplr/test-support/test-rollback.rb",
|
74
77
|
"lib/xamplr/test-support/test.rb",
|
78
|
+
"lib/xamplr/tests/.gitignore",
|
79
|
+
"lib/xamplr/tests/redis/Makefile",
|
80
|
+
"lib/xamplr/tests/redis/author.rb",
|
81
|
+
"lib/xamplr/tests/redis/project-generator.rb",
|
82
|
+
"lib/xamplr/tests/redis/redis_spec.rb",
|
83
|
+
"lib/xamplr/tests/redis/spec.opts",
|
84
|
+
"lib/xamplr/tests/redis/spec_helper.rb",
|
85
|
+
"lib/xamplr/tests/redis/testing-db/.gitignore",
|
86
|
+
"lib/xamplr/tests/redis/testing-db/Makefile",
|
87
|
+
"lib/xamplr/tests/redis/testing-db/unit-testing.redis.conf",
|
88
|
+
"lib/xamplr/tests/redis/xml/redis-test.xml",
|
75
89
|
"lib/xamplr/to-ruby.rb",
|
76
90
|
"lib/xamplr/to-xml.rb",
|
77
91
|
"lib/xamplr/visitor.rb",
|
@@ -125,14 +139,14 @@ Gem::Specification.new do |s|
|
|
125
139
|
|
126
140
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
127
141
|
s.add_runtime_dependency(%q<xamplr-pp>, [">= 1.2.0"])
|
128
|
-
s.add_runtime_dependency(%q<
|
142
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.3"])
|
129
143
|
else
|
130
144
|
s.add_dependency(%q<xamplr-pp>, [">= 1.2.0"])
|
131
|
-
s.add_dependency(%q<
|
145
|
+
s.add_dependency(%q<nokogiri>, [">= 1.4.3"])
|
132
146
|
end
|
133
147
|
else
|
134
148
|
s.add_dependency(%q<xamplr-pp>, [">= 1.2.0"])
|
135
|
-
s.add_dependency(%q<
|
149
|
+
s.add_dependency(%q<nokogiri>, [">= 1.4.3"])
|
136
150
|
end
|
137
151
|
end
|
138
152
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xamplr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 1.9.
|
9
|
+
- 14
|
10
|
+
version: 1.9.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bob Hutchison
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-02 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,19 +35,19 @@ dependencies:
|
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: nokogiri
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 1
|
46
46
|
segments:
|
47
47
|
- 1
|
48
|
-
-
|
48
|
+
- 4
|
49
49
|
- 3
|
50
|
-
version: 1.
|
50
|
+
version: 1.4.3
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
description: xamplr is the ruby version of xampl.
|
@@ -79,6 +79,8 @@ files:
|
|
79
79
|
- lib/xamplr/exceptions.rb
|
80
80
|
- lib/xamplr/from-xml-orig.rb
|
81
81
|
- lib/xamplr/from-xml.rb
|
82
|
+
- lib/xamplr/from-xml.rb.libxml
|
83
|
+
- lib/xamplr/from-xml.rb.nokogiri
|
82
84
|
- lib/xamplr/indexed-array.rb
|
83
85
|
- lib/xamplr/iterator.rb
|
84
86
|
- lib/xamplr/mixins.rb
|
@@ -91,7 +93,8 @@ files:
|
|
91
93
|
- lib/xamplr/persisters/dumb.rb
|
92
94
|
- lib/xamplr/persisters/filesystem.rb
|
93
95
|
- lib/xamplr/persisters/in-memory.rb
|
94
|
-
- lib/xamplr/persisters/mongo.rb
|
96
|
+
- lib/xamplr/persisters/mongo.rb.cannot-use
|
97
|
+
- lib/xamplr/persisters/redis.rb
|
95
98
|
- lib/xamplr/persisters/simple.rb
|
96
99
|
- lib/xamplr/persisters/tokyo-cabinet.rb
|
97
100
|
- lib/xamplr/persisters/tokyo-cabinet.rb.1-DB
|
@@ -115,6 +118,17 @@ files:
|
|
115
118
|
- lib/xamplr/test-support/test-names.rb
|
116
119
|
- lib/xamplr/test-support/test-rollback.rb
|
117
120
|
- lib/xamplr/test-support/test.rb
|
121
|
+
- lib/xamplr/tests/.gitignore
|
122
|
+
- lib/xamplr/tests/redis/Makefile
|
123
|
+
- lib/xamplr/tests/redis/author.rb
|
124
|
+
- lib/xamplr/tests/redis/project-generator.rb
|
125
|
+
- lib/xamplr/tests/redis/redis_spec.rb
|
126
|
+
- lib/xamplr/tests/redis/spec.opts
|
127
|
+
- lib/xamplr/tests/redis/spec_helper.rb
|
128
|
+
- lib/xamplr/tests/redis/testing-db/.gitignore
|
129
|
+
- lib/xamplr/tests/redis/testing-db/Makefile
|
130
|
+
- lib/xamplr/tests/redis/testing-db/unit-testing.redis.conf
|
131
|
+
- lib/xamplr/tests/redis/xml/redis-test.xml
|
118
132
|
- lib/xamplr/to-ruby.rb
|
119
133
|
- lib/xamplr/to-xml.rb
|
120
134
|
- lib/xamplr/visitor.rb
|