slideshow-models 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/lib/slideshow/commands/build.rb +84 -0
- data/lib/slideshow/version.rb +1 -1
- data/test/test_build_deck.rb +57 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7c495dbff4118e7db27edcc657493e04f0da5c9
|
4
|
+
data.tar.gz: 2b4f190a814eb0cfbdf42f846d50e974e2e06487
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5daad9297ada4ec336eac0ac4bfe80a4bc3b300479c9ccca1cf11c42ac60bd3a38309a3ea61c77807b4cf0848963c74ff16ce8d0410814717c5d4299dfd5a95c
|
7
|
+
data.tar.gz: ce799acaa508fc3a185c6352b00718c5f030bbb1bbb0429b7eca9554530c831546f392ff17a346f9c5d6b454ffc1d4b2f3c26a47e53b26b8927d43dc863960b4
|
data/Manifest.txt
CHANGED
@@ -204,6 +204,90 @@ class Build
|
|
204
204
|
end # method create_slideshow
|
205
205
|
|
206
206
|
|
207
|
+
|
208
|
+
def create_deck_from_string( buf )
|
209
|
+
|
210
|
+
##
|
211
|
+
## todo/fix: cleanup how to handle files/folders
|
212
|
+
## e.g. do we need outdir,srcdir,usrdir ??
|
213
|
+
## does srcdir make any sense for "inline" buffer??
|
214
|
+
## use srcdir==usrdir - and what is usrdir default ?? etc.
|
215
|
+
|
216
|
+
|
217
|
+
## use a tmp folder for output - why? why not?
|
218
|
+
# - no "real" output other than debug files
|
219
|
+
|
220
|
+
# expand output path in current dir and make sure output path exists
|
221
|
+
outdir = File.expand_path( config.output_path, usrdir )
|
222
|
+
logger.debug "setting outdir to >#{outdir}<"
|
223
|
+
|
224
|
+
FileUtils.makedirs( outdir ) unless File.directory? outdir
|
225
|
+
|
226
|
+
|
227
|
+
### todo/fix:
|
228
|
+
## reset headers too - why? why not?
|
229
|
+
|
230
|
+
# shared variables for templates (binding)
|
231
|
+
content_for = {} # reset content_for hash
|
232
|
+
# give helpers/plugins a session-like hash
|
233
|
+
session = {} # reset session hash for plugins/helpers
|
234
|
+
|
235
|
+
name = 'untitled' ## default name (auto-detect from first file e.g. rest.txt => rest etc.)
|
236
|
+
|
237
|
+
content = ''
|
238
|
+
|
239
|
+
gen = Gen.new( @config,
|
240
|
+
@headers,
|
241
|
+
session,
|
242
|
+
content_for )
|
243
|
+
|
244
|
+
## use a "fake" filename for now - why? why not?
|
245
|
+
fn = 'index.txt'
|
246
|
+
|
247
|
+
dirname = File.dirname( fn )
|
248
|
+
basename = File.basename( fn, '.*' )
|
249
|
+
extname = File.extname( fn )
|
250
|
+
logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}"
|
251
|
+
|
252
|
+
name = basename
|
253
|
+
puts "Preparing slideshow '#{basename}'..."
|
254
|
+
|
255
|
+
|
256
|
+
# change working dir to sourcefile dir
|
257
|
+
# todo: add a -c option to commandline? to let you set cwd?
|
258
|
+
|
259
|
+
srcdir = File.expand_path( dirname, usrdir )
|
260
|
+
logger.debug "setting srcdir to >#{srcdir}<"
|
261
|
+
|
262
|
+
logger.debug "changing cwd to src - new >#{srcdir}<, old >#{Dir.pwd}<"
|
263
|
+
Dir.chdir srcdir
|
264
|
+
|
265
|
+
|
266
|
+
####################
|
267
|
+
## todo/fix: move ctx to Gen.initialize - why? why not?
|
268
|
+
# move outdir, usrdir, name to Gen.initialize ??
|
269
|
+
# add basename, dirname ?
|
270
|
+
gen_ctx = {
|
271
|
+
name: name,
|
272
|
+
srcdir: srcdir,
|
273
|
+
outdir: outdir,
|
274
|
+
usrdir: usrdir,
|
275
|
+
}
|
276
|
+
|
277
|
+
content = gen.render( buf, gen_ctx )
|
278
|
+
|
279
|
+
logger.debug "restoring cwd to usr - new >#{usrdir}<, old >#{Dir.pwd}<"
|
280
|
+
Dir.chdir( usrdir )
|
281
|
+
|
282
|
+
# post-processing (all-in-one HTML with directive as HTML comments)
|
283
|
+
deck = Deck.new( content, header_level: config.header_level,
|
284
|
+
use_slide: config.slide? )
|
285
|
+
|
286
|
+
deck
|
287
|
+
end # method create_deck_from_string
|
288
|
+
|
289
|
+
|
290
|
+
|
207
291
|
end # class Build
|
208
292
|
|
209
293
|
end # class Slideshow
|
data/lib/slideshow/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_build_deck.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestBuildDeck < MiniTest::Test
|
12
|
+
|
13
|
+
|
14
|
+
def test_build_test
|
15
|
+
|
16
|
+
opts = Slideshow::Opts.new
|
17
|
+
|
18
|
+
opts.verbose = true # turn on (verbose) debug output
|
19
|
+
opts.output_path = "#{Slideshow.root}/tmp/#{Time.now.to_i}"
|
20
|
+
|
21
|
+
config = Slideshow::Config.new( opts )
|
22
|
+
config.load
|
23
|
+
config.dump
|
24
|
+
|
25
|
+
b = Slideshow::Build.new( config )
|
26
|
+
buf = File.read_utf8( "#{Slideshow.root}/test/samples/test.md" )
|
27
|
+
deck = b.create_deck_from_string( buf )
|
28
|
+
|
29
|
+
pp deck
|
30
|
+
|
31
|
+
assert true
|
32
|
+
end # method test_build
|
33
|
+
|
34
|
+
|
35
|
+
def test_build_test_content_for
|
36
|
+
|
37
|
+
opts = Slideshow::Opts.new
|
38
|
+
|
39
|
+
opts.verbose = true # turn on (verbose) debug output
|
40
|
+
opts.output_path = "#{Slideshow.root}/tmp/#{Time.now.to_i}"
|
41
|
+
|
42
|
+
config = Slideshow::Config.new( opts )
|
43
|
+
config.load
|
44
|
+
config.dump
|
45
|
+
|
46
|
+
b = Slideshow::Build.new( config )
|
47
|
+
buf = File.read_utf8( "#{Slideshow.root}/test/samples/test_content_for.md" )
|
48
|
+
deck = b.create_deck_from_string( buf )
|
49
|
+
|
50
|
+
pp deck
|
51
|
+
|
52
|
+
assert true
|
53
|
+
end # method test_build
|
54
|
+
|
55
|
+
|
56
|
+
end # class TestBuildDeck
|
57
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slideshow-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: props
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- test/templates/test/test.html
|
177
177
|
- test/templates/test/test.txt
|
178
178
|
- test/test_build.rb
|
179
|
+
- test/test_build_deck.rb
|
179
180
|
- test/test_kramdown.rb
|
180
181
|
- test/test_slide.rb
|
181
182
|
- test/test_version.rb
|