liquidoc 0.8.1 → 0.9.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 +5 -5
- data/lib/liquid_tags.rb +12 -0
- data/lib/liquidoc.rb +62 -10
- data/lib/liquidoc/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 66391a246f45a5d814fa084fa90dd6d84e86fb5e871b6a539a77451fc1729d62
|
4
|
+
data.tar.gz: 7ccd14f246cc5b0577a81f4bdeff17bd9ecf38af6484c69d9cc3bca3695b3cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02ba0eb644ca0f479b4383cf91eaadbac99cad397dd149d20841d06528338bddaf18fdfcb29ec1d9a8645076be5e2bb5fb87c7abbfce33e3773a882e714bc89a
|
7
|
+
data.tar.gz: fd785c1be75bbfa445190545ef7958307b1e32dbb1af5c27973b7bdddacff87413017b2cd6295acd7306b28a4181d9a226badf038687f3378ab4369ef3264900
|
data/lib/liquid_tags.rb
ADDED
data/lib/liquidoc.rb
CHANGED
@@ -45,6 +45,9 @@ require 'jekyll'
|
|
45
45
|
@output_filename = 'index'
|
46
46
|
@attributes = {}
|
47
47
|
@passed_attrs = {}
|
48
|
+
@passed_vars = {}
|
49
|
+
@passed_configvars = {}
|
50
|
+
@parseconfig = false
|
48
51
|
@verbose = false
|
49
52
|
@quiet = false
|
50
53
|
@explicit = false
|
@@ -66,8 +69,16 @@ FileUtils::mkdir_p("#{@build_dir}/pre") unless File.exists?("#{@build_dir}/pre")
|
|
66
69
|
# ===
|
67
70
|
|
68
71
|
# Establish source, template, index, etc details for build jobs from a config file
|
69
|
-
def config_build config_file
|
72
|
+
def config_build config_file, config_vars={}, parse=false
|
70
73
|
@logger.debug "Using config file #{config_file}."
|
74
|
+
if config_vars or parse
|
75
|
+
# If config variables are passed on the CLI, we want to parse the config file
|
76
|
+
# and use the parsed version for the rest fo this routine
|
77
|
+
config_out = "#{@build_dir}/pre/#{File.basename(config_file)}"
|
78
|
+
liquify(nil,config_file, config_out, config_vars)
|
79
|
+
config_file = config_out
|
80
|
+
@logger.debug "Config parsed! Using #{config_out} for build."
|
81
|
+
end
|
71
82
|
validate_file_input(config_file, "config")
|
72
83
|
begin
|
73
84
|
config = YAML.load_file(config_file)
|
@@ -92,12 +103,15 @@ def iterate_build cfg
|
|
92
103
|
type = step.type
|
93
104
|
case type # a switch to evaluate the 'action' parameter for each step in the iteration...
|
94
105
|
when "parse"
|
95
|
-
|
106
|
+
if step.data
|
107
|
+
data = DataSrc.new(step.data)
|
108
|
+
end
|
96
109
|
builds = step.builds
|
97
|
-
|
110
|
+
builds.each do |bld|
|
98
111
|
build = Build.new(bld, type) # create an instance of the Build class; Build.new accepts a 'bld' hash & action 'type'
|
99
112
|
if build.template
|
100
113
|
@explainer.info build.message
|
114
|
+
build.add_vars!(@passed_vars) unless @passed_vars.empty?
|
101
115
|
liquify(data, build.template, build.output, build.variables) # perform the liquify operation
|
102
116
|
else
|
103
117
|
regurgidata(data, build.output)
|
@@ -120,7 +134,7 @@ def iterate_build cfg
|
|
120
134
|
render_doc(doc, build) # perform the render operation
|
121
135
|
end
|
122
136
|
when "deploy"
|
123
|
-
@logger.warn "Deploy actions are limited and experimental
|
137
|
+
@logger.warn "Deploy actions are limited and experimental."
|
124
138
|
jekyll_serve(build)
|
125
139
|
else
|
126
140
|
@logger.warn "The action `#{type}` is not valid."
|
@@ -276,7 +290,11 @@ class BuildConfigStep
|
|
276
290
|
text = ". #{stage}Draws data from `#{self.data[0]}`"
|
277
291
|
end
|
278
292
|
else
|
279
|
-
|
293
|
+
if self.data
|
294
|
+
text = ". #{stage}Draws data from `#{self.data['file']}`"
|
295
|
+
else
|
296
|
+
text = ". #{stage}Uses data passed via CLI --var options."
|
297
|
+
end
|
280
298
|
end
|
281
299
|
text.concat("#{reason},") if reason
|
282
300
|
text.concat(" and parses it as follows:")
|
@@ -356,6 +374,11 @@ class Build
|
|
356
374
|
@build['variables']
|
357
375
|
end
|
358
376
|
|
377
|
+
def add_vars! vars
|
378
|
+
vars.to_h unless vars.is_a? Hash
|
379
|
+
self.variables.merge!vars
|
380
|
+
end
|
381
|
+
|
359
382
|
def message
|
360
383
|
# dynamically build a message, possibly appending a reason
|
361
384
|
unless @build['message']
|
@@ -664,9 +687,19 @@ end
|
|
664
687
|
|
665
688
|
# Parse given data using given template, generating given output
|
666
689
|
def liquify datasrc, template_file, output, variables=nil
|
667
|
-
|
668
|
-
|
669
|
-
|
690
|
+
if datasrc
|
691
|
+
input = get_data(datasrc)
|
692
|
+
nested = { "data" => get_data(datasrc)}
|
693
|
+
input.merge!nested
|
694
|
+
end
|
695
|
+
if variables
|
696
|
+
if input
|
697
|
+
input.merge!variables
|
698
|
+
else
|
699
|
+
input = variables
|
700
|
+
end
|
701
|
+
end
|
702
|
+
@logger.error "Parse operations need at least a data file or variables." unless input
|
670
703
|
validate_file_input(template_file, "template")
|
671
704
|
if variables
|
672
705
|
vars = { "vars" => variables }
|
@@ -906,6 +939,7 @@ end
|
|
906
939
|
|
907
940
|
def jekyll_serve build
|
908
941
|
# Locally serve Jekyll as per the primary Jekyll config file
|
942
|
+
@logger.debug "Attempting Jekyll serve operation."
|
909
943
|
config_file = build.props['files'][0]
|
910
944
|
if build.props['arguments']
|
911
945
|
opts_args = build.props['arguments'].to_opts_args
|
@@ -1096,6 +1130,24 @@ command_parser = OptionParser.new do|opts|
|
|
1096
1130
|
@jekyll_serve = true
|
1097
1131
|
end
|
1098
1132
|
|
1133
|
+
opts.on("--var KEY=VALUE", "For passing variables directly to the 'vars.' scope template via command line, for non-config builds only.") do |n|
|
1134
|
+
pair = {}
|
1135
|
+
k,v = n.split('=')
|
1136
|
+
pair[k] = v
|
1137
|
+
@passed_vars.merge!pair
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
opts.on("-x", "--cvar KEY=VALUE", "For sending variables to the 'vars.' scope of the config file and triggering Liquid parsing of config.") do |n|
|
1141
|
+
pair = {}
|
1142
|
+
k,v = n.split('=')
|
1143
|
+
pair[k] = v
|
1144
|
+
@passed_configvars.merge!pair
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
opts.on("--parse-config", "Preprocess the designated configuration file as a Liquid template. Superfluous when passing -x/--cvar arguments.") do
|
1148
|
+
@parseconfig = true
|
1149
|
+
end
|
1150
|
+
|
1099
1151
|
opts.on("-h", "--help", "Returns help.") do
|
1100
1152
|
puts opts
|
1101
1153
|
exit
|
@@ -1117,12 +1169,12 @@ explainer_init
|
|
1117
1169
|
unless @config_file
|
1118
1170
|
@logger.debug "Executing config-free build based on API/CLI arguments alone."
|
1119
1171
|
if @data_file
|
1120
|
-
liquify(@data_file, @template_file, @output_file)
|
1172
|
+
liquify(@data_file, @template_file, @output_file, @passed_vars)
|
1121
1173
|
end
|
1122
1174
|
if @index_file
|
1123
1175
|
@logger.warn "Rendering via command line arguments is not yet implemented. Use a config file."
|
1124
1176
|
end
|
1125
1177
|
else
|
1126
1178
|
@logger.debug "Executing... config_build"
|
1127
|
-
config_build(@config_file)
|
1179
|
+
config_build(@config_file, @passed_configvars, @parseconfig)
|
1128
1180
|
end
|
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.9.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: 2018-
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -49,6 +49,7 @@ extensions: []
|
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
51
|
- bin/liquidoc
|
52
|
+
- lib/liquid_tags.rb
|
52
53
|
- lib/liquidoc.rb
|
53
54
|
- lib/liquidoc/version.rb
|
54
55
|
homepage: https://github.com/scalingdata/liquidoc
|
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
73
|
version: '0'
|
73
74
|
requirements: []
|
74
75
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.7.7
|
76
77
|
signing_key:
|
77
78
|
specification_version: 4
|
78
79
|
summary: A highly configurable command-line tool for parsing data and content in common
|