Class: Resume

Inherits:
Object
  • Object
show all
Defined in:
lib/resume_gem.rb

Instance Method Summary collapse

Constructor Details

#initialize(resume_data = 'resume.yml', resume_content = 'resume.md') ⇒ Resume

Returns a new instance of Resume.



11
12
13
14
15
# File 'lib/resume_gem.rb', line 11

def initialize(resume_data = 'resume.yml', resume_content = 'resume.md')
  base = File.join(File.dirname(__FILE__),'..','data')
  @resume = resume_data.is_a?(String) ? YAML::load_file(File.join(base,resume_data)) : resume_data
  @resume_content = resume_content.is_a?(String) ? File.read(File.join(base,resume_content)) : resume_content
end

Instance Method Details

#contact_informationObject



21
22
23
24
25
# File 'lib/resume_gem.rb', line 21

def contact_information
  contact_info = @resume['contact_information']
  contact_info += "\nresume url: #{@resume['resume_url']}" if @resume['resume_url']
  contact_info
end

#htmlObject



41
42
43
44
45
46
47
# File 'lib/resume_gem.rb', line 41

def html
  title = "Dan Mayer's Resume"
  base = File.join(File.dirname(__FILE__),'..')
  resume = RDiscount.new(@resume_content, :smart).to_html
  eruby = Erubis::Eruby.new(File.read(File.join(base,'./views/index.erubis')))
  eruby.result(binding())    
end

#latexObject



36
37
38
39
# File 'lib/resume_gem.rb', line 36

def latex
  doc = Maruku.new(@resume_content)
  doc.to_latex_document
end

#mission_statementObject



17
18
19
# File 'lib/resume_gem.rb', line 17

def mission_statement
  @resume['mission_statement']
end

#open_htmlObject



63
64
65
66
# File 'lib/resume_gem.rb', line 63

def open_html
  tmp_file = write_html_and_css_to_disk()
  Launchy::Browser.new.visit("file://"+File.expand_path(tmp_file))
end

#open_resume_siteObject



27
28
29
30
# File 'lib/resume_gem.rb', line 27

def open_resume_site
  url = @resume['resume_url']
  Launchy::Browser.new.visit(url)
end

#textObject



32
33
34
# File 'lib/resume_gem.rb', line 32

def text
  @resume_content
end

#write_html_and_css_to_disk(root_path = '/tmp') ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/resume_gem.rb', line 49

def write_html_and_css_to_disk(root_path = '/tmp')
  base = File.join(File.dirname(__FILE__),'..')
  #root_path = File.join(base,root_path)
  #FileUtils.mkdir_p root_path unless File.exists?(root_path)
 
  css = Less::Engine.new(File.new(File.join(base,"views/style.less"))).to_css
  tmp_css = File.join(root_path,'style.css')
  File.open(tmp_css, 'w') {|f| f.write(css) }

  tmp_file = File.join(root_path,'index.html')
  File.open(tmp_file, 'w') {|f| f.write(self.html) }
  tmp_file
end