inversion 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/ChangeLog +35 -2
- data/History.rdoc +9 -0
- data/Rakefile +1 -1
- data/lib/inversion.rb +2 -2
- data/lib/inversion/mixins.rb +32 -0
- data/lib/inversion/renderstate.rb +2 -30
- data/lib/inversion/template.rb +24 -11
- data/spec/inversion/template_spec.rb +23 -5
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,8 +1,41 @@
|
|
1
|
+
2012-05-07 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* .hgtags:
|
4
|
+
Added tag v0.10.0 for changeset 64cf302354aa
|
5
|
+
[79bc44fab294] [tip]
|
6
|
+
|
7
|
+
* .hgsigs:
|
8
|
+
Added signature for changeset 9d9c49d532be
|
9
|
+
[64cf302354aa] [v0.10.0]
|
10
|
+
|
11
|
+
* .rvm.gems, History.rdoc, Manifest.txt, Rakefile, bin/inversion,
|
12
|
+
experiments/benchmark-parser.rb, experiments/demo.rb,
|
13
|
+
experiments/dumptemplate.rb, lib/inversion.rb,
|
14
|
+
lib/inversion/logging.rb, lib/inversion/mixins.rb,
|
15
|
+
lib/inversion/parser.rb, lib/inversion/renderstate.rb,
|
16
|
+
lib/inversion/template.rb, lib/inversion/template/begintag.rb,
|
17
|
+
lib/inversion/template/codetag.rb,
|
18
|
+
lib/inversion/template/commenttag.rb,
|
19
|
+
lib/inversion/template/configtag.rb,
|
20
|
+
lib/inversion/template/elsetag.rb,
|
21
|
+
lib/inversion/template/elsiftag.rb,
|
22
|
+
lib/inversion/template/endtag.rb, lib/inversion/template/fortag.rb,
|
23
|
+
lib/inversion/template/iftag.rb,
|
24
|
+
lib/inversion/template/includetag.rb,
|
25
|
+
lib/inversion/template/node.rb, lib/inversion/template/rescuetag.rb,
|
26
|
+
lib/inversion/template/tag.rb, lib/inversion/template/textnode.rb,
|
27
|
+
lib/inversion/template/unlesstag.rb,
|
28
|
+
lib/inversion/template/yieldtag.rb, spec/inversion/logging_spec.rb,
|
29
|
+
spec/inversion/mixins_spec.rb, spec/inversion_spec.rb,
|
30
|
+
spec/lib/helpers.rb:
|
31
|
+
Convert to Loggability for logging.
|
32
|
+
[9d9c49d532be]
|
33
|
+
|
1
34
|
2012-04-24 Michael Granger <ged@FaerieMUD.org>
|
2
35
|
|
3
36
|
* .hgtags:
|
4
37
|
Added tag v0.9.0 for changeset 27f082ef7985
|
5
|
-
[dd18f3255985] [
|
38
|
+
[dd18f3255985] [github/master]
|
6
39
|
|
7
40
|
* .hgsigs:
|
8
41
|
Added signature for changeset b208fa9154b1
|
@@ -21,7 +54,7 @@
|
|
21
54
|
|
22
55
|
* manual/src/tags.page:
|
23
56
|
Fix the include tag example in the manual.
|
24
|
-
[b5fcbae36ff2]
|
57
|
+
[b5fcbae36ff2]
|
25
58
|
|
26
59
|
2012-04-02 Michael Granger <ged@FaerieMUD.org>
|
27
60
|
|
data/History.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== v0.10.1 [2012-06-22] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
- Bugfix: duplicated templates get distinct copies of their attributes.
|
4
|
+
|
5
|
+
|
6
|
+
== v0.10.0 [2012-05-07] Michael Granger <ged@FaerieMUD.org>
|
7
|
+
|
8
|
+
- Added signature for changeset 9d9c49d532be
|
9
|
+
|
1
10
|
== v0.10.0 [2012-05-07] Michael Granger <ged@FaerieMUD.org>
|
2
11
|
|
3
12
|
- Convert to Loggability for logging.
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ hoespec = Hoe.spec 'inversion' do
|
|
20
20
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
21
21
|
self.developer 'Mahlon E. Smith', 'mahlon@martini.nu'
|
22
22
|
|
23
|
-
self.dependency 'loggability', '~> 0.
|
23
|
+
self.dependency 'loggability', '~> 0.2'
|
24
24
|
|
25
25
|
self.dependency 'rdoc', '~> 3.12', :development
|
26
26
|
self.dependency 'rspec', '~> 2.8', :development
|
data/lib/inversion.rb
CHANGED
@@ -25,10 +25,10 @@ module Inversion
|
|
25
25
|
warn ">>> Inversion requires Ruby 1.9.2 or later. <<<" if RUBY_VERSION < '1.9.2'
|
26
26
|
|
27
27
|
# Library version constant
|
28
|
-
VERSION = '0.10.
|
28
|
+
VERSION = '0.10.1'
|
29
29
|
|
30
30
|
# Version-control revision constant
|
31
|
-
REVISION = %q$Revision:
|
31
|
+
REVISION = %q$Revision: 432abb56d593 $
|
32
32
|
|
33
33
|
|
34
34
|
### Get the Inversion version.
|
data/lib/inversion/mixins.rb
CHANGED
@@ -196,5 +196,37 @@ module Inversion
|
|
196
196
|
|
197
197
|
end # module MethodUtilities
|
198
198
|
|
199
|
+
|
200
|
+
# A collection of data-manipulation functions.
|
201
|
+
module DataUtilities
|
202
|
+
|
203
|
+
### Recursively copy the specified +obj+ and return the result.
|
204
|
+
def deep_copy( obj )
|
205
|
+
# self.log.debug "Deep copying: %p" % [ obj ]
|
206
|
+
|
207
|
+
# Handle mocks during testing
|
208
|
+
return obj if obj.class.name == 'RSpec::Mocks::Mock'
|
209
|
+
|
210
|
+
return case obj
|
211
|
+
when NilClass, Numeric, TrueClass, FalseClass, Symbol
|
212
|
+
obj
|
213
|
+
|
214
|
+
when Array
|
215
|
+
obj.map {|o| deep_copy(o) }
|
216
|
+
|
217
|
+
when Hash
|
218
|
+
newhash = {}
|
219
|
+
obj.each do |k,v|
|
220
|
+
newhash[ deep_copy(k) ] = deep_copy( v )
|
221
|
+
end
|
222
|
+
newhash
|
223
|
+
|
224
|
+
else
|
225
|
+
obj.clone
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
end # module DataUtilities
|
230
|
+
|
199
231
|
end # module Inversion
|
200
232
|
|
@@ -8,6 +8,8 @@ require 'inversion' unless defined?( Inversion )
|
|
8
8
|
# An object that provides an encapsulation of the template's state while it is rendering.
|
9
9
|
class Inversion::RenderState
|
10
10
|
extend Loggability
|
11
|
+
include Inversion::DataUtilities
|
12
|
+
|
11
13
|
|
12
14
|
# Loggability API -- set up logging through the Inversion module's logger
|
13
15
|
log_to :inversion
|
@@ -436,35 +438,5 @@ class Inversion::RenderState
|
|
436
438
|
end
|
437
439
|
|
438
440
|
|
439
|
-
#######
|
440
|
-
private
|
441
|
-
#######
|
442
|
-
|
443
|
-
### Recursively copy the specified +obj+ and return the result.
|
444
|
-
def deep_copy( obj )
|
445
|
-
# self.log.debug "Deep copying: %p" % [ obj ]
|
446
|
-
|
447
|
-
# Handle mocks during testing
|
448
|
-
return obj if obj.class.name == 'RSpec::Mocks::Mock'
|
449
|
-
|
450
|
-
return case obj
|
451
|
-
when NilClass, Numeric, TrueClass, FalseClass, Symbol
|
452
|
-
obj
|
453
|
-
|
454
|
-
when Array
|
455
|
-
obj.map {|o| deep_copy(o) }
|
456
|
-
|
457
|
-
when Hash
|
458
|
-
newhash = {}
|
459
|
-
obj.each do |k,v|
|
460
|
-
newhash[ deep_copy(k) ] = deep_copy( v )
|
461
|
-
end
|
462
|
-
newhash
|
463
|
-
|
464
|
-
else
|
465
|
-
obj.clone
|
466
|
-
end
|
467
|
-
end
|
468
|
-
|
469
441
|
end # class Inversion::RenderState
|
470
442
|
|
data/lib/inversion/template.rb
CHANGED
@@ -18,6 +18,8 @@ end
|
|
18
18
|
# can be used to populate it when rendered.
|
19
19
|
class Inversion::Template
|
20
20
|
extend Loggability
|
21
|
+
include Inversion::DataUtilities
|
22
|
+
|
21
23
|
|
22
24
|
# Loggability API -- set up logging through the Inversion module's logger
|
23
25
|
log_to :inversion
|
@@ -140,14 +142,9 @@ class Inversion::Template
|
|
140
142
|
self.log.debug "Parse state is: %p" % [ parsestate ]
|
141
143
|
end
|
142
144
|
|
143
|
-
# carry global template options to the parser.
|
144
|
-
opts = self.class.config.merge( opts )
|
145
|
-
|
146
145
|
@source = source
|
147
|
-
@parser = Inversion::Parser.new( self, opts )
|
148
146
|
@node_tree = [] # Parser expects this to always be an Array
|
149
|
-
@
|
150
|
-
@options = nil
|
147
|
+
@options = opts
|
151
148
|
@attributes = {}
|
152
149
|
@source_file = nil
|
153
150
|
@created_at = Time.now
|
@@ -157,6 +154,14 @@ class Inversion::Template
|
|
157
154
|
end
|
158
155
|
|
159
156
|
|
157
|
+
### Copy constructor -- make copies of some internal data structures, too.
|
158
|
+
def initialize_copy( other )
|
159
|
+
@options = deep_copy( other.options )
|
160
|
+
@node_tree = deep_copy( other.node_tree )
|
161
|
+
@attributes = deep_copy( other.attributes )
|
162
|
+
end
|
163
|
+
|
164
|
+
|
160
165
|
######
|
161
166
|
public
|
162
167
|
######
|
@@ -223,13 +228,19 @@ class Inversion::Template
|
|
223
228
|
### Return a human-readable representation of the template object suitable
|
224
229
|
### for debugging.
|
225
230
|
def inspect
|
226
|
-
|
231
|
+
nodemap = if $DEBUG
|
232
|
+
", node_tree: %p" % [ self.node_tree.map(&:as_comment_body) ]
|
233
|
+
else
|
234
|
+
''
|
235
|
+
end
|
236
|
+
|
237
|
+
return "#<%s:%08x (loaded from %s) attributes: %p, options: %p%s>" % [
|
227
238
|
self.class.name,
|
228
239
|
self.object_id / 2,
|
229
240
|
self.source_file ? self.source_file : "memory",
|
230
|
-
self.attributes,
|
231
|
-
self.node_tree.map(&:as_comment_body),
|
241
|
+
self.attributes.keys,
|
232
242
|
self.options,
|
243
|
+
nodemap
|
233
244
|
]
|
234
245
|
end
|
235
246
|
|
@@ -252,9 +263,11 @@ class Inversion::Template
|
|
252
263
|
|
253
264
|
### Parse the given +source+ into the template node tree.
|
254
265
|
def parse( source, parsestate=nil )
|
255
|
-
|
266
|
+
opts = self.class.config.merge( self.options )
|
267
|
+
parser = Inversion::Parser.new( self, opts )
|
268
|
+
|
256
269
|
@attributes.clear
|
257
|
-
@node_tree =
|
270
|
+
@node_tree = parser.parse( source, parsestate )
|
258
271
|
@source = source
|
259
272
|
|
260
273
|
self.define_attribute_accessors
|
@@ -62,10 +62,16 @@ describe Inversion::Template do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "carries its global configuration to the parser" do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
begin
|
66
|
+
orig_config = Inversion::Template.config
|
67
|
+
Inversion::Template.configure( :ignore_unknown_tags => false )
|
68
|
+
|
69
|
+
expect {
|
70
|
+
Inversion::Template.new( '<?rumple an unknown tag ?>' )
|
71
|
+
}.to raise_error( Inversion::ParseError, /unknown tag/i )
|
72
|
+
ensure
|
73
|
+
Inversion::Template.config = orig_config
|
74
|
+
end
|
69
75
|
end
|
70
76
|
|
71
77
|
it "can make an human-readable string version of itself suitable for debugging" do
|
@@ -74,7 +80,19 @@ describe Inversion::Template do
|
|
74
80
|
tmpl.inspect.should =~ /Inversion::Template/
|
75
81
|
tmpl.inspect.should =~ %r{/tmp/inspect.tmpl}
|
76
82
|
tmpl.inspect.should =~ /attributes/
|
77
|
-
tmpl.inspect.
|
83
|
+
tmpl.inspect.should_not =~ /node_tree/
|
84
|
+
end
|
85
|
+
|
86
|
+
it "includes the node tree in the inspected object if debugging is enabled" do
|
87
|
+
begin
|
88
|
+
debuglevel = $DEBUG
|
89
|
+
$DEBUG = true
|
90
|
+
|
91
|
+
tmpl = Inversion::Template.new( '<?attr something ?>' )
|
92
|
+
tmpl.inspect.should =~ /node_tree/
|
93
|
+
ensure
|
94
|
+
$DEBUG = debuglevel
|
95
|
+
end
|
78
96
|
end
|
79
97
|
|
80
98
|
it "provides accessors for attributes that aren't identifiers in the template" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
|
38
38
|
Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
|
39
39
|
cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
40
|
-
date: 2012-
|
40
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: loggability
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
49
|
+
version: '0.2'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '0.
|
57
|
+
version: '0.2'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: hoe-mercurial
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|