deas-nm 0.2.0 → 0.3.0

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/deas-nm.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_development_dependency("assert", ["~> 2.12"])
22
22
 
23
- gem.add_dependency("deas", ["~> 0.28"])
23
+ gem.add_dependency("deas", ["~> 0.29"])
24
24
  gem.add_dependency("nm", ["~> 0.4"])
25
25
 
26
26
  end
data/lib/deas-nm.rb CHANGED
@@ -28,21 +28,21 @@ module Deas::Nm
28
28
  @nm_serializer ||= (self.opts['serializer'] || DEFAULT_SERIALIZER)
29
29
  end
30
30
 
31
- def render(template_name, view_handler, locals)
31
+ def render(template_name, view_handler, locals, &content)
32
32
  self.nm_serializer.call(
33
33
  self.nm_source.render(template_name, render_locals(view_handler, locals)),
34
34
  template_name
35
35
  )
36
36
  end
37
37
 
38
- def partial(template_name, locals)
38
+ def partial(template_name, locals, &content)
39
39
  self.nm_serializer.call(
40
40
  self.nm_source.render(template_name, locals),
41
41
  template_name
42
42
  )
43
43
  end
44
44
 
45
- def capture_partial(template_name, locals, &content)
45
+ def compile(template_name, compiled_content)
46
46
  raise NotImplementedError
47
47
  end
48
48
 
@@ -1,4 +1,4 @@
1
1
  module Deas; end
2
2
  module Deas::Nm
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
@@ -0,0 +1,39 @@
1
+ require 'assert'
2
+ require 'deas-nm'
3
+
4
+ class Deas::Nm::TemplateEngine
5
+
6
+ class SystemTests < Assert::Context
7
+ desc "Deas::Nm::TemplateEngine"
8
+ setup do
9
+ @view = OpenStruct.new({
10
+ :identifier => Factory.integer,
11
+ :name => Factory.string
12
+ })
13
+ @locals = { 'local1' => Factory.string }
14
+
15
+ @engine = Deas::Nm::TemplateEngine.new({
16
+ 'source_path' => TEST_SUPPORT_PATH,
17
+ 'serializer' => proc{ |obj, template_name| obj.to_s }
18
+ })
19
+ end
20
+ subject{ @engine }
21
+
22
+ should "render nm template files and serialize them" do
23
+ exp = Factory.template_json_rendered(subject, @view, @locals).to_s
24
+ assert_equal exp, subject.render('template.json', @view, @locals)
25
+ end
26
+
27
+ should "render nm partials and serialize them" do
28
+ exp = Factory.partial_json_rendered(subject, @locals).to_s
29
+ assert_equal exp, subject.partial('_partial.json', @locals)
30
+ end
31
+
32
+ should "render nm templates that render partials and serialize them" do
33
+ exp = Factory.template_partial_json_rendered(subject, @view, @locals).to_s
34
+ assert_equal exp, subject.render('template_partial.json', @view, @locals)
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -17,7 +17,7 @@ class Deas::Nm::TemplateEngine
17
17
 
18
18
  should have_imeths :nm_source, :nm_handler_local, :nm_logger_local
19
19
  should have_imeths :nm_serializer
20
- should have_imeths :render, :partial, :capture_partial
20
+ should have_imeths :render, :partial, :compile
21
21
 
22
22
  should "be a Deas template engine" do
23
23
  assert_kind_of Deas::TemplateEngine, subject
@@ -54,53 +54,12 @@ class Deas::Nm::TemplateEngine
54
54
  assert_equal obj, subject.nm_serializer.call(obj, Factory.string)
55
55
  end
56
56
 
57
- should "render nm template files and serialize them" do
58
- engine = Deas::Nm::TemplateEngine.new({
59
- 'source_path' => TEST_SUPPORT_PATH,
60
- 'serializer' => proc{ |obj, template_name| obj.to_s }
61
- })
62
- view_handler = OpenStruct.new({
63
- :identifier => Factory.integer,
64
- :name => Factory.string
65
- })
66
- locals = { 'local1' => Factory.string }
67
- exp = Factory.template_json_rendered(engine, view_handler, locals).to_s
68
-
69
- assert_equal exp, engine.render('template.json', view_handler, locals)
70
- end
71
-
72
- should "render nm partials and serialize them" do
73
- engine = Deas::Nm::TemplateEngine.new({
74
- 'source_path' => TEST_SUPPORT_PATH,
75
- 'serializer' => proc{ |obj, template_name| obj.to_s }
76
- })
77
- locals = { 'local1' => Factory.string }
78
- exp = Factory.partial_json_rendered(engine, locals).to_s
79
-
80
- assert_equal exp, engine.partial('_partial.json', locals)
81
- end
82
-
83
- should "not implement the engine capture partial method" do
57
+ should "not implement the engine compile method" do
84
58
  assert_raises NotImplementedError do
85
- subject.capture_partial('_partial.json', {})
59
+ subject.compile('_partial.json', Factory.text)
86
60
  end
87
61
  end
88
62
 
89
- should "render nm templates that render partials and serialize them" do
90
- engine = Deas::Nm::TemplateEngine.new({
91
- 'source_path' => TEST_SUPPORT_PATH,
92
- 'serializer' => proc{ |obj, template_name| obj.to_s }
93
- })
94
- view_handler = OpenStruct.new({
95
- :identifier => Factory.integer,
96
- :name => Factory.string
97
- })
98
- locals = { 'local1' => Factory.string }
99
- exp = Factory.template_partial_json_rendered(engine, view_handler, locals).to_s
100
-
101
- assert_equal exp, engine.render('template_partial.json', view_handler, locals)
102
- end
103
-
104
63
  end
105
64
 
106
65
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deas-nm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-11-25 00:00:00 Z
19
+ date: 2015-01-08 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -39,11 +39,11 @@ dependencies:
39
39
  requirements:
40
40
  - - ~>
41
41
  - !ruby/object:Gem::Version
42
- hash: 51
42
+ hash: 49
43
43
  segments:
44
44
  - 0
45
- - 28
46
- version: "0.28"
45
+ - 29
46
+ version: "0.29"
47
47
  type: :runtime
48
48
  name: deas
49
49
  version_requirements: *id002
@@ -88,6 +88,7 @@ files:
88
88
  - test/support/factory.rb
89
89
  - test/support/template.json.nm
90
90
  - test/support/template_partial.json.nm
91
+ - test/system/template_engine_tests.rb
91
92
  - test/unit/template_engine_tests.rb
92
93
  - tmp/.gitkeep
93
94
  homepage: http://github.com/redding/deas-nm
@@ -129,4 +130,5 @@ test_files:
129
130
  - test/support/factory.rb
130
131
  - test/support/template.json.nm
131
132
  - test/support/template_partial.json.nm
133
+ - test/system/template_engine_tests.rb
132
134
  - test/unit/template_engine_tests.rb