Class: Rawfeed::Resume

Inherits:
Object
  • Object
show all
Defined in:
lib/rawfeed/content/resume.rb

Class Method Summary collapse

Class Method Details

.restore_pageObject



10
11
12
13
14
15
16
17
18
19
20
21
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/rawfeed/content/resume.rb', line 10

def self.restore_page
  Rawfeed::Utils.create_directory(Rawfeed::CONFIG['PAGES_DIR'])
  slug = "resume"
  filepath = File.join(Rawfeed::CONFIG['PAGES_DIR'], "#{slug}.#{CONFIG['markdown_extension']}")

  # capture ctrl+c
  trap("INT") do
    puts "\n[!] Operation canceled by user (Ctrl+C).".yellow
    exit!
  end

  if File.exist?(filepath)
    answer = Rawfeed::Utils.confirm("#{filepath} already exists. Do you want to overwrite?")
    abort("Operation canceled by user.") if answer == 'n'
  end

  File.open(filepath, 'w') do |file|
    file.puts("---")
    file.puts("layout: resume")
    file.puts("author: # \"Your Name\"")
    file.puts("title: Resume")
    file.puts("order: 4")
    file.puts("emoji: 📜")
    file.puts("in_menu: true")
    file.puts("published: false")
    file.puts("toc:")
    file.puts("  enable: false")
    file.puts("permalink: /resume/")
    file.puts("---")
    file.puts("")
    file.puts "<!-- There is no need to put anything here -->"
  end

  puts "[*] Created page #{filepath} successfully!".green
  puts "[!] Note: Remember to set \"published\" to \"true\" to publish.".yellow

end