liquidoc 0.10.0 → 0.12.0.pre.rc4
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 +211 -94
- data/lib/liquidoc/version.rb +1 -1
- metadata +20 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fb2c899ee28ead304240eb43845e3e2fe178d9853ef79c726a0ba6ce95c9214
|
4
|
+
data.tar.gz: b7f1363b8a9734d16ce2f874562e2abb2233cc1afe5844285060676471fd624b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b93027fd037a3fec80d16848a55ac34bde034418584d436740d64ce696cc1732ce63e80914d3bf181b774020b346292f4bc50d40b747ac41a30a006d4c810d9
|
7
|
+
data.tar.gz: b9ff1ced8dc5cb9e269baad24dbfa6fe810a3876e77e4d89aa7c2fbc40561cdd894d7b9a374f21ad0727509f0c3268774952975dfe522e6f8b185497c6eca256
|
data/lib/liquidoc.rb
CHANGED
@@ -40,6 +40,7 @@ require 'highline'
|
|
40
40
|
@configs_dir = @base_dir + '_configs'
|
41
41
|
@templates_dir = @base_dir + '_templates/'
|
42
42
|
@data_dir = @base_dir + '_data/'
|
43
|
+
@data_files = nil
|
43
44
|
@attributes_file_def = '_data/asciidoctor.yml'
|
44
45
|
@attributes_file = @attributes_file_def
|
45
46
|
@pdf_theme_file = 'theme/pdf-theme.yml'
|
@@ -56,6 +57,7 @@ require 'highline'
|
|
56
57
|
@search_index = false
|
57
58
|
@search_index_dry = ''
|
58
59
|
@safemode = true
|
60
|
+
@render_count = 0
|
59
61
|
|
60
62
|
# Instantiate the main Logger object, which is always running
|
61
63
|
@logger = Logger.new(STDOUT)
|
@@ -66,6 +68,7 @@ end
|
|
66
68
|
|
67
69
|
|
68
70
|
FileUtils::mkdir_p("#{@build_dir}") unless File.exists?("#{@build_dir}")
|
71
|
+
FileUtils::rm_rf("#{@build_dir}/pre")
|
69
72
|
FileUtils::mkdir_p("#{@build_dir}/pre") unless File.exists?("#{@build_dir}/pre")
|
70
73
|
|
71
74
|
|
@@ -74,15 +77,21 @@ FileUtils::mkdir_p("#{@build_dir}/pre") unless File.exists?("#{@build_dir}/pre")
|
|
74
77
|
# ===
|
75
78
|
|
76
79
|
# Establish source, template, index, etc details for build jobs from a config file
|
77
|
-
def config_build config_file, config_vars={}, parse=false
|
80
|
+
def config_build config_file, config_vars={}, data_files=nil, parse=false
|
78
81
|
@logger.debug "Using config file #{config_file}."
|
79
82
|
validate_file_input(config_file, "config")
|
80
|
-
if config_vars.length > 0 or parse or contains_liquid(config_file)
|
83
|
+
if config_vars.length > 0 or data_files or parse or contains_liquid(config_file)
|
81
84
|
@logger.debug "Config_vars: #{config_vars.length}"
|
82
85
|
# If config variables are passed on the CLI, we want to parse the config file
|
83
86
|
# and use the parsed version for the rest fo this routine
|
84
87
|
config_out = "#{@build_dir}/pre/#{File.basename(config_file)}"
|
85
|
-
|
88
|
+
data_obj = DataObj.new()
|
89
|
+
if data_files
|
90
|
+
payload = get_payload(data_files)
|
91
|
+
data_obj.add_payload!(payload)
|
92
|
+
end
|
93
|
+
data_obj.add_data!(config_vars, "vars")
|
94
|
+
liquify(data_obj, config_file, config_out)
|
86
95
|
config_file = config_out
|
87
96
|
@logger.debug "Config parsed! Using #{config_out} for build."
|
88
97
|
validate_file_input(config_file, "config")
|
@@ -124,18 +133,28 @@ def iterate_build cfg
|
|
124
133
|
type = step.type
|
125
134
|
case type # a switch to evaluate the 'action' parameter for each step in the iteration...
|
126
135
|
when "parse"
|
136
|
+
builds = step.builds
|
137
|
+
data_obj = DataObj.new()
|
127
138
|
if step.data
|
128
|
-
|
139
|
+
data_files = DataFiles.new(step.data)
|
140
|
+
payload = get_payload(data_files)
|
141
|
+
data_obj.add_payload!(payload)
|
129
142
|
end
|
130
|
-
builds = step.builds
|
131
143
|
builds.each do |bld|
|
132
|
-
build = Build.new(bld, type) # create an instance of the Build class; Build.new accepts a 'bld' hash & action 'type'
|
144
|
+
build = Build.new(bld, type, data_obj) # create an instance of the Build class; Build.new accepts a 'bld' hash & action 'type'
|
133
145
|
if build.template
|
146
|
+
# Prep & perform a Liquid-parsed build
|
134
147
|
@explainer.info build.message
|
135
|
-
build.
|
136
|
-
liquify(data, build.template, build.output
|
137
|
-
else
|
138
|
-
|
148
|
+
build.add_data!(build.variables, "vars") if build.variables
|
149
|
+
liquify(build.data, build.template, build.output) # perform the liquify operation
|
150
|
+
else # Prep & perform a direct conversion
|
151
|
+
# Delete nested data and vars objects
|
152
|
+
build.data.remove_scope("data")
|
153
|
+
build.data.remove_scope("vars")
|
154
|
+
# Add vars from CLI or config args
|
155
|
+
build.data.add_data!(build.variables) unless build.variables.empty?
|
156
|
+
build.data.add_data!(@passed_vars) unless @passed_vars.empty?
|
157
|
+
regurgidata(build.data, build.output)
|
139
158
|
end
|
140
159
|
end
|
141
160
|
when "migrate"
|
@@ -151,7 +170,7 @@ def iterate_build cfg
|
|
151
170
|
builds = step.builds
|
152
171
|
for bld in builds
|
153
172
|
doc = AsciiDocument.new(step.source)
|
154
|
-
attrs = ingest_attributes(step.data) if step.data # Set attributes from
|
173
|
+
attrs = ingest_attributes(step.data) if step.data # Set attributes from YAML files
|
155
174
|
doc.add_attrs!(attrs) # Set attributes from the action-level data file
|
156
175
|
build = Build.new(bld, type) # create an instance of the Build class; Build.new accepts a 'bld' hash & action 'type' string
|
157
176
|
build.set("backend", derive_backend(doc.type, build.output) ) unless build.backend
|
@@ -170,6 +189,10 @@ def iterate_build cfg
|
|
170
189
|
end
|
171
190
|
end
|
172
191
|
|
192
|
+
# ===
|
193
|
+
# Helper procs
|
194
|
+
# ===
|
195
|
+
|
173
196
|
# Verify files exist
|
174
197
|
def validate_file_input file, type
|
175
198
|
@logger.debug "Validating input file for #{type} file #{file}"
|
@@ -401,11 +424,12 @@ end #class Action
|
|
401
424
|
|
402
425
|
class Build
|
403
426
|
|
404
|
-
def initialize build, type
|
427
|
+
def initialize build, type, data=DataObj.new
|
405
428
|
build['attributes'] = Hash.new unless build['attributes']
|
406
429
|
build['props'] = build['properties'] if build['properties']
|
407
430
|
@build = build
|
408
431
|
@type = type
|
432
|
+
@data = data
|
409
433
|
@build['variables'] = {} unless @build['variables']
|
410
434
|
end
|
411
435
|
|
@@ -434,14 +458,23 @@ class Build
|
|
434
458
|
end
|
435
459
|
|
436
460
|
def variables
|
461
|
+
# Variables added in the config build:variables: param
|
462
|
+
# Not for manipulation
|
437
463
|
@build['variables']
|
438
464
|
end
|
439
465
|
|
440
|
-
def
|
441
|
-
|
442
|
-
self.variables.merge!vars
|
466
|
+
def data
|
467
|
+
@data unless @data.nil?
|
443
468
|
end
|
444
469
|
|
470
|
+
def add_data! data, scope=""
|
471
|
+
@data.add_data!(data, scope)
|
472
|
+
end
|
473
|
+
|
474
|
+
# def vars
|
475
|
+
# self.data['vars']
|
476
|
+
# end
|
477
|
+
|
445
478
|
def message
|
446
479
|
# dynamically build a message, possibly appending a reason
|
447
480
|
unless @build['message']
|
@@ -504,10 +537,6 @@ class Build
|
|
504
537
|
end
|
505
538
|
end
|
506
539
|
|
507
|
-
# def prop_files_list # force the array back to a list of files (for CLI)
|
508
|
-
# props['files'].force_array if props['files']
|
509
|
-
# end
|
510
|
-
|
511
540
|
def search
|
512
541
|
props['search']
|
513
542
|
end
|
@@ -561,7 +590,7 @@ class Build
|
|
561
590
|
when "render"
|
562
591
|
reqs = ["output"]
|
563
592
|
end
|
564
|
-
for req in
|
593
|
+
for req in reqs
|
565
594
|
if (defined?(req)).nil?
|
566
595
|
raise "ActionSettingMissing"
|
567
596
|
end
|
@@ -571,32 +600,30 @@ class Build
|
|
571
600
|
end # class Build
|
572
601
|
|
573
602
|
class DataSrc
|
603
|
+
# Organizes metadata about an ingestible data source
|
574
604
|
# initialization means establishing a proper hash for the 'data' param
|
575
|
-
def initialize
|
605
|
+
def initialize sources
|
576
606
|
@datasrc = {}
|
577
|
-
@datasrc['file'] =
|
607
|
+
@datasrc['file'] = sources
|
578
608
|
@datasrc['ext'] = ''
|
579
|
-
@datasrc['
|
580
|
-
|
581
|
-
|
582
|
-
@datasrc['
|
583
|
-
|
584
|
-
|
585
|
-
@datasrc['pattern'] = datasrc['pattern']
|
609
|
+
@datasrc['pattern'] = nil
|
610
|
+
if sources.is_a? Hash # data var is a hash, so add 'ext' to it by extracting it from filename
|
611
|
+
@datasrc['file'] = sources['file']
|
612
|
+
@datasrc['ext'] = File.extname(sources['file'])
|
613
|
+
if (defined?(sources['pattern']))
|
614
|
+
@datasrc['pattern'] = sources['pattern']
|
586
615
|
end
|
587
|
-
if (defined?(
|
588
|
-
@datasrc['type'] =
|
616
|
+
if (defined?(sources['type']))
|
617
|
+
@datasrc['type'] = sources['type']
|
589
618
|
end
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
else
|
597
|
-
raise "InvalidDataSource"
|
598
|
-
end
|
619
|
+
elsif sources.is_a? String
|
620
|
+
@datasrc['ext'] = File.extname(sources)
|
621
|
+
elsif sources.is_a? Array
|
622
|
+
sources.each do |src|
|
623
|
+
@datasrc['name'] = File.basename(@datasrc['file'])
|
599
624
|
end
|
625
|
+
else
|
626
|
+
raise "InvalidDataSource"
|
600
627
|
end
|
601
628
|
end
|
602
629
|
|
@@ -608,6 +635,10 @@ class DataSrc
|
|
608
635
|
@datasrc['ext']
|
609
636
|
end
|
610
637
|
|
638
|
+
def name
|
639
|
+
File.basename(self.file,File.extname(self.file))
|
640
|
+
end
|
641
|
+
|
611
642
|
def type
|
612
643
|
if @datasrc['type'] # if we're carrying a 'type' setting for data, pass it along
|
613
644
|
datatype = @datasrc['type']
|
@@ -619,7 +650,7 @@ class DataSrc
|
|
619
650
|
# @logger.error "Data file extension must be one of: .yml, .json, .xml, or .csv or else declared in config file."
|
620
651
|
raise "FileExtensionUnknown"
|
621
652
|
end
|
622
|
-
datatype =
|
653
|
+
datatype = self.ext
|
623
654
|
datatype = datatype[1..-1] # removes leading dot char
|
624
655
|
end
|
625
656
|
unless datatype.downcase.match(/yml|json|xml|csv|regex/) # 'type' must be one of these permitted vals
|
@@ -632,6 +663,84 @@ class DataSrc
|
|
632
663
|
def pattern
|
633
664
|
@datasrc['pattern']
|
634
665
|
end
|
666
|
+
end # class DataSrc
|
667
|
+
|
668
|
+
# DataFiles
|
669
|
+
class DataFiles
|
670
|
+
# Accepts a single String, Hash, or Array
|
671
|
+
# String must be a path/filename
|
672
|
+
# Hash must contain file: and optionally type: and pattern:
|
673
|
+
# Array must contain path/filenames as strings
|
674
|
+
# Returns array of DataSrc objects
|
675
|
+
def initialize data_sources
|
676
|
+
@data_sources = []
|
677
|
+
if data_sources.is_a? Array
|
678
|
+
data_sources.each do |src|
|
679
|
+
@data_sources << DataSrc.new(src)
|
680
|
+
end
|
681
|
+
else # data_sources is String or Hash
|
682
|
+
@data_sources[0] = DataSrc.new(data_sources)
|
683
|
+
end
|
684
|
+
@src_class = data_sources.class
|
685
|
+
end
|
686
|
+
|
687
|
+
def sources
|
688
|
+
# An Array of DataSrc objects
|
689
|
+
@data_sources
|
690
|
+
end
|
691
|
+
|
692
|
+
def type
|
693
|
+
# returns the original class of the object used to init this obj
|
694
|
+
@src_class
|
695
|
+
end
|
696
|
+
|
697
|
+
end
|
698
|
+
|
699
|
+
class DataObj
|
700
|
+
# DataObj
|
701
|
+
#
|
702
|
+
# Scoped variables for feeding a Liquid parsing operation
|
703
|
+
def initialize
|
704
|
+
@data = {"vars" => {}}
|
705
|
+
end
|
706
|
+
|
707
|
+
def add_data! data, scope=""
|
708
|
+
# Merges data into existing scope or creates a new scope
|
709
|
+
if scope.empty? # store new object at root of this object
|
710
|
+
self.data.merge!data
|
711
|
+
else # store new object as a subordinate, named object
|
712
|
+
if self.data.key?(scope) # merge/append into existing object
|
713
|
+
self.data[scope].merge!data if self.data[scope].is_a? Hash
|
714
|
+
self.data[scope] << data if self.data[scope].is_a? Array
|
715
|
+
else # create a new key named after the scope
|
716
|
+
scoped_hash = { scope => data }
|
717
|
+
self.data.merge!scoped_hash
|
718
|
+
end
|
719
|
+
end
|
720
|
+
end
|
721
|
+
|
722
|
+
def add_payload! payload
|
723
|
+
# Expects an Array of Hashes ([{name=>String, data=>Object},...])
|
724
|
+
if payload.size == 1
|
725
|
+
# If payload is a single Hash, store it at the root level (no scope)
|
726
|
+
self.add_data!(payload[0]['data']) if payload[0]['data'].is_a? Hash
|
727
|
+
# Insert arrays into the data. scope, and for backward compatibility, hashes as well
|
728
|
+
self.add_data!(payload[0]['data'], "data")
|
729
|
+
end
|
730
|
+
# For ALL payloads, create a self-named obj scope
|
731
|
+
payload.each do |obj|
|
732
|
+
self.add_data!(obj['data'], obj['name']) # Insert object under self-named scope
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
def data
|
737
|
+
@data
|
738
|
+
end
|
739
|
+
|
740
|
+
def remove_scope scope
|
741
|
+
self.data.delete(scope)
|
742
|
+
end
|
743
|
+
|
635
744
|
end
|
636
745
|
|
637
746
|
class AsciiDocument
|
@@ -660,31 +769,33 @@ class AsciiDocument
|
|
660
769
|
end
|
661
770
|
end
|
662
771
|
|
663
|
-
class AsciiDoctorConfig
|
664
|
-
def initialize out, type, back
|
665
|
-
|
666
|
-
end
|
667
|
-
end
|
668
|
-
|
669
772
|
# ===
|
670
773
|
# Action-specific procs
|
671
774
|
# ===
|
672
775
|
# PARSE-type build procs
|
673
776
|
# ===
|
674
777
|
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
778
|
+
def get_payload data_files
|
779
|
+
# data_files: a proper DataFile object
|
780
|
+
payload = []
|
781
|
+
data_files.sources.each do |src|
|
782
|
+
obj = {}
|
783
|
+
begin
|
784
|
+
data = ingest_data(src) # Extract data from file
|
785
|
+
rescue Exception => ex
|
786
|
+
@logger.error "#{ex.class}: #{ex.message}"
|
787
|
+
raise "DataFileReadFail (#{src.file})"
|
788
|
+
end
|
789
|
+
obj['name'] = src.name
|
790
|
+
obj['data'] = data
|
791
|
+
payload << obj
|
680
792
|
end
|
681
|
-
|
682
|
-
return ingest_data(datasrc)
|
793
|
+
return payload
|
683
794
|
end
|
684
795
|
|
685
|
-
# Pull in a semi-structured data file, converting contents to a Ruby
|
796
|
+
# Pull in a semi-structured data file, converting contents to a Ruby object
|
686
797
|
def ingest_data datasrc
|
687
|
-
raise "
|
798
|
+
raise "InvalidDataSrcObject" unless datasrc.is_a? DataSrc
|
688
799
|
case datasrc.type
|
689
800
|
when "yml"
|
690
801
|
begin
|
@@ -724,9 +835,6 @@ def ingest_data datasrc
|
|
724
835
|
raise "MissingRegexPattern"
|
725
836
|
end
|
726
837
|
end
|
727
|
-
if data.is_a? Array
|
728
|
-
data = {"data" => data}
|
729
|
-
end
|
730
838
|
return data
|
731
839
|
end
|
732
840
|
|
@@ -757,29 +865,12 @@ def parse_regex data_file, pattern
|
|
757
865
|
end
|
758
866
|
|
759
867
|
# Parse given data using given template, generating given output
|
760
|
-
def liquify
|
761
|
-
if datasrc
|
762
|
-
input = get_data(datasrc)
|
763
|
-
nested = { "data" => get_data(datasrc)}
|
764
|
-
input.merge!nested
|
765
|
-
end
|
766
|
-
if variables
|
767
|
-
if input
|
768
|
-
input.merge!variables
|
769
|
-
else
|
770
|
-
input = variables
|
771
|
-
end
|
772
|
-
end
|
773
|
-
@logger.error "Parse operations need at least a data file or variables." unless input
|
868
|
+
def liquify data_obj, template_file, output
|
774
869
|
validate_file_input(template_file, "template")
|
775
|
-
if variables
|
776
|
-
vars = { "vars" => variables }
|
777
|
-
input.merge!vars
|
778
|
-
end
|
779
870
|
begin
|
780
871
|
template = File.read(template_file) # reads the template file
|
781
872
|
template = Liquid::Template.parse(template) # compiles template
|
782
|
-
rendered = template.render(
|
873
|
+
rendered = template.render(data_obj.data) # renders the output
|
783
874
|
rescue Exception => ex
|
784
875
|
message = "Problem rendering Liquid template. #{template_file}\n" \
|
785
876
|
"#{ex.class} thrown. #{ex.message}"
|
@@ -794,14 +885,32 @@ def liquify datasrc, template_file, output, variables=nil
|
|
794
885
|
end
|
795
886
|
end
|
796
887
|
|
797
|
-
def
|
798
|
-
|
888
|
+
def cli_liquify data_files=nil, template_file=nil, output_file=nil, passed_vars
|
889
|
+
# converts command-line options into liquify or regurgidata inputs
|
890
|
+
data_obj = DataObj.new()
|
891
|
+
if data_files
|
892
|
+
payload = get_payload(data_files)
|
893
|
+
data_obj.add_payload!(payload)
|
894
|
+
end
|
895
|
+
if template_file
|
896
|
+
# data_obj.add_data!(ingested, "data") if df
|
897
|
+
data_obj.add_data!(passed_vars, "vars") if passed_vars
|
898
|
+
liquify(data_obj, template_file, output_file)
|
899
|
+
else
|
900
|
+
data_obj.remove_scope("vars")
|
901
|
+
data_obj.add_data!(passed_vars) if passed_vars
|
902
|
+
regurgidata(data_obj, output_file)
|
903
|
+
end
|
904
|
+
end
|
905
|
+
|
906
|
+
def regurgidata data_obj, output
|
907
|
+
# converts data files from one format directly to another
|
799
908
|
raise "UnrecognizedFileExtension" unless File.extname(output).match(/\.yml|\.json|\.xml|\.csv/)
|
800
909
|
case File.extname(output)
|
801
910
|
when ".yml"
|
802
|
-
new_data = data.to_yaml
|
911
|
+
new_data = data_obj.data.to_yaml
|
803
912
|
when ".json"
|
804
|
-
new_data = data.to_json
|
913
|
+
new_data = data_obj.data.to_json
|
805
914
|
when ".xml"
|
806
915
|
@logger.warn "XML output not yet implemented."
|
807
916
|
when ".csv"
|
@@ -809,9 +918,11 @@ def regurgidata datasrc, output
|
|
809
918
|
end
|
810
919
|
if new_data
|
811
920
|
begin
|
812
|
-
|
921
|
+
generate_file(new_data, output)
|
922
|
+
# File.open(output, 'w') { |file| file.write(new_data) }
|
813
923
|
@logger.info "Data converted and saved to #{output}."
|
814
|
-
rescue
|
924
|
+
rescue Exception => ex
|
925
|
+
@logger.error "#{ex.class}: #{ex.message}"
|
815
926
|
raise "FileWriteError"
|
816
927
|
end
|
817
928
|
end
|
@@ -879,7 +990,7 @@ def ingest_attributes attr_file
|
|
879
990
|
begin
|
880
991
|
new_attrs = new_attrs[block_name]
|
881
992
|
rescue
|
882
|
-
raise "InvalidAttributesBlock"
|
993
|
+
raise "InvalidAttributesBlock (#{filename}:#{block_name})"
|
883
994
|
end
|
884
995
|
end
|
885
996
|
rescue Exception => ex
|
@@ -910,6 +1021,8 @@ def derive_backend type, out_file
|
|
910
1021
|
end
|
911
1022
|
|
912
1023
|
def render_doc doc, build
|
1024
|
+
@render_count += 1
|
1025
|
+
@logger.info "### Build ##{@render_count}"
|
913
1026
|
case build.backend
|
914
1027
|
when "html5", "pdf"
|
915
1028
|
asciidocify(doc, build)
|
@@ -953,6 +1066,7 @@ def asciidocify doc, build
|
|
953
1066
|
# Perform the aciidoctor convert
|
954
1067
|
if build.backend == "pdf"
|
955
1068
|
@logger.info "Generating PDF. This can take some time..."
|
1069
|
+
attrs.merge!({"pdf-theme"=>build.style}) if build.style
|
956
1070
|
end
|
957
1071
|
Asciidoctor.convert_file(
|
958
1072
|
doc.index,
|
@@ -964,7 +1078,7 @@ def asciidocify doc, build
|
|
964
1078
|
safe: "unsafe",
|
965
1079
|
sourcemap: true,
|
966
1080
|
verbose: @verbose,
|
967
|
-
mkdirs: true
|
1081
|
+
mkdirs: true,
|
968
1082
|
)
|
969
1083
|
@logger.info "Rendered file #{to_file}."
|
970
1084
|
end
|
@@ -980,18 +1094,19 @@ def generate_site doc, build
|
|
980
1094
|
attrs.merge!(build.attributes) if build.attributes
|
981
1095
|
attrs = {"asciidoctor" => {"attributes" => attrs} }
|
982
1096
|
attrs_yaml = attrs.to_yaml # Convert it all back to Yaml, as we're going to write a file to feed back to Jekyll
|
983
|
-
File.open("#{@build_dir}/pre/
|
984
|
-
build.add_config_file("#{@build_dir}/pre/
|
1097
|
+
File.open("#{@build_dir}/pre/attributes_#{@render_count}.yml", 'w') { |file| file.write(attrs_yaml) }
|
1098
|
+
build.add_config_file("#{@build_dir}/pre/attributes_#{@render_count}.yml")
|
985
1099
|
config_list = build.prop_files_array.join(',') # flatten the Array back down for the CLI
|
986
1100
|
quiet = "--quiet" if @quiet || @explicit
|
987
1101
|
if build.props['arguments']
|
988
|
-
opts_args_file = "#{@build_dir}/pre/
|
1102
|
+
opts_args_file = "#{@build_dir}/pre/jekyll_opts_args_#{@render_count}.yml"
|
989
1103
|
opts_args = build.props['arguments']
|
990
1104
|
File.open(opts_args_file, 'w') { |file|
|
991
1105
|
file.write(opts_args.to_yaml)}
|
992
1106
|
config_list << ",#{opts_args_file}"
|
993
1107
|
end
|
994
1108
|
base_args = "--config #{config_list}"
|
1109
|
+
base_args += " --trace" if @verbose
|
995
1110
|
command = "bundle exec jekyll build #{base_args} #{quiet}"
|
996
1111
|
if @search_index
|
997
1112
|
# TODO enable config-based admin api key ingest once config is dynamic
|
@@ -1214,8 +1329,10 @@ command_parser = OptionParser.new do|opts|
|
|
1214
1329
|
@config_file = @base_dir + n
|
1215
1330
|
end
|
1216
1331
|
|
1217
|
-
opts.on("-d PATH", "--data=PATH", "Semi-structured data source (input) path. Ex. path/to/data.yml. Required unless --config is called." ) do |n|
|
1218
|
-
|
1332
|
+
opts.on("-d PATH[,PATH]", "--data=PATH[,PATH]", "Semi-structured data source (input) path or paths. Ex. path/to/data.yml or data/file1.yml,data/file2.json. Required unless --config is called; optional with config." ) do |n|
|
1333
|
+
data_files = n.split(',')
|
1334
|
+
data_files = data_files.map! {|file| @base_dir + file}
|
1335
|
+
@data_files = DataFiles.new(data_files)
|
1219
1336
|
end
|
1220
1337
|
|
1221
1338
|
opts.on("-f PATH", "--from=PATH", "Directory to copy assets from." ) do |n|
|
@@ -1307,13 +1424,13 @@ explainer_init
|
|
1307
1424
|
|
1308
1425
|
unless @config_file
|
1309
1426
|
@logger.debug "Executing config-free build based on API/CLI arguments alone."
|
1310
|
-
if @
|
1311
|
-
|
1427
|
+
if @data_files
|
1428
|
+
cli_liquify(@data_files, @template_file, @output_file, @passed_vars)
|
1312
1429
|
end
|
1313
1430
|
if @index_file
|
1314
1431
|
@logger.warn "Rendering via command line arguments is not yet implemented. Use a config file."
|
1315
1432
|
end
|
1316
1433
|
else
|
1317
1434
|
@logger.debug "Executing... config_build"
|
1318
|
-
config_build(@config_file, @passed_vars, @parseconfig)
|
1435
|
+
config_build(@config_file, @passed_vars, @data_files, @parseconfig)
|
1319
1436
|
end
|
data/lib/liquidoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquidoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0.pre.rc4
|
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: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.15'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: asciidoctor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: asciidoctor-pdf
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.5.
|
89
|
+
version: 1.5.3
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.5.
|
96
|
+
version: 1.5.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: logger
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +128,28 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '4.0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '4.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: jekyll-asciidoc
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '3.0'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '3.0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: highline
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +177,7 @@ files:
|
|
177
177
|
- bin/liquidoc
|
178
178
|
- lib/liquidoc.rb
|
179
179
|
- lib/liquidoc/version.rb
|
180
|
-
homepage: https://github.com/
|
180
|
+
homepage: https://github.com/DocOps/liquidoc
|
181
181
|
licenses:
|
182
182
|
- MIT
|
183
183
|
metadata:
|
@@ -197,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: 2.7.0
|
199
199
|
requirements: []
|
200
|
-
|
201
|
-
rubygems_version: 2.7.6
|
200
|
+
rubygems_version: 3.0.3
|
202
201
|
signing_key:
|
203
202
|
specification_version: 4
|
204
203
|
summary: A highly configurable command-line tool for parsing data and content in common
|