Method: Doing::WWID#archive

Defined in:
lib/doing/wwid/modify.rb

#archive(section = Doing.setting('current_section'), options) ⇒ Object

Move entries from a section to Archive or other specified section

Parameters:

  • section (String) (defaults to: Doing.setting('current_section'))

    The source section

  • options (Hash)

    Options



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/doing/wwid/modify.rb', line 417

def archive(section = Doing.setting('current_section'), options)
  options ||= {}
  count       = options[:keep] || 0
  destination = options[:destination] || 'Archive'
  tags        = options[:tags] || []
  bool        = options[:bool] || :and

  section = choose_section if section.nil? || section =~ /choose/i
  archive_all = section =~ /^all$/i # && !(tags.nil? || tags.empty?)
  section = guess_section(section) unless archive_all

  @content.add_section(destination, log: true)
  # add_section(Section.new('Archive')) if destination =~ /^archive$/i && [email protected]?('Archive')

  destination = guess_section(destination)

  if @content.section?(destination) && (@content.section?(section) || archive_all)
    do_archive(section, destination, { count: count, tags: tags, bool: bool, search: options[:search], label: options[:label], before: options[:before], after: options[:after], from: options[:from] })
    write(doing_file)
  else
    raise InvalidArgument, 'Either source or destination does not exist'
  end
end