class DocxTemplater::Command
Public Class Methods
generate_doc(options = {})
click to toggle source
# File lib/docx_templater/command.rb, line 23 def self.generate_doc(options = {}) DocxTemplater.template_docx options end
new(args)
click to toggle source
# File lib/docx_templater/command.rb, line 5 def initialize(args) @args = args @options = {} end
Public Instance Methods
run()
click to toggle source
# File lib/docx_templater/command.rb, line 10 def run @opts = OptionParser.new(&method(:set_opts)) @opts.parse!(@args) process! exit 0 rescue Exception => ex raise ex if @options[:trace] || SystemExit === ex $stderr.print "#{ex.class}: " if ex.class != RuntimeError $stderr.puts ex.message $stderr.puts ' Use --trace for backtrace.' exit 1 end
Protected Instance Methods
process!()
click to toggle source
# File lib/docx_templater/command.rb, line 29 def process! args = @args.dup @options[:input] = file = args.shift @options[:output] = destination = args.shift @options[:input] = file = "-" unless file if File.directory?(@options[:input]) Dir["#{@options[:input]}/**/*.#{format}"].each { |file| _process(file, destination) } else _process(file, destination) end end
Private Instance Methods
_process(file, destination = nil)
click to toggle source
# File lib/docx_templater/command.rb, line 50 def _process(file, destination = nil) end
input_is_dir?()
click to toggle source
# File lib/docx_templater/command.rb, line 46 def input_is_dir? File.directory? @options[:input] end