class Rndr::CLI
Parent CLI
controls for Rndr
. @author Bob Killen <rkillen@umich.edu>
Public Instance Methods
check()
click to toggle source
# File lib/rndr/cli.rb, line 27 def check results = Rndr.matches(path: options[:template], ext: options[:extension], ignore_path: options[:ignore]) template_vars = Rndr.read_vars(path: options[:vars], merge: options[:merge], merge_opts: options[:merge_opts]) results.each do |path| template = Template.new(path: path, vars: template_vars) print_check_result(path: path, result: template.render?) end end
list()
click to toggle source
# File lib/rndr/cli.rb, line 48 def list results = Rndr.matches(path: options[:template], ext: options[:extension], ignore_path: options[:ignore]) if results.empty? puts 'No matching results.' else puts results end end
render()
click to toggle source
# File lib/rndr/cli.rb, line 77 def render # rubocop:disable Metrics/AbcSize results = Rndr.matches(path: options[:template], ext: options[:extension], ignore_path: options[:ignore]) template_vars = Rndr.read_vars(path: options[:vars], merge: options[:merge], merge_opts: options[:merge_opts]) results.each do |path| template = Template.new(path: path, vars: template_vars) render_path = path.gsub(/.#{options[:extension]}$/, '') template.render(render_path) if template.render? print_check_result(path: render_path, result: template.render?) end end
vars()
click to toggle source
# File lib/rndr/cli.rb, line 103 def vars result = Rndr.read_vars(path: options[:vars], merge: options[:merge], merge_opts: options[:merge_opts]) case options[:format].downcase when 'json' puts result.to_json when 'yaml' puts result.to_yaml else puts 'Invalid Format.' end end
version()
click to toggle source
# File lib/rndr/cli.rb, line 118 def version puts "Rndr Version: #{Rndr::VERSION}" end
Private Instance Methods
print_check_result(path:, result:)
click to toggle source
print_check_result
puts the results of an attempted Template.render?
action. @param path [String] Path to template or rendered template. @param result [Boolean] True is successfully rendered template.
# File lib/rndr/cli.rb, line 127 def print_check_result(path:, result:) case result when true puts "#{path} [OK]" when false puts "#{path} [FAIL]" end end