Class: Ever2boost::CsonGenerator

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

Class Method Summary collapse

Class Method Details

.build(folder_hash, note) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ever2boost/cson_generator.rb', line 6

def build(folder_hash, note)
  cson = <<-EOS
type: "MARKDOWN_NOTE"
folder: "#{folder_hash}"
title: "#{note.title}"
content: '''
  # #{note.title}
  #{note.md_content}
'''
tags: []
isStarred: false
createdAt: "#{timestamp}"
updatedAt: "#{timestamp}"
  EOS
end

.output(folder_hash, note, output_dir) ⇒ Object



26
27
28
29
30
31
# File 'lib/ever2boost/cson_generator.rb', line 26

def output(folder_hash, note, output_dir)
  Util.make_notes_dir(output_dir)
  File.open("#{output_dir}/notes/#{note.file_name}.cson", 'w') do |f|
    f.write(build(folder_hash, note))
  end
end

.timestampObject



22
23
24
# File 'lib/ever2boost/cson_generator.rb', line 22

def timestamp
  Time.new.getutc.strftime('%Y-%m-%dT%H:%M:%S')
end