liquidoc 0.3.0 → 0.4.0
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 +4 -4
- data/lib/liquidoc.rb +55 -43
- data/lib/liquidoc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a430c1aff6da069b98f775ec32e1e6b4392bd44b
|
4
|
+
data.tar.gz: 1b8b0d19f71c46709b4c6960f71567ab299c96a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 541de3451669ef6a77cbc5c800baaa9d85f03033f660396eb0afaa6b694d3b803892d7daf7b5ad6479a7891f51d941313569e6147aea2d4a2bb5d5180c400180
|
7
|
+
data.tar.gz: 340ba705cce103d733002e9ddc02b3ae3bb1f86c32149bbe78cb2b574e015a1951bbfc4024c559f12dc1179eed0ddeda87c136aabf0d5e786915d1520935ee86
|
data/lib/liquidoc.rb
CHANGED
@@ -7,6 +7,7 @@ require 'asciidoctor'
|
|
7
7
|
require 'logger'
|
8
8
|
require 'csv'
|
9
9
|
require 'crack/xml'
|
10
|
+
require 'fileutils'
|
10
11
|
|
11
12
|
# ===
|
12
13
|
# Table of Contents
|
@@ -14,15 +15,15 @@ require 'crack/xml'
|
|
14
15
|
#
|
15
16
|
# 1. dependencies stack
|
16
17
|
# 2. default settings
|
17
|
-
# 3. general
|
18
|
-
# 4. object classes
|
19
|
-
# 5. action-specific
|
20
|
-
# 5a. parse
|
21
|
-
# 5b. migrate
|
22
|
-
# 5c. render
|
23
|
-
# 6. text manipulation
|
24
|
-
# 7. command/option parser
|
25
|
-
# 8. executive
|
18
|
+
# 3. general procs def
|
19
|
+
# 4. object classes def
|
20
|
+
# 5. action-specific procs def
|
21
|
+
# 5a. parse procs def
|
22
|
+
# 5b. migrate procs def
|
23
|
+
# 5c. render procs def
|
24
|
+
# 6. text manipulation modules/classes def
|
25
|
+
# 7. command/option parser def
|
26
|
+
# 8. executive proc calls
|
26
27
|
|
27
28
|
# ===
|
28
29
|
# Default settings
|
@@ -33,7 +34,6 @@ require 'crack/xml'
|
|
33
34
|
@configs_dir = @base_dir + '_configs'
|
34
35
|
@templates_dir = @base_dir + '_templates/'
|
35
36
|
@data_dir = @base_dir + '_data/'
|
36
|
-
@output_dir = @base_dir + '_output/'
|
37
37
|
@attributes_file_def = '_data/asciidoctor.yml'
|
38
38
|
@attributes_file = @attributes_file_def
|
39
39
|
@pdf_theme_file = 'theme/pdf-theme.yml'
|
@@ -48,7 +48,7 @@ require 'crack/xml'
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# ===
|
51
|
-
# Executive
|
51
|
+
# Executive procs
|
52
52
|
# ===
|
53
53
|
|
54
54
|
# Establish source, template, index, etc details for build jobs from a config file
|
@@ -84,7 +84,9 @@ def iterate_build cfg
|
|
84
84
|
liquify(data, build.template, build.output) # perform the liquify operation
|
85
85
|
end
|
86
86
|
when "migrate"
|
87
|
-
|
87
|
+
inclusive = true
|
88
|
+
inclusive = step.options['inclusive'] if defined?(step.options['inclusive'])
|
89
|
+
copy_assets(step.source, step.target, inclusive)
|
88
90
|
when "render"
|
89
91
|
@logger.warn "Render actions not yet implemented."
|
90
92
|
when "deploy"
|
@@ -182,6 +184,18 @@ class BuildConfigStep
|
|
182
184
|
return @@step['data']
|
183
185
|
end
|
184
186
|
|
187
|
+
def source
|
188
|
+
return @@step['source']
|
189
|
+
end
|
190
|
+
|
191
|
+
def target
|
192
|
+
return @@step['target']
|
193
|
+
end
|
194
|
+
|
195
|
+
def options
|
196
|
+
return @@step['options']
|
197
|
+
end
|
198
|
+
|
185
199
|
def builds
|
186
200
|
return @@step['builds']
|
187
201
|
end
|
@@ -202,15 +216,14 @@ class Build
|
|
202
216
|
def initialize build, type
|
203
217
|
@@build = build
|
204
218
|
@@type = type
|
205
|
-
@@logger = Logger.new(STDOUT)
|
206
219
|
required = []
|
207
220
|
case type
|
208
221
|
when "parse"
|
209
222
|
required = ["template,output"]
|
210
|
-
when "render"
|
211
|
-
required = ["index,output"]
|
212
223
|
when "migrate"
|
213
224
|
required = ["source,target"]
|
225
|
+
when "render"
|
226
|
+
required = ["index,output"]
|
214
227
|
end
|
215
228
|
for req in required
|
216
229
|
if (defined?(req)).nil?
|
@@ -231,14 +244,6 @@ class Build
|
|
231
244
|
@@build['index']
|
232
245
|
end
|
233
246
|
|
234
|
-
def source
|
235
|
-
@@build['source']
|
236
|
-
end
|
237
|
-
|
238
|
-
def target
|
239
|
-
@@build['target']
|
240
|
-
end
|
241
|
-
|
242
247
|
end #class Build
|
243
248
|
|
244
249
|
class DataSrc
|
@@ -305,9 +310,9 @@ class DataSrc
|
|
305
310
|
end
|
306
311
|
|
307
312
|
# ===
|
308
|
-
# Action-specific
|
309
|
-
#
|
310
|
-
# PARSE-type build
|
313
|
+
# Action-specific procs
|
314
|
+
# ===
|
315
|
+
# PARSE-type build procs
|
311
316
|
# ===
|
312
317
|
|
313
318
|
# Pull in a semi-structured data file, converting contents to a Ruby hash
|
@@ -316,7 +321,7 @@ def ingest_data datasrc
|
|
316
321
|
unless datasrc.is_a? Object
|
317
322
|
raise "InvalidDataObject"
|
318
323
|
end
|
319
|
-
# This
|
324
|
+
# This proc should really begin here, once the datasrc object is in order
|
320
325
|
case datasrc.type
|
321
326
|
when "yml"
|
322
327
|
begin
|
@@ -407,8 +412,9 @@ def liquify datasrc, template_file, output
|
|
407
412
|
end
|
408
413
|
unless output.downcase == "stdout"
|
409
414
|
output_file = output
|
415
|
+
base_path = File.dirname(output)
|
410
416
|
begin
|
411
|
-
Dir.mkdir(
|
417
|
+
Dir.mkdir(base_path) unless File.exists?(base_path)
|
412
418
|
File.open(output_file, 'w') { |file| file.write(rendered) } # saves file
|
413
419
|
rescue Exception => ex
|
414
420
|
@logger.error "Failed to save output.\n#{ex.class} #{ex.message}"
|
@@ -424,30 +430,36 @@ def liquify datasrc, template_file, output
|
|
424
430
|
end
|
425
431
|
|
426
432
|
# ===
|
427
|
-
# MIGRATE-type
|
433
|
+
# MIGRATE-type procs
|
428
434
|
# ===
|
429
435
|
|
430
|
-
# Copy images and other
|
431
|
-
def copy_assets src, dest
|
432
|
-
if
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
end
|
438
|
-
@logger.debug "#{
|
436
|
+
# Copy images and other files into target dir
|
437
|
+
def copy_assets src, dest, inclusive=true
|
438
|
+
if File.file?(src) # for sources that are files
|
439
|
+
target_dir = File.dirname(dest)
|
440
|
+
else # if src is a directory
|
441
|
+
unless inclusive then src = src + "/." end
|
442
|
+
target_dir = dest
|
443
|
+
end
|
444
|
+
@logger.debug "Copying #{src} to #{dest}"
|
445
|
+
# puts "Dir name: " + File.dirname(dest)
|
446
|
+
# puts "Dir exists: " + File.exists?(File.dirname(dest)).to_s
|
439
447
|
begin
|
440
|
-
FileUtils.mkdir_p(dest) unless File.exists?(
|
441
|
-
|
448
|
+
FileUtils.mkdir_p(dest) unless File.exists?(target_dir)
|
449
|
+
if File.directory?(src)
|
450
|
+
FileUtils.cp_r(src, dest)
|
451
|
+
else
|
452
|
+
FileUtils.cp(src, dest)
|
453
|
+
end
|
454
|
+
@logger.info "Copied assets."
|
442
455
|
rescue Exception => ex
|
443
456
|
@logger.warn "Problem while copying assets. #{ex.message}"
|
444
|
-
|
457
|
+
raise
|
445
458
|
end
|
446
|
-
@logger.debug "\s\s#{recursively}opied: #{src} --> #{dest}/#{src}"
|
447
459
|
end
|
448
460
|
|
449
461
|
# ===
|
450
|
-
# RENDER-type
|
462
|
+
# RENDER-type procs
|
451
463
|
# ===
|
452
464
|
|
453
465
|
# Gather attributes from a fixed attributes file
|
data/lib/liquidoc/version.rb
CHANGED