class DocumentList

Module API

Public Class Methods

new(paths, config) click to toggle source

Public

# File lib/document.rb, line 11
def initialize(paths, config)
  @documents = []
  if paths.empty?
    for item in config['documents']
      paths.push(item['main'])
    end
  end
  for path in !paths.empty? ? paths : ['README.md']
    main_path = path
    edit_path = nil
    sync_path = nil
    for item in config['documents']
      if path == item['main']
        edit_path = item.fetch('edit', nil)
        sync_path = item.fetch('sync', nil)
        break
      end
    end
    document = Document.new(main_path, edit_path:edit_path, sync_path:sync_path)
    @documents.push(document)
  end
end

Public Instance Methods

edit() click to toggle source
# File lib/document.rb, line 34
def edit()
  for document in @documents
    document.edit()
  end
end
sync() click to toggle source
# File lib/document.rb, line 40
def sync()
  success = true
  for document in @documents
    valid = document.test(sync:true)
    success = success && valid
    if valid
      document.sync()
    end
  end
  return success
end
test(exit_first:false) click to toggle source
# File lib/document.rb, line 52
def test(exit_first:false)
  success = true
  for document, index in @documents.each_with_index
    number = index + 1
    valid = document.test(exit_first:exit_first)
    success = success && valid
    print_message(nil, (number < @documents.length ? 'separator' : 'blank'))
  end
  return success
end