inversion 0.10.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,10 +1,36 @@
1
+ 2012-07-06 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * lib/inversion/renderstate.rb, lib/inversion/template.rb,
4
+ spec/inversion/renderstate_spec.rb:
5
+ Transcode output according to the :encoding option if set on a
6
+ template
7
+ [2202c6ed520b] [tip]
8
+
9
+ * lib/inversion/mixins.rb:
10
+ Don't try to deep copy Encoding objects, either
11
+ [424709b51350]
12
+
13
+ 2012-06-27 Michael Granger <ged@FaerieMUD.org>
14
+
15
+ * .hgtags:
16
+ Added tag v0.10.2 for changeset 043b32a2d9a6
17
+ [5b926937058b]
18
+
19
+ * .hgsigs:
20
+ Added signature for changeset 7236fd2ac3fb
21
+ [043b32a2d9a6] [v0.10.2]
22
+
23
+ * History.rdoc, lib/inversion.rb:
24
+ Bump the patch version, update history.
25
+ [7236fd2ac3fb]
26
+
1
27
  2012-06-27 Mahlon E. Smith <mahlon@martini.nu>
2
28
 
3
29
  * lib/inversion/mixins.rb, lib/inversion/template.rb,
4
30
  spec/inversion/mixins_spec.rb:
5
31
  Add Modules/Classes to the immediate object list when deep copying.
6
32
  Don't needlessly deep_copy the node tree on template duplication.
7
- [fb0ab0db2042] [tip]
33
+ [fb0ab0db2042]
8
34
 
9
35
  2012-06-22 Michael Granger <ged@FaerieMUD.org>
10
36
 
data/History.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ == v0.11.0 [2012-07-06] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Automatically transcode output according to the registered encoding
4
+ if the template is created with one
5
+
6
+
1
7
  == v0.10.2 [2012-06-27] Mahlon E. Smith <mahlon@martini.nu>
2
8
 
3
9
  - Bugfix: Don't dup Classes and Modules in template attributes.
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.2'
28
+ VERSION = '0.11.0'
29
29
 
30
30
  # Version-control revision constant
31
- REVISION = %q$Revision: 7236fd2ac3fb $
31
+ REVISION = %q$Revision: 92d48ef3085e $
32
32
 
33
33
 
34
34
  ### Get the Inversion version.
@@ -212,7 +212,7 @@ module Inversion
212
212
  return obj if obj.class.name == 'RSpec::Mocks::Mock'
213
213
 
214
214
  return case obj
215
- when NilClass, Numeric, TrueClass, FalseClass, Symbol, Module
215
+ when NilClass, Numeric, TrueClass, FalseClass, Symbol, Module, Encoding
216
216
  obj
217
217
 
218
218
  when Array
@@ -264,6 +264,7 @@ class Inversion::RenderState
264
264
  if self.rendering_enabled?
265
265
  self.destination << self.make_node_comment( node ) if self.options[:debugging_comments]
266
266
  previous_node = nil
267
+ enc = self.options[:encoding] || Encoding.default_internal
267
268
 
268
269
  begin
269
270
  # Allow render to be delegated to subobjects
@@ -273,8 +274,8 @@ class Inversion::RenderState
273
274
  node = node.render( self )
274
275
  end
275
276
 
276
- # self.log.debug " adding a %p to the destination (%p)" %
277
- # [ node.class, self.destination.class ]
277
+ # self.log.debug " adding a %p (%p; encoding: %s) to the destination (%p)" %
278
+ # [ node.class, node, node.respond_to?(:encoding) ? node.encoding : 'n/a', self.destination.class ]
278
279
  self.destination << node
279
280
  # self.log.debug " just appended %p to %p" % [ node, self.destination ]
280
281
  rescue ::StandardError => err
@@ -290,7 +291,14 @@ class Inversion::RenderState
290
291
 
291
292
  ### Turn the rendered node structure into the final rendered String.
292
293
  def to_s
293
- return @output.flatten.map( &:to_s ).join
294
+ strings = @output.flatten.map( &:to_s )
295
+
296
+ if enc = self.options[ :encoding ]
297
+ self.log.debug "Encoding rendered template parts to %s" % [ enc ]
298
+ strings.map! {|str| str.encode(enc) }
299
+ end
300
+
301
+ return strings.join
294
302
  end
295
303
 
296
304
 
@@ -116,9 +116,8 @@ class Inversion::Template
116
116
  end
117
117
 
118
118
  # We trust files read from disk
119
- encoding = opts.delete( :encoding )
120
- source = if encoding
121
- tmpl.read( encoding: encoding )
119
+ source = if opts.key?( :encoding )
120
+ tmpl.read( encoding: opts[:encoding] )
122
121
  else
123
122
  tmpl.read
124
123
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rspec -cfd -b
2
+ # encoding: utf-8
2
3
  # vim: set noet nosta sw=4 ts=4 :
3
4
 
4
5
  BEGIN {
@@ -383,5 +384,24 @@ describe Inversion::RenderState do
383
384
 
384
385
  end
385
386
 
387
+
388
+ describe "encoding support" do
389
+
390
+ it "transcodes attribute values if the template's encoding is set" do
391
+ attributes = {
392
+ good_doggie: "Стрелка".encode('koi8-u'),
393
+ little: "arrow".encode('us-ascii')
394
+ }
395
+
396
+ state = Inversion::RenderState.new( attributes, encoding: 'utf-8' )
397
+
398
+ state << Inversion::Template::AttrTag.new( 'good_doggie' )
399
+ state << Inversion::Template::AttrTag.new( 'little' )
400
+
401
+ state.to_s.encoding.should be( Encoding::UTF_8 )
402
+ end
403
+
404
+ end
405
+
386
406
  end
387
407
 
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.2
4
+ version: 0.11.0
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-06-27 00:00:00.000000000 Z
40
+ date: 2012-07-06 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: loggability
metadata.gz.sig CHANGED
Binary file