reveal-ck 0.1.5 → 0.1.6
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/README.md +19 -35
- data/Rakefile +1 -1
- data/lib/reveal-ck.rb +13 -2
- data/lib/reveal-ck/build_task.rb +9 -4
- data/lib/reveal-ck/builder.rb +11 -7
- data/lib/reveal-ck/config.rb +13 -8
- data/lib/reveal-ck/file_slicer.rb +5 -7
- data/lib/reveal-ck/file_splicer.rb +7 -12
- data/lib/reveal-ck/file_string_replacer.rb +6 -7
- data/lib/reveal-ck/presentation.rb +10 -26
- data/lib/reveal-ck/presentation_builder.rb +51 -38
- data/lib/reveal-ck/presentation_dsl.rb +54 -0
- data/lib/reveal-ck/slide_builder.rb +45 -30
- data/lib/reveal-ck/slides_html_builder.rb +12 -3
- data/lib/reveal-ck/template_finder.rb +3 -5
- data/lib/reveal-ck/template_processor.rb +6 -7
- data/lib/reveal-ck/version.rb +1 -1
- data/rakelib/cane.rake +10 -0
- data/rakelib/simplecov.rake +1 -0
- data/spec/data/dsl/slides.rb +13 -0
- data/spec/data/slides_html_builder/slides.rb +14 -4
- data/spec/lib/reveal-ck/builder_spec.rb +37 -0
- data/spec/lib/reveal-ck/file_string_replacer_spec.rb +3 -1
- data/spec/lib/reveal-ck/presentation_builder_spec.rb +5 -4
- data/spec/lib/reveal-ck/presentation_dsl_spec.rb +40 -0
- data/spec/lib/reveal-ck/presentation_spec.rb +0 -17
- data/spec/lib/reveal-ck/template_finder_spec.rb +13 -4
- metadata +52 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjdkMTYxMjE5OGFhMDQ5ZmNiMzdhYWQwZGYwOGM3NTQ4NmNhYmYzOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTU5OTMwZGI1NTc5OTJjNDc1MDk4YTFlNjY4NjA1ZWJhZGRkZjI2YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2E1N2FlMzVhM2JmMWU0M2YzYmMwYzIwNGZjMzYxY2U3NGY0MWQzYWM0NmVh
|
10
|
+
M2RiOTE0NTRiYjJiMzRmYWUwOWE1Y2IyMDI1ZmE4ZDQyODA4OTQzZjRhOTg3
|
11
|
+
ZmEzNmU5OTJiYTFhZjRiNTNjMDA3ZjViZjg2YmQzZGU2NTJjYmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTNiOTVhZDNhOGE5ZWExYmUzM2Y2MTM5Njk2YjhiZWM5OTVkZjYyZDNkOWJl
|
14
|
+
MmE0OGQ4NjFhOWQwNDg2NzBjOTZjOTA5YWRiZDk5NGUyYjcwMmQ3MTdiM2Zm
|
15
|
+
YmY5MjUwMTJlOTY0NzVmOGIwNjlkZTMwZjQ0ODI2ZWJmM2I1NTE=
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# reveal-ck: a [reveal.js][reveal-js] construction kit
|
2
2
|
|
3
3
|
[![Build Status][travis-reveal-ck-badge]](https://travis-ci.org/jedcn/reveal-ck)
|
4
|
+
[![Code Climate][code-climate-reveal-ck-badge]](https://codeclimate.com/github/jedcn/reveal-ck)
|
4
5
|
|
5
6
|
## Overview
|
6
7
|
|
@@ -36,9 +37,9 @@ The thought behind this project to help you focus on what *you* want
|
|
36
37
|
to say.
|
37
38
|
|
38
39
|
For me, focusing becomes easier and my thoughts clearer when I reduce
|
39
|
-
the list of slides to a single file (`slides.slim` or
|
40
|
-
`slides.
|
41
|
-
there
|
40
|
+
the list of slides to a single file (`slides.slim`, `slides.haml`, or
|
41
|
+
`slides.rb`). This file only contains the slide content that I am
|
42
|
+
presenting and there is minimal markup.
|
42
43
|
|
43
44
|
* If you look at the presentation in a browser, you can't scan all of
|
44
45
|
the slides at once. You need to visit them. If you're looking at a
|
@@ -55,42 +56,25 @@ there's minimal markup.
|
|
55
56
|
In the end, [reveal.js][reveal-js], can make things pretty, but only
|
56
57
|
you can make a presentation that is worthwhile.
|
57
58
|
|
58
|
-
##
|
59
|
+
## Getting Started
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
You can author a set of slides by writing in a templating language,
|
62
|
+
such as [Slim][slim] or [Haml][haml], or you can build them
|
63
|
+
programmatically in ruby. Check out the
|
64
|
+
[getting started][reveal-ck-getting-started] instructions, and let me
|
65
|
+
know if you have any trouble.
|
64
66
|
|
65
|
-
|
66
|
-
opportunity to author slides in ruby. It comes with a small number of
|
67
|
-
pre-built templates that encapsulate reveal.js tag names, attributes,
|
68
|
-
and classes aside and provides classes that enable you to create
|
69
|
-
slides programmatically. See `examples/programmatic-slides.rb` for an
|
70
|
-
example.
|
67
|
+
## Development
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
(which replaces `slides.slim` or `slides.haml`) and write something
|
75
|
-
like this:
|
69
|
+
If you are interested in hacking on reveal-ck, check out the
|
70
|
+
[development page][reveal-ck-development].
|
76
71
|
|
77
|
-
|
78
|
-
slide 'title',
|
79
|
-
title: 'Here we go!',
|
80
|
-
author: 'Jed Northridge'
|
81
|
-
|
82
|
-
slide 'quote',
|
83
|
-
content: "when you don't create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create."
|
84
|
-
|
85
|
-
['3', '2', '1', 'Contact!'].each do |s|
|
86
|
-
slide 'text', content: s
|
87
|
-
end
|
88
|
-
```
|
89
|
-
|
90
|
-
You can now run `reveal-ck generate` with `slides.rb` and build slides
|
91
|
-
in ruby.
|
92
|
-
|
93
|
-
[jedcn-reveal-ck]: http://jedcn.com/posts/reveal-ck
|
72
|
+
[code-climate-reveal-ck-badge]: https://codeclimate.com/github/jedcn/reveal-ck.png
|
94
73
|
[github-jedcn-reveal-ck-template]: http://github.com/jedcn/reveal-ck-template
|
74
|
+
[haml]: http://haml.info/
|
75
|
+
[jedcn-reveal-ck]: http://jedcn.com/posts/reveal-ck
|
76
|
+
[reveal-ck-development]: https://github.com/jedcn/reveal-ck/blob/master/doc/development.md
|
77
|
+
[reveal-ck-getting-started]: https://github.com/jedcn/reveal-ck/blob/master/doc/getting_started.md
|
95
78
|
[reveal-js]: http://lab.hakim.se/reveal-js
|
79
|
+
[slim]: http://slim-lang.com/
|
96
80
|
[travis-reveal-ck-badge]: https://travis-ci.org/jedcn/reveal-ck.png
|
data/Rakefile
CHANGED
data/lib/reveal-ck.rb
CHANGED
@@ -12,8 +12,19 @@ require_relative 'reveal-ck/builder'
|
|
12
12
|
require_relative 'reveal-ck/slides_html_builder'
|
13
13
|
require_relative 'reveal-ck/slide_builder'
|
14
14
|
require_relative 'reveal-ck/presentation_builder'
|
15
|
+
require_relative 'reveal-ck/presentation_dsl'
|
15
16
|
|
17
|
+
# RevealCK::LOCATION is the path where reveal-ck is residing on your
|
18
|
+
# system as a gem.
|
16
19
|
module RevealCK
|
17
|
-
|
18
|
-
|
20
|
+
lib = File.dirname __FILE__
|
21
|
+
root = File.join lib, '..'
|
22
|
+
LOCATION = File.expand_path root
|
23
|
+
end
|
24
|
+
|
25
|
+
# RevealCK::REVEALJS_FILES is a list of files that compromise
|
26
|
+
# reveal.js bundled into this gem.
|
27
|
+
module RevealCK
|
28
|
+
revealjs = File.join LOCATION, 'reveal.js'
|
29
|
+
REVEALJS_FILES = Dir.glob "#{revealjs}/**/*"
|
19
30
|
end
|
data/lib/reveal-ck/build_task.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A BuildTask couple a written description (in the form of a
|
4
|
+
# string) with an action in (the form of a proc). It executes the
|
5
|
+
# proc on demand via go!
|
6
|
+
#
|
2
7
|
class BuildTask
|
3
8
|
|
4
|
-
def initialize(
|
5
|
-
@description =
|
6
|
-
@action =
|
9
|
+
def initialize(description, action)
|
10
|
+
@description = description
|
11
|
+
@action = action
|
7
12
|
end
|
8
13
|
|
9
|
-
def go
|
14
|
+
def go
|
10
15
|
@action.call
|
11
16
|
end
|
12
17
|
end
|
data/lib/reveal-ck/builder.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A Builder knows how to execute BuildTasks. These are added
|
4
|
+
# via add_task, and executed via build!
|
5
|
+
#
|
6
|
+
# It is expected to be subclassed, and the subclass must override
|
7
|
+
# register_tasks.
|
8
|
+
#
|
2
9
|
class Builder
|
3
10
|
|
4
11
|
def register_tasks
|
5
|
-
raise
|
12
|
+
raise 'Subclasses must implement register_tasks'
|
6
13
|
end
|
7
14
|
|
8
|
-
def add_task(description, action)
|
9
|
-
@tasks << BuildTask.new(
|
10
|
-
description: description,
|
11
|
-
action: action
|
12
|
-
})
|
15
|
+
def add_task(description, &action)
|
16
|
+
@tasks << BuildTask.new(description, action)
|
13
17
|
end
|
14
18
|
|
15
19
|
def build!
|
16
20
|
register_tasks unless @tasks
|
17
|
-
@tasks.each {|task| task.go
|
21
|
+
@tasks.each { |task| task.go }
|
18
22
|
end
|
19
23
|
|
20
24
|
end
|
data/lib/reveal-ck/config.rb
CHANGED
@@ -1,32 +1,37 @@
|
|
1
1
|
require 'toml'
|
2
2
|
|
3
3
|
module RevealCK
|
4
|
+
#
|
5
|
+
# Public: A Config knows about the core configuration values of a
|
6
|
+
# RevealCK Presentation: title, author, theme, etc. It knows about
|
7
|
+
# sensible defaults, and it can read these from a toml file.
|
8
|
+
#
|
4
9
|
class Config
|
5
10
|
|
6
|
-
def initialize(args={})
|
11
|
+
def initialize(args = {})
|
7
12
|
config_file = args[:config_file]
|
8
13
|
@config = load_config config_file
|
9
14
|
end
|
10
15
|
|
11
16
|
def title
|
12
|
-
@config[
|
17
|
+
@config['title']
|
13
18
|
end
|
14
19
|
|
15
20
|
def author
|
16
|
-
@config[
|
21
|
+
@config['author']
|
17
22
|
end
|
18
23
|
|
19
24
|
def theme
|
20
|
-
@config[
|
25
|
+
@config['presentation']['theme']
|
21
26
|
end
|
22
27
|
|
23
28
|
private
|
24
29
|
|
25
30
|
DEFAULTS = {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
'title' => 'Slides',
|
32
|
+
'author' => 'Hakim El Hattab',
|
33
|
+
'presentation' => {
|
34
|
+
'theme' => 'default'
|
30
35
|
}
|
31
36
|
}
|
32
37
|
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A FileSlicer knows how to remove a section of a file.
|
4
|
+
#
|
2
5
|
class FileSlicer
|
3
6
|
|
4
|
-
def self.remove!(
|
5
|
-
slice_file = if File.exists? path
|
6
|
-
path
|
7
|
-
else
|
8
|
-
File.expand_path(File.join(Dir.pwd, path))
|
9
|
-
end
|
7
|
+
def self.remove!(slice_file, range)
|
10
8
|
lines = File.open(slice_file).readlines
|
11
9
|
slicer = FileSlicer.new lines
|
12
10
|
sliced_lines = slicer.remove range
|
13
|
-
File.open(slice_file, 'w') { |
|
11
|
+
File.open(slice_file, 'w') { |file| file << sliced_lines.join }
|
14
12
|
end
|
15
13
|
|
16
14
|
def initialize(lines)
|
@@ -1,4 +1,8 @@
|
|
1
1
|
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A FileSplicer knows how to insert a list of lines into a
|
4
|
+
# file.
|
5
|
+
#
|
2
6
|
class FileSplicer
|
3
7
|
|
4
8
|
def initialize(lines)
|
@@ -14,26 +18,17 @@ module RevealCK
|
|
14
18
|
|
15
19
|
def self.insert!(to_insert, opts)
|
16
20
|
to_insert_lines = readlines to_insert
|
17
|
-
insert_into_file =
|
21
|
+
insert_into_file = opts[:into]
|
18
22
|
insert_into_lines = readlines insert_into_file
|
19
23
|
|
20
24
|
splicer = FileSplicer.new insert_into_lines
|
21
25
|
spliced_lines = splicer.insert to_insert_lines, after: opts[:after]
|
22
|
-
File.open(insert_into_file, 'w') { |
|
26
|
+
File.open(insert_into_file, 'w') { |file| file << spliced_lines.join }
|
23
27
|
end
|
24
28
|
|
25
29
|
private
|
26
30
|
|
27
|
-
def self.
|
28
|
-
if File.exists? path
|
29
|
-
path
|
30
|
-
else
|
31
|
-
File.expand_original(File.join(Dir.pwd, to_insert))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.readlines(path)
|
36
|
-
file = find_file path
|
31
|
+
def self.readlines(file)
|
37
32
|
File.open(file).readlines
|
38
33
|
end
|
39
34
|
|
@@ -1,16 +1,15 @@
|
|
1
1
|
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A FileStringReplacer knows how to replace one string
|
4
|
+
# in a file with another.
|
5
|
+
#
|
2
6
|
class FileStringReplacer
|
3
7
|
|
4
|
-
def self.replace!(
|
8
|
+
def self.replace!(file, args)
|
5
9
|
old, new = args[:old], args[:new]
|
6
|
-
file = if File.exists? path
|
7
|
-
path
|
8
|
-
else
|
9
|
-
File.expand_path(File.join(Dir.pwd, path))
|
10
|
-
end
|
11
10
|
lines = File.open(file).read
|
12
11
|
lines = lines.sub old, new
|
13
|
-
File.open(file, 'w') { |
|
12
|
+
File.open(file, 'w') { |file| file << lines }
|
14
13
|
end
|
15
14
|
|
16
15
|
end
|
@@ -1,4 +1,10 @@
|
|
1
1
|
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A Presentation is an ordered list of slides. It provides
|
4
|
+
# access to the content of the slides on demand. It it also the
|
5
|
+
# mechanism by which the slide "dsl" is defined and loaded into
|
6
|
+
# being.
|
7
|
+
#
|
2
8
|
class Presentation
|
3
9
|
|
4
10
|
attr_accessor :theme, :title, :author
|
@@ -13,34 +19,12 @@ module RevealCK
|
|
13
19
|
end
|
14
20
|
|
15
21
|
def content
|
16
|
-
|
22
|
+
content = ''
|
17
23
|
@slides.each do |slide|
|
18
|
-
|
19
|
-
|
24
|
+
content << slide.html
|
25
|
+
content << "\n\n"
|
20
26
|
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
module RevealCK
|
28
|
-
class Presentation
|
29
|
-
|
30
|
-
def self.load(file)
|
31
|
-
presentation = Presentation.new
|
32
|
-
content = File.open(file).read
|
33
|
-
presentation.eval content
|
34
|
-
presentation
|
35
|
-
end
|
36
|
-
|
37
|
-
def eval(s)
|
38
|
-
instance_eval s
|
39
|
-
end
|
40
|
-
|
41
|
-
def slide(template, variables)
|
42
|
-
variables[:template] = template
|
43
|
-
add_slide(Slide.new(variables))
|
27
|
+
content
|
44
28
|
end
|
45
29
|
|
46
30
|
end
|
@@ -14,12 +14,13 @@ module RevealCK
|
|
14
14
|
@image_files = args[:image_files]
|
15
15
|
@slides_file = args[:slides_file]
|
16
16
|
@presentation = args[:presentation]
|
17
|
-
|
17
|
+
missing_info = 'either :slides_file or :presentation is required'
|
18
|
+
raise missing_info unless @slides_file || @presentation
|
18
19
|
@output_dir = args[:output_dir]
|
19
20
|
@config = args[:config]
|
20
21
|
end
|
21
22
|
|
22
|
-
def output_dir(child=nil)
|
23
|
+
def output_dir(child = nil)
|
23
24
|
if child
|
24
25
|
File.join(@output_dir, child)
|
25
26
|
else
|
@@ -30,52 +31,64 @@ module RevealCK
|
|
30
31
|
private
|
31
32
|
|
32
33
|
def register_tasks
|
33
|
-
|
34
34
|
@tasks = []
|
35
|
+
slides_html = output_dir 'slides.html'
|
36
|
+
create_dir output_dir
|
37
|
+
transform_slides @slides_file, @presentation, slides_html
|
38
|
+
bundle_revealjs output_dir
|
39
|
+
bundle_image_files image_files, output_dir('images')
|
40
|
+
config = @presentation || @config
|
41
|
+
create_index_html slides_html, output_dir('index.html'), config
|
42
|
+
end
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
44
|
+
def create_dir(dir)
|
45
|
+
add_task "Ensuring #{dir}/ exists" do
|
46
|
+
FileUtils.mkdir_p dir, verbose: false
|
47
|
+
end
|
48
|
+
end
|
40
49
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
builder.write_to file: output_dir('slides.html')
|
46
|
-
}
|
50
|
+
def transform_slides(slides_file, presentation, slides_html)
|
51
|
+
if slides_file
|
52
|
+
description = "Transforming #{slides_file} into '#{slides_html}'}"
|
53
|
+
builder = SlidesHtmlBuilder.new input_file: slides_file
|
47
54
|
else
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
description = "Transforming Presentation into '#{slides_html}'}"
|
56
|
+
builder = SlidesHtmlBuilder.new presentation: presentation
|
57
|
+
end
|
58
|
+
add_task description do
|
59
|
+
builder.write_to file: slides_html
|
53
60
|
end
|
61
|
+
end
|
54
62
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
63
|
+
def bundle_revealjs(output_dir)
|
64
|
+
add_task "Bundling up the revealjs stuff into #{output_dir}/" do
|
65
|
+
FileUtils.cp_r(RevealCK::REVEALJS_FILES,
|
66
|
+
output_dir,
|
67
|
+
verbose: false)
|
68
|
+
end
|
69
|
+
end
|
59
70
|
|
71
|
+
def bundle_image_files(image_files, image_output_dir)
|
60
72
|
if image_files
|
61
|
-
add_task "Copying in images into #{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
73
|
+
add_task "Copying in images into '#{image_output_dir}'" do
|
74
|
+
FileUtils.mkdir_p(image_output_dir, verbose: false)
|
75
|
+
FileUtils.cp_r(image_files,
|
76
|
+
image_output_dir,
|
77
|
+
verbose: false)
|
78
|
+
end
|
66
79
|
end
|
67
|
-
|
68
|
-
add_task "Creating slides/index.html",
|
69
|
-
lambda {
|
70
|
-
slide_builder = SlideBuilder.new({
|
71
|
-
user_slides: output_dir('slides.html'),
|
72
|
-
reveal_slides: output_dir('index.html'),
|
73
|
-
config: @presentation || config
|
74
|
-
})
|
75
|
-
slide_builder.build!
|
76
|
-
}
|
77
|
-
|
78
80
|
end
|
79
81
|
|
82
|
+
def create_index_html(slides_html, index_html, config)
|
83
|
+
add_task 'Creating slides/index.html' do
|
84
|
+
slide_builder =
|
85
|
+
SlideBuilder.new({
|
86
|
+
user_slides: slides_html,
|
87
|
+
reveal_slides: index_html,
|
88
|
+
config: config
|
89
|
+
})
|
90
|
+
slide_builder.build!
|
91
|
+
end
|
92
|
+
end
|
80
93
|
end
|
81
94
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A PresentationDSL defines the DSL behind a
|
4
|
+
# presentation. It also knows how to load file containing the DSL.
|
5
|
+
#
|
6
|
+
class PresentationDSL
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@slides = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def theme(theme = 'default')
|
13
|
+
@theme = theme
|
14
|
+
end
|
15
|
+
|
16
|
+
def title(title = 'Slides')
|
17
|
+
@title = title
|
18
|
+
end
|
19
|
+
|
20
|
+
def author(author = '')
|
21
|
+
@author = author
|
22
|
+
end
|
23
|
+
|
24
|
+
def slide(template, variables)
|
25
|
+
variables[:template] = template
|
26
|
+
@slides << RevealCK::Slide.new(variables)
|
27
|
+
end
|
28
|
+
|
29
|
+
def build
|
30
|
+
presentation = RevealCK::Presentation.new
|
31
|
+
presentation.theme = @theme
|
32
|
+
presentation.author = @author
|
33
|
+
presentation.title = @title
|
34
|
+
@slides.each do |slide|
|
35
|
+
presentation.add_slide slide
|
36
|
+
end
|
37
|
+
presentation
|
38
|
+
end
|
39
|
+
|
40
|
+
require 'docile'
|
41
|
+
|
42
|
+
def presentation(&block)
|
43
|
+
Docile.dsl_eval(PresentationDSL.new, &block).build
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.load(file)
|
47
|
+
builder = PresentationDSL.new
|
48
|
+
contents = File.open(file).read
|
49
|
+
result = builder.instance_eval contents
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -23,43 +23,58 @@ module RevealCK
|
|
23
23
|
|
24
24
|
@tasks = []
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
remove_default_content reveal_slides
|
27
|
+
add_user_content reveal_slides, user_slides
|
28
|
+
replace_title reveal_slides, config.title
|
29
|
+
replace_author reveal_slides, config.author
|
30
|
+
replace_theme reveal_slides, config.theme
|
31
|
+
end
|
32
|
+
|
33
|
+
def remove_default_content(file)
|
34
|
+
add_task 'Slicing out reveal.js default slides' do
|
35
|
+
begin_line_num = 38 # Line where I see <div class="slides">
|
36
|
+
end_line_num = 346 # Closing <div>
|
37
|
+
default_slides = begin_line_num..end_line_num
|
38
|
+
FileSlicer.remove! file, default_slides
|
39
|
+
end
|
40
|
+
end
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
def add_user_content(file, user_slides)
|
43
|
+
add_task "Splicing in slides from #{user_slides}" do
|
44
|
+
FileSplicer.insert!(user_slides,
|
45
|
+
into: file,
|
46
|
+
after: '<div class="slides">')
|
47
|
+
end
|
48
|
+
end
|
42
49
|
|
50
|
+
def replace_title(file, title)
|
43
51
|
old_title = 'reveal.js - The HTML Presentation Framework'
|
44
|
-
new_title =
|
45
|
-
add_task
|
46
|
-
|
47
|
-
|
48
|
-
|
52
|
+
new_title = title
|
53
|
+
add_task 'Replacing the <title>' do
|
54
|
+
FileStringReplacer.replace!(file,
|
55
|
+
old: old_title,
|
56
|
+
new: new_title)
|
57
|
+
end
|
58
|
+
end
|
49
59
|
|
60
|
+
def replace_author(file, author)
|
50
61
|
old_author = 'name="author" content="Hakim El Hattab"'
|
51
|
-
new_author = 'name="author" content="' +
|
52
|
-
add_task "Replacing the <meta name='author'>"
|
53
|
-
|
54
|
-
|
55
|
-
|
62
|
+
new_author = 'name="author" content="' + author + '"'
|
63
|
+
add_task "Replacing the <meta name='author'>" do
|
64
|
+
FileStringReplacer.replace!(file,
|
65
|
+
old: old_author,
|
66
|
+
new: new_author)
|
67
|
+
end
|
68
|
+
end
|
56
69
|
|
70
|
+
def replace_theme(file, theme)
|
57
71
|
old_theme = 'href="css/theme/default.css" id="theme"'
|
58
|
-
new_theme = 'href="css/theme/' +
|
59
|
-
add_task 'Replacing the core theme'
|
60
|
-
|
61
|
-
|
62
|
-
|
72
|
+
new_theme = 'href="css/theme/' + theme + '.css" id="theme"'
|
73
|
+
add_task 'Replacing the core theme' do
|
74
|
+
FileStringReplacer.replace!(file,
|
75
|
+
old: old_theme,
|
76
|
+
new: new_theme)
|
77
|
+
end
|
63
78
|
end
|
64
79
|
|
65
80
|
end
|
@@ -1,16 +1,25 @@
|
|
1
1
|
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A SlidesHtmlBuilder knows how to create the intermediate
|
4
|
+
# file slides.html. This file is a users generate slide content, and
|
5
|
+
# is ultimately inserted within reveal.js.
|
6
|
+
#
|
7
|
+
# A slides.html can be created from a template or from an instance
|
8
|
+
# of a Presentation.
|
9
|
+
#
|
2
10
|
class SlidesHtmlBuilder
|
3
11
|
|
4
12
|
def initialize(args)
|
5
13
|
@input_file = args[:input_file]
|
6
14
|
@presentation = args[:presentation]
|
7
|
-
|
15
|
+
missing_info = 'either :input_file or :presentation are required'
|
16
|
+
raise missing_info unless @input_file || @presentation
|
8
17
|
end
|
9
18
|
|
10
19
|
def render
|
11
20
|
if @input_file
|
12
21
|
if @input_file.end_with? '.rb'
|
13
|
-
presentation = RevealCK::
|
22
|
+
presentation = RevealCK::PresentationDSL.load @input_file
|
14
23
|
presentation.content
|
15
24
|
else
|
16
25
|
template = TemplateProcessor.open @input_file
|
@@ -23,7 +32,7 @@ module RevealCK
|
|
23
32
|
|
24
33
|
def write_to(args)
|
25
34
|
file = args[:file] || raise(':file is required')
|
26
|
-
File.open(file, 'w') { |
|
35
|
+
File.open(file, 'w') { |file| file << render }
|
27
36
|
end
|
28
37
|
|
29
38
|
end
|
@@ -9,16 +9,14 @@ module RevealCK
|
|
9
9
|
|
10
10
|
attr_reader :paths
|
11
11
|
|
12
|
-
def initialize(args={})
|
12
|
+
def initialize(args = {})
|
13
13
|
@paths = args[:paths] || default_paths
|
14
14
|
end
|
15
15
|
|
16
16
|
def default_paths
|
17
17
|
pwd = Dir.pwd
|
18
|
-
pwd_templates =
|
19
|
-
reveal_ck_templates =
|
20
|
-
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'templates'))
|
21
|
-
|
18
|
+
pwd_templates = pwd, 'templates'
|
19
|
+
reveal_ck_templates = File.join RevealCK::LOCATION, 'templates'
|
22
20
|
[pwd, pwd_templates, reveal_ck_templates]
|
23
21
|
end
|
24
22
|
|
@@ -4,6 +4,10 @@ require 'slim'
|
|
4
4
|
::Slim::Engine.set_default_options pretty: true
|
5
5
|
|
6
6
|
module RevealCK
|
7
|
+
#
|
8
|
+
# Public: A TemplateProcessor is given a template and expected to
|
9
|
+
# render it.
|
10
|
+
#
|
7
11
|
class TemplateProcessor
|
8
12
|
|
9
13
|
require 'tilt'
|
@@ -12,16 +16,11 @@ module RevealCK
|
|
12
16
|
@template = Tilt.new file
|
13
17
|
end
|
14
18
|
|
15
|
-
def output(scope=nil, locals = {})
|
19
|
+
def output(scope = nil, locals = {})
|
16
20
|
@template.render scope, locals
|
17
21
|
end
|
18
22
|
|
19
|
-
def self.open(
|
20
|
-
file = if File.exists? path
|
21
|
-
path
|
22
|
-
else
|
23
|
-
File.expand_path(File.join(Dir.pwd, path))
|
24
|
-
end
|
23
|
+
def self.open(file)
|
25
24
|
TemplateProcessor.new file
|
26
25
|
end
|
27
26
|
|
data/lib/reveal-ck/version.rb
CHANGED
data/rakelib/cane.rake
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
CLEAN << 'coverage'
|
@@ -1,4 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -20,7 +20,9 @@ module RevealCK
|
|
20
20
|
Dir.mktmpdir do |tmp_dir|
|
21
21
|
FileUtils.cp before_replace, tmp_dir
|
22
22
|
test_file = File.join tmp_dir, 'before_replace'
|
23
|
-
FileStringReplacer.replace!
|
23
|
+
FileStringReplacer.replace!(test_file,
|
24
|
+
old: ' hideaway at sea',
|
25
|
+
new: 'hh coconuts!')
|
24
26
|
test_file_contents = File.open(test_file).read
|
25
27
|
after_replace_contents = File.open(after_replace).read
|
26
28
|
test_file_contents.should == after_replace_contents
|
@@ -23,10 +23,11 @@ module RevealCK
|
|
23
23
|
|
24
24
|
tmp_dir = Dir.mktmpdir
|
25
25
|
|
26
|
-
presentation_builder =
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
presentation_builder =
|
27
|
+
PresentationBuilder.new({
|
28
|
+
presentation: presentation,
|
29
|
+
output_dir: tmp_dir,
|
30
|
+
})
|
30
31
|
presentation_builder.build!
|
31
32
|
|
32
33
|
expect(File.exists? File.join(tmp_dir, "index.html")).to be_true
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RevealCK
|
4
|
+
describe PresentationDSL do
|
5
|
+
|
6
|
+
let :dsl_file do
|
7
|
+
File.join 'spec', 'data', 'dsl', 'slides.rb'
|
8
|
+
end
|
9
|
+
|
10
|
+
let :presentation do
|
11
|
+
PresentationDSL.load dsl_file
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#load' do
|
15
|
+
it 'can build a RevealCK::Presentation from a file' do
|
16
|
+
result = PresentationDSL.load dsl_file
|
17
|
+
expect(result).to be_a Presentation
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.author' do
|
22
|
+
it 'defines the author in the Presentation' do
|
23
|
+
expect(presentation.author).to eq 'Presentation Author'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.theme' do
|
28
|
+
it 'defines the theme in the Presentation' do
|
29
|
+
expect(presentation.theme).to eq 'night'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.title' do
|
34
|
+
it 'defines the title in the Presentation' do
|
35
|
+
expect(presentation.title).to eq 'Presentation Title'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -57,22 +57,5 @@ module RevealCK
|
|
57
57
|
expect(presentation.author).to eq 'Hakim El Hattab'
|
58
58
|
end
|
59
59
|
|
60
|
-
describe '#slide' do
|
61
|
-
it 'is a shortcut for creating a new Slide and calling #add_slide' do
|
62
|
-
presentation = Presentation.new
|
63
|
-
|
64
|
-
expect(Slide)
|
65
|
-
.to(receive(:new)
|
66
|
-
.with({ template: 'text', content: 'spec' })
|
67
|
-
.and_call_original)
|
68
|
-
|
69
|
-
expect(presentation)
|
70
|
-
.to(receive(:add_slide)
|
71
|
-
.with(kind_of(Slide)))
|
72
|
-
|
73
|
-
presentation.eval "slide('text', { content: 'spec' })"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
60
|
end
|
78
61
|
end
|
@@ -22,7 +22,8 @@ module RevealCK
|
|
22
22
|
|
23
23
|
it 'can be assigned via initializer' do
|
24
24
|
Dir.mktmpdir do |dir|
|
25
|
-
|
25
|
+
paths = [ dir, File.join(dir, 'templates') ]
|
26
|
+
finder = TemplateFinder.new paths: paths
|
26
27
|
expect(finder.paths).to include dir
|
27
28
|
expect(finder.paths).to include File.join(dir, 'templates')
|
28
29
|
expect(finder.paths.size).to eq 2
|
@@ -56,11 +57,16 @@ module RevealCK
|
|
56
57
|
|
57
58
|
it 'searches all paths to find templates' do
|
58
59
|
result = finder.find 'automated'
|
59
|
-
|
60
|
+
automated_slim = File.join('automated', 'automated.slim')
|
61
|
+
expect(result).to include automated_slim
|
62
|
+
|
60
63
|
result = finder.find 'custom'
|
61
|
-
|
64
|
+
custom_slim = File.join('custom', 'custom.slim')
|
65
|
+
expect(result).to include custom_slim
|
66
|
+
|
62
67
|
result = finder.find 'title'
|
63
|
-
|
68
|
+
title_slim = File.join('reveal-ck', 'templates', 'title.slim')
|
69
|
+
expect(result).to include title_slim
|
64
70
|
end
|
65
71
|
|
66
72
|
it 'searchs paths in order and returns the first match' do
|
@@ -73,6 +79,9 @@ module RevealCK
|
|
73
79
|
expect(result).to include File.join('custom', 'common.haml')
|
74
80
|
end
|
75
81
|
|
82
|
+
it 'raises if it cannot find what you asked for' do
|
83
|
+
expect { finder.find 'unknown' }.to raise_error
|
84
|
+
end
|
76
85
|
end
|
77
86
|
end
|
78
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reveal-ck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jed Northridge
|
@@ -108,6 +108,48 @@ dependencies:
|
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 10.1.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: docile
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.1.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.1.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: cane
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
111
153
|
- !ruby/object:Gem::Dependency
|
112
154
|
name: rspec
|
113
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,14 +287,17 @@ files:
|
|
245
287
|
- lib/reveal-ck/file_string_replacer.rb
|
246
288
|
- lib/reveal-ck/presentation.rb
|
247
289
|
- lib/reveal-ck/presentation_builder.rb
|
290
|
+
- lib/reveal-ck/presentation_dsl.rb
|
248
291
|
- lib/reveal-ck/slide.rb
|
249
292
|
- lib/reveal-ck/slide_builder.rb
|
250
293
|
- lib/reveal-ck/slides_html_builder.rb
|
251
294
|
- lib/reveal-ck/template_finder.rb
|
252
295
|
- lib/reveal-ck/template_processor.rb
|
253
296
|
- lib/reveal-ck/version.rb
|
297
|
+
- rakelib/cane.rake
|
254
298
|
- rakelib/cucumber.rake
|
255
299
|
- rakelib/rspec.rake
|
300
|
+
- rakelib/simplecov.rake
|
256
301
|
- templates/code.slim
|
257
302
|
- templates/image.slim
|
258
303
|
- templates/quote.slim
|
@@ -264,6 +309,7 @@ files:
|
|
264
309
|
- features/support/env.rb
|
265
310
|
- features/support/file_management.rb
|
266
311
|
- spec/data/config/config.toml
|
312
|
+
- spec/data/dsl/slides.rb
|
267
313
|
- spec/data/haml/basic.haml
|
268
314
|
- spec/data/html/converted_basic_haml.html
|
269
315
|
- spec/data/html/converted_basic_slim.html
|
@@ -283,11 +329,13 @@ files:
|
|
283
329
|
- spec/data/template_finder/automated/common.haml
|
284
330
|
- spec/data/template_finder/custom/common.haml
|
285
331
|
- spec/data/template_finder/custom/custom.slim
|
332
|
+
- spec/lib/reveal-ck/builder_spec.rb
|
286
333
|
- spec/lib/reveal-ck/config_spec.rb
|
287
334
|
- spec/lib/reveal-ck/file_slicer_spec.rb
|
288
335
|
- spec/lib/reveal-ck/file_splicer_spec.rb
|
289
336
|
- spec/lib/reveal-ck/file_string_replacer_spec.rb
|
290
337
|
- spec/lib/reveal-ck/presentation_builder_spec.rb
|
338
|
+
- spec/lib/reveal-ck/presentation_dsl_spec.rb
|
291
339
|
- spec/lib/reveal-ck/presentation_spec.rb
|
292
340
|
- spec/lib/reveal-ck/slide_spec.rb
|
293
341
|
- spec/lib/reveal-ck/slides_html_builder_spec.rb
|
@@ -326,6 +374,7 @@ test_files:
|
|
326
374
|
- features/support/env.rb
|
327
375
|
- features/support/file_management.rb
|
328
376
|
- spec/data/config/config.toml
|
377
|
+
- spec/data/dsl/slides.rb
|
329
378
|
- spec/data/haml/basic.haml
|
330
379
|
- spec/data/html/converted_basic_haml.html
|
331
380
|
- spec/data/html/converted_basic_slim.html
|
@@ -345,11 +394,13 @@ test_files:
|
|
345
394
|
- spec/data/template_finder/automated/common.haml
|
346
395
|
- spec/data/template_finder/custom/common.haml
|
347
396
|
- spec/data/template_finder/custom/custom.slim
|
397
|
+
- spec/lib/reveal-ck/builder_spec.rb
|
348
398
|
- spec/lib/reveal-ck/config_spec.rb
|
349
399
|
- spec/lib/reveal-ck/file_slicer_spec.rb
|
350
400
|
- spec/lib/reveal-ck/file_splicer_spec.rb
|
351
401
|
- spec/lib/reveal-ck/file_string_replacer_spec.rb
|
352
402
|
- spec/lib/reveal-ck/presentation_builder_spec.rb
|
403
|
+
- spec/lib/reveal-ck/presentation_dsl_spec.rb
|
353
404
|
- spec/lib/reveal-ck/presentation_spec.rb
|
354
405
|
- spec/lib/reveal-ck/slide_spec.rb
|
355
406
|
- spec/lib/reveal-ck/slides_html_builder_spec.rb
|