smartdown 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -0
- data/lib/smartdown/api/outcome.rb +2 -1
- data/lib/smartdown/api/question.rb +2 -1
- data/lib/smartdown/parser/directory_input.rb +23 -3
- data/lib/smartdown/version.rb +1 -1
- data/spec/fixtures/directory_input/snippets/nested/nested_again/nsn1.txt +1 -0
- data/spec/parser/directory_input_spec.rb +10 -4
- metadata +16 -14
data/README.md
CHANGED
@@ -378,6 +378,23 @@ extension, eg `my-flow-name/snippets/my_snippet.txt`.
|
|
378
378
|
|
379
379
|
The contents of `my_snippet` will be inserted into the outcome/question.
|
380
380
|
|
381
|
+
###Snippet Organisation
|
382
|
+
|
383
|
+
You can organise related snippets into a sub-directory of arbitrary depth
|
384
|
+
|
385
|
+
For example:
|
386
|
+
|
387
|
+
```
|
388
|
+
## My header
|
389
|
+
|
390
|
+
Markdown copy..
|
391
|
+
|
392
|
+
{{snippet: my_sub_directory/my_snippet}}
|
393
|
+
|
394
|
+
More copy...
|
395
|
+
```
|
396
|
+
Where `snippet_name` is in a `snippets/` directory in the flow root with a `.txt` extension, eg `my-flow-name/snippets/my_sub_directory/my_snippet.txt`.
|
397
|
+
|
381
398
|
## Scenarios
|
382
399
|
|
383
400
|
Scenarios are meant to be run as test to check that a Smartdown flow behaves
|
@@ -3,7 +3,8 @@ module Smartdown
|
|
3
3
|
class Outcome < Node
|
4
4
|
|
5
5
|
def next_steps
|
6
|
-
elements.find{|element| element.is_a? Smartdown::Model::Element::NextSteps}
|
6
|
+
next_steps = elements.find{ |element| element.is_a? Smartdown::Model::Element::NextSteps}
|
7
|
+
next_steps.content if next_steps && !next_steps.content.empty?
|
7
8
|
end
|
8
9
|
|
9
10
|
end
|
@@ -48,7 +48,8 @@ module Smartdown
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def build_govspeak(elements)
|
51
|
-
elements.select { |element| markdown_element?(element) }
|
51
|
+
markdown_elements = elements.select { |element| markdown_element?(element) }
|
52
|
+
markdown_elements.map(&:content).join("\n") unless markdown_elements.empty?
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -24,7 +24,7 @@ module Smartdown
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def snippets
|
27
|
-
|
27
|
+
recursive_files_relatively_renamed("snippets")
|
28
28
|
end
|
29
29
|
|
30
30
|
def filenames_hash
|
@@ -42,15 +42,35 @@ module Smartdown
|
|
42
42
|
InputFile.new(filename)
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
def recursive_files_relatively_renamed(parent_dir, depth=nil)
|
47
|
+
parent_path = @coversheet_path.dirname + parent_dir
|
48
|
+
return [] unless File.exists?(parent_path)
|
49
|
+
|
50
|
+
depth ||= parent_path.each_filename.count
|
51
|
+
parent_path.each_child.flat_map do |path|
|
52
|
+
if path.directory?
|
53
|
+
recursive_files_relatively_renamed(path, depth)
|
54
|
+
else
|
55
|
+
InputFile.new(path, relatively_name(path, depth))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def relatively_name(path, depth)
|
61
|
+
path.each_filename.to_a[depth..-1].join('/')
|
62
|
+
end
|
63
|
+
|
45
64
|
end
|
46
65
|
|
47
66
|
class InputFile
|
48
|
-
def initialize(path)
|
67
|
+
def initialize(path, name=nil)
|
49
68
|
@path = Pathname.new(path.to_s)
|
69
|
+
@name = name ||= @path.basename
|
50
70
|
end
|
51
71
|
|
52
72
|
def name
|
53
|
-
@
|
73
|
+
@name.to_s.split(".").first
|
54
74
|
end
|
55
75
|
|
56
76
|
def read
|
data/lib/smartdown/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
nested snippet
|
@@ -49,10 +49,16 @@ describe Smartdown::Parser::DirectoryInput do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "#snippets" do
|
52
|
-
it "returns an InputFile for every file in the snippets folder" do
|
53
|
-
expect(input.snippets).to match([
|
54
|
-
|
55
|
-
|
52
|
+
it "returns an InputFile for every file, ending in .txt, in the snippets folder to arbitrary sub directory depth" do
|
53
|
+
expect(input.snippets).to match([
|
54
|
+
instance_of(Smartdown::Parser::InputFile),
|
55
|
+
instance_of(Smartdown::Parser::InputFile),
|
56
|
+
])
|
57
|
+
expect(input.snippets.map(&:name)).to include("sn1")
|
58
|
+
expect(input.snippets.map(&:read)).to include("snippet one\n")
|
59
|
+
|
60
|
+
expect(input.snippets.map(&:name)).to include("nested/nested_again/nsn1")
|
61
|
+
expect(input.snippets.map(&:read)).to include("nested snippet\n")
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
16
|
-
requirement: &
|
16
|
+
requirement: &10521380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.6.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10521380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &10520820 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10520820
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &10520420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10520420
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: gem_publisher
|
49
|
-
requirement: &
|
49
|
+
requirement: &10519900 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10519900
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: timecop
|
60
|
-
requirement: &
|
60
|
+
requirement: &10519480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *10519480
|
69
69
|
description:
|
70
70
|
email: david.heath@digital.cabinet-office.gov.uk
|
71
71
|
executables:
|
@@ -200,6 +200,7 @@ files:
|
|
200
200
|
- spec/fixtures/directory_input/outcomes/o1.txt
|
201
201
|
- spec/fixtures/directory_input/questions/q1.txt
|
202
202
|
- spec/fixtures/directory_input/cover-sheet.txt
|
203
|
+
- spec/fixtures/directory_input/snippets/nested/nested_again/nsn1.txt
|
203
204
|
- spec/fixtures/directory_input/snippets/sn1.txt
|
204
205
|
- spec/fixtures/acceptance/question-and-outcome/question-and-outcome.txt
|
205
206
|
- spec/fixtures/acceptance/question-and-outcome/outcomes/o1.txt
|
@@ -268,7 +269,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
268
269
|
version: '0'
|
269
270
|
segments:
|
270
271
|
- 0
|
271
|
-
hash: -
|
272
|
+
hash: -3693296040115547194
|
272
273
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
273
274
|
none: false
|
274
275
|
requirements:
|
@@ -277,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
278
|
version: '0'
|
278
279
|
segments:
|
279
280
|
- 0
|
280
|
-
hash: -
|
281
|
+
hash: -3693296040115547194
|
281
282
|
requirements: []
|
282
283
|
rubyforge_project:
|
283
284
|
rubygems_version: 1.8.11
|
@@ -322,6 +323,7 @@ test_files:
|
|
322
323
|
- spec/fixtures/directory_input/outcomes/o1.txt
|
323
324
|
- spec/fixtures/directory_input/questions/q1.txt
|
324
325
|
- spec/fixtures/directory_input/cover-sheet.txt
|
326
|
+
- spec/fixtures/directory_input/snippets/nested/nested_again/nsn1.txt
|
325
327
|
- spec/fixtures/directory_input/snippets/sn1.txt
|
326
328
|
- spec/fixtures/acceptance/question-and-outcome/question-and-outcome.txt
|
327
329
|
- spec/fixtures/acceptance/question-and-outcome/outcomes/o1.txt
|