Module: MultiformatCV
- Defined in:
- lib/multiformatcv.rb,
lib/multiformatcv/version.rb
Defined Under Namespace
Classes: Contact, Job, Personal, Project, Resume
Constant Summary collapse
- YML_FILES =
YAML files that will be read from the specified directory
%w( contact jobs personal )
- VERSION =
"0.0.3"
Class Method Summary collapse
-
.generate(opts = {}) ⇒ String
Parse yaml files located at data directory.
Class Method Details
.generate(opts = {}) ⇒ String
Parse yaml files located at data directory
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/multiformatcv.rb', line 20 def self.generate(opts = {}) opts['format'] ||= 'html' opts['data_dir'] ||= 'data' opts['templates'] ||= File.("../multiformatcv/templates", __FILE__) opts['output'] ||= STDOUT template = File.read("#{ opts['templates'] }/cv.#{ opts['format'] }.erb") resume = Resume.new yml = nil YML_FILES.each do |f| yml = YAML.load_file("#{ opts['data_dir'] }/#{ f }.yml") if yml then resume.send("add_#{ f }", yml[f]) end end result = eval Erubi::Engine.new(template).src if opts['output'] == STDOUT then puts result else File.open(opts['output'], "w") { |f| f.write(result) } end end |