Class: Kcfu::FileUtil

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

Constant Summary collapse

ROOT_CLIPPING_FOLDER_NAME =
'kindle_clippings'

Instance Method Summary collapse

Instance Method Details

#parse_file(path, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kcfu/file_util.rb', line 8

def parse_file(path, options = {})
  parser.parse_file(path).each do |import_clipping|
    existed_clippings = parse_export_file(export_file_path(import_clipping))

    next unless not_clipped_before?(existed_clippings, import_clipping)

    existed_clippings << import_clipping

    sorted_clippings = existed_clippings.sort { |x, y| x.added_on <=> y.added_on }

    save_clipping_to_file(export_file_path(import_clipping), sorted_clippings)
  end

  conver_markdown(path) if options[:convert] == :markdown
end