liquidoc 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/liquidoc.rb +56 -60
- data/lib/liquidoc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d93d2ba43725019138268b7cbc3e90df6a8edf7f
|
4
|
+
data.tar.gz: 4ae07aca59730f64a1e9769d9c2c2c964027d0ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94f1db1b4a534a2ac0630290286ed98e133d4412fc2a42e4121c4733a751219f76713c7992e8bf4bb128d30667c5343edc658f1729b5dd48557652ec69bac2f0
|
7
|
+
data.tar.gz: 0a5fbaf300323cc475ca61ab1b2ddb475b9a4ca91944bdadf34c10a83373e9a7f462efc4dc39c3fed3755fb575c680c7c408e607703e28e4127ceacd06ca5762
|
data/lib/liquidoc.rb
CHANGED
@@ -92,7 +92,6 @@ def iterate_build cfg
|
|
92
92
|
copy_assets(step.source, step.target, inclusive)
|
93
93
|
when "render"
|
94
94
|
if defined?(step.data) # if we're passing attributes as a YAML file, let's ingest that up front
|
95
|
-
validate_file_input(step.data, "data")
|
96
95
|
attrs = ingest_attributes(step.data)
|
97
96
|
else
|
98
97
|
attrs = {}
|
@@ -290,28 +289,21 @@ class DataSrc
|
|
290
289
|
# initialization means establishing a proper hash for the 'data' param
|
291
290
|
def initialize datasrc
|
292
291
|
@datasrc = {}
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
292
|
+
@datasrc['file'] = datasrc
|
293
|
+
@datasrc['ext'] = File.extname(datasrc)
|
294
|
+
@datasrc['type'] = false
|
295
|
+
@datasrc['pattern'] = false
|
296
|
+
if datasrc.is_a? Hash # data var is a hash, so add 'ext' to it by extracting it from filename
|
297
|
+
@datasrc['file'] = datasrc['file']
|
298
|
+
@datasrc['ext'] = File.extname(datasrc['file'])
|
299
|
+
if (defined?(datasrc['pattern']))
|
300
|
+
@datasrc['pattern'] = datasrc['pattern']
|
301
301
|
end
|
302
|
-
|
303
|
-
|
304
|
-
@datasrc['file'] = datasrc['file']
|
305
|
-
@datasrc['ext'] = File.extname(datasrc['file'])
|
306
|
-
if (defined?(datasrc['pattern']))
|
307
|
-
@datasrc['pattern'] = datasrc['pattern']
|
308
|
-
end
|
309
|
-
if (defined?(datasrc['type']))
|
310
|
-
@datasrc['type'] = datasrc['type']
|
311
|
-
end
|
312
|
-
else # datasrc is neither String nor Hash
|
313
|
-
raise "InvalidDataSource"
|
302
|
+
if (defined?(datasrc['type']))
|
303
|
+
@datasrc['type'] = datasrc['type']
|
314
304
|
end
|
305
|
+
else # datasrc is neither String nor Hash
|
306
|
+
raise "InvalidDataSource"
|
315
307
|
end
|
316
308
|
end
|
317
309
|
|
@@ -396,20 +388,20 @@ def ingest_data datasrc
|
|
396
388
|
case datasrc.type
|
397
389
|
when "yml"
|
398
390
|
begin
|
399
|
-
|
391
|
+
data = YAML.load_file(datasrc.file)
|
400
392
|
rescue Exception => ex
|
401
393
|
@logger.error "There was a problem with the data file. #{ex.message}"
|
402
394
|
end
|
403
395
|
when "json"
|
404
396
|
begin
|
405
|
-
|
397
|
+
data = JSON.parse(File.read(datasrc.file))
|
406
398
|
rescue Exception => ex
|
407
399
|
@logger.error "There was a problem with the data file. #{ex.message}"
|
408
400
|
end
|
409
401
|
when "xml"
|
410
402
|
begin
|
411
403
|
data = Crack::XML.parse(File.read(datasrc.file))
|
412
|
-
|
404
|
+
data = data['root']
|
413
405
|
rescue Exception => ex
|
414
406
|
@logger.error "There was a problem with the data file. #{ex.message}"
|
415
407
|
end
|
@@ -422,13 +414,13 @@ def ingest_data datasrc
|
|
422
414
|
i = i+1
|
423
415
|
end
|
424
416
|
output = {"data" => output}
|
425
|
-
|
417
|
+
data = output
|
426
418
|
rescue
|
427
419
|
@logger.error "The CSV format is invalid."
|
428
420
|
end
|
429
421
|
when "regex"
|
430
422
|
if datasrc.pattern
|
431
|
-
|
423
|
+
data = parse_regex(datasrc.file, datasrc.pattern)
|
432
424
|
else
|
433
425
|
@logger.error "You must supply a regex pattern with your free-form data file."
|
434
426
|
raise "MissingRegexPattern"
|
@@ -533,16 +525,40 @@ end
|
|
533
525
|
# RENDER-type procs
|
534
526
|
# ===
|
535
527
|
|
536
|
-
# Gather attributes from
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
528
|
+
# Gather attributes from one or more fixed attributes files
|
529
|
+
def ingest_attributes attr_file
|
530
|
+
file_array = attr_file.split(",")
|
531
|
+
attrs = {}
|
532
|
+
for f in file_array
|
533
|
+
if f.include? ":"
|
534
|
+
file = f.split(":")
|
535
|
+
filename = file[0]
|
536
|
+
block_name = file[1]
|
537
|
+
else
|
538
|
+
filename = f
|
539
|
+
block_name = false
|
540
|
+
end
|
541
|
+
validate_file_input(filename, "attributes")
|
542
|
+
begin
|
543
|
+
new_attrs = YAML.load_file(filename)
|
544
|
+
if block_name
|
545
|
+
begin
|
546
|
+
new_attrs = new_attrs[block_name]
|
547
|
+
rescue
|
548
|
+
raise "InvalidAttributesBlock"
|
549
|
+
end
|
550
|
+
end
|
551
|
+
rescue Exception => ex
|
552
|
+
@logger.error "Attributes block invalid. #{ex.class}: #{ex.message}"
|
553
|
+
raise "AttributeBlockError"
|
554
|
+
end
|
555
|
+
begin
|
556
|
+
attrs.merge!new_attrs
|
557
|
+
rescue Exception => ex
|
558
|
+
raise "AttributesMergeError #{ex.message}"
|
559
|
+
end
|
545
560
|
end
|
561
|
+
return attrs
|
546
562
|
end
|
547
563
|
|
548
564
|
def derive_backend type, out_file
|
@@ -593,7 +609,7 @@ def asciidocify doc, build
|
|
593
609
|
verbose: @verbose,
|
594
610
|
mkdirs: true
|
595
611
|
)
|
596
|
-
else # For PDFs, we're calling the asciidoctor-pdf CLI, as the main dependency
|
612
|
+
else # For PDFs, we're calling the asciidoctor-pdf CLI, as the main dependency doesn't seem to perform the same way
|
597
613
|
attributes = '-a ' + doc.attributes.map{|k,v| "#{k}='#{v}'"}.join(' -a ')
|
598
614
|
command = "asciidoctor-pdf -o #{to_file} -b pdf -d #{build.doctype} -S unsafe #{attributes} -a no-header-footer --trace #{doc.index}"
|
599
615
|
@logger.debug "Running #{command}"
|
@@ -646,34 +662,14 @@ module CustomFilters
|
|
646
662
|
end
|
647
663
|
end
|
648
664
|
|
649
|
-
|
650
|
-
# https://github.com/slate-studio/engine/blob/master/lib/locomotive/core_ext.rb
|
651
|
-
def slugify(options = {})
|
652
|
-
options = { :sep => '_', :without_extension => false, :downcase => false, :underscore => false }.merge(options)
|
653
|
-
# replace accented chars with ther ascii equivalents
|
654
|
-
s = ActiveSupport::Inflector.transliterate(self).to_s
|
655
|
-
# No more than one slash in a row
|
656
|
-
s.gsub!(/(\/[\/]+)/, '/')
|
657
|
-
# Remove leading or trailing space
|
658
|
-
s.strip!
|
659
|
-
# Remove leading or trailing slash
|
660
|
-
s.gsub!(/(^[\/]+)|([\/]+$)/, '')
|
661
|
-
# Remove extensions
|
662
|
-
s.gsub!(/(\.[a-zA-Z]{2,})/, '') if options[:without_extension]
|
665
|
+
def slugify input
|
663
666
|
# Downcase
|
664
|
-
s.downcase! if options[:downcase]
|
665
667
|
# Turn unwanted chars into the seperator
|
666
|
-
s.
|
667
|
-
|
668
|
-
s.gsub!(/[\-]/i, '_') if options[:underscore]
|
668
|
+
s = input.to_s.downcase
|
669
|
+
s.gsub!(/[^a-zA-Z0-9\-_\+\/]+/i, "-")
|
669
670
|
s
|
670
671
|
end
|
671
|
-
|
672
|
-
replace(self.slugify(options))
|
673
|
-
end
|
674
|
-
def parameterize!(sep = '_')
|
675
|
-
replace(self.parameterize(sep))
|
676
|
-
end
|
672
|
+
|
677
673
|
end
|
678
674
|
|
679
675
|
# register custom Liquid filters
|
data/lib/liquidoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquidoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Dominick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|