clerq 0.3.3 → 0.3.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b4f176e14fda651b8525a736fa58e13067aa7fe1921c654b42f846c0fd16db3
4
- data.tar.gz: 1da7ae883db48480c39329da9edd22be59497084f5dc9f7d94b202a0787df787
3
+ metadata.gz: 74e2ec342a403fb52eef258b5c8e537c9b64ec266f31f934edaaefe8cffadfd1
4
+ data.tar.gz: 1f2baaec876667bfd67d99e75d36abc20e4f1ddcbe99e60687093d48325b51f9
5
5
  SHA512:
6
- metadata.gz: a860df3d47d44149ceb5794d1c80b8ca850311c02d73177492538eb354b455bd4aecdec0a2217972a21613919c33ca3967c9d95bfb3eaf80517df5b138656e32
7
- data.tar.gz: 6350de56e1620422880c76ce19d9daea6c0bc9549edb1719eee3c8ef7bb2453b063852489698464fd2049e1f11e2845b0d0f1b77319f91f9179a6353f962bd62
6
+ metadata.gz: 0dafc680ff7353b9102d2f8d869258c19980d2b35202c2c2fc10de639cd3223d619af8726e592a65924f5c30bcee0fc0ded2ab6923df193ac1dd5fdbed597b1b
7
+ data.tar.gz: b6f732d36363c8a5eb4d283b14fa27c209909724820676b19541d767cee77cae69113dad1fea454e7aaf474c4ac06982543a9ffe34fbc337ad8a24c57dd38ca2
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Change log
2
2
 
3
- ## 0.3.3 (2021-07-05)
3
+ ## 0.3.4 (2021-06-01)
4
+
5
+ * Now the gem works for both Ruby versions 2.X and 3.X.
6
+ * Improved templates. MarkupNode was extracted to separate file and single template defalult.md.erb was left; cleaned templates tests.
7
+ * Improved `promo:publish` command and now it's using default.md.erb
8
+
9
+ ## 0.3.3 (2021-05-25)
4
10
 
5
11
  * Updated keyword argument in Service class to support Ruby 3. If you need Ruby 2.X support, you should use v0.3.2.
6
12
  * Updated `minitest`, `bundler` and `thor` dependencies.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clerq (0.3.3)
4
+ clerq (0.3.4)
5
5
  thor (~> 1.0.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -18,11 +18,19 @@ Install it yourself as:
18
18
 
19
19
  $ gem install clerq
20
20
 
21
- For Ruby 2.X you should use version 0.3.2:
21
+ ## Promo
22
22
 
23
- $ gem install clerq -v 0.3.2
23
+ ![Clerq Promo Project](promo.png)
24
24
 
25
- It's because of keyword arguments changes in Ruby 3
25
+ Inside Clerq there is a demo project that was created and is still used to develop Clerq itself and its script-extensions. You can see the project [here](https://github.com/nvoynov/clerq/tree/master/lib/assets/promo) ([requirements sources](https://github.com/nvoynov/clerq/tree/master/lib/assets/promo/src) and produced documents [Clerq SRS.md](https://github.com/nvoynov/clerq/blob/master/lib/assets/promo/bin/Clerq%20SRS.md), [Clerq SRS.docx](https://github.com/nvoynov/clerq/blob/master/lib/assets/promo/bin/Clerq%20SRS.docx))
26
+
27
+ I am sure this project will be useful when you get to know the product. So, I propose to open it now and look inside as you move forward. Do the following in your console:
28
+
29
+ $ clerq new promo
30
+ $ cd promo
31
+ $ clerq promo
32
+ $ atom .
33
+ $ thor list
26
34
 
27
35
  ## Usage
28
36
 
@@ -65,7 +73,7 @@ Where
65
73
  * `#` familiar markdown header that indicates a new `node`;
66
74
  * `[p1]` is an optional identifier that becomes `node.id`;
67
75
  * `Part two` is an optional `node.title`;
68
- * `{{parent: top}}` in an optional metadata section that becomes `node.meta`;
76
+ * `{{parent: top}}` is an optional metadata section that becomes `node.meta`;
69
77
  * and finally `Body` is an optional `node.body`.
70
78
 
71
79
  ```markdown
@@ -140,7 +148,7 @@ parent: r}}
140
148
 
141
149
  #### Assets
142
150
 
143
- When you want to provide some assets or links to something outside the repository you can provide the lint to the assets. Put the asset in the `bin/assets` folder and specify the link.
151
+ When you want to provide some assets or links to something outside the repository you can provide the link to the assets. Put the asset in the `bin/assets` folder and specify the link.
144
152
 
145
153
  ```markdown
146
154
  # [ent] Entities
@@ -237,9 +245,9 @@ Clerq provides the following main service objects:
237
245
  * `LoadAssembly` loads whole repository to Node class;
238
246
  * `CheckAssembly` checks the assembly for errors (ids and links);
239
247
  * `QueryNode` provides ability to query nodes from assembly;
240
- * `QueryTemplate` return template by the template name;
248
+ * `QueryTemplate` returns template by the template name;
241
249
  * `CreateNode` crates new node in the repository;
242
- * `RenderNode` return text rendered by ERB.
250
+ * `RenderNode` returns text rendered by ERB.
243
251
 
244
252
  The first part of each repository related task is to get repository assembly. It can be performed through `NodeRepository#assemble` or `LoadAssembly.call()`. Each of these methods returns Node that provides [Enumerable](https://ruby-doc.org/core-2.6.5/Enumerable.html) interface.
245
253
 
@@ -330,21 +338,22 @@ And then you can run the task by
330
338
 
331
339
  This example is just very basic and your automation scripts could be much more complex.
332
340
 
333
- Another quick example is [clerq.thor] (https://github.com/nvoynov/clerq/blob/master/clerq.thor) file that was created just to overcome handling curly bracket `{{}}` in Jekyll and now I run `thor clerqsrc:docs` every time after changing this file.
341
+ Another quick example is the [clerq.thor](https://github.com/nvoynov/clerq/blob/master/clerq.thor) file that was created just to overcome handling curly bracket `{{}}` in Jekyll and now I run `thor clerq:src:docs` every time after changing this file.
334
342
 
335
343
  ### Templating
336
344
 
337
- The Clerq provides the ability to precise adjusting the output for `clerq build` command by erb-templates and gives you two basic templates from the box.
345
+ The output of the `clerq build` command can be precisely adjusted by modifying the corresponding "erb" template.
338
346
 
339
- * [default.md.erb](https://github.com/nvoynov/clerq/blob/master/lib/assets/tt/default.md.erb) that just combines all nodes to one markdown document;
340
- * [pandoc.md.erb](https://github.com/nvoynov/clerq/blob/master/lib/assets/tt/pandoc.md.erb) is more advanced, it produces [Pandoc's Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown) and provides three followed macros for node body:
341
- * `{{@@list}}` - replaces the macro with the list of child nodes;
342
- * `{{@@tree}}` - replaces the macro with the tree of child nodes;
343
- * `{{@@skip}}` - skip all content inside the brackets.
347
+ One can see the standard template in [default.md.erb](https://github.com/nvoynov/clerq/blob/master/lib/assets/tt/default.md.erb). It produced output in [Pandoc's Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown) format and supports the following macros in node body:
348
+
349
+ * `{{@@list}}` - replaces the macro with the list of child nodes;
350
+ * `{{@@tree}}` - replaces the macro with the tree of child nodes;
351
+ * `{{@@eval}}` - eval ruby code inside the brackets;
352
+ * `{{@@skip}}` - skip all content inside the brackets.
344
353
 
345
354
  ### Publishing
346
355
 
347
- In addition to the `clerq build` command in [lib/clerq_doc.thor](https://github.com/nvoynov/clerq/blob/master/lib/assets/lib/clerq_doc.rb) I provided the example of basic documents management tasks (it will be placed in new project `lib` folder). You can find there two example of commands that you can start your own publishing automation.
356
+ In addition to the `clerq build` command one can find an example of basic documents management tasks in the [lib/clerq_doc.thor](https://github.com/nvoynov/clerq/blob/master/lib/assets/lib/clerq_doc.thor) (it will be placed in new project `lib` folder). You can find there two example of commands that you can start your own publishing automation.
348
357
 
349
358
  * `thor clerq:doc:publish` will create `<project>.docx` and `<project>.html`;
350
359
  * `thor clerq:doc:grab` will import provided document into the current project repository.
@@ -355,10 +364,6 @@ In addition to the `clerq build` command in [lib/clerq_doc.thor](https://github.
355
364
 
356
365
  The one issue I certain in is when you are using different version of thor, your custom scripts won't work.
357
366
 
358
- ### Test suite
359
-
360
- Because `default.md.erb` and `pandoc.md.erb` have inside the same class `MarkupNode`, sometimes one of `default_spec.rb` or `pandoc_spec.rb` fails.
361
-
362
367
  ## Some considerations
363
368
 
364
369
  ### Some obvious things
@@ -369,10 +374,6 @@ Hold your projects in Git.
369
374
 
370
375
  Use pandoc for generating output in different formats
371
376
 
372
- ### MarkupNode
373
-
374
- Don't like the current dirty solution with templates and incorporated MarkupNode that does all that stuff with macro. It is the first attempt to provide template that can skip comments.
375
-
376
377
  ### Several artifacts
377
378
 
378
379
  Because Clerq has `-q/--query QUERY_STRING` option you can be interested in developing several different artifacts in one project.
data/docs/README.md CHANGED
@@ -18,6 +18,20 @@ Install it yourself as:
18
18
 
19
19
  $ gem install clerq
20
20
 
21
+ ## Promo
22
+
23
+ ![Clerq Promo Project](promo.png)
24
+
25
+ Inside Clerq there is a demo project that was created and is still used to develop Clerq itself and its script-extensions. You can see the project [here](https://github.com/nvoynov/clerq/tree/master/lib/assets/promo) ([requirements sources](https://github.com/nvoynov/clerq/tree/master/lib/assets/promo/src) and produced documents [Clerq SRS.md](https://github.com/nvoynov/clerq/blob/master/lib/assets/promo/bin/Clerq%20SRS.md), [Clerq SRS.docx](https://github.com/nvoynov/clerq/blob/master/lib/assets/promo/bin/Clerq%20SRS.docx))
26
+
27
+ I am sure this project will be useful when you get to know the product. So, I propose to open it now and look inside as you move forward. Do the following in your console:
28
+
29
+ $ clerq new promo
30
+ $ cd promo
31
+ $ clerq promo
32
+ $ atom .
33
+ $ thor list
34
+
21
35
  ## Usage
22
36
 
23
37
  The Clerq is entirely based on one single domain entity `Node` that represents a node of tree hierarchy and provides `id`, `title`, `body`, and `metadata` attributes. It supposes the following simple workflow:
@@ -61,7 +75,7 @@ Where
61
75
  * `#` familiar markdown header that indicates a new `node`;
62
76
  * `[p1]` is an optional identifier that becomes `node.id`;
63
77
  * `Part two` is an optional `node.title`;
64
- * {% raw %}`{{parent: top}}`{% endraw %} in an optional metadata section that becomes `node.meta`;
78
+ * {% raw %}`{{parent: top}}`{% endraw %} is an optional metadata section that becomes `node.meta`;
65
79
  * and finally `Body` is an optional `node.body`.
66
80
 
67
81
  {% raw %}
@@ -146,7 +160,7 @@ parent: r}}
146
160
 
147
161
  #### Assets
148
162
 
149
- When you want to provide some assets or links to something outside the repository you can provide the lint to the assets. Put the asset in the `bin/assets` folder and specify the link.
163
+ When you want to provide some assets or links to something outside the repository you can provide the link to the assets. Put the asset in the `bin/assets` folder and specify the link.
150
164
 
151
165
  {% raw %}
152
166
  ```markdown
@@ -245,9 +259,9 @@ Clerq provides the following main service objects:
245
259
  * `LoadAssembly` loads whole repository to Node class;
246
260
  * `CheckAssembly` checks the assembly for errors (ids and links);
247
261
  * `QueryNode` provides ability to query nodes from assembly;
248
- * `QueryTemplate` return template by the template name;
262
+ * `QueryTemplate` returns template by the template name;
249
263
  * `CreateNode` crates new node in the repository;
250
- * `RenderNode` return text rendered by ERB.
264
+ * `RenderNode` returns text rendered by ERB.
251
265
 
252
266
  The first part of each repository related task is to get repository assembly. It can be performed through `NodeRepository#assemble` or `LoadAssembly.call()`. Each of these methods returns Node that provides [Enumerable](https://ruby-doc.org/core-2.6.5/Enumerable.html) interface.
253
267
 
@@ -342,21 +356,22 @@ And then you can run the task by
342
356
 
343
357
  This example is just very basic and your automation scripts could be much more complex.
344
358
 
345
- Another quick example is [clerq.thor] (https://github.com/nvoynov/clerq/blob/master/clerq.thor) file that was created just to overcome handling curly bracket {% raw %}`{{}}`{% endraw %} in Jekyll and now I run `thor clerqsrc:docs` every time after changing this file.
359
+ Another quick example is the [clerq.thor](https://github.com/nvoynov/clerq/blob/master/clerq.thor) file that was created just to overcome handling curly bracket {% raw %}`{{}}`{% endraw %} in Jekyll and now I run `thor clerq:src:docs` every time after changing this file.
346
360
 
347
361
  ### Templating
348
362
 
349
- The Clerq provides the ability to precise adjusting the output for `clerq build` command by erb-templates and gives you two basic templates from the box.
363
+ The output of the `clerq build` command can be precisely adjusted by modifying the corresponding "erb" template.
350
364
 
351
- * [default.md.erb](https://github.com/nvoynov/clerq/blob/master/lib/assets/tt/default.md.erb) that just combines all nodes to one markdown document;
352
- * [pandoc.md.erb](https://github.com/nvoynov/clerq/blob/master/lib/assets/tt/pandoc.md.erb) is more advanced, it produces [Pandoc's Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown) and provides three followed macros for node body:
353
- * {% raw %}`{{@@list}}`{% endraw %} - replaces the macro with the list of child nodes;
354
- * {% raw %}`{{@@tree}}`{% endraw %} - replaces the macro with the tree of child nodes;
355
- * {% raw %}`{{@@skip}}`{% endraw %} - skip all content inside the brackets.
365
+ One can see the standard template in [default.md.erb](https://github.com/nvoynov/clerq/blob/master/lib/assets/tt/default.md.erb). It produced output in [Pandoc's Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown) format and supports the following macros in node body:
366
+
367
+ * {% raw %}`{{@@list}}`{% endraw %} - replaces the macro with the list of child nodes;
368
+ * {% raw %}`{{@@tree}}`{% endraw %} - replaces the macro with the tree of child nodes;
369
+ * {% raw %}`{{@@eval}}`{% endraw %} - eval ruby code inside the brackets;
370
+ * {% raw %}`{{@@skip}}`{% endraw %} - skip all content inside the brackets.
356
371
 
357
372
  ### Publishing
358
373
 
359
- In addition to the `clerq build` command in [lib/clerq_doc.thor](https://github.com/nvoynov/clerq/blob/master/lib/assets/lib/clerq_doc.rb) I provided the example of basic documents management tasks (it will be placed in new project `lib` folder). You can find there two example of commands that you can start your own publishing automation.
374
+ In addition to the `clerq build` command one can find an example of basic documents management tasks in the [lib/clerq_doc.thor](https://github.com/nvoynov/clerq/blob/master/lib/assets/lib/clerq_doc.thor) (it will be placed in new project `lib` folder). You can find there two example of commands that you can start your own publishing automation.
360
375
 
361
376
  * `thor clerq:doc:publish` will create `<project>.docx` and `<project>.html`;
362
377
  * `thor clerq:doc:grab` will import provided document into the current project repository.
@@ -367,10 +382,6 @@ In addition to the `clerq build` command in [lib/clerq_doc.thor](https://github.
367
382
 
368
383
  The one issue I certain in is when you are using different version of thor, your custom scripts won't work.
369
384
 
370
- ### Test suite
371
-
372
- Because `default.md.erb` and `pandoc.md.erb` have inside the same class `MarkupNode`, sometimes one of `default_spec.rb` or `pandoc_spec.rb` fails.
373
-
374
385
  ## Some considerations
375
386
 
376
387
  ### Some obvious things
@@ -381,10 +392,6 @@ Hold your projects in Git.
381
392
 
382
393
  Use pandoc for generating output in different formats
383
394
 
384
- ### MarkupNode
385
-
386
- Don't like the current dirty solution with templates and incorporated MarkupNode that does all that stuff with macro. It is the first attempt to provide template that can skip comments.
387
-
388
395
  ### Several artifacts
389
396
 
390
397
  Because Clerq has `-q/--query QUERY_STRING` option you can be interested in developing several different artifacts in one project.
data/docs/promo.png ADDED
Binary file
@@ -27,7 +27,7 @@ class ClerqDoc < Thor
27
27
  }
28
28
 
29
29
  # Why does one need to grab the document?
30
- # it started in MS Word but the author decieded to pкoceed in Clerq
30
+ # it started in MS Word but the author decieded to proceed in Clerq
31
31
  # it is the source for the clerq project, SRS based on Vision?
32
32
  # something else?
33
33
  # TODO provide -q/--query QUERY_STRING parameter
@@ -0,0 +1,77 @@
1
+ # encoding: UTF-8
2
+
3
+ # Macro that can be used in MarkupNode
4
+ #
5
+ # Usage:
6
+ # node = MarkupNode(Clerq::Entities::Node.new(
7
+ # id: 'id', body: Some text that contains {{@@macro}}")
8
+ # )
9
+ # macro = Macro.new
10
+ # macro.(node.body, node) # "Some text that contains [processed macro]"
11
+ class MarkupMacro
12
+ attr_reader :title, :regex
13
+ # TODO: find more situable name
14
+ # Process macro that must be implemented in subclasses
15
+ # @param macro [String] macrotext
16
+ # @param node [Node] the context in which the macro is processed
17
+ # @return [String] a text processed by macro
18
+ def process(macro, node)
19
+ end
20
+ end
21
+
22
+ # Just skip macro and all the text inside it
23
+ class SkipMacro < MarkupMacro
24
+ def initialize
25
+ @title = "Skip"
26
+ @regex = /{{@@skip[\s\S]*?}}/
27
+ end
28
+
29
+ def process(macro, node = nil)
30
+ ""
31
+ end
32
+ end
33
+
34
+ # Evaluates ruby code placed inside the macro
35
+ class EvalMacro < MarkupMacro
36
+ def initialize
37
+ @title = "Eval"
38
+ @regex = /{{@@eval[\s\S]*?}}/
39
+ @extra = /{{@@eval([\s\S]*?)}}/
40
+ end
41
+
42
+ def process(macro, node)
43
+ body = @extra.match(macro)[1]
44
+ eval(body, binding)
45
+ end
46
+ end
47
+
48
+ # Builds a list of Node#items where items linked to appropriate headers
49
+ class ListMacro < MarkupMacro
50
+ def initialize
51
+ @title = "List"
52
+ @regex = /{{@@list}}/
53
+ end
54
+
55
+ def process(macro, node)
56
+ node.items.inject([]) do |ary, n|
57
+ ary << "* [#{n.title}](##{node.url(n.id)})"
58
+ end.join("\n")
59
+ end
60
+ end
61
+
62
+ # Builds a tree of Node#items where items linked to appropriate headers
63
+ class TreeMacro < MarkupMacro
64
+ def initialize
65
+ @title = "Tree"
66
+ @regex = /{{@@tree}}/
67
+ end
68
+
69
+ def process(macro, node)
70
+ this_level = node.nesting_level + 1
71
+ node.to_a.drop(1).inject([]) do |ary, n|
72
+ lead_spaces = ' ' * (n.nesting_level - this_level)
73
+ ary << "#{lead_spaces}* [#{n.title}](##{node.url(n.id)})"
74
+ end.join("\n")
75
+ end
76
+
77
+ end
@@ -0,0 +1,86 @@
1
+ require 'delegate'
2
+ require_relative 'markup_macro'
3
+
4
+ # MarkupNode is an wrapper introduced to simplify
5
+ # producing Pandoc markdown output.
6
+ # It's a delegator to the Node class
7
+ class MarkupNode < SimpleDelegator
8
+
9
+ # register available macros
10
+ @@macros = Array.new.tap do |ary|
11
+ ary << SkipMacro.new
12
+ ary << ListMacro.new
13
+ ary << TreeMacro.new
14
+ ary << EvalMacro.new
15
+ ary.freeze
16
+ end
17
+
18
+ def markup
19
+ [title, meta, body].select{|part| !part.empty?}.join("\n\n")
20
+ end
21
+
22
+ # @return [String] output text of node.title
23
+ def title
24
+ s = super
25
+ s = ".#{id.split(/\./).last}" if s.empty?
26
+ "#{'#' * nesting_level} #{s} {##{url(id)}}"
27
+ end
28
+
29
+ # @return [String] output text of node.meta
30
+ def meta
31
+ return '' if nesting_level == 0
32
+ return '' if super[:skip_meta]
33
+
34
+ hsh = {id: id}.merge(super)
35
+ hsh.delete(:order_index)
36
+ hsh.delete(:filename)
37
+ hsh.delete(:parent)
38
+ [].tap{|ary|
39
+ ary << "Attribute | Value"
40
+ ary << "--------- | -----"
41
+ hsh.each{|k,v| ary << "#{k} | #{v}"}
42
+ }.join("\n")
43
+ end
44
+
45
+ # @return [String] output text for node.body
46
+ def body
47
+ String.new(super).tap do |txt|
48
+ process_links!(txt)
49
+ process_macro!(txt)
50
+ txt.gsub!(/^$\n{2,}/, "\n")
51
+ end
52
+ end
53
+
54
+ # @return [String] output text for link [[node.id]]
55
+ def link(ref)
56
+ node = root.find{|n| n.id == ref}
57
+ return "[#{ref}](#unknown)" unless node
58
+ "[#{node.title}](##{url(ref)})"
59
+ end
60
+
61
+ # @return [String] url for node.id
62
+ def url(id)
63
+ r = id.start_with?(/[[:digit:]]/) ? "p#{id}" : id
64
+ r.downcase
65
+ .gsub(/[^A-Za-z0-9]{1,}/, '-')
66
+ .gsub(/^-/, '')
67
+ .gsub(/-$/, '')
68
+ end
69
+
70
+ private
71
+
72
+ # process links and replace macros by markup output
73
+ # @param source [String] input string
74
+ # @return [String] markup output
75
+ def process_links!(source)
76
+ links.each{ |l| source.gsub!("[[#{l}]]", link(l)) }
77
+ end
78
+
79
+ def process_macro!(source)
80
+ @@macros.each do |macro|
81
+ source.scan(macro.regex).each do |i|
82
+ source.gsub!(i, macro.process(i, self))
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,91 @@
1
+ require 'clerq'
2
+ require 'minitest/autorun'
3
+ require_relative "../markup_macro"
4
+ require_relative "../markup_node"
5
+ include Clerq::Entities
6
+
7
+ describe MarkupMacro do
8
+
9
+ let(:node) {
10
+ node = Node.new(title: "SRS")
11
+ node << Node.new(id: "ii", title: "Introduction")
12
+ node << Node.new(id: "ur", title: "User Requirements")
13
+ node << Node.new(id: "fr", title: "Functional Requirements")
14
+ node.item("ur") << Node.new(id: ".us", title: "User Stories")
15
+ node.item("ur") << Node.new(id: ".uc", title: "Use Cases")
16
+ MarkupNode.new(node)
17
+ }
18
+
19
+ describe "SkipMacro#process" do
20
+ let(:macro) { SkipMacro.new }
21
+ let(:input) { "{{@skip some text}}" }
22
+ let(:result) { "" }
23
+
24
+ it 'must return result' do
25
+ _(macro.process(input, node)).must_equal result
26
+ end
27
+ end
28
+
29
+ describe "EvalMacro#process" do
30
+ let(:macro) { EvalMacro.new }
31
+ let(:input) {
32
+ <<~EOF
33
+ {{@@eval
34
+ ary = []
35
+ 3.times{|i| ary << "Hello, World!"}
36
+ ary.join("\n")
37
+ }}
38
+ EOF
39
+ }
40
+ let(:result) {
41
+ <<~EOF.chomp
42
+ Hello, World!
43
+ Hello, World!
44
+ Hello, World!
45
+ EOF
46
+ }
47
+
48
+ it 'must return result' do
49
+ _(macro.process(input, node)).must_equal result
50
+ end
51
+
52
+ it 'must pass node binding' do
53
+ _(macro.process("{{@@eval \"#{node.id} #{node.title}\"}}", node)).must_equal " SRS"
54
+ end
55
+ end
56
+
57
+ describe "ListMacro#process" do
58
+ let(:macro) { ListMacro.new }
59
+ let(:input) { "{{@@list}}" }
60
+ let(:result) {
61
+ <<~EOF.chomp
62
+ * [Introduction](#ii)
63
+ * [User Requirements](#ur)
64
+ * [Functional Requirements](#fr)
65
+ EOF
66
+ }
67
+
68
+ it 'must return result' do
69
+ _(macro.process(input, node)).must_equal result
70
+ end
71
+ end
72
+
73
+ describe "TreeMacro#process" do
74
+ let(:macro) { TreeMacro.new }
75
+ let(:input) { "{{@@tree}}" }
76
+ let(:result) {
77
+ <<~EOF.chomp
78
+ * [Introduction](#ii)
79
+ * [User Requirements](#ur)
80
+ * [User Stories](#ur-us)
81
+ * [Use Cases](#ur-uc)
82
+ * [Functional Requirements](#fr)
83
+ EOF
84
+ }
85
+
86
+ it 'must return result' do
87
+ _(macro.process(input, node)).must_equal result
88
+ end
89
+ end
90
+
91
+ end