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
@@ -1,30 +1,39 @@
|
|
1
1
|
module RevealCK
|
2
2
|
#
|
3
|
-
# Public: A Presentation is
|
4
|
-
#
|
5
|
-
# mechanism by which the slide "dsl" is defined and loaded into
|
6
|
-
# being.
|
3
|
+
# Public: A Presentation is slide html and metadata. Access html via
|
4
|
+
# #html. Access metadata via theme, title, author, transition.
|
7
5
|
#
|
8
6
|
class Presentation
|
9
7
|
|
10
|
-
|
8
|
+
include Config
|
9
|
+
|
10
|
+
attr_accessor :html
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@
|
14
|
-
|
13
|
+
@html = ''
|
14
|
+
end
|
15
|
+
|
16
|
+
def add(content)
|
17
|
+
@html << content.html
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.from_template(path)
|
21
|
+
presentation = Presentation.new
|
22
|
+
template = Templates::Processor.open path
|
23
|
+
presentation.html = template.output({})
|
24
|
+
presentation
|
15
25
|
end
|
16
26
|
|
17
|
-
def
|
18
|
-
|
27
|
+
def self.from_dsl(path)
|
28
|
+
RevealCK::PresentationDSL.load path
|
19
29
|
end
|
20
30
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
31
|
+
def self.load(path)
|
32
|
+
if path.end_with? '.rb'
|
33
|
+
Presentation.from_dsl path
|
34
|
+
else
|
35
|
+
Presentation.from_template path
|
26
36
|
end
|
27
|
-
content
|
28
37
|
end
|
29
38
|
|
30
39
|
end
|
@@ -5,35 +5,44 @@ module RevealCK
|
|
5
5
|
#
|
6
6
|
class PresentationDSL
|
7
7
|
|
8
|
+
attr_reader :author, :title, :theme, :transition
|
9
|
+
|
8
10
|
def initialize
|
9
11
|
@slides = []
|
10
12
|
end
|
11
13
|
|
12
|
-
def theme(theme
|
14
|
+
def theme(theme)
|
13
15
|
@theme = theme
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
18
|
+
def transition(transition)
|
19
|
+
@transition = transition
|
20
|
+
end
|
21
|
+
|
22
|
+
def title(title)
|
17
23
|
@title = title
|
18
24
|
end
|
19
25
|
|
20
|
-
def author(author
|
26
|
+
def author(author)
|
21
27
|
@author = author
|
22
28
|
end
|
23
29
|
|
24
|
-
def slide(template, variables)
|
30
|
+
def slide(template, variables = {})
|
25
31
|
variables[:template] = template
|
26
32
|
@slides << RevealCK::Slide.new(variables)
|
27
33
|
end
|
28
34
|
|
35
|
+
def contents_of(path)
|
36
|
+
File.open(path).read
|
37
|
+
end
|
38
|
+
|
29
39
|
def build
|
30
40
|
presentation = RevealCK::Presentation.new
|
31
|
-
presentation.theme = @theme
|
32
|
-
presentation.
|
33
|
-
presentation.
|
34
|
-
|
35
|
-
|
36
|
-
end
|
41
|
+
presentation.theme = @theme if @theme
|
42
|
+
presentation.transition = @transition if @transition
|
43
|
+
presentation.author = @author if @author
|
44
|
+
presentation.title = @title if @title
|
45
|
+
@slides.each { |slide| presentation.add slide }
|
37
46
|
presentation
|
38
47
|
end
|
39
48
|
|
@@ -46,8 +55,7 @@ module RevealCK
|
|
46
55
|
def self.load(file)
|
47
56
|
builder = PresentationDSL.new
|
48
57
|
contents = File.open(file).read
|
49
|
-
|
50
|
-
result
|
58
|
+
builder.instance_eval(contents)
|
51
59
|
end
|
52
60
|
|
53
61
|
end
|
data/lib/reveal-ck/slide.rb
CHANGED
@@ -7,13 +7,13 @@ module RevealCK
|
|
7
7
|
|
8
8
|
def initialize(args)
|
9
9
|
template = args[:template] || raise(':template is required')
|
10
|
-
file =
|
11
|
-
@template =
|
10
|
+
file = Templates::Finder.new.find template
|
11
|
+
@template = Templates::Processor.open file
|
12
12
|
@variables = args
|
13
13
|
end
|
14
14
|
|
15
15
|
def html
|
16
|
-
@template.output(
|
16
|
+
@template.output(@variables)
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RevealCK
|
2
|
+
module Templates
|
3
|
+
#
|
4
|
+
# Public: This class is home to a simple algorithm for looking up
|
5
|
+
# files in a series of directories. Directory order matters, and the
|
6
|
+
# first match for the file will be returned. It'll raise if it can't
|
7
|
+
# find the file you've asked for.
|
8
|
+
#
|
9
|
+
class Finder
|
10
|
+
|
11
|
+
attr_reader :paths
|
12
|
+
|
13
|
+
def initialize(args = {})
|
14
|
+
@paths = args[:paths] || default_paths
|
15
|
+
end
|
16
|
+
|
17
|
+
def default_paths
|
18
|
+
pwd_templates = File.join Dir.pwd, 'templates'
|
19
|
+
reveal_ck_templates = File.join RevealCK::LOCATION, 'templates'
|
20
|
+
[pwd_templates, reveal_ck_templates]
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(template_name)
|
24
|
+
paths.each do |path|
|
25
|
+
glob_pattern = "#{File.join(path, template_name)}*"
|
26
|
+
Dir.glob(glob_pattern).each do |match|
|
27
|
+
return match unless File.directory? match
|
28
|
+
end
|
29
|
+
end
|
30
|
+
raise "Unable to find #{template_name} in #{paths}"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# Setup Slim
|
3
|
+
require 'slim'
|
4
|
+
::Slim::Engine.set_default_options pretty: true
|
5
|
+
|
6
|
+
module RevealCK
|
7
|
+
module Templates
|
8
|
+
#
|
9
|
+
# Public: A Processor is given a template and expected to render
|
10
|
+
# it.
|
11
|
+
#
|
12
|
+
class Processor
|
13
|
+
|
14
|
+
require 'tilt'
|
15
|
+
|
16
|
+
def initialize(file)
|
17
|
+
@template = Tilt.new file
|
18
|
+
end
|
19
|
+
|
20
|
+
def output(locals = {})
|
21
|
+
scope = RenderScope.new
|
22
|
+
@template.render scope, locals
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.open(file)
|
26
|
+
Processor.new file
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RevealCK
|
2
|
+
module Templates
|
3
|
+
#
|
4
|
+
# Public: A new instance of RenderScope is created and made
|
5
|
+
# available when templates are rendered. Instance methods on it
|
6
|
+
# are availale to templates.
|
7
|
+
#
|
8
|
+
class RenderScope
|
9
|
+
def contents_of(path)
|
10
|
+
File.open(path).read
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/reveal-ck/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
title = "The Never Sea Slides"
|
@@ -3,10 +3,14 @@ presentation do
|
|
3
3
|
title 'Presentation Title'
|
4
4
|
author 'Presentation Author'
|
5
5
|
theme 'night'
|
6
|
+
transition 'page'
|
6
7
|
|
7
8
|
slide 'text',
|
8
9
|
content: 'Hello World'
|
9
10
|
|
11
|
+
slide 'code',
|
12
|
+
content: contents_of('lib/reveal-ck.rb')
|
13
|
+
|
10
14
|
slide 'text',
|
11
15
|
content: 'Thanks!'
|
12
16
|
|
File without changes
|
File without changes
|
data/spec/data/{template_finder/custom/common.haml → templates/finder/templates/template_two.slim}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'examples/programmatic_slides.rb' do
|
4
|
+
|
5
|
+
it 'prints output from a presentation with several slides' do
|
6
|
+
expect($stdout).to receive :puts
|
7
|
+
expect {
|
8
|
+
load 'examples/programmatic_slides.rb'
|
9
|
+
}.to_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RevealCK
|
4
|
+
module Builders
|
5
|
+
|
6
|
+
describe Builder, 'when subclassed' do
|
7
|
+
|
8
|
+
it 'requires that subclasses implement #register_tasks' do
|
9
|
+
class BadBuilder < Builder; end
|
10
|
+
bad_builder = BadBuilder.new
|
11
|
+
expect { bad_builder.register_tasks }.to raise_error
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'invokes each registered task when it receives #build' do
|
15
|
+
|
16
|
+
class TestBuilder < Builder
|
17
|
+
|
18
|
+
attr_reader :value
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@value = 0
|
22
|
+
end
|
23
|
+
|
24
|
+
def register_tasks
|
25
|
+
@tasks = []
|
26
|
+
@value = 0
|
27
|
+
add_task 'Set Value to 1' do
|
28
|
+
@value = 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
test_builder = TestBuilder.new
|
34
|
+
test_builder.build!
|
35
|
+
expect(test_builder.value).to eq 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
module RevealCK
|
5
|
+
module Builders
|
6
|
+
describe PackagedSlides do
|
7
|
+
|
8
|
+
let :presentation do
|
9
|
+
presentation = Presentation.new
|
10
|
+
presentation.title = "Presentation Title"
|
11
|
+
presentation.author = "Presentation Author"
|
12
|
+
|
13
|
+
presentation.add(Slide.new({
|
14
|
+
template: 'intro',
|
15
|
+
title: presentation.title,
|
16
|
+
author: presentation.author,
|
17
|
+
site: 'http://site.com',
|
18
|
+
twitter: 'twitter'
|
19
|
+
}))
|
20
|
+
presentation
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can build reveal.js slides from a Presentation' do
|
24
|
+
|
25
|
+
tmp_dir = Dir.mktmpdir
|
26
|
+
|
27
|
+
packaged_slides =
|
28
|
+
PackagedSlides.new({
|
29
|
+
presentation: presentation,
|
30
|
+
output_dir: tmp_dir,
|
31
|
+
})
|
32
|
+
packaged_slides.build!
|
33
|
+
|
34
|
+
expect(File.exists? File.join(tmp_dir, "index.html")).to be_true
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
module RevealCK
|
6
|
+
module Changers
|
7
|
+
describe Slicer do
|
8
|
+
|
9
|
+
describe '.remove!' do
|
10
|
+
|
11
|
+
let :before_remove do
|
12
|
+
spec_data 'changers', 'slicer', 'before_remove'
|
13
|
+
end
|
14
|
+
|
15
|
+
let :after_remove do
|
16
|
+
spec_data 'changers', 'slicer', 'after_remove'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'removes a range of lines from a file' do
|
20
|
+
Dir.mktmpdir do |tmp_dir|
|
21
|
+
FileUtils.cp before_remove, tmp_dir
|
22
|
+
test_file = File.join tmp_dir, 'before_remove'
|
23
|
+
Slicer.remove! test_file, 3..6
|
24
|
+
test_file_contents = File.open(test_file).read
|
25
|
+
after_remove_contents = File.open(after_remove).read
|
26
|
+
test_file_contents.should == after_remove_contents
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#remove' do
|
32
|
+
|
33
|
+
it 'returns lines with the range removed' do
|
34
|
+
lines = [
|
35
|
+
'a',
|
36
|
+
'b',
|
37
|
+
'c',
|
38
|
+
'd'
|
39
|
+
]
|
40
|
+
slicer = Slicer.new lines
|
41
|
+
slicer.remove(1..2).should == ['a', 'd']
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|