Class: Net::FS::GmailBackup

Inherits:
Object
  • Object
show all
Defined in:
lib/net/fs/gmail-backup.rb

Overview

Net::FS::GmailBackup - Backup files to Gmail.

This is a proof-of-concept developer’s release.

License

Net::FS::GmailBackup is released under the Apache License, Version 2.0

Author

Blair Christensen. <[email protected]>

Copyright © 2007, Blair Christensen

Constant Summary collapse

VERSION =

Net::FS::GmailBackup version

'0.0.1'

Instance Method Summary collapse

Constructor Details

#initialize(user, password) ⇒ GmailBackup

Create connection to Gmail. Returns Net::FS::GmailBackup object.

Example:

require 'rubygems'
gem     'net-fs-gmail-backup', '>= 0.0.1'
require 'net/fs/gmail-backup'
backup = Net::FS::Gmail::Backup.new('your.gmail.account', 'your password')


41
42
43
# File 'lib/net/fs/gmail-backup.rb', line 41

def initialize(user, password)
  @fs = Net::FS::Gmail.new(user, password)
end

Instance Method Details

#backup(directory) ⇒ Object

Backup directory to Gmail.

This method will backup all files located in directory to Gmail. Directories and files in subdirectories will not be backed up at this time. In addition, this performs a full backup with each run, backing up each file regardless of whether it has changed.

Example:

backup.backup('/Users/blair')  # Backup my home directory to Gmail


56
57
58
59
60
61
62
63
64
65
# File 'lib/net/fs/gmail-backup.rb', line 56

def backup(directory)
  Dir[ "#{directory}/*" ].each do |f|
    if File.file?(f)
      @fs.store(f, nil) # TODO 20071025 workaround bug in Net::FS::Gmail 0.0.1
      puts "Backed up: #{f}"
    else
      STDERR.puts "Skipping: #{f}"
    end
  end
end