reveal-ck 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 +8 -8
- data/bin/reveal-ck +18 -12
- data/lib/reveal-ck.rb +3 -10
- data/lib/reveal-ck/builders.rb +4 -0
- data/lib/reveal-ck/builders/build_task.rb +21 -0
- data/lib/reveal-ck/builders/builder.rb +27 -0
- data/lib/reveal-ck/builders/index_html.rb +85 -0
- data/lib/reveal-ck/builders/packaged_slides.rb +84 -0
- data/lib/reveal-ck/changers.rb +3 -0
- data/lib/reveal-ck/changers/slicer.rb +25 -0
- data/lib/reveal-ck/changers/splicer.rb +37 -0
- data/lib/reveal-ck/changers/string_replacer.rb +18 -0
- data/lib/reveal-ck/config.rb +51 -23
- data/lib/reveal-ck/presentation.rb +24 -15
- data/lib/reveal-ck/presentation_dsl.rb +20 -12
- data/lib/reveal-ck/slide.rb +3 -3
- data/lib/reveal-ck/templates.rb +3 -0
- data/lib/reveal-ck/templates/finder.rb +35 -0
- data/lib/reveal-ck/templates/processor.rb +32 -0
- data/lib/reveal-ck/templates/render_scope.rb +14 -0
- data/lib/reveal-ck/version.rb +1 -1
- data/rakelib/examples.rake +7 -0
- data/spec/data/{slicer → changers/slicer}/after_remove +0 -0
- data/spec/data/{slicer → changers/slicer}/before_remove +0 -0
- data/spec/data/{splicer → changers/splicer}/abcd +0 -0
- data/spec/data/{splicer → changers/splicer}/after_insert +0 -0
- data/spec/data/{splicer → changers/splicer}/before_insert +0 -0
- data/spec/data/{string_replacer → changers/string_replacer}/after_replace +0 -0
- data/spec/data/{string_replacer → changers/string_replacer}/before_replace +0 -0
- data/spec/data/config/full_config.toml +7 -0
- data/spec/data/config/partial_config.toml +1 -0
- data/spec/data/presentation/slides.haml +2 -0
- data/spec/data/presentation/slides.rb +5 -0
- data/spec/data/{dsl/slides.rb → presentation_dsl/dsl.rb} +4 -0
- data/spec/data/templates/finder/code/function.rb +3 -0
- data/spec/data/{template_finder/automated/automated.slim → templates/finder/quotes/create} +0 -0
- data/spec/data/{template_finder/automated/common.haml → templates/finder/templates/template_one.slim} +0 -0
- data/spec/data/{template_finder/custom/common.haml → templates/finder/templates/template_two.slim} +0 -0
- data/spec/data/{template_finder/custom/custom.slim → templates/finder/templates/text.slim} +0 -0
- data/spec/data/{haml → templates/processor}/basic.haml +0 -0
- data/spec/data/{slim → templates/processor}/basic.slim +0 -0
- data/spec/data/templates/render_scope/quote +2 -0
- data/spec/examples/programmatic_slides_spec.rb +12 -0
- data/spec/examples/slide_output_spec.rb +12 -0
- data/spec/lib/reveal-ck/builders/builder_spec.rb +39 -0
- data/spec/lib/reveal-ck/builders/packaged_slides_spec.rb +39 -0
- data/spec/lib/reveal-ck/changers/slicer_spec.rb +46 -0
- data/spec/lib/reveal-ck/changers/splicer_spec.rb +45 -0
- data/spec/lib/reveal-ck/changers/string_replacer_spec.rb +35 -0
- data/spec/lib/reveal-ck/config_spec.rb +68 -20
- data/spec/lib/reveal-ck/presentation_dsl_spec.rb +21 -11
- data/spec/lib/reveal-ck/presentation_spec.rb +40 -38
- data/spec/lib/reveal-ck/slide_spec.rb +3 -3
- data/spec/lib/reveal-ck/templates/finder_spec.rb +88 -0
- data/spec/lib/reveal-ck/templates/processor_spec.rb +31 -0
- data/spec/lib/reveal-ck/templates/render_scope_spec.rb +24 -0
- data/templates/{title.slim → intro.slim} +0 -0
- metadata +77 -71
- data/lib/reveal-ck/build_task.rb +0 -19
- data/lib/reveal-ck/builder.rb +0 -25
- data/lib/reveal-ck/file_slicer.rb +0 -23
- data/lib/reveal-ck/file_splicer.rb +0 -36
- data/lib/reveal-ck/file_string_replacer.rb +0 -16
- data/lib/reveal-ck/presentation_builder.rb +0 -94
- data/lib/reveal-ck/slide_builder.rb +0 -81
- data/lib/reveal-ck/slides_html_builder.rb +0 -39
- data/lib/reveal-ck/template_finder.rb +0 -33
- data/lib/reveal-ck/template_processor.rb +0 -28
- data/spec/data/config/config.toml +0 -6
- data/spec/data/html/converted_basic_haml.html +0 -10
- data/spec/data/html/converted_basic_slim.html +0 -10
- data/spec/data/html/reveal-js-index.html +0 -375
- data/spec/data/slides_html_builder/slides.haml +0 -3
- data/spec/data/slides_html_builder/slides.rb +0 -14
- data/spec/data/slides_html_builder/slides.slim +0 -2
- data/spec/lib/reveal-ck/builder_spec.rb +0 -37
- data/spec/lib/reveal-ck/file_slicer_spec.rb +0 -44
- data/spec/lib/reveal-ck/file_splicer_spec.rb +0 -43
- data/spec/lib/reveal-ck/file_string_replacer_spec.rb +0 -34
- data/spec/lib/reveal-ck/presentation_builder_spec.rb +0 -37
- data/spec/lib/reveal-ck/slides_html_builder_spec.rb +0 -102
- data/spec/lib/reveal-ck/template_finder_spec.rb +0 -87
- data/spec/lib/reveal-ck/template_processor_spec.rb +0 -29
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
module RevealCK
|
6
|
+
module Changers
|
7
|
+
describe Splicer do
|
8
|
+
|
9
|
+
describe '.insert!' do
|
10
|
+
|
11
|
+
let :before_insert do
|
12
|
+
spec_data 'changers', 'splicer', 'before_insert'
|
13
|
+
end
|
14
|
+
|
15
|
+
let :abcd do
|
16
|
+
spec_data 'changers', 'splicer', 'abcd'
|
17
|
+
end
|
18
|
+
|
19
|
+
let :after_insert do
|
20
|
+
spec_data 'changers', 'splicer', 'after_insert'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'inserts one file into another' do
|
24
|
+
Dir.mktmpdir do |tmp_dir|
|
25
|
+
FileUtils.cp before_insert, tmp_dir
|
26
|
+
test_file = File.join tmp_dir, 'before_insert'
|
27
|
+
Splicer.insert! abcd, into: test_file, after: '3'
|
28
|
+
test_file_contents = File.open(test_file).read
|
29
|
+
after_insert_contents = File.open(after_insert).read
|
30
|
+
test_file_contents.should == after_insert_contents
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#insert' do
|
36
|
+
it 'inserts lines after a match' do
|
37
|
+
original = ['0', '1', '2', '3']
|
38
|
+
splicer = Splicer.new original
|
39
|
+
result = splicer.insert ['a', 'b', 'c'], after: '2'
|
40
|
+
result.should == ['0', '1', '2', 'a', 'b', 'c', '3']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
module RevealCK
|
6
|
+
module Changers
|
7
|
+
describe StringReplacer do
|
8
|
+
|
9
|
+
describe '.replace!' do
|
10
|
+
|
11
|
+
let :before_replace do
|
12
|
+
spec_data 'changers', 'string_replacer', 'before_replace'
|
13
|
+
end
|
14
|
+
|
15
|
+
let :after_replace do
|
16
|
+
spec_data 'changers', 'string_replacer', 'after_replace'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'replaces content within a file' do
|
20
|
+
Dir.mktmpdir do |tmp_dir|
|
21
|
+
FileUtils.cp before_replace, tmp_dir
|
22
|
+
test_file = File.join tmp_dir, 'before_replace'
|
23
|
+
StringReplacer.replace!(test_file,
|
24
|
+
old: ' hideaway at sea',
|
25
|
+
new: 'hh coconuts!')
|
26
|
+
test_file_contents = File.open(test_file).read
|
27
|
+
after_replace_contents = File.open(after_replace).read
|
28
|
+
test_file_contents.should == after_replace_contents
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,50 +1,98 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module RevealCK
|
4
|
+
|
4
5
|
describe Config do
|
5
6
|
|
6
|
-
|
7
|
+
class Example
|
8
|
+
include Config
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when included in a class' do
|
12
|
+
|
13
|
+
it 'supplies an #theme, and #theme=' do
|
14
|
+
example = Example.new
|
15
|
+
example.theme = 'night'
|
16
|
+
expect(example.theme).to eq 'night'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'supplies a default theme' do
|
20
|
+
example = Example.new
|
21
|
+
expect(example.theme).to eq 'default'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'supplies an #author, and #author=' do
|
25
|
+
example = Example.new
|
26
|
+
example.author = 'Jed Northridge'
|
27
|
+
expect(example.author).to eq 'Jed Northridge'
|
28
|
+
end
|
7
29
|
|
8
|
-
|
9
|
-
|
30
|
+
it 'supplies a default author' do
|
31
|
+
example = Example.new
|
32
|
+
expect(example.author).to eq ''
|
10
33
|
end
|
11
34
|
|
12
|
-
it '#title
|
13
|
-
|
35
|
+
it 'supplies an #title, and #title=' do
|
36
|
+
example = Example.new
|
37
|
+
example.title = 'My Presentation'
|
38
|
+
expect(example.title).to eq 'My Presentation'
|
14
39
|
end
|
15
40
|
|
16
|
-
it '
|
17
|
-
|
41
|
+
it 'supplies a default title' do
|
42
|
+
example = Example.new
|
43
|
+
expect(example.title).to eq 'Slides'
|
18
44
|
end
|
19
45
|
|
20
|
-
it '#
|
21
|
-
|
46
|
+
it 'supplies an #transition, and #transition=' do
|
47
|
+
example = Example.new
|
48
|
+
example.transition = 'page'
|
49
|
+
expect(example.transition).to eq 'page'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'supplies a default transition' do
|
53
|
+
example = Example.new
|
54
|
+
expect(example.transition).to eq 'default'
|
22
55
|
end
|
23
56
|
|
24
57
|
end
|
25
58
|
|
26
|
-
|
59
|
+
describe '#merge_config' do
|
27
60
|
|
28
|
-
let :
|
29
|
-
|
61
|
+
let :full_config_file do
|
62
|
+
spec_data 'config', 'full_config.toml'
|
30
63
|
end
|
31
64
|
|
32
|
-
let :
|
33
|
-
|
65
|
+
let :partial_config_file do
|
66
|
+
spec_data 'config', 'partial_config.toml'
|
34
67
|
end
|
35
68
|
|
36
|
-
it '
|
37
|
-
|
69
|
+
it 'writes unset config options stored in a file' do
|
70
|
+
example = Example.new
|
71
|
+
example.merge_config file: full_config_file
|
72
|
+
expect(example.title).to eq 'The Never Sea Slides'
|
73
|
+
expect(example.author).to eq 'Captain Hook'
|
74
|
+
expect(example.theme).to eq 'night'
|
75
|
+
expect(example.transition).to eq 'page'
|
38
76
|
end
|
39
77
|
|
40
|
-
it '
|
41
|
-
|
78
|
+
it 'can grab just a single option' do
|
79
|
+
example = Example.new
|
80
|
+
example.merge_config file: partial_config_file
|
81
|
+
expect(example.title).to eq 'The Never Sea Slides'
|
42
82
|
end
|
43
83
|
|
44
|
-
it '
|
45
|
-
|
84
|
+
it 'will not overwrite already set config options' do
|
85
|
+
example = Example.new
|
86
|
+
example.author = 'Jed Northridge'
|
87
|
+
example.transition = 'fade'
|
88
|
+
example.merge_config file: full_config_file
|
89
|
+
expect(example.author).to eq 'Jed Northridge'
|
90
|
+
expect(example.transition).to eq 'fade'
|
91
|
+
expect(example.title).to eq 'The Never Sea Slides'
|
92
|
+
expect(example.theme).to eq 'night'
|
46
93
|
end
|
47
94
|
|
48
95
|
end
|
96
|
+
|
49
97
|
end
|
50
98
|
end
|
@@ -4,37 +4,47 @@ module RevealCK
|
|
4
4
|
describe PresentationDSL do
|
5
5
|
|
6
6
|
let :dsl_file do
|
7
|
-
|
7
|
+
spec_data 'presentation_dsl', 'dsl.rb'
|
8
8
|
end
|
9
9
|
|
10
10
|
let :presentation do
|
11
11
|
PresentationDSL.load dsl_file
|
12
12
|
end
|
13
13
|
|
14
|
-
describe '
|
14
|
+
describe '.load' do
|
15
15
|
it 'can build a RevealCK::Presentation from a file' do
|
16
16
|
result = PresentationDSL.load dsl_file
|
17
17
|
expect(result).to be_a Presentation
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe '
|
22
|
-
|
21
|
+
describe 'A Presentation loaded from a dsl' do
|
22
|
+
|
23
|
+
let :html do
|
24
|
+
presentation.html
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'retains the author in the dsl file' do
|
23
28
|
expect(presentation.author).to eq 'Presentation Author'
|
24
29
|
end
|
25
|
-
end
|
26
30
|
|
27
|
-
|
28
|
-
it 'defines the theme in the Presentation' do
|
31
|
+
it 'retains the theme in the dsl file' do
|
29
32
|
expect(presentation.theme).to eq 'night'
|
30
33
|
end
|
31
|
-
end
|
32
34
|
|
33
|
-
|
34
|
-
it 'defines the title in the Presentation' do
|
35
|
+
it 'retains the title in the dsl file' do
|
35
36
|
expect(presentation.title).to eq 'Presentation Title'
|
36
37
|
end
|
37
|
-
end
|
38
38
|
|
39
|
+
it 'retains the transition in the dsl file' do
|
40
|
+
expect(presentation.transition).to eq 'page'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'retains the slides defined in the dsl file' do
|
44
|
+
expect(html).to include 'Hello World'
|
45
|
+
expect(html).to include 'Thanks!'
|
46
|
+
expect(html).to include 'module RevealCK'
|
47
|
+
end
|
48
|
+
end
|
39
49
|
end
|
40
50
|
end
|
@@ -3,58 +3,60 @@ require 'spec_helper'
|
|
3
3
|
module RevealCK
|
4
4
|
describe Presentation do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
presentation.add_slide double('slide', html: "second")
|
12
|
-
end
|
13
|
-
|
6
|
+
let :presentation do
|
7
|
+
presentation = Presentation.new
|
8
|
+
presentation.add double('content', html: 'first')
|
9
|
+
presentation.add double('content', html: 'second')
|
10
|
+
presentation
|
14
11
|
end
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
presentation = Presentation.new
|
20
|
-
presentation.add_slide double('slide', html: "first")
|
21
|
-
presentation.add_slide double('slide', html: "second")
|
22
|
-
presentation
|
23
|
-
end
|
13
|
+
let :html do
|
14
|
+
presentation.html
|
15
|
+
end
|
24
16
|
|
25
|
-
|
26
|
-
|
17
|
+
describe '#add' do
|
18
|
+
it 'adds to a growing list of html' do
|
19
|
+
expect(html).to include 'first'
|
20
|
+
expect(html).to include 'second'
|
21
|
+
expect(html.strip).to start_with 'first'
|
22
|
+
expect(html.strip).to end_with 'second'
|
27
23
|
end
|
24
|
+
end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
expect(
|
26
|
+
describe '#html' do
|
27
|
+
it 'returns the html, in order, added so far' do
|
28
|
+
expect(html).to start_with 'first'
|
29
|
+
expect(html).to end_with 'second'
|
32
30
|
end
|
33
|
-
|
34
31
|
end
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
presentation.theme = 'night'
|
40
|
-
expect(presentation.theme).to eq 'night'
|
41
|
-
end
|
33
|
+
let :slides_haml do
|
34
|
+
spec_data 'presentation', 'slides.haml'
|
35
|
+
end
|
42
36
|
|
43
|
-
|
44
|
-
|
37
|
+
describe '.from_template' do
|
38
|
+
it 'loads presentation html from a template' do
|
39
|
+
presentation = Presentation.from_template slides_haml
|
40
|
+
html = presentation.html
|
41
|
+
expect(html).to start_with '<section>'
|
42
|
+
expect(html).to include 'slides.haml'
|
43
|
+
expect(html).to include '</section>'
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
|
-
|
49
|
-
presentation
|
50
|
-
presentation.title = 'My Favorite Slides'
|
51
|
-
expect(presentation.title).to eq 'My Favorite Slides'
|
47
|
+
let :slides_rb do
|
48
|
+
spec_data 'presentation', 'slides.rb'
|
52
49
|
end
|
53
50
|
|
54
|
-
|
55
|
-
presentation
|
56
|
-
|
57
|
-
|
51
|
+
describe '.from_dsl' do
|
52
|
+
it 'loads presentation html and metadata from a dsl' do
|
53
|
+
presentation = Presentation.from_dsl slides_rb
|
54
|
+
html = presentation.html
|
55
|
+
expect(html).to start_with '<section>'
|
56
|
+
expect(html).to include 'slides.rb'
|
57
|
+
expect(html).to include '</section>'
|
58
|
+
expect(presentation.theme).to eq 'night'
|
59
|
+
end
|
58
60
|
end
|
59
61
|
|
60
62
|
end
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
module RevealCK
|
4
4
|
describe Slide do
|
5
5
|
|
6
|
-
let :
|
7
|
-
Slide.new template: '
|
6
|
+
let :intro_slide do
|
7
|
+
Slide.new template: 'intro',
|
8
8
|
title: 'Reveal.js',
|
9
9
|
subtitle: 'HTML Presentations Made Easy',
|
10
10
|
author: 'Hakim El Hattab',
|
@@ -14,7 +14,7 @@ module RevealCK
|
|
14
14
|
|
15
15
|
describe '#html' do
|
16
16
|
it 'produces html output' do
|
17
|
-
output =
|
17
|
+
output = intro_slide.html
|
18
18
|
expect(output).to include 'Reveal.js'
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module RevealCK
|
6
|
+
module Templates
|
7
|
+
describe Finder do
|
8
|
+
|
9
|
+
let :reveal_ck_dir do
|
10
|
+
Dir.pwd
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#paths' do
|
14
|
+
|
15
|
+
it 'defaults to Dir.pwd/templates and reveal-ck/templates' do
|
16
|
+
Dir.mktmpdir do |dir|
|
17
|
+
Dir.chdir(dir) do
|
18
|
+
finder = Finder.new
|
19
|
+
expect(finder.paths).to include File.join(Dir.pwd, 'templates')
|
20
|
+
expect(finder.paths)
|
21
|
+
.to(include File.join(reveal_ck_dir, 'templates'))
|
22
|
+
expect(finder.paths.size).to eq 2
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'can be assigned via initializer' do
|
28
|
+
Dir.mktmpdir do |dir|
|
29
|
+
paths = [ dir, File.join(dir, 'templates') ]
|
30
|
+
finder = Finder.new paths: paths
|
31
|
+
expect(finder.paths).to include dir
|
32
|
+
expect(finder.paths).to include File.join(dir, 'templates')
|
33
|
+
expect(finder.paths.size).to eq 2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#find' do
|
40
|
+
|
41
|
+
let :project_templates do
|
42
|
+
spec_data 'templates', 'finder', 'templates'
|
43
|
+
end
|
44
|
+
|
45
|
+
let :reveal_ck_templates_dir do
|
46
|
+
File.join reveal_ck_dir, 'templates'
|
47
|
+
end
|
48
|
+
|
49
|
+
let :finder do
|
50
|
+
paths = [project_templates, reveal_ck_templates_dir]
|
51
|
+
Finder.new paths: paths
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'searches project templates/ and reveal-ck/templates' do
|
55
|
+
result = finder.find 'template_one'
|
56
|
+
template_one = File.join('templates', 'template_one.slim')
|
57
|
+
expect(result).to include template_one
|
58
|
+
|
59
|
+
result = finder.find 'intro'
|
60
|
+
intro_slim = File.join('reveal-ck', 'templates', 'intro.slim')
|
61
|
+
expect(result).to include intro_slim
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'searches in order and returns the first match' do
|
65
|
+
result = finder.find 'text'
|
66
|
+
expect(result).to include File.join('templates', 'text.slim')
|
67
|
+
|
68
|
+
result = finder.find 'quote'
|
69
|
+
expect(result).to include reveal_ck_templates_dir
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'searches for files based on the beginnings of names' do
|
73
|
+
result = finder.find 'tex'
|
74
|
+
expect(result).to include File.join('templates', 'text.slim')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'only finds regular files' do
|
78
|
+
result = finder.find 'code'
|
79
|
+
expect(result).to include reveal_ck_templates_dir
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'raises if it cannot find what you asked for' do
|
83
|
+
expect { finder.find 'unknown' }.to raise_error
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|