Giter Site home page Giter Site logo

sabredav-export's Introduction

sabredav_export

Saves remote SabreDAV calendars and address books to disk. Intended for use with the Backup gem (but it's not a requirement).

Dependencies

  1. A SabreDAV server (tested with Baïkal)

  2. For calendar exports, the iCalendar Export Plugin

  3. For address book exports, the [vCard Export Plugin] (https://code.google.com/p/sabredav/wiki/VCFExportPlugin)

  4. Ruby (tested with 1.9.3 and 2.1)

  5. curl (for HTTP Digest Authentication)

Installation

Please add this to your Gemfile:

gem 'sabredav_export', :git => '[email protected]:toddmazierski/sabredav-export.git', :ref => 'v0.0.2'

Configuration

To configure, pass a block to SabreDAVExport.config:

SabreDAVExport.config do |config|
  config.caldav_url  = 'https://example.com/cal.php'
  config.carddav_url = 'https://example.com/card.php'
  config.username    = 'admin'
  config.password    = 'swordfish'
end

Please note that the username in this context is for authentication purposes.

Usage

# Create a new instance.
address_book = SabreDAVExport::AddressBook.new('paul', 'geologists')
# => #<SabreDAVExport::AddressBook @name="geologists", @username="paul">

# Save the data to disk.
address_book.save
# => 27170

# Test the validity of the data.
address_book.test
# => true

# Here's the location on disk.
address_book.pathname
# => #<Pathname:/tmp/paul-geologists.vcard>

# Let's take a peek at the file.
address_book.pathname.open.lines.to_a[0..2]
# => ["BEGIN:VCARD\r\n",
#  "VERSION:3.0\r\n",
#  "PRODID:-//Apple Inc.//Address Book 6.1.2//EN\r\n"]

# Clean up what's saved to disk.
address_book.clean_up
# => 1

In a Backup model

In this example:

  1. Resources are saved and tested in the before hook

  2. Each pathname is added to an archive

  3. Finally, what's saved to disk is cleaned up in the after hook

Model.new(:baikal, 'Baïkal server backups') do
  resources = [
    SabreDAVExport::Calendar.new('paul', 'excavations'),
    SabreDAVExport::AddressBook.new('paul', 'geologists')
  ]

  before do
    resources.each(&:save)
    resources.each(&:test)
  end

  after { resources.each(&:clean_up) }

  archive :backups do |archive|
    resources.each do |resource|
      archive.add resource.pathname
    end
  end
end

sabredav-export's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.