cutaneous 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e398300a8b3fdc0ed8a26b9b0864006c792a8f6
4
- data.tar.gz: 7d6d810c48e137af8b4b5c9cc2b479bdb3d299f1
3
+ metadata.gz: 012024660b2cd0de6db4295f59f2dd7f627280a4
4
+ data.tar.gz: ae08e8b3fcdc18c3060104beb02acb4f7e77b3f6
5
5
  SHA512:
6
- metadata.gz: 5c5f8cfd091d40a3a5a126d7ebf13843f0ed82aa314799bc5a53d6dfcab89f10e8f7620d2749414a88623cee28b33cf85e27ac7e3cbe042d9db8e3fe08979f98
7
- data.tar.gz: a51d2b7c1f921f5e794b4532693644932039c1429e84c853b99969a54eb59f321cd1b5e3ee52b18b2beeab76bb913ff52477037249d22ac41692a9e228350367
6
+ metadata.gz: 034dc2af99470678f14e0e687c09d946cd52545fc1b515a59c53b379b90d5a01920572db4d28c1bd1d3ae169840b8a9d0aa04ac75e6b94a119c27e6a749ebeaf
7
+ data.tar.gz: 0e083ff19ecab0be7f48e40a23a2166c188ab41521c0b0c784584369b2a098457f69b34e32bc69fd9733660952d79c5236766b3818823449188a978928df1099
data/cutaneous.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
  ## If your rubyforge_project name is different, then edit it and comment out
15
15
  ## the sub! line in the Rakefile
16
16
  s.name = 'cutaneous'
17
- s.version = '0.1.6'
18
- s.date = '2013-09-14'
17
+ s.version = '0.1.7'
18
+ s.date = '2013-11-14'
19
19
  s.rubyforge_project = 'cutaneous'
20
20
 
21
21
  ## Make sure your summary is short. The description may be as long
@@ -5,10 +5,10 @@ module Cutaneous
5
5
  class Context < Delegator
6
6
  attr_accessor :__buf, :__loader, :__target, :__locals
7
7
 
8
- def initialize(target, locals_or_context = {})
8
+ def initialize(target, locals = {}, parent_context = nil)
9
9
  super(target)
10
10
  @__target, @__locals = target, {}
11
- __update_context(locals_or_context)
11
+ __update_context(locals, parent_context)
12
12
  end
13
13
 
14
14
  def __decode_params(params)
@@ -25,8 +25,7 @@ module Cutaneous
25
25
  end
26
26
 
27
27
  def clone(locals = {})
28
- context = self.class.new(__target, self)
29
- context.__update_with_locals(locals)
28
+ context = self.class.new(__target, locals, self)
30
29
  context
31
30
  end
32
31
 
@@ -52,16 +51,14 @@ module Cutaneous
52
51
  # Default behaviour is to silently discard errors
53
52
  end
54
53
 
55
- def __update_context(parent)
56
- case parent
57
- when Hash
58
- __update_with_locals(parent)
59
- when Cutaneous::Context
54
+ def __update_context(locals, parent)
55
+ unless parent.nil?
60
56
  parent.instance_variables.reject { |var| /^@__/o === var.to_s }.each do |variable|
61
57
  instance_variable_set(variable, parent.instance_variable_get(variable))
62
58
  end
63
59
  __update_with_locals(parent.__locals) if parent.respond_to?(:__locals)
64
60
  end
61
+ __update_with_locals(locals)
65
62
  end
66
63
 
67
64
  # Sets up the local variables and also creates singleton methods on this
@@ -7,7 +7,7 @@ module Cutaneous
7
7
 
8
8
  def initialize(template_roots, syntax = Cutaneous::FirstPassSyntax, default_format = "html")
9
9
  @roots = Array(template_roots)
10
- @syntax = syntax
10
+ @syntax = syntax
11
11
  @loader_class = FileLoader
12
12
  @default_format = default_format
13
13
  end
@@ -24,7 +24,7 @@ module Cutaneous
24
24
 
25
25
  # Create and cache a file loader on a per-format basis
26
26
  def file_loader(format)
27
- file_loader_instance(format.to_s).tap do |loader|
27
+ file_loader_instance(format.to_sym).tap do |loader|
28
28
  loader.syntax = @syntax
29
29
  end
30
30
  end
data/lib/cutaneous.rb CHANGED
@@ -7,7 +7,7 @@ require 'cutaneous/lexer'
7
7
  require 'cutaneous/compiler'
8
8
 
9
9
  module Cutaneous
10
- VERSION = "0.1.6"
10
+ VERSION = "0.1.7"
11
11
 
12
12
  class CompilationError < Exception; end
13
13
 
data/test/helper.rb CHANGED
@@ -9,7 +9,7 @@ class TestContext < Cutaneous::Context
9
9
  end
10
10
 
11
11
  class MiniTest::Spec
12
- def ContextHash(params = {})
13
- TestContext.new(Object.new, params)
12
+ def ContextHash(params = {}, parent = nil)
13
+ TestContext.new(Object.new, params, parent)
14
14
  end
15
15
  end
data/test/test_core.rb CHANGED
@@ -217,7 +217,7 @@ describe Cutaneous do
217
217
  it "Passes any instance variables & locals between contexts" do
218
218
  context = ContextHash(right: "left")
219
219
  result1 = engine.render("instance", context)
220
- context = ContextHash(context)
220
+ context = ContextHash({}, context)
221
221
  result2 = engine.render("instance", context)
222
222
  result2.must_equal result1
223
223
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutaneous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garry Hill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-14 00:00:00.000000000 Z
11
+ date: 2013-11-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Cutaneous is the Ruby templating language designed for use with Spontaneous
14
14
  CMS. It has a simple syntax but powerful features such as Djano style template inheritance