Module: DocxTemplater
- Defined in:
- lib/docx_templater.rb,
lib/docx_templater/command.rb,
lib/docx_templater/version.rb,
lib/docx_templater/docx_creator.rb,
lib/docx_templater/template_processor.rb
Defined Under Namespace
Classes: Command, DocxCreator, TemplateProcessor
Constant Summary collapse
- VERSION =
'0.1.1'
Class Method Summary collapse
- .log(str) ⇒ Object
-
.open_output_file(output_file) ⇒ Object
Open word file in mac os(with word installed).
-
.template_docx(options = {}) ⇒ Object
template docx file.
Class Method Details
.log(str) ⇒ Object
8 9 10 11 |
# File 'lib/docx_templater.rb', line 8 def log(str) # braindead logging puts str if ENV['DEBUG'] end |
.open_output_file(output_file) ⇒ Object
Open word file in mac os(with word installed)
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/docx_templater.rb', line 36 def open_output_file(output_file) puts "\n************************************" puts ' >>> Only will work on mac <<<' puts 'NOW attempting to open created file in Word.' cmd = "open #{output_file}" puts " will run '#{cmd}'" puts '************************************' system cmd end |
.template_docx(options = {}) ⇒ Object
template docx file
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/docx_templater.rb', line 23 def template_docx( = {}) puts "options: #{}" DocxTemplater::DocxCreator.new([:input_file], [:data]).generate_docx_file([:output_file]) archive = Zip::File.open([:output_file]) archive.close DocxTemplater.open_output_file [:output_file] end |