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 =
Gem version
'0.0.5'
Class Method Summary collapse
-
.generate(opts = {}) ⇒ MultiformatCV::Resume
Parse yaml files located at data directory.
Class Method Details
.generate(opts = {}) ⇒ MultiformatCV::Resume
Parse yaml files located at data directory
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/multiformatcv.rb', line 22 def self.generate(opts = {}) opts['format'] ||= 'html' opts['data_dir'] ||= 'data' opts['templates'] ||= default_template_path opts['output'] ||= nil 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 resume.rendered = eval Erubi::Engine.new(template).src if opts['output'] then File.open(opts['output'], 'w') { |f| f.write(resume.rendered) } end resume end |