backup 3.0.11 → 3.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +5 -0
 - data/backup.gemspec +1 -1
 - data/lib/backup/configuration/notifier/campfire.rb +17 -0
 - data/lib/backup/dependency.rb +13 -1
 - data/lib/backup/model.rb +1 -1
 - data/lib/backup/notifier/campfire.rb +179 -0
 - data/lib/backup/version.rb +1 -1
 - data/lib/backup.rb +7 -5
 - data/spec/model_spec.rb +1 -1
 - data/spec/notifier/campfire_spec.rb +96 -0
 - metadata +22 -3
 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -4,6 +4,7 @@ GEM 
     | 
|
| 
       4 
4 
     | 
    
         
             
                activesupport (3.0.5)
         
     | 
| 
       5 
5 
     | 
    
         
             
                addressable (2.2.4)
         
     | 
| 
       6 
6 
     | 
    
         
             
                builder (3.0.0)
         
     | 
| 
      
 7 
     | 
    
         
            +
                crack (0.1.8)
         
     | 
| 
       7 
8 
     | 
    
         
             
                diff-lcs (1.1.2)
         
     | 
| 
       8 
9 
     | 
    
         
             
                dropbox (1.2.3)
         
     | 
| 
       9 
10 
     | 
    
         
             
                  json (>= 1.2.0)
         
     | 
| 
         @@ -32,6 +33,8 @@ GEM 
     | 
|
| 
       32 
33 
     | 
    
         
             
                  rspec-instafail (~> 0.1.4)
         
     | 
| 
       33 
34 
     | 
    
         
             
                  ruby-progressbar (~> 0.0.9)
         
     | 
| 
       34 
35 
     | 
    
         
             
                hashie (1.0.0)
         
     | 
| 
      
 36 
     | 
    
         
            +
                httparty (0.7.4)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  crack (= 0.1.8)
         
     | 
| 
       35 
38 
     | 
    
         
             
                i18n (0.5.0)
         
     | 
| 
       36 
39 
     | 
    
         
             
                infinity_test (1.0.2)
         
     | 
| 
       37 
40 
     | 
    
         
             
                  notifiers (>= 1.1.0)
         
     | 
| 
         @@ -90,7 +93,9 @@ DEPENDENCIES 
     | 
|
| 
       90 
93 
     | 
    
         
             
              dropbox (~> 1.2.3)
         
     | 
| 
       91 
94 
     | 
    
         
             
              fog (~> 0.7.0)
         
     | 
| 
       92 
95 
     | 
    
         
             
              fuubar
         
     | 
| 
      
 96 
     | 
    
         
            +
              httparty (~> 0.7.4)
         
     | 
| 
       93 
97 
     | 
    
         
             
              infinity_test
         
     | 
| 
      
 98 
     | 
    
         
            +
              json (~> 1.5.1)
         
     | 
| 
       94 
99 
     | 
    
         
             
              mail (~> 2.2.15)
         
     | 
| 
       95 
100 
     | 
    
         
             
              mocha
         
     | 
| 
       96 
101 
     | 
    
         
             
              net-scp (~> 1.0.4)
         
     | 
    
        data/backup.gemspec
    CHANGED
    
    | 
         @@ -19,7 +19,7 @@ Gem::Specification.new do |gem| 
     | 
|
| 
       19 
19 
     | 
    
         
             
                                server through FTP, SFTP, SCP and RSync), it provide Syncers (RSync, S3) for efficient backups,
         
     | 
| 
       20 
20 
     | 
    
         
             
                                it can archive files and directories, it can cycle backups, it can do incremental backups, it
         
     | 
| 
       21 
21 
     | 
    
         
             
                                can compress backups, it can encrypt backups (OpenSSL or GPG), it can notify you about
         
     | 
| 
       22 
     | 
    
         
            -
                                successful and/or failed backups (Email  
     | 
| 
      
 22 
     | 
    
         
            +
                                successful and/or failed backups (Email, Twitter and Campfire). It is very extensible and easy to add new
         
     | 
| 
       23 
23 
     | 
    
         
             
                                functionality to. It\'s easy to use.'
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
              ##
         
     | 
    
        data/lib/backup/dependency.rb
    CHANGED
    
    | 
         @@ -55,7 +55,19 @@ module Backup 
     | 
|
| 
       55 
55 
     | 
    
         
             
                    'twitter' => {
         
     | 
| 
       56 
56 
     | 
    
         
             
                      :require => 'twitter',
         
     | 
| 
       57 
57 
     | 
    
         
             
                      :version => '~> 1.1.2',
         
     | 
| 
       58 
     | 
    
         
            -
                      :for     => ' 
     | 
| 
      
 58 
     | 
    
         
            +
                      :for     => 'Sending Twitter Updates (Twitter Notifier)'
         
     | 
| 
      
 59 
     | 
    
         
            +
                    },
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    'httparty' => {
         
     | 
| 
      
 62 
     | 
    
         
            +
                      :require => 'httparty',
         
     | 
| 
      
 63 
     | 
    
         
            +
                      :version => '~> 0.7.4',
         
     | 
| 
      
 64 
     | 
    
         
            +
                      :for     => 'Sending Http Updates'
         
     | 
| 
      
 65 
     | 
    
         
            +
                    },
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                    'json' => {
         
     | 
| 
      
 68 
     | 
    
         
            +
                      :require => 'json',
         
     | 
| 
      
 69 
     | 
    
         
            +
                      :version => '~> 1.5.1',
         
     | 
| 
      
 70 
     | 
    
         
            +
                      :for     => 'Parsing JSON for HTTParty'
         
     | 
| 
       59 
71 
     | 
    
         
             
                    }
         
     | 
| 
       60 
72 
     | 
    
         
             
                  }
         
     | 
| 
       61 
73 
     | 
    
         
             
                end
         
     | 
    
        data/lib/backup/model.rb
    CHANGED
    
    | 
         @@ -240,7 +240,7 @@ module Backup 
     | 
|
| 
       240 
240 
     | 
    
         
             
                # becomes a single (transferrable) packaged file.
         
     | 
| 
       241 
241 
     | 
    
         
             
                def package!
         
     | 
| 
       242 
242 
     | 
    
         
             
                  Logger.message "Backup started packaging everything to a single archive file."
         
     | 
| 
       243 
     | 
    
         
            -
                  run( 
     | 
| 
      
 243 
     | 
    
         
            +
                  run(%|#{ utility(:tar) } -c -f '#{ File.join(TMP_PATH, "#{TIME}.#{TRIGGER}.tar") }' -C '#{ TMP_PATH }' '#{ TRIGGER }'|)
         
     | 
| 
       244 
244 
     | 
    
         
             
                end
         
     | 
| 
       245 
245 
     | 
    
         | 
| 
       246 
246 
     | 
    
         
             
                ##
         
     | 
| 
         @@ -0,0 +1,179 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ##
         
     | 
| 
      
 4 
     | 
    
         
            +
            # If the Ruby version of this process is 1.8.x or less
         
     | 
| 
      
 5 
     | 
    
         
            +
            # then use the JSON gem. Otherwise if the current process is running
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Ruby 1.9.x or later then it is built in and we can load it from the Ruby core lib
         
     | 
| 
      
 7 
     | 
    
         
            +
            if RUBY_VERSION < '1.9.0'
         
     | 
| 
      
 8 
     | 
    
         
            +
              Backup::Dependency.load('json')
         
     | 
| 
      
 9 
     | 
    
         
            +
            else
         
     | 
| 
      
 10 
     | 
    
         
            +
              require 'json'
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            ##
         
     | 
| 
      
 14 
     | 
    
         
            +
            # Load the HTTParty library from the gem
         
     | 
| 
      
 15 
     | 
    
         
            +
            Backup::Dependency.load('httparty')
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            module Backup
         
     | 
| 
      
 18 
     | 
    
         
            +
              module Notifier
         
     | 
| 
      
 19 
     | 
    
         
            +
                class Campfire < Base
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 22 
     | 
    
         
            +
                  # Campfire credentials
         
     | 
| 
      
 23 
     | 
    
         
            +
                  attr_accessor :token, :subdomain, :room_id
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # Container for the Model object
         
     | 
| 
      
 27 
     | 
    
         
            +
                  attr_accessor :model
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 30 
     | 
    
         
            +
                  # Instantiates a new Backup::Notifier::Campfire object
         
     | 
| 
      
 31 
     | 
    
         
            +
                  def initialize(&block)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    load_defaults!
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    instance_eval(&block) if block_given?
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    set_defaults!
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 40 
     | 
    
         
            +
                  # Performs the notification
         
     | 
| 
      
 41 
     | 
    
         
            +
                  # Takes an exception object that might've been created if an exception occurred.
         
     | 
| 
      
 42 
     | 
    
         
            +
                  # If this is the case it'll invoke notify_failure!(exception), otherwise, if no
         
     | 
| 
      
 43 
     | 
    
         
            +
                  # error was raised, it'll go ahead and notify_success!
         
     | 
| 
      
 44 
     | 
    
         
            +
                  #
         
     | 
| 
      
 45 
     | 
    
         
            +
                  # If'll only perform these if on_success is true or on_failure is true
         
     | 
| 
      
 46 
     | 
    
         
            +
                  def perform!(model, exception = false)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    @model = model
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    if notify_on_success? and exception.eql?(false)
         
     | 
| 
      
 50 
     | 
    
         
            +
                      log!
         
     | 
| 
      
 51 
     | 
    
         
            +
                      notify_success!
         
     | 
| 
      
 52 
     | 
    
         
            +
                    elsif notify_on_failure? and not exception.eql?(false)
         
     | 
| 
      
 53 
     | 
    
         
            +
                      log!
         
     | 
| 
      
 54 
     | 
    
         
            +
                      notify_failure!(exception)
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                private
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 61 
     | 
    
         
            +
                  # Sends a message informing the user that the backup operation
         
     | 
| 
      
 62 
     | 
    
         
            +
                  # proceeded without any errors
         
     | 
| 
      
 63 
     | 
    
         
            +
                  def notify_success!
         
     | 
| 
      
 64 
     | 
    
         
            +
                    send_message("[Backup::Succeeded] #{model.label} (#{ File.basename(Backup::Model.file) })")
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 68 
     | 
    
         
            +
                  # Sends a message informing the user that the backup operation
         
     | 
| 
      
 69 
     | 
    
         
            +
                  # raised an exception
         
     | 
| 
      
 70 
     | 
    
         
            +
                  def notify_failure!(exception)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    send_message("[Backup::Failed] #{model.label} (#{ File.basename(Backup::Model.file) })")
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 75 
     | 
    
         
            +
                  # Setting up credentials
         
     | 
| 
      
 76 
     | 
    
         
            +
                  def set_defaults!
         
     | 
| 
      
 77 
     | 
    
         
            +
                    @campfire_client = {
         
     | 
| 
      
 78 
     | 
    
         
            +
                      :token     => @token,
         
     | 
| 
      
 79 
     | 
    
         
            +
                      :subdomain => @subdomain,
         
     | 
| 
      
 80 
     | 
    
         
            +
                      :room_id   => @room_id
         
     | 
| 
      
 81 
     | 
    
         
            +
                    }
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 85 
     | 
    
         
            +
                  # Creates a new Campfire::Interface object and passes in the
         
     | 
| 
      
 86 
     | 
    
         
            +
                  # campfire clients "room_id", "subdomain" and "token". Using this object
         
     | 
| 
      
 87 
     | 
    
         
            +
                  # the provided "message" will be sent to the desired Campfire chat room
         
     | 
| 
      
 88 
     | 
    
         
            +
                  def send_message(message)
         
     | 
| 
      
 89 
     | 
    
         
            +
                    room = Interface.room(
         
     | 
| 
      
 90 
     | 
    
         
            +
                      @campfire_client[:room_id],
         
     | 
| 
      
 91 
     | 
    
         
            +
                      @campfire_client[:subdomain],
         
     | 
| 
      
 92 
     | 
    
         
            +
                      @campfire_client[:token]
         
     | 
| 
      
 93 
     | 
    
         
            +
                    )
         
     | 
| 
      
 94 
     | 
    
         
            +
                    room.message(message)
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 98 
     | 
    
         
            +
                  # The Campfire::Interface acts as the Interface for the Campfire class.
         
     | 
| 
      
 99 
     | 
    
         
            +
                  # It uses the HTTParty library and the Campfire::Room class to communicate
         
     | 
| 
      
 100 
     | 
    
         
            +
                  # with the Campfire rooms. HTTParty provides the Campfire::Interface with the methods
         
     | 
| 
      
 101 
     | 
    
         
            +
                  # necessary to communicate (inside the HTTParty module) such as the class methods:
         
     | 
| 
      
 102 
     | 
    
         
            +
                  # * post
         
     | 
| 
      
 103 
     | 
    
         
            +
                  # * base_uri
         
     | 
| 
      
 104 
     | 
    
         
            +
                  # * basic_auth
         
     | 
| 
      
 105 
     | 
    
         
            +
                  class Interface
         
     | 
| 
      
 106 
     | 
    
         
            +
                    include HTTParty
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 109 
     | 
    
         
            +
                    # We communicate using the JSON data format
         
     | 
| 
      
 110 
     | 
    
         
            +
                    headers 'Content-Type' => 'application/json'
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 113 
     | 
    
         
            +
                    # Instantiates a new Campfire::Room object with
         
     | 
| 
      
 114 
     | 
    
         
            +
                    # the provided arguments and returns this object
         
     | 
| 
      
 115 
     | 
    
         
            +
                    def self.room(room_id, subdomain, token)
         
     | 
| 
      
 116 
     | 
    
         
            +
                      Room.new(room_id, subdomain, token)
         
     | 
| 
      
 117 
     | 
    
         
            +
                    end
         
     | 
| 
      
 118 
     | 
    
         
            +
                  end
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 121 
     | 
    
         
            +
                  # The Campfire::Room acts as a model for an actual room on the Campfire service.
         
     | 
| 
      
 122 
     | 
    
         
            +
                  # And it uses the Campfire::Interface's (HTTParty) class methods to communicate based
         
     | 
| 
      
 123 
     | 
    
         
            +
                  # on the provided parameters (room_id, subdomain and token)
         
     | 
| 
      
 124 
     | 
    
         
            +
                  class Room
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 127 
     | 
    
         
            +
                    # These are the necessary attributes that Campfire requires
         
     | 
| 
      
 128 
     | 
    
         
            +
                    # in order to communicate with the correct chat rooms
         
     | 
| 
      
 129 
     | 
    
         
            +
                    attr_reader :room_id, :subdomain, :token
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 132 
     | 
    
         
            +
                    # Instantiates a new Campfire::Room object and sets all the
         
     | 
| 
      
 133 
     | 
    
         
            +
                    # necessary arguments (@room_id, @subdomain, @token)
         
     | 
| 
      
 134 
     | 
    
         
            +
                    def initialize(room_id, subdomain, token)
         
     | 
| 
      
 135 
     | 
    
         
            +
                      @room_id   = room_id
         
     | 
| 
      
 136 
     | 
    
         
            +
                      @subdomain = subdomain
         
     | 
| 
      
 137 
     | 
    
         
            +
                      @token     = token
         
     | 
| 
      
 138 
     | 
    
         
            +
                    end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 141 
     | 
    
         
            +
                    # Wrapper method for the #send_message (private) method
         
     | 
| 
      
 142 
     | 
    
         
            +
                    def message(message)
         
     | 
| 
      
 143 
     | 
    
         
            +
                      send_message(message)
         
     | 
| 
      
 144 
     | 
    
         
            +
                    end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                  private
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 149 
     | 
    
         
            +
                    # Takes a "message" as argument, the "type" defaults to "Textmessage".
         
     | 
| 
      
 150 
     | 
    
         
            +
                    # This method builds up a POST request with the necessary params (serialized to JSON format)
         
     | 
| 
      
 151 
     | 
    
         
            +
                    # and sends it to the Campfire service in order to submit the message
         
     | 
| 
      
 152 
     | 
    
         
            +
                    def send_message(message, type = 'Textmessage')
         
     | 
| 
      
 153 
     | 
    
         
            +
                      post 'speak', :body => {
         
     | 
| 
      
 154 
     | 
    
         
            +
                        :message => {
         
     | 
| 
      
 155 
     | 
    
         
            +
                          :body => message,
         
     | 
| 
      
 156 
     | 
    
         
            +
                          :type => type
         
     | 
| 
      
 157 
     | 
    
         
            +
                        }
         
     | 
| 
      
 158 
     | 
    
         
            +
                      }.to_json
         
     | 
| 
      
 159 
     | 
    
         
            +
                    end
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 162 
     | 
    
         
            +
                    # Builds/sets up the Campfire::Interface attributes and submits
         
     | 
| 
      
 163 
     | 
    
         
            +
                    # the POST request that was built in the #send_message (private) method
         
     | 
| 
      
 164 
     | 
    
         
            +
                    def post(action, options = {})
         
     | 
| 
      
 165 
     | 
    
         
            +
                      Interface.base_uri("https://#{subdomain}.campfirenow.com")
         
     | 
| 
      
 166 
     | 
    
         
            +
                      Interface.basic_auth(token, 'x')
         
     | 
| 
      
 167 
     | 
    
         
            +
                      Interface.post(room_url_for(action), options)
         
     | 
| 
      
 168 
     | 
    
         
            +
                    end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                    ##
         
     | 
| 
      
 171 
     | 
    
         
            +
                    # Returns the url for the specified room (in JSON format)
         
     | 
| 
      
 172 
     | 
    
         
            +
                    def room_url_for(action)
         
     | 
| 
      
 173 
     | 
    
         
            +
                      "/room/#{room_id}/#{action}.json"
         
     | 
| 
      
 174 
     | 
    
         
            +
                    end
         
     | 
| 
      
 175 
     | 
    
         
            +
                  end
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
                end
         
     | 
| 
      
 178 
     | 
    
         
            +
              end
         
     | 
| 
      
 179 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/backup/version.rb
    CHANGED
    
    
    
        data/lib/backup.rb
    CHANGED
    
    | 
         @@ -21,7 +21,7 @@ module Backup 
     | 
|
| 
       21 
21 
     | 
    
         
             
              COMPRESSORS = ['Gzip']
         
     | 
| 
       22 
22 
     | 
    
         
             
              ENCRYPTORS  = ['OpenSSL', 'GPG']
         
     | 
| 
       23 
23 
     | 
    
         
             
              SYNCERS     = ['RSync', 'S3']
         
     | 
| 
       24 
     | 
    
         
            -
              NOTIFIERS   = ['Mail', 'Twitter']
         
     | 
| 
      
 24 
     | 
    
         
            +
              NOTIFIERS   = ['Mail', 'Twitter', 'Campfire']
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
              ##
         
     | 
| 
       27 
27 
     | 
    
         
             
              # Backup's internal paths
         
     | 
| 
         @@ -62,6 +62,7 @@ module Backup 
     | 
|
| 
       62 
62 
     | 
    
         
             
                  autoload :Base,    File.join(CONFIGURATION_PATH, 'notifier', 'base')
         
     | 
| 
       63 
63 
     | 
    
         
             
                  autoload :Mail,    File.join(CONFIGURATION_PATH, 'notifier', 'mail')
         
     | 
| 
       64 
64 
     | 
    
         
             
                  autoload :Twitter, File.join(CONFIGURATION_PATH, 'notifier', 'twitter')
         
     | 
| 
      
 65 
     | 
    
         
            +
                  autoload :Campfire, File.join(CONFIGURATION_PATH, 'notifier', 'campfire')
         
     | 
| 
       65 
66 
     | 
    
         
             
                end
         
     | 
| 
       66 
67 
     | 
    
         | 
| 
       67 
68 
     | 
    
         
             
                module Encryptor
         
     | 
| 
         @@ -150,10 +151,11 @@ module Backup 
     | 
|
| 
       150 
151 
     | 
    
         
             
              ##
         
     | 
| 
       151 
152 
     | 
    
         
             
              # Autoload notification files
         
     | 
| 
       152 
153 
     | 
    
         
             
              module Notifier
         
     | 
| 
       153 
     | 
    
         
            -
                autoload :Base, 
     | 
| 
       154 
     | 
    
         
            -
                autoload :Binder, 
     | 
| 
       155 
     | 
    
         
            -
                autoload :Mail, 
     | 
| 
       156 
     | 
    
         
            -
                autoload :Twitter, 
     | 
| 
      
 154 
     | 
    
         
            +
                autoload :Base,     File.join(NOTIFIER_PATH, 'base')
         
     | 
| 
      
 155 
     | 
    
         
            +
                autoload :Binder,   File.join(NOTIFIER_PATH, 'binder')
         
     | 
| 
      
 156 
     | 
    
         
            +
                autoload :Mail,     File.join(NOTIFIER_PATH, 'mail')
         
     | 
| 
      
 157 
     | 
    
         
            +
                autoload :Twitter,  File.join(NOTIFIER_PATH, 'twitter')
         
     | 
| 
      
 158 
     | 
    
         
            +
                autoload :Campfire, File.join(NOTIFIER_PATH, 'campfire')
         
     | 
| 
       157 
159 
     | 
    
         
             
              end
         
     | 
| 
       158 
160 
     | 
    
         | 
| 
       159 
161 
     | 
    
         
             
              ##
         
     | 
    
        data/spec/model_spec.rb
    CHANGED
    
    | 
         @@ -205,7 +205,7 @@ describe Backup::Model do 
     | 
|
| 
       205 
205 
     | 
    
         | 
| 
       206 
206 
     | 
    
         
             
                it 'should package the folder' do
         
     | 
| 
       207 
207 
     | 
    
         
             
                  model.expects(:utility).with(:tar).returns(:tar)
         
     | 
| 
       208 
     | 
    
         
            -
                  model.expects(:run).with( 
     | 
| 
      
 208 
     | 
    
         
            +
                  model.expects(:run).with(%|tar -c -f '#{ File.join( Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar" ) }' -C '#{ Backup::TMP_PATH }' '#{ Backup::TRIGGER }'|)
         
     | 
| 
       209 
209 
     | 
    
         
             
                  model.send(:package!)
         
     | 
| 
       210 
210 
     | 
    
         
             
                end
         
     | 
| 
       211 
211 
     | 
    
         | 
| 
         @@ -0,0 +1,96 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe Backup::Notifier::Campfire do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:notifier) do
         
     | 
| 
      
 7 
     | 
    
         
            +
                Backup::Notifier::Campfire.new do |campfire|
         
     | 
| 
      
 8 
     | 
    
         
            +
                  campfire.token     = 'token'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  campfire.subdomain = 'subdomain'
         
     | 
| 
      
 10 
     | 
    
         
            +
                  campfire.room_id   = 'room_id'
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              it do
         
     | 
| 
      
 15 
     | 
    
         
            +
                notifier.token.should     == 'token'
         
     | 
| 
      
 16 
     | 
    
         
            +
                notifier.subdomain.should == 'subdomain'
         
     | 
| 
      
 17 
     | 
    
         
            +
                notifier.room_id.should   == 'room_id'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                notifier.on_success.should == true
         
     | 
| 
      
 20 
     | 
    
         
            +
                notifier.on_failure.should == true
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              describe 'defaults' do
         
     | 
| 
      
 24 
     | 
    
         
            +
                it do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  Backup::Configuration::Notifier::Campfire.defaults do |twitter|
         
     | 
| 
      
 26 
     | 
    
         
            +
                    twitter.token      = 'old_token'
         
     | 
| 
      
 27 
     | 
    
         
            +
                    twitter.on_success = false
         
     | 
| 
      
 28 
     | 
    
         
            +
                    twitter.on_failure = true
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    notifier      = Backup::Notifier::Campfire.new do |twitter|
         
     | 
| 
      
 31 
     | 
    
         
            +
                    twitter.token = 'new_token'
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  notifier.token.should      == 'new_token'
         
     | 
| 
      
 35 
     | 
    
         
            +
                  notifier.on_success.should == false
         
     | 
| 
      
 36 
     | 
    
         
            +
                  notifier.on_failure.should == true
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              describe '#initialize' do
         
     | 
| 
      
 41 
     | 
    
         
            +
                it do
         
     | 
| 
      
 42 
     | 
    
         
            +
                  Backup::Notifier::Campfire.any_instance.expects(:set_defaults!)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  Backup::Notifier::Campfire.new
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              describe '#perform!' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                let(:model) { Backup::Model.new('blah', 'blah') {} }
         
     | 
| 
      
 49 
     | 
    
         
            +
                before do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  notifier.on_success = false
         
     | 
| 
      
 51 
     | 
    
         
            +
                  notifier.on_failure = false
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                context "when successful" do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    Backup::Logger.expects(:message).with("Backup::Notifier::Campfire started notifying about the process.")
         
     | 
| 
      
 57 
     | 
    
         
            +
                    notifier.expects("notify_success!")
         
     | 
| 
      
 58 
     | 
    
         
            +
                    notifier.on_success = true
         
     | 
| 
      
 59 
     | 
    
         
            +
                    notifier.perform!(model)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 63 
     | 
    
         
            +
                    notifier.expects("notify_success!").never
         
     | 
| 
      
 64 
     | 
    
         
            +
                    notifier.on_success = false
         
     | 
| 
      
 65 
     | 
    
         
            +
                    notifier.perform!(model)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                context "when failed" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 71 
     | 
    
         
            +
                    Backup::Logger.expects(:message).with("Backup::Notifier::Campfire started notifying about the process.")
         
     | 
| 
      
 72 
     | 
    
         
            +
                    notifier.expects("notify_failure!")
         
     | 
| 
      
 73 
     | 
    
         
            +
                    notifier.on_failure = true
         
     | 
| 
      
 74 
     | 
    
         
            +
                    notifier.perform!(model, Exception.new)
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 78 
     | 
    
         
            +
                    notifier.expects("notify_failure!").never
         
     | 
| 
      
 79 
     | 
    
         
            +
                    notifier.on_failure = false
         
     | 
| 
      
 80 
     | 
    
         
            +
                    notifier.perform!(model, Exception.new)
         
     | 
| 
      
 81 
     | 
    
         
            +
                  end
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              describe Backup::Notifier::Campfire::Interface do
         
     | 
| 
      
 86 
     | 
    
         
            +
                let(:room) do
         
     | 
| 
      
 87 
     | 
    
         
            +
                  Backup::Notifier::Campfire::Room.new('room_id', 'subdomain', 'token')
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                it do
         
     | 
| 
      
 91 
     | 
    
         
            +
                  room.token.should     == 'token'
         
     | 
| 
      
 92 
     | 
    
         
            +
                  room.subdomain.should == 'subdomain'
         
     | 
| 
      
 93 
     | 
    
         
            +
                  room.room_id.should   == 'room_id'
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
              end
         
     | 
| 
      
 96 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,8 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: backup
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 31
         
     | 
| 
       4 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
      
 6 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 3
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 12
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 3.0.12
         
     | 
| 
       6 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       8 
13 
     | 
    
         
             
            - Michael van Rooijen
         
     | 
| 
         @@ -10,7 +15,7 @@ autorequire: 
     | 
|
| 
       10 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
17 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            date: 2011-03- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-03-29 00:00:00 +02:00
         
     | 
| 
       14 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       15 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       16 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -21,6 +26,11 @@ dependencies: 
     | 
|
| 
       21 
26 
     | 
    
         
             
                requirements: 
         
     | 
| 
       22 
27 
     | 
    
         
             
                - - ~>
         
     | 
| 
       23 
28 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 29 
     | 
    
         
            +
                    hash: 43
         
     | 
| 
      
 30 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 31 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 32 
     | 
    
         
            +
                    - 14
         
     | 
| 
      
 33 
     | 
    
         
            +
                    - 6
         
     | 
| 
       24 
34 
     | 
    
         
             
                    version: 0.14.6
         
     | 
| 
       25 
35 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       26 
36 
     | 
    
         
             
              version_requirements: *id001
         
     | 
| 
         @@ -60,6 +70,7 @@ files: 
     | 
|
| 
       60 
70 
     | 
    
         
             
            - lib/backup/configuration/encryptor/open_ssl.rb
         
     | 
| 
       61 
71 
     | 
    
         
             
            - lib/backup/configuration/helpers.rb
         
     | 
| 
       62 
72 
     | 
    
         
             
            - lib/backup/configuration/notifier/base.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/backup/configuration/notifier/campfire.rb
         
     | 
| 
       63 
74 
     | 
    
         
             
            - lib/backup/configuration/notifier/mail.rb
         
     | 
| 
       64 
75 
     | 
    
         
             
            - lib/backup/configuration/notifier/twitter.rb
         
     | 
| 
       65 
76 
     | 
    
         
             
            - lib/backup/configuration/storage/base.rb
         
     | 
| 
         @@ -86,6 +97,7 @@ files: 
     | 
|
| 
       86 
97 
     | 
    
         
             
            - lib/backup/model.rb
         
     | 
| 
       87 
98 
     | 
    
         
             
            - lib/backup/notifier/base.rb
         
     | 
| 
       88 
99 
     | 
    
         
             
            - lib/backup/notifier/binder.rb
         
     | 
| 
      
 100 
     | 
    
         
            +
            - lib/backup/notifier/campfire.rb
         
     | 
| 
       89 
101 
     | 
    
         
             
            - lib/backup/notifier/mail.rb
         
     | 
| 
       90 
102 
     | 
    
         
             
            - lib/backup/notifier/templates/notify_failure.erb
         
     | 
| 
       91 
103 
     | 
    
         
             
            - lib/backup/notifier/templates/notify_success.erb
         
     | 
| 
         @@ -154,6 +166,7 @@ files: 
     | 
|
| 
       154 
166 
     | 
    
         
             
            - spec/encryptor/open_ssl_spec.rb
         
     | 
| 
       155 
167 
     | 
    
         
             
            - spec/logger_spec.rb
         
     | 
| 
       156 
168 
     | 
    
         
             
            - spec/model_spec.rb
         
     | 
| 
      
 169 
     | 
    
         
            +
            - spec/notifier/campfire_spec.rb
         
     | 
| 
       157 
170 
     | 
    
         
             
            - spec/notifier/mail_spec.rb
         
     | 
| 
       158 
171 
     | 
    
         
             
            - spec/notifier/twitter_spec.rb
         
     | 
| 
       159 
172 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
         @@ -183,12 +196,18 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       183 
196 
     | 
    
         
             
              requirements: 
         
     | 
| 
       184 
197 
     | 
    
         
             
              - - ">="
         
     | 
| 
       185 
198 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 199 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 200 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 201 
     | 
    
         
            +
                  - 0
         
     | 
| 
       186 
202 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       187 
203 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       188 
204 
     | 
    
         
             
              none: false
         
     | 
| 
       189 
205 
     | 
    
         
             
              requirements: 
         
     | 
| 
       190 
206 
     | 
    
         
             
              - - ">="
         
     | 
| 
       191 
207 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 208 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 209 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 210 
     | 
    
         
            +
                  - 0
         
     | 
| 
       192 
211 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       193 
212 
     | 
    
         
             
            requirements: []
         
     | 
| 
       194 
213 
     | 
    
         | 
| 
         @@ -196,6 +215,6 @@ rubyforge_project: 
     | 
|
| 
       196 
215 
     | 
    
         
             
            rubygems_version: 1.6.1
         
     | 
| 
       197 
216 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       198 
217 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       199 
     | 
    
         
            -
            summary: "Backup is a RubyGem (for UNIX-like operating systems: Linux, Mac OSX) that allows you to configure and perform backups in a simple manner using an elegant Ruby DSL. It supports various databases (MySQL, PostgreSQL, MongoDB and Redis), it supports various storage locations (Amazon S3, Rackspace Cloud Files, Dropbox, any remote server through FTP, SFTP, SCP and RSync), it provide Syncers (RSync, S3) for efficient backups, it can archive files and directories, it can cycle backups, it can do incremental backups, it can compress backups, it can encrypt backups (OpenSSL or GPG), it can notify you about successful and/or failed backups (Email  
     | 
| 
      
 218 
     | 
    
         
            +
            summary: "Backup is a RubyGem (for UNIX-like operating systems: Linux, Mac OSX) that allows you to configure and perform backups in a simple manner using an elegant Ruby DSL. It supports various databases (MySQL, PostgreSQL, MongoDB and Redis), it supports various storage locations (Amazon S3, Rackspace Cloud Files, Dropbox, any remote server through FTP, SFTP, SCP and RSync), it provide Syncers (RSync, S3) for efficient backups, it can archive files and directories, it can cycle backups, it can do incremental backups, it can compress backups, it can encrypt backups (OpenSSL or GPG), it can notify you about successful and/or failed backups (Email, Twitter and Campfire). It is very extensible and easy to add new functionality to. It's easy to use."
         
     | 
| 
       200 
219 
     | 
    
         
             
            test_files: []
         
     | 
| 
       201 
220 
     | 
    
         |