inversion 0.17.4 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +5 -0
- data/lib/inversion.rb +2 -2
- data/lib/inversion/template.rb +10 -0
- data/spec/inversion/template_spec.rb +15 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39e86e1e9f455dde60d2b962de255981046f23c7
|
4
|
+
data.tar.gz: 1c043e470b3a221fd196fd671d7791987039f1f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e56eddccd69b4d0078c6355344ed85f02eb6665928f32facf52b2417c17b4fe774517fe358d2460b8b15674d811aea1ebd2e45e8e00e89a496be2ef87735238d
|
7
|
+
data.tar.gz: fc8c6f9dafbdd0eb44bb440e1a2ce1e9fdffdde1179d842eb81802e3c2023254c08d4f663ad6d78026b829922f35f036fe37e5394d3854ab6bd64716870fadf2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
data/lib/inversion.rb
CHANGED
@@ -26,10 +26,10 @@ module Inversion
|
|
26
26
|
warn ">>> Inversion requires Ruby 2.0.0 or later. <<<" if RUBY_VERSION < '2.0.0'
|
27
27
|
|
28
28
|
# Library version constant
|
29
|
-
VERSION = '0.
|
29
|
+
VERSION = '0.18.0'
|
30
30
|
|
31
31
|
# Version-control revision constant
|
32
|
-
REVISION = %q$Revision:
|
32
|
+
REVISION = %q$Revision: 644316d7a5e8 $
|
33
33
|
|
34
34
|
|
35
35
|
### Get the Inversion version.
|
data/lib/inversion/template.rb
CHANGED
@@ -82,6 +82,11 @@ end
|
|
82
82
|
# a purposeful delay between reloads for busy servers. Defaults to +0+
|
83
83
|
# (disabled).
|
84
84
|
#
|
85
|
+
# [:strict_attributes]
|
86
|
+
# Disable getting/setting attributes that aren't explicitly declared with a tag.
|
87
|
+
# Trying to get/set an attribute that isn't declared in the template with this
|
88
|
+
# option enabled will result in a NoMethodError being raised.
|
89
|
+
#
|
85
90
|
#
|
86
91
|
class Inversion::Template
|
87
92
|
extend Loggability
|
@@ -121,6 +126,7 @@ class Inversion::Template
|
|
121
126
|
:ignore_unknown_tags => true,
|
122
127
|
:template_paths => [],
|
123
128
|
:stat_delay => 0,
|
129
|
+
:strict_attributes => false,
|
124
130
|
|
125
131
|
# Rendering options
|
126
132
|
:on_render_error => :comment,
|
@@ -391,6 +397,10 @@ class Inversion::Template
|
|
391
397
|
def method_missing( sym, *args, &block )
|
392
398
|
return super unless sym.to_s =~ /^([a-z]\w+)=?$/i
|
393
399
|
attribute = $1
|
400
|
+
|
401
|
+
raise NoMethodError, "no tag attribute '%s' (strict mode)" % [ attribute ] if
|
402
|
+
self.options[:strict_attributes]
|
403
|
+
|
394
404
|
self.install_accessors( attribute )
|
395
405
|
|
396
406
|
# Call the new method via #method to avoid a method_missing loop.
|
@@ -65,6 +65,7 @@ describe Inversion::Template do
|
|
65
65
|
tmpl.render( &renderblock )
|
66
66
|
end
|
67
67
|
|
68
|
+
|
68
69
|
it "carries its global configuration to the parser" do
|
69
70
|
begin
|
70
71
|
orig_config = described_class.config
|
@@ -78,6 +79,7 @@ describe Inversion::Template do
|
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
82
|
+
|
81
83
|
it "carries its global configuration to per-template options" do
|
82
84
|
begin
|
83
85
|
orig_config = described_class.config
|
@@ -103,6 +105,7 @@ describe Inversion::Template do
|
|
103
105
|
expect( tmpl.inspect ).to_not match( /node_tree/ )
|
104
106
|
end
|
105
107
|
|
108
|
+
|
106
109
|
it "includes the node tree in the inspected object if debugging is enabled" do
|
107
110
|
begin
|
108
111
|
debuglevel = $DEBUG
|
@@ -115,12 +118,24 @@ describe Inversion::Template do
|
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
121
|
+
|
118
122
|
it "provides accessors for attributes that aren't identifiers in the template" do
|
119
123
|
tmpl = described_class.new( '' )
|
120
124
|
tmpl.foo = :bar
|
121
125
|
expect( tmpl.foo ).to eq( :bar )
|
122
126
|
end
|
123
127
|
|
128
|
+
|
129
|
+
it "raises instead of generating an accessor if configured with strict attributes" do
|
130
|
+
tmpl = described_class.new( '<?attr bar ?>', strict_attributes: true )
|
131
|
+
expect { tmpl.foo = :bar }.to raise_error( NoMethodError, "no tag attribute 'foo' (strict mode)" )
|
132
|
+
expect { tmpl.foo }.to raise_error( NoMethodError, "no tag attribute 'foo' (strict mode)")
|
133
|
+
|
134
|
+
tmpl.bar = :foo
|
135
|
+
expect( tmpl.bar ).to eq( :foo )
|
136
|
+
end
|
137
|
+
|
138
|
+
|
124
139
|
it "can pass an encoding option to IO.open through the template constructor" do
|
125
140
|
content = 'some stuff'.encode( 'utf-8' )
|
126
141
|
expect( IO ).to receive( :read ).with( '/a/utf8/template.tmpl', encoding: 'utf-8' ).and_return( content )
|
@@ -270,7 +285,6 @@ describe Inversion::Template do
|
|
270
285
|
end
|
271
286
|
|
272
287
|
|
273
|
-
|
274
288
|
context "without template paths set" do
|
275
289
|
|
276
290
|
before( :each ) 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.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
G8LHR7EjtPPmqCCunfyecJ6MmCNaiJCBxq2NYzyNmluPyHT8+0fuB5kccUVZm6CD
|
32
32
|
xn3DzOkDE6NYbk8gC9rTsA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-
|
34
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: loggability
|
metadata.gz.sig
CHANGED
Binary file
|