Module: MultiformatCV

Defined in:
lib/multiformatcv.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 )

Class Method Summary collapse

Class Method Details

.generate(opts = {}) ⇒ String

Parse yaml files located at data directory

Parameters:

  • opts (Hash) (defaults to: {})

    Options to specify format and templates source

Options Hash (opts):

  • :data_dir (String)

    Directory where the YAML files are located.

  • :format (Symbol)

    One of [ :html, :tex ]

  • :templates (String)

    Directory where templates are located, expected template files are ‘cv.#{ format }.erb`

Returns:

  • (String)

    Evaluated Erubi::Engine’s source

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/multiformatcv.rb', line 20

def self.generate(opts = {})
  opts[:format] ||= :html
  opts[:data_dir] ||= 'data'
  opts[:templates] ||= File.expand_path("../multiformatcv/templates", __FILE__)

  template = File.read("#{ opts[:templates] }/cv.#{ opts[:format].to_s }.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

  eval Erubi::Engine.new(template).src
end