reveal.rb 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile.lock +15 -1
- data/README.md +8 -1
- data/Rakefile +7 -0
- data/lib/reveal/cli.rb +15 -97
- data/lib/reveal/command.rb +109 -0
- data/lib/reveal/templates/revealjs/css/print/paper.css +193 -167
- data/lib/reveal/templates/revealjs/css/print/pdf.css +20 -53
- data/lib/reveal/templates/revealjs/css/reveal.css +1175 -0
- data/lib/reveal/templates/revealjs/css/theme/beige.css +183 -60
- data/lib/reveal/templates/revealjs/css/theme/black.css +267 -0
- data/lib/reveal/templates/revealjs/css/theme/blood.css +190 -80
- data/lib/reveal/templates/revealjs/css/theme/league.css +273 -0
- data/lib/reveal/templates/revealjs/css/theme/moon.css +174 -51
- data/lib/reveal/templates/revealjs/css/theme/night.css +171 -42
- data/lib/reveal/templates/revealjs/css/theme/serif.css +187 -58
- data/lib/reveal/templates/revealjs/css/theme/simple.css +179 -50
- data/lib/reveal/templates/revealjs/css/theme/sky.css +176 -47
- data/lib/reveal/templates/revealjs/css/theme/solarized.css +174 -51
- data/lib/reveal/templates/revealjs/css/theme/white.css +267 -0
- data/lib/reveal/templates/revealjs/index.html +411 -0
- data/lib/reveal/templates/revealjs/js/reveal.js +4508 -0
- data/lib/reveal/templates/revealjs/lib/css/zenburn.css +74 -71
- data/lib/reveal/templates/revealjs/lib/font/{league_gothic_license → league-gothic/LICENSE} +0 -0
- data/lib/reveal/templates/revealjs/lib/font/league-gothic/league-gothic.css +10 -0
- data/lib/reveal/templates/revealjs/lib/font/league-gothic/league-gothic.eot +0 -0
- data/lib/reveal/templates/revealjs/lib/font/league-gothic/league-gothic.ttf +0 -0
- data/lib/reveal/templates/revealjs/lib/font/league-gothic/league-gothic.woff +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/LICENSE +45 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-italic.ttf +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-regular.ttf +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-semibold.ttf +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-semibolditalic.eot +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-semibolditalic.ttf +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro-semibolditalic.woff +0 -0
- data/lib/reveal/templates/revealjs/lib/font/source-sans-pro/source-sans-pro.css +39 -0
- data/lib/reveal/templates/revealjs/lib/js/html5shiv.js +0 -0
- data/lib/reveal/templates/revealjs/plugin/highlight/highlight.js +2 -4
- data/lib/reveal/templates/revealjs/plugin/leap/leap.js +4 -2
- data/lib/reveal/templates/revealjs/plugin/markdown/example.html +3 -3
- data/lib/reveal/templates/revealjs/plugin/markdown/example.md +0 -0
- data/lib/reveal/templates/revealjs/plugin/markdown/markdown.js +10 -9
- data/lib/reveal/templates/revealjs/plugin/markdown/marked.js +2 -33
- data/lib/reveal/templates/revealjs/plugin/math/math.js +1 -1
- data/lib/reveal/templates/revealjs/plugin/multiplex/client.js +0 -0
- data/lib/reveal/templates/revealjs/plugin/multiplex/index.js +0 -0
- data/lib/reveal/templates/revealjs/plugin/multiplex/master.js +0 -0
- data/lib/reveal/templates/revealjs/plugin/notes/notes.html +321 -182
- data/lib/reveal/templates/revealjs/plugin/notes/notes.js +89 -45
- data/lib/reveal/templates/revealjs/plugin/notes-server/client.js +49 -46
- data/lib/reveal/templates/revealjs/plugin/notes-server/index.js +28 -21
- data/lib/reveal/templates/revealjs/plugin/notes-server/notes.html +351 -97
- data/lib/reveal/templates/revealjs/plugin/print-pdf/print-pdf.js +24 -20
- data/lib/reveal/templates/revealjs/plugin/remotes/remotes.js +0 -0
- data/lib/reveal/templates/revealjs/plugin/search/search.js +0 -0
- data/lib/reveal/templates/revealjs/plugin/zoom-js/zoom.js +78 -58
- data/lib/reveal/templates/template.html +17 -24
- data/lib/reveal/version.rb +1 -1
- data/lib/reveal.rb +1 -0
- data/reveal.rb.gemspec +3 -0
- data/spec/lib/reveal/cli_spec.rb +26 -0
- data/spec/lib/reveal/command_spec.rb +165 -0
- metadata +65 -28
- data/lib/reveal/templates/revealjs/css/reveal.min.css +0 -7
- data/lib/reveal/templates/revealjs/css/theme/README.md +0 -25
- data/lib/reveal/templates/revealjs/css/theme/default.css +0 -148
- data/lib/reveal/templates/revealjs/css/theme/source/beige.scss +0 -50
- data/lib/reveal/templates/revealjs/css/theme/source/blood.scss +0 -91
- data/lib/reveal/templates/revealjs/css/theme/source/default.scss +0 -42
- data/lib/reveal/templates/revealjs/css/theme/source/moon.scss +0 -68
- data/lib/reveal/templates/revealjs/css/theme/source/night.scss +0 -35
- data/lib/reveal/templates/revealjs/css/theme/source/serif.scss +0 -35
- data/lib/reveal/templates/revealjs/css/theme/source/simple.scss +0 -38
- data/lib/reveal/templates/revealjs/css/theme/source/sky.scss +0 -46
- data/lib/reveal/templates/revealjs/css/theme/source/solarized.scss +0 -74
- data/lib/reveal/templates/revealjs/css/theme/template/mixins.scss +0 -29
- data/lib/reveal/templates/revealjs/css/theme/template/settings.scss +0 -34
- data/lib/reveal/templates/revealjs/css/theme/template/theme.scss +0 -170
- data/lib/reveal/templates/revealjs/js/reveal.min.js +0 -9
- data/lib/reveal/templates/revealjs/lib/font/league_gothic-webfont.eot +0 -0
- data/lib/reveal/templates/revealjs/lib/font/league_gothic-webfont.svg +0 -230
- data/lib/reveal/templates/revealjs/lib/font/league_gothic-webfont.ttf +0 -0
- data/lib/reveal/templates/revealjs/lib/font/league_gothic-webfont.woff +0 -0
- data/lib/reveal/templates/revealjs/plugin/postmessage/example.html +0 -39
- data/lib/reveal/templates/revealjs/plugin/postmessage/postmessage.js +0 -42
@@ -2,12 +2,24 @@
|
|
2
2
|
(function(){
|
3
3
|
var isEnabled = true;
|
4
4
|
|
5
|
-
document.querySelector( '.reveal' ).addEventListener( 'mousedown', function( event ) {
|
5
|
+
document.querySelector( '.reveal .slides' ).addEventListener( 'mousedown', function( event ) {
|
6
6
|
var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'alt' ) + 'Key';
|
7
7
|
|
8
|
+
var zoomPadding = 20;
|
9
|
+
var revealScale = Reveal.getScale();
|
10
|
+
|
8
11
|
if( event[ modifier ] && isEnabled ) {
|
9
12
|
event.preventDefault();
|
10
|
-
|
13
|
+
|
14
|
+
var bounds = event.target.getBoundingClientRect();
|
15
|
+
|
16
|
+
zoom.to({
|
17
|
+
x: ( bounds.left * revealScale ) - zoomPadding,
|
18
|
+
y: ( bounds.top * revealScale ) - zoomPadding,
|
19
|
+
width: ( bounds.width * revealScale ) + ( zoomPadding * 2 ),
|
20
|
+
height: ( bounds.height * revealScale ) + ( zoomPadding * 2 ),
|
21
|
+
pan: false
|
22
|
+
});
|
11
23
|
}
|
12
24
|
} );
|
13
25
|
|
@@ -16,11 +28,11 @@
|
|
16
28
|
})();
|
17
29
|
|
18
30
|
/*!
|
19
|
-
* zoom.js 0.
|
31
|
+
* zoom.js 0.3 (modified for use with reveal.js)
|
20
32
|
* http://lab.hakim.se/zoom-js
|
21
33
|
* MIT licensed
|
22
34
|
*
|
23
|
-
* Copyright (C) 2011-
|
35
|
+
* Copyright (C) 2011-2014 Hakim El Hattab, http://hakim.se
|
24
36
|
*/
|
25
37
|
var zoom = (function(){
|
26
38
|
|
@@ -35,8 +47,6 @@ var zoom = (function(){
|
|
35
47
|
var panEngageTimeout = -1,
|
36
48
|
panUpdateInterval = -1;
|
37
49
|
|
38
|
-
var currentOptions = null;
|
39
|
-
|
40
50
|
// Check for transform support so that we can fallback otherwise
|
41
51
|
var supportsTransforms = 'WebkitTransform' in document.body.style ||
|
42
52
|
'MozTransform' in document.body.style ||
|
@@ -58,7 +68,7 @@ var zoom = (function(){
|
|
58
68
|
if( level !== 1 && event.keyCode === 27 ) {
|
59
69
|
zoom.out();
|
60
70
|
}
|
61
|
-
}
|
71
|
+
} );
|
62
72
|
|
63
73
|
// Monitor mouse movement for panning
|
64
74
|
document.addEventListener( 'mousemove', function( event ) {
|
@@ -66,38 +76,56 @@ var zoom = (function(){
|
|
66
76
|
mouseX = event.clientX;
|
67
77
|
mouseY = event.clientY;
|
68
78
|
}
|
69
|
-
}
|
79
|
+
} );
|
70
80
|
|
71
81
|
/**
|
72
|
-
* Applies the CSS required to zoom in,
|
82
|
+
* Applies the CSS required to zoom in, prefers the use of CSS3
|
73
83
|
* transforms but falls back on zoom for IE.
|
74
84
|
*
|
75
|
-
* @param {
|
76
|
-
* @param {Number} pageOffsetY
|
77
|
-
* @param {Number} elementOffsetX
|
78
|
-
* @param {Number} elementOffsetY
|
85
|
+
* @param {Object} rect
|
79
86
|
* @param {Number} scale
|
80
87
|
*/
|
81
|
-
function magnify(
|
88
|
+
function magnify( rect, scale ) {
|
89
|
+
|
90
|
+
var scrollOffset = getScrollOffset();
|
91
|
+
|
92
|
+
// Ensure a width/height is set
|
93
|
+
rect.width = rect.width || 1;
|
94
|
+
rect.height = rect.height || 1;
|
95
|
+
|
96
|
+
// Center the rect within the zoomed viewport
|
97
|
+
rect.x -= ( window.innerWidth - ( rect.width * scale ) ) / 2;
|
98
|
+
rect.y -= ( window.innerHeight - ( rect.height * scale ) ) / 2;
|
82
99
|
|
83
100
|
if( supportsTransforms ) {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
101
|
+
// Reset
|
102
|
+
if( scale === 1 ) {
|
103
|
+
document.body.style.transform = '';
|
104
|
+
document.body.style.OTransform = '';
|
105
|
+
document.body.style.msTransform = '';
|
106
|
+
document.body.style.MozTransform = '';
|
107
|
+
document.body.style.WebkitTransform = '';
|
108
|
+
}
|
109
|
+
// Scale
|
110
|
+
else {
|
111
|
+
var origin = scrollOffset.x +'px '+ scrollOffset.y +'px',
|
112
|
+
transform = 'translate('+ -rect.x +'px,'+ -rect.y +'px) scale('+ scale +')';
|
113
|
+
|
114
|
+
document.body.style.transformOrigin = origin;
|
115
|
+
document.body.style.OTransformOrigin = origin;
|
116
|
+
document.body.style.msTransformOrigin = origin;
|
117
|
+
document.body.style.MozTransformOrigin = origin;
|
118
|
+
document.body.style.WebkitTransformOrigin = origin;
|
119
|
+
|
120
|
+
document.body.style.transform = transform;
|
121
|
+
document.body.style.OTransform = transform;
|
122
|
+
document.body.style.msTransform = transform;
|
123
|
+
document.body.style.MozTransform = transform;
|
124
|
+
document.body.style.WebkitTransform = transform;
|
125
|
+
}
|
98
126
|
}
|
99
127
|
else {
|
100
|
-
// Reset
|
128
|
+
// Reset
|
101
129
|
if( scale === 1 ) {
|
102
130
|
document.body.style.position = '';
|
103
131
|
document.body.style.left = '';
|
@@ -106,11 +134,11 @@ var zoom = (function(){
|
|
106
134
|
document.body.style.height = '';
|
107
135
|
document.body.style.zoom = '';
|
108
136
|
}
|
109
|
-
//
|
137
|
+
// Scale
|
110
138
|
else {
|
111
139
|
document.body.style.position = 'relative';
|
112
|
-
document.body.style.left = ( - (
|
113
|
-
document.body.style.top = ( - (
|
140
|
+
document.body.style.left = ( - ( scrollOffset.x + rect.x ) / scale ) + 'px';
|
141
|
+
document.body.style.top = ( - ( scrollOffset.y + rect.y ) / scale ) + 'px';
|
114
142
|
document.body.style.width = ( scale * 100 ) + '%';
|
115
143
|
document.body.style.height = ( scale * 100 ) + '%';
|
116
144
|
document.body.style.zoom = scale;
|
@@ -119,11 +147,13 @@ var zoom = (function(){
|
|
119
147
|
|
120
148
|
level = scale;
|
121
149
|
|
122
|
-
if(
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
150
|
+
if( document.documentElement.classList ) {
|
151
|
+
if( level !== 1 ) {
|
152
|
+
document.documentElement.classList.add( 'zoomed' );
|
153
|
+
}
|
154
|
+
else {
|
155
|
+
document.documentElement.classList.remove( 'zoomed' );
|
156
|
+
}
|
127
157
|
}
|
128
158
|
}
|
129
159
|
|
@@ -159,7 +189,7 @@ var zoom = (function(){
|
|
159
189
|
function getScrollOffset() {
|
160
190
|
return {
|
161
191
|
x: window.scrollX !== undefined ? window.scrollX : window.pageXOffset,
|
162
|
-
y: window.scrollY !== undefined ? window.scrollY : window.
|
192
|
+
y: window.scrollY !== undefined ? window.scrollY : window.pageYOffset
|
163
193
|
}
|
164
194
|
}
|
165
195
|
|
@@ -175,6 +205,7 @@ var zoom = (function(){
|
|
175
205
|
* - scale: can be used instead of width/height to explicitly set scale
|
176
206
|
*/
|
177
207
|
to: function( options ) {
|
208
|
+
|
178
209
|
// Due to an implementation limitation we can't zoom in
|
179
210
|
// to another element without zooming out first
|
180
211
|
if( level !== 1 ) {
|
@@ -188,11 +219,12 @@ var zoom = (function(){
|
|
188
219
|
if( !!options.element ) {
|
189
220
|
// Space around the zoomed in element to leave on screen
|
190
221
|
var padding = 20;
|
222
|
+
var bounds = options.element.getBoundingClientRect();
|
191
223
|
|
192
|
-
options.
|
193
|
-
options.
|
194
|
-
options.
|
195
|
-
options.
|
224
|
+
options.x = bounds.left - padding;
|
225
|
+
options.y = bounds.top - padding;
|
226
|
+
options.width = bounds.width + ( padding * 2 );
|
227
|
+
options.height = bounds.height + ( padding * 2 );
|
196
228
|
}
|
197
229
|
|
198
230
|
// If width/height values are set, calculate scale from those values
|
@@ -204,13 +236,7 @@ var zoom = (function(){
|
|
204
236
|
options.x *= options.scale;
|
205
237
|
options.y *= options.scale;
|
206
238
|
|
207
|
-
|
208
|
-
|
209
|
-
if( options.element ) {
|
210
|
-
scrollOffset.x -= ( window.innerWidth - ( options.width * options.scale ) ) / 2;
|
211
|
-
}
|
212
|
-
|
213
|
-
magnify( scrollOffset.x, scrollOffset.y, options.x, options.y, options.scale );
|
239
|
+
magnify( options, options.scale );
|
214
240
|
|
215
241
|
if( options.pan !== false ) {
|
216
242
|
|
@@ -222,8 +248,6 @@ var zoom = (function(){
|
|
222
248
|
|
223
249
|
}
|
224
250
|
}
|
225
|
-
|
226
|
-
currentOptions = options;
|
227
251
|
}
|
228
252
|
},
|
229
253
|
|
@@ -234,13 +258,7 @@ var zoom = (function(){
|
|
234
258
|
clearTimeout( panEngageTimeout );
|
235
259
|
clearInterval( panUpdateInterval );
|
236
260
|
|
237
|
-
|
238
|
-
|
239
|
-
if( currentOptions && currentOptions.element ) {
|
240
|
-
scrollOffset.x -= ( window.innerWidth - ( currentOptions.width * currentOptions.scale ) ) / 2;
|
241
|
-
}
|
242
|
-
|
243
|
-
magnify( scrollOffset.x, scrollOffset.y, 0, 0, 1 );
|
261
|
+
magnify( { x: 0, y: 0 }, 1 );
|
244
262
|
|
245
263
|
level = 1;
|
246
264
|
},
|
@@ -256,3 +274,5 @@ var zoom = (function(){
|
|
256
274
|
|
257
275
|
})();
|
258
276
|
|
277
|
+
|
278
|
+
|
@@ -12,23 +12,21 @@
|
|
12
12
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
13
13
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
14
14
|
|
15
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
15
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
|
16
16
|
|
17
|
-
<link rel="stylesheet" href="css/reveal.
|
18
|
-
<link rel="stylesheet" href="css/theme/
|
17
|
+
<link rel="stylesheet" href="css/reveal.css">
|
18
|
+
<link rel="stylesheet" href="css/theme/black.css" id="theme">
|
19
19
|
|
20
|
-
<!--
|
20
|
+
<!-- Code syntax highlighting -->
|
21
21
|
<link rel="stylesheet" href="lib/css/zenburn.css">
|
22
22
|
|
23
|
-
<!--
|
23
|
+
<!-- Printing and PDF exports -->
|
24
24
|
<script>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
31
|
-
}
|
25
|
+
var link = document.createElement( 'link' );
|
26
|
+
link.rel = 'stylesheet';
|
27
|
+
link.type = 'text/css';
|
28
|
+
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
29
|
+
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
32
30
|
</script>
|
33
31
|
|
34
32
|
<!--[if lt IE 9]>
|
@@ -48,11 +46,11 @@
|
|
48
46
|
</div>
|
49
47
|
|
50
48
|
<script src="lib/js/head.min.js"></script>
|
51
|
-
<script src="js/reveal.
|
49
|
+
<script src="js/reveal.js"></script>
|
52
50
|
|
53
51
|
<script>
|
54
52
|
|
55
|
-
// Full list of configuration options available
|
53
|
+
// Full list of configuration options available at:
|
56
54
|
// https://github.com/hakimel/reveal.js#configuration
|
57
55
|
Reveal.initialize({
|
58
56
|
controls: true,
|
@@ -60,21 +58,16 @@
|
|
60
58
|
history: true,
|
61
59
|
center: true,
|
62
60
|
|
63
|
-
|
64
|
-
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
|
61
|
+
transition: 'slide', // none/fade/slide/convex/concave/zoom
|
65
62
|
|
66
|
-
//
|
67
|
-
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
|
68
|
-
// parallaxBackgroundSize: '2100px 900px',
|
69
|
-
|
70
|
-
// Optional libraries used to extend on reveal.js
|
63
|
+
// Optional reveal.js plugins
|
71
64
|
dependencies: [
|
72
65
|
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
73
66
|
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
74
67
|
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
75
|
-
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
|
76
|
-
{ src: 'plugin/zoom-js/zoom.js', async: true
|
77
|
-
{ src: 'plugin/notes/notes.js', async: true
|
68
|
+
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
|
69
|
+
{ src: 'plugin/zoom-js/zoom.js', async: true },
|
70
|
+
{ src: 'plugin/notes/notes.js', async: true }
|
78
71
|
]
|
79
72
|
});
|
80
73
|
|
data/lib/reveal/version.rb
CHANGED
data/lib/reveal.rb
CHANGED
data/reveal.rb.gemspec
CHANGED
@@ -16,4 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency 'm'
|
21
|
+
gem.add_development_dependency 'byebug'
|
19
22
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
require_relative '../../../lib/reveal'
|
5
|
+
|
6
|
+
describe Reveal::Cli do
|
7
|
+
let :subject do
|
8
|
+
Reveal::Cli
|
9
|
+
end
|
10
|
+
|
11
|
+
let :logger do
|
12
|
+
Minitest::Mock.new
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.process' do
|
16
|
+
it 'delegates to Reveal::Command method call with arguments' do
|
17
|
+
command = Minitest::Mock.new
|
18
|
+
command.expect(:send, nil, ['method_name', ['arg1', 'arg2']])
|
19
|
+
|
20
|
+
Reveal::Command.stub(:new, command) do
|
21
|
+
subject.process(['method-name', 'arg1', 'arg2'])
|
22
|
+
command.verify
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
require 'tmpdir'
|
5
|
+
require_relative '../../../lib/reveal'
|
6
|
+
|
7
|
+
describe Reveal::Command do
|
8
|
+
let :subject do
|
9
|
+
Reveal::Command.new(logger)
|
10
|
+
end
|
11
|
+
|
12
|
+
let :logger do
|
13
|
+
Minitest::Mock.new
|
14
|
+
end
|
15
|
+
|
16
|
+
let :root_path do
|
17
|
+
Dir.mktmpdir
|
18
|
+
end
|
19
|
+
|
20
|
+
before do
|
21
|
+
FileUtils.mkdir("#{root_path}/reveal")
|
22
|
+
FileUtils.mkdir_p("#{root_path}/lib/reveal/templates")
|
23
|
+
FileUtils.cd("#{root_path}/reveal")
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
FileUtils.rm_rf(root_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#create' do
|
31
|
+
describe "when there's already a directory with the presentation name" do
|
32
|
+
before do
|
33
|
+
FileUtils.mkdir('my_presentation')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'raises an exception' do
|
37
|
+
-> { subject.create(['my_presentation']) }.must_raise RuntimeError
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when there isn't a directory with the presentation name" do
|
42
|
+
it 'creates source and output dir' do
|
43
|
+
logger.expect(:info, nil, [String])
|
44
|
+
|
45
|
+
subject.create(['my_presentation'])
|
46
|
+
|
47
|
+
Dir.exist?('my_presentation/source').must_equal true
|
48
|
+
Dir.exist?('my_presentation/output').must_equal true
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'logs a success message' do
|
52
|
+
logger.expect(:info, nil, ["Presentation 'my_presentation' created."])
|
53
|
+
|
54
|
+
subject.create(['my_presentation'])
|
55
|
+
|
56
|
+
logger.verify
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#add_slide' do
|
62
|
+
describe 'when the presentation exists' do
|
63
|
+
before do
|
64
|
+
FileUtils.touch('template.html')
|
65
|
+
File.write('reveal.yml', {}.to_yaml)
|
66
|
+
FileUtils.mkdir('source')
|
67
|
+
FileUtils.mkdir('output')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'creates a new slide file' do
|
71
|
+
logger.expect(:info, nil, [String])
|
72
|
+
subject.add_slide(['slide1'])
|
73
|
+
|
74
|
+
File.exist?('source/slide1.md').must_equal true
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'writes the updated configuration' do
|
78
|
+
logger.expect(:info, nil, [String])
|
79
|
+
subject.add_slide(['slide1'])
|
80
|
+
|
81
|
+
config = YAML.load(File.read('reveal.yml'))
|
82
|
+
config['slides'].must_equal ['slide1']
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'logs a success message' do
|
86
|
+
logger.expect(:info, nil, ["Slide 'source/slide1.md' created."])
|
87
|
+
|
88
|
+
subject.add_slide(['slide1'])
|
89
|
+
|
90
|
+
logger.verify
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "when the presentation doesn't exist" do
|
95
|
+
it 'raises an exception' do
|
96
|
+
-> { subject.add_slide(['slide1']) }.must_raise RuntimeError
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#generate' do
|
102
|
+
describe 'when the presentation exists' do
|
103
|
+
before do
|
104
|
+
FileUtils.touch('template.html')
|
105
|
+
File.write('reveal.yml', {}.to_yaml)
|
106
|
+
FileUtils.mkdir('source')
|
107
|
+
FileUtils.mkdir('output')
|
108
|
+
File.write('template.html', 'Presentation: <slides>')
|
109
|
+
File.write('source/slide1.md', 'slide 1 content')
|
110
|
+
File.write('source/slide2.md', 'slide 2 content')
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'and slides are automatically ordered' do
|
114
|
+
it 'Updates the generated presentation with automatic slide ordering' do
|
115
|
+
logger.expect(:info, nil, [String])
|
116
|
+
subject.generate
|
117
|
+
|
118
|
+
output = File.read('output/index.html')
|
119
|
+
output.must_match /^Presentation: .*slide 1 content.*slide 2 content/m
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'and slides are manually ordered' do
|
124
|
+
before do
|
125
|
+
File.write('reveal.yml', { 'order' => 'manual', 'slides' => ['slide2', 'slide1'] }.to_yaml)
|
126
|
+
logger.expect(:info, nil, [String])
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'Updates the generated presentation respecting the ordering' do
|
130
|
+
subject.generate
|
131
|
+
|
132
|
+
output = File.read('output/index.html')
|
133
|
+
output.must_match /^Presentation: .*slide 2 content.*slide 1 content/m
|
134
|
+
end
|
135
|
+
|
136
|
+
describe 'and some slides are missing' do
|
137
|
+
before do
|
138
|
+
File.write('reveal.yml', { 'order' => 'manual', 'slides' => ['slide2', 'slide1', 'slide3'] }.to_yaml)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'ignores missing slides' do
|
142
|
+
subject.generate
|
143
|
+
|
144
|
+
output = File.read('output/index.html')
|
145
|
+
output.must_match /^Presentation: .*slide 2 content.*slide 1 content/m
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'logs a success message' do
|
151
|
+
logger.expect(:info, nil, ["'output/index.html' presentation file generated."])
|
152
|
+
|
153
|
+
subject.generate
|
154
|
+
|
155
|
+
logger.verify
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "when the presentation doesn't exist" do
|
160
|
+
it 'raises an exception' do
|
161
|
+
-> { subject.generate(nil) }.must_raise RuntimeError
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|