Top Level Namespace

Defined Under Namespace

Modules: Zolaposta

Instance Method Summary collapse

Instance Method Details

#cancel_operationObject



37
38
39
40
# File 'lib/zolaposta.rb', line 37

def cancel_operation()
  puts 'Operation cancelled. Exiting...'.colorize(:red)
  exit
end

#generate_frontmatter(title, description, tags) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/zolaposta.rb', line 5

def generate_frontmatter(title, description, tags)
  frontmatter = {
    'date' => Date.today.strftime('%Y-%m-%d')
  }

  frontmatter['title'] = title unless title.empty?

  frontmatter['description'] = description unless description.empty?

  frontmatter['taxonomies'] = { 'tags' => tags } unless tags.empty?

  TomlRB.dump(frontmatter)
end

#get_tags_from_userObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/zolaposta.rb', line 24

def get_tags_from_user()
  tags = []

  loop do
    tag = get_user_input('Enter a tag (press enter to add another tag, or leave blank if done): ')
    break if tag.empty?

    tags << tag
  end

  tags
end

#get_user_input(prompt) ⇒ Object



19
20
21
22
# File 'lib/zolaposta.rb', line 19

def get_user_input(prompt)
  print prompt.colorize(color: :blue, mode: :bold)
  gets.chomp
end