reveal-ck 0.1.6 → 0.1.7
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 +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
@@ -1,14 +0,0 @@
|
|
1
|
-
presentation do
|
2
|
-
|
3
|
-
matz_says = %{
|
4
|
-
No. It's kinda complex. Ruby is simple in appearance, but is very
|
5
|
-
complex inside, just like our human body.
|
6
|
-
}
|
7
|
-
|
8
|
-
citation = 'http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/2773'
|
9
|
-
|
10
|
-
slide 'quote',
|
11
|
-
headline: 'Hello Ruby!',
|
12
|
-
quote: matz_says,
|
13
|
-
citation: citation
|
14
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RevealCK
|
4
|
-
|
5
|
-
describe Builder, 'when subclassed' do
|
6
|
-
|
7
|
-
it 'requires that subclasses implement #register_tasks' do
|
8
|
-
class BadBuilder < Builder; end
|
9
|
-
bad_builder = BadBuilder.new
|
10
|
-
expect { bad_builder.register_tasks }.to raise_error
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'invokes each registered task when it receives #build' do
|
14
|
-
|
15
|
-
class TestBuilder < Builder
|
16
|
-
|
17
|
-
attr_reader :value
|
18
|
-
|
19
|
-
def initialize
|
20
|
-
@value = 0
|
21
|
-
end
|
22
|
-
|
23
|
-
def register_tasks
|
24
|
-
@tasks = []
|
25
|
-
@value = 0
|
26
|
-
add_task 'Set Value to 1' do
|
27
|
-
@value = 1
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
test_builder = TestBuilder.new
|
33
|
-
test_builder.build!
|
34
|
-
expect(test_builder.value).to eq 1
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
module RevealCK
|
6
|
-
describe FileSlicer do
|
7
|
-
|
8
|
-
describe '.remove!' do
|
9
|
-
|
10
|
-
let :before_remove do
|
11
|
-
File.join spec_dir, 'data', 'slicer', 'before_remove'
|
12
|
-
end
|
13
|
-
|
14
|
-
let :after_remove do
|
15
|
-
File.join spec_dir, 'data', 'slicer', 'after_remove'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'removes a range of lines from a file' do
|
19
|
-
Dir.mktmpdir do |tmp_dir|
|
20
|
-
FileUtils.cp before_remove, tmp_dir
|
21
|
-
test_file = File.join tmp_dir, 'before_remove'
|
22
|
-
FileSlicer.remove! test_file, 3..6
|
23
|
-
test_file_contents = File.open(test_file).read
|
24
|
-
after_remove_contents = File.open(after_remove).read
|
25
|
-
test_file_contents.should == after_remove_contents
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#remove' do
|
31
|
-
|
32
|
-
it 'returns lines with the range removed' do
|
33
|
-
lines = [
|
34
|
-
'a',
|
35
|
-
'b',
|
36
|
-
'c',
|
37
|
-
'd'
|
38
|
-
]
|
39
|
-
slicer = FileSlicer.new lines
|
40
|
-
slicer.remove(1..2).should == ['a', 'd']
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
module RevealCK
|
6
|
-
describe FileSplicer do
|
7
|
-
|
8
|
-
describe '.insert!' do
|
9
|
-
|
10
|
-
let :before_insert do
|
11
|
-
File.join spec_dir, 'data', 'splicer', 'before_insert'
|
12
|
-
end
|
13
|
-
|
14
|
-
let :abcd do
|
15
|
-
File.join spec_dir, 'data', 'splicer', 'abcd'
|
16
|
-
end
|
17
|
-
|
18
|
-
let :after_insert do
|
19
|
-
File.join spec_dir, 'data', 'splicer', 'after_insert'
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'inserts one file into another' do
|
23
|
-
Dir.mktmpdir do |tmp_dir|
|
24
|
-
FileUtils.cp before_insert, tmp_dir
|
25
|
-
test_file = File.join tmp_dir, 'before_insert'
|
26
|
-
FileSplicer.insert! abcd, into: test_file, after: '3'
|
27
|
-
test_file_contents = File.open(test_file).read
|
28
|
-
after_insert_contents = File.open(after_insert).read
|
29
|
-
test_file_contents.should == after_insert_contents
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#insert' do
|
35
|
-
it 'inserts lines after a match' do
|
36
|
-
original = ['0', '1', '2', '3']
|
37
|
-
splicer = FileSplicer.new original
|
38
|
-
result = splicer.insert ['a', 'b', 'c'], after: '2'
|
39
|
-
result.should == ['0', '1', '2', 'a', 'b', 'c', '3']
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
module RevealCK
|
6
|
-
|
7
|
-
describe FileStringReplacer do
|
8
|
-
|
9
|
-
describe '.replace!' do
|
10
|
-
|
11
|
-
let :before_replace do
|
12
|
-
File.join spec_dir, 'data', 'string_replacer', 'before_replace'
|
13
|
-
end
|
14
|
-
|
15
|
-
let :after_replace do
|
16
|
-
File.join spec_dir, 'data', '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
|
-
FileStringReplacer.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
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'tmpdir'
|
3
|
-
|
4
|
-
module RevealCK
|
5
|
-
describe PresentationBuilder do
|
6
|
-
|
7
|
-
let :presentation do
|
8
|
-
presentation = Presentation.new
|
9
|
-
presentation.title = "Presentation Title"
|
10
|
-
presentation.author = "Presentation Author"
|
11
|
-
|
12
|
-
presentation.add_slide(Slide.new({
|
13
|
-
template: 'title',
|
14
|
-
title: presentation.title,
|
15
|
-
author: presentation.author,
|
16
|
-
site: 'http://site.com',
|
17
|
-
twitter: 'twitter'
|
18
|
-
}))
|
19
|
-
presentation
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'can build reveal.js slides from a Presentation' do
|
23
|
-
|
24
|
-
tmp_dir = Dir.mktmpdir
|
25
|
-
|
26
|
-
presentation_builder =
|
27
|
-
PresentationBuilder.new({
|
28
|
-
presentation: presentation,
|
29
|
-
output_dir: tmp_dir,
|
30
|
-
})
|
31
|
-
presentation_builder.build!
|
32
|
-
|
33
|
-
expect(File.exists? File.join(tmp_dir, "index.html")).to be_true
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
module RevealCK
|
5
|
-
describe SlidesHtmlBuilder do
|
6
|
-
|
7
|
-
let :data do
|
8
|
-
File.join 'spec', 'data', 'slides_html_builder'
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'when working with slim' do
|
12
|
-
|
13
|
-
let :input_file do
|
14
|
-
File.join data, 'slides.slim'
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#render' do
|
18
|
-
it 'knows how to create slide content from slim' do
|
19
|
-
builder = SlidesHtmlBuilder.new input_file: input_file
|
20
|
-
expect(builder.render).to include "<section>"
|
21
|
-
expect(builder.render).to include "<h1>"
|
22
|
-
expect(builder.render).to include "Hello Slim!"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when working with haml' do
|
29
|
-
|
30
|
-
let :input_file do
|
31
|
-
File.join data, 'slides.haml'
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#render' do
|
35
|
-
it 'knows how to create slide content from haml' do
|
36
|
-
builder = SlidesHtmlBuilder.new input_file: input_file
|
37
|
-
expect(builder.render).to include "<section>"
|
38
|
-
expect(builder.render).to include "<h1>"
|
39
|
-
expect(builder.render).to include "Hello Haml!"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when working with ruby' do
|
46
|
-
|
47
|
-
let :input_file do
|
48
|
-
File.join data, 'slides.rb'
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#render' do
|
52
|
-
it 'knows how to create slide content from ruby' do
|
53
|
-
builder = SlidesHtmlBuilder.new input_file: input_file
|
54
|
-
expect(builder.render).to include "<section>"
|
55
|
-
expect(builder.render).to include "<h2>"
|
56
|
-
expect(builder.render).to include "Hello Ruby!"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when working with a Presentation' do
|
63
|
-
|
64
|
-
let :presentation do
|
65
|
-
quote = Slide.new({
|
66
|
-
template: 'quote',
|
67
|
-
content: 'Hello Ruby!',
|
68
|
-
citation: 'https://www.ruby-lang.org/en/about/'
|
69
|
-
})
|
70
|
-
presentation = Presentation.new
|
71
|
-
presentation.add_slide quote
|
72
|
-
presentation
|
73
|
-
end
|
74
|
-
|
75
|
-
describe '#render' do
|
76
|
-
it 'knows how to create slide content from a Presentation' do
|
77
|
-
builder = SlidesHtmlBuilder.new presentation: presentation
|
78
|
-
expect(builder.render).to include "<section>"
|
79
|
-
expect(builder.render).to include "<blockquote"
|
80
|
-
expect(builder.render).to include "Hello Ruby!"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#write_to' do
|
87
|
-
|
88
|
-
it 'can write #rendered output to a file' do
|
89
|
-
input_file = File.join data, 'slides.haml'
|
90
|
-
builder = SlidesHtmlBuilder.new input_file: input_file
|
91
|
-
tmp_file = Tempfile.new 'slides.html'
|
92
|
-
builder.write_to file: tmp_file.path
|
93
|
-
|
94
|
-
written_content = File.open(tmp_file).read
|
95
|
-
expect(written_content).to include "<section>"
|
96
|
-
expect(written_content).to include "<h1>"
|
97
|
-
expect(written_content).to include "Hello Haml!"
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'tmpdir'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
module RevealCK
|
6
|
-
|
7
|
-
describe TemplateFinder 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, Dir.pwd/templates, and reveal-ck/templates' do
|
16
|
-
finder = TemplateFinder.new
|
17
|
-
expect(finder.paths).to include Dir.pwd
|
18
|
-
expect(finder.paths).to include File.join(Dir.pwd, 'templates')
|
19
|
-
expect(finder.paths).to include File.join(reveal_ck_dir, 'templates')
|
20
|
-
expect(finder.paths.size).to eq 3
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'can be assigned via initializer' do
|
24
|
-
Dir.mktmpdir do |dir|
|
25
|
-
paths = [ dir, File.join(dir, 'templates') ]
|
26
|
-
finder = TemplateFinder.new paths: paths
|
27
|
-
expect(finder.paths).to include dir
|
28
|
-
expect(finder.paths).to include File.join(dir, 'templates')
|
29
|
-
expect(finder.paths.size).to eq 2
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#find' do
|
36
|
-
|
37
|
-
let :template_finder_dir do
|
38
|
-
File.join reveal_ck_dir, 'spec', 'data', 'template_finder'
|
39
|
-
end
|
40
|
-
|
41
|
-
let :automated_dir do
|
42
|
-
File.join template_finder_dir, 'automated'
|
43
|
-
end
|
44
|
-
|
45
|
-
let :custom_dir do
|
46
|
-
File.join template_finder_dir, 'custom'
|
47
|
-
end
|
48
|
-
|
49
|
-
let :reveal_ck_templates_dir do
|
50
|
-
File.join reveal_ck_dir, 'templates'
|
51
|
-
end
|
52
|
-
|
53
|
-
let :finder do
|
54
|
-
paths = [custom_dir, automated_dir, reveal_ck_templates_dir]
|
55
|
-
TemplateFinder.new paths: paths
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'searches all paths to find templates' do
|
59
|
-
result = finder.find 'automated'
|
60
|
-
automated_slim = File.join('automated', 'automated.slim')
|
61
|
-
expect(result).to include automated_slim
|
62
|
-
|
63
|
-
result = finder.find 'custom'
|
64
|
-
custom_slim = File.join('custom', 'custom.slim')
|
65
|
-
expect(result).to include custom_slim
|
66
|
-
|
67
|
-
result = finder.find 'title'
|
68
|
-
title_slim = File.join('reveal-ck', 'templates', 'title.slim')
|
69
|
-
expect(result).to include title_slim
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'searchs paths in order and returns the first match' do
|
73
|
-
result = finder.find 'common.haml'
|
74
|
-
expect(result).to include File.join('custom', 'common.haml')
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'can search by partial file name' do
|
78
|
-
result = finder.find 'common'
|
79
|
-
expect(result).to include File.join('custom', 'common.haml')
|
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
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RevealCK
|
4
|
-
describe TemplateProcessor do
|
5
|
-
|
6
|
-
let :slim_file do
|
7
|
-
File.join Dir.pwd, 'spec', 'data', 'slim', 'basic.slim'
|
8
|
-
end
|
9
|
-
|
10
|
-
let :haml_file do
|
11
|
-
File.join Dir.pwd, 'spec', 'data', 'haml', 'basic.haml'
|
12
|
-
end
|
13
|
-
|
14
|
-
let :pretty_printed_basic do
|
15
|
-
/<p>\s+This is basic (Slim|Haml)\s+<\/p>/
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'can process a slim template' do
|
19
|
-
processor = TemplateProcessor.open slim_file
|
20
|
-
processor.output.should match pretty_printed_basic
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'can process a haml template' do
|
24
|
-
processor = TemplateProcessor.open haml_file
|
25
|
-
processor.output.should match pretty_printed_basic
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|