nm 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ data.tar.gz: a775f8cf829f10a9890879b5a8f227da85eca3a7
4
+ metadata.gz: 43d84fe3504eccd6241abaf2a1842d511410323d
5
+ SHA512:
6
+ data.tar.gz: 049217416ebbbc9e98bc3a464ceff8e35111929eb6c9a1b06655a1e1abfa90cddbb5c9d63648d80f3996539828fe93ade692f66377267f5adc899c7cc40b287d
7
+ metadata.gz: de20fcd9575520aec65cc71137448b32ba1fcb129399222f1086e14af899493ca6e6f454622b23c52f86be0b7e95dfe6a61fa77fffa9bd20e6b472a96f06e778
data/Gemfile CHANGED
@@ -2,12 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rake'
6
- gem 'pry'
5
+ gem 'pry', "~> 0.9.0"
7
6
  gem "whysoslow"
8
-
9
7
  gem 'rabl'
10
-
11
- platform :rbx do
12
- gem 'rubysl'
13
- end
File without changes
data/README.md CHANGED
@@ -125,8 +125,7 @@ This will render the same output as above.
125
125
 
126
126
  ### Markup Aliases
127
127
 
128
- If you find you need to use a local named `node` or `map`, these markup methods are aliased as
129
- `n`, `_node`, `m`, and `_map` respectively. Any combination of aliases is valid:
128
+ If you find you need to use a local named `node` or `map`, the markup methods are aliased as `n`, `_node`, `m`, and `_map` respectively. Any combination of aliases is valid:
130
129
 
131
130
  ```ruby
132
131
  node 'slideshow' do
data/lib/nm.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "nm/version"
2
2
  require 'nm/source'
3
3
 
4
- module Nm
5
- end
4
+ module Nm; end
@@ -5,8 +5,6 @@ module Nm
5
5
 
6
6
  class Source
7
7
 
8
- EXT = ".nm"
9
-
10
8
  attr_reader :root, :cache, :template_class
11
9
 
12
10
  def initialize(root, opts = nil)
@@ -29,22 +27,22 @@ module Nm
29
27
  end
30
28
  end
31
29
 
32
- def render(file_name, locals = nil)
33
- @template_class.new(self, source_file_path(file_name), locals || {}).__data__
30
+ def render(template_name, locals = nil)
31
+ @template_class.new(self, source_file_path(template_name), locals || {}).__data__
34
32
  end
35
33
 
36
34
  alias_method :partial, :render
37
35
 
38
36
  private
39
37
 
40
- def source_file_path(file_name)
41
- self.root.join("#{file_name}#{EXT}").to_s
38
+ def source_file_path(template_name)
39
+ Dir.glob(self.root.join("#{template_name}*")).first
42
40
  end
43
41
 
44
42
  class NullCache
45
- def [](file_name); end
46
- def []=(file_name, value); end
47
- def keys; []; end
43
+ def [](template_name); end
44
+ def []=(template_name, value); end
45
+ def keys; []; end
48
46
  end
49
47
 
50
48
  end
@@ -1,3 +1,3 @@
1
1
  module Nm
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/nm.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Nm::VERSION
9
9
  gem.authors = ["Kelly Redding", "Collin Redding"]
10
10
  gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
11
- gem.description = %q{Data templating system.}
12
11
  gem.summary = %q{Data templating system.}
12
+ gem.description = %q{Data templating system.}
13
13
  gem.homepage = "http://github.com/redding/nm"
14
14
  gem.license = 'MIT'
15
15
 
@@ -21,6 +21,6 @@ Gem::Specification.new do |gem|
21
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
22
  gem.require_paths = ["lib"]
23
23
 
24
- gem.add_development_dependency("assert", ["~> 2.12"])
24
+ gem.add_development_dependency("assert", ["~> 2.15.1"])
25
25
 
26
26
  end
@@ -0,0 +1,3 @@
1
+ node 'locals' do
2
+ node 'key', key
3
+ end
@@ -12,10 +12,6 @@ class Nm::Source
12
12
  end
13
13
  subject{ @source_class }
14
14
 
15
- should "know its extension" do
16
- assert_equal ".nm", subject::EXT
17
- end
18
-
19
15
  end
20
16
 
21
17
  class InitTests < UnitTests
@@ -88,19 +84,19 @@ class Nm::Source
88
84
  class RenderTests < InitTests
89
85
  desc "`render` method"
90
86
  setup do
91
- @file_name = "locals"
87
+ @template_name = ['locals', 'locals_alt'].choice
92
88
  @file_locals = { 'key' => 'a-value' }
93
- @file_path = Factory.template_file("#{@file_name}#{@source_class::EXT}")
89
+ @file_path = Dir.glob("#{Factory.template_file(@template_name)}*").first
94
90
  end
95
91
 
96
- should "render a template for the given file name and return its data" do
92
+ should "render a template for the given template name and return its data" do
97
93
  exp = Nm::Template.new(subject, @file_path, @file_locals).__data__
98
- assert_equal exp, subject.render(@file_name, @file_locals)
94
+ assert_equal exp, subject.render(@template_name, @file_locals)
99
95
  end
100
96
 
101
97
  should "alias `render` as `partial`" do
102
- exp = subject.render(@file_name, @file_locals)
103
- assert_equal exp, subject.partial(@file_name, @file_locals)
98
+ exp = subject.render(@template_name, @file_locals)
99
+ assert_equal exp, subject.partial(@template_name, @file_locals)
104
100
  end
105
101
 
106
102
  end
@@ -137,7 +137,7 @@ class Nm::Template
137
137
  setup do
138
138
  @source = Nm::Source.new(Factory.template_root)
139
139
 
140
- @obj_file_name = "obj"
140
+ @obj_template_name = "obj"
141
141
  @obj = {
142
142
  'obj' => {
143
143
  'a' => 'Aye',
@@ -146,7 +146,7 @@ class Nm::Template
146
146
  }
147
147
  }
148
148
 
149
- @list_file_name = "list"
149
+ @list_template_name = "list"
150
150
  @list = [
151
151
  { '1' => 1 },
152
152
  { '2' => 2 },
@@ -159,23 +159,23 @@ class Nm::Template
159
159
  class RenderMethodTests < RenderTests
160
160
  desc "`render` method"
161
161
 
162
- should "render a template for the given file name and add its data" do
162
+ should "render a template for the given template name and add its data" do
163
163
  t = Nm::Template.new(@source)
164
- assert_equal @obj, t.__render__(@obj_file_name).__data__
164
+ assert_equal @obj, t.__render__(@obj_template_name).__data__
165
165
  end
166
166
 
167
167
  should "be aliased as `render`, `_render` and `r`" do
168
168
  t = Nm::Template.new(@source)
169
- assert_equal @obj, t.__render__(@obj_file_name).__data__
169
+ assert_equal @obj, t.__render__(@obj_template_name).__data__
170
170
 
171
171
  t = Nm::Template.new(@source)
172
- assert_equal @obj, t.render(@obj_file_name).__data__
172
+ assert_equal @obj, t.render(@obj_template_name).__data__
173
173
 
174
174
  t = Nm::Template.new(@source)
175
- assert_equal @obj, t._render(@obj_file_name).__data__
175
+ assert_equal @obj, t._render(@obj_template_name).__data__
176
176
 
177
177
  t = Nm::Template.new(@source)
178
- assert_equal @obj, t.r(@obj_file_name).__data__
178
+ assert_equal @obj, t.r(@obj_template_name).__data__
179
179
  end
180
180
 
181
181
  should "merge if call returns an obj and called after a `__node__` call" do
@@ -183,14 +183,14 @@ class Nm::Template
183
183
  t.__node__('1', 'One')
184
184
 
185
185
  exp = {'1' => 'One'}.merge(@obj)
186
- assert_equal exp, t.__render__(@obj_file_name).__data__
186
+ assert_equal exp, t.__render__(@obj_template_name).__data__
187
187
  end
188
188
 
189
189
  should "complain if call returns an obj and called after a `__map__` call" do
190
190
  t = Nm::Template.new(@source)
191
191
  t.__map__([1,2,3])
192
192
  assert_raises Nm::InvalidError do
193
- t.__render__(@obj_file_name).__data__
193
+ t.__render__(@obj_template_name).__data__
194
194
  end
195
195
  end
196
196
 
@@ -199,7 +199,7 @@ class Nm::Template
199
199
  t.__map__([1,2,3])
200
200
 
201
201
  exp = [1,2,3].concat(@list)
202
- assert_equal exp, t.__render__(@list_file_name).__data__
202
+ assert_equal exp, t.__render__(@list_template_name).__data__
203
203
  end
204
204
 
205
205
  should "complain if call returns a list and called after a `__node__` call" do
@@ -207,7 +207,7 @@ class Nm::Template
207
207
  t.__node__('1', 'One')
208
208
 
209
209
  assert_raises Nm::InvalidError do
210
- t.__render__(@list_file_name).__data__
210
+ t.__render__(@list_template_name).__data__
211
211
  end
212
212
  end
213
213
 
@@ -216,33 +216,33 @@ class Nm::Template
216
216
  class PartialMethodTests < RenderTests
217
217
  desc "`partial` method"
218
218
  setup do
219
- @partial_obj_file_name = "_obj"
219
+ @partial_obj_template_name = "_obj"
220
220
  @partial_obj = {
221
221
  'a' => 'Aye',
222
222
  'b' => 'Bee',
223
223
  'c' => 'See'
224
224
  }
225
- @partial_list_file_name = "_list"
225
+ @partial_list_template_name = "_list"
226
226
  @partial_list = @list
227
227
  end
228
228
 
229
229
  should "render a template for the given partial name and add its data" do
230
230
  t = Nm::Template.new(@source)
231
- assert_equal @partial_obj, t.__partial__(@partial_obj_file_name).__data__
231
+ assert_equal @partial_obj, t.__partial__(@partial_obj_template_name).__data__
232
232
  end
233
233
 
234
234
  should "be aliased as `render`, `_render` and `r`" do
235
235
  t = Nm::Template.new(@source)
236
- assert_equal @partial_obj, t.__partial__(@partial_obj_file_name).__data__
236
+ assert_equal @partial_obj, t.__partial__(@partial_obj_template_name).__data__
237
237
 
238
238
  t = Nm::Template.new(@source)
239
- assert_equal @partial_obj, t.partial(@partial_obj_file_name).__data__
239
+ assert_equal @partial_obj, t.partial(@partial_obj_template_name).__data__
240
240
 
241
241
  t = Nm::Template.new(@source)
242
- assert_equal @partial_obj, t._partial(@partial_obj_file_name).__data__
242
+ assert_equal @partial_obj, t._partial(@partial_obj_template_name).__data__
243
243
 
244
244
  t = Nm::Template.new(@source)
245
- assert_equal @partial_obj, t.p(@partial_obj_file_name).__data__
245
+ assert_equal @partial_obj, t.p(@partial_obj_template_name).__data__
246
246
  end
247
247
 
248
248
  should "merge if call returns an obj and called after a `__node__` call" do
@@ -250,14 +250,14 @@ class Nm::Template
250
250
  t.__node__('1', 'One')
251
251
 
252
252
  exp = {'1' => 'One'}.merge(@partial_obj)
253
- assert_equal exp, t.__partial__(@partial_obj_file_name).__data__
253
+ assert_equal exp, t.__partial__(@partial_obj_template_name).__data__
254
254
  end
255
255
 
256
256
  should "complain if call returns an obj and called after a `__map__` call" do
257
257
  t = Nm::Template.new(@source)
258
258
  t.__map__([1,2,3])
259
259
  assert_raises Nm::InvalidError do
260
- t.__partial__(@partial_obj_file_name).__data__
260
+ t.__partial__(@partial_obj_template_name).__data__
261
261
  end
262
262
  end
263
263
 
@@ -266,7 +266,7 @@ class Nm::Template
266
266
  t.__map__([1,2,3])
267
267
 
268
268
  exp = [1,2,3].concat(@partial_list)
269
- assert_equal exp, t.__partial__(@partial_list_file_name).__data__
269
+ assert_equal exp, t.__partial__(@partial_list_template_name).__data__
270
270
  end
271
271
 
272
272
  should "complain if call returns a list and called after a `__node__` call" do
@@ -274,7 +274,7 @@ class Nm::Template
274
274
  t.__node__('1', 'One')
275
275
 
276
276
  assert_raises Nm::InvalidError do
277
- t.__partial__(@partial_list_file_name).__data__
277
+ t.__partial__(@partial_list_template_name).__data__
278
278
  end
279
279
  end
280
280
 
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
4
+ version: 0.5.1
11
5
  platform: ruby
12
6
  authors:
13
7
  - Kelly Redding
@@ -16,23 +10,18 @@ autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
12
 
19
- date: 2015-01-19 00:00:00 Z
13
+ date: 2016-04-05 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
16
+ name: assert
17
+ prerelease: false
22
18
  requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
19
  requirements:
25
20
  - - ~>
26
21
  - !ruby/object:Gem::Version
27
- hash: 27
28
- segments:
29
- - 2
30
- - 12
31
- version: "2.12"
22
+ version: 2.15.1
32
23
  type: :development
33
- name: assert
34
24
  version_requirements: *id001
35
- prerelease: false
36
25
  description: Data templating system.
37
26
  email:
38
27
  - kelly@kellyredding.com
@@ -46,9 +35,8 @@ extra_rdoc_files: []
46
35
  files:
47
36
  - .gitignore
48
37
  - Gemfile
49
- - LICENSE.txt
38
+ - LICENSE
50
39
  - README.md
51
- - Rakefile
52
40
  - lib/nm.rb
53
41
  - lib/nm/ext.rb
54
42
  - lib/nm/source.rb
@@ -64,6 +52,7 @@ files:
64
52
  - test/support/templates/aliases.nm
65
53
  - test/support/templates/list.nm
66
54
  - test/support/templates/locals.nm
55
+ - test/support/templates/locals_alt.inem
67
56
  - test/support/templates/obj.nm
68
57
  - test/unit/ext_tests.rb
69
58
  - test/unit/source_tests.rb
@@ -72,35 +61,28 @@ files:
72
61
  homepage: http://github.com/redding/nm
73
62
  licenses:
74
63
  - MIT
64
+ metadata: {}
65
+
75
66
  post_install_message:
76
67
  rdoc_options: []
77
68
 
78
69
  require_paths:
79
70
  - lib
80
71
  required_ruby_version: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ">="
73
+ - &id002
74
+ - ">="
84
75
  - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
76
  version: "0"
89
77
  required_rubygems_version: !ruby/object:Gem::Requirement
90
- none: false
91
78
  requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
79
+ - *id002
98
80
  requirements: []
99
81
 
100
82
  rubyforge_project:
101
- rubygems_version: 1.8.25
83
+ rubygems_version: 2.5.1
102
84
  signing_key:
103
- specification_version: 3
85
+ specification_version: 4
104
86
  summary: Data templating system.
105
87
  test_files:
106
88
  - test/helper.rb
@@ -111,6 +93,7 @@ test_files:
111
93
  - test/support/templates/aliases.nm
112
94
  - test/support/templates/list.nm
113
95
  - test/support/templates/locals.nm
96
+ - test/support/templates/locals_alt.inem
114
97
  - test/support/templates/obj.nm
115
98
  - test/unit/ext_tests.rb
116
99
  - test/unit/source_tests.rb
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"