Sha256: 5ddda80687a9b86cdb2e41fe9e7d55ed7226db354b15371819ec9f6789bec723

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

# Connectivity and Record Gems
require 'net/ssh'
require 'net/scp'
require 'aws/s3'
require 'sqlite3'

# Load in Adapters
require 'backup/adapters/base'
require 'backup/adapters/mysql'
require 'backup/adapters/archive'

# Load in Connectors
require 'backup/connection/s3'

# Load in Storage
require 'backup/storage/s3'
require 'backup/storage/scp'

# Load in Backup Recorders
require 'backup/record/s3'
require 'backup/record/scp'

# Load in Configuration
require 'backup/configuration/base'
require 'backup/configuration/adapter'
require 'backup/configuration/storage'
require 'backup/configuration/helpers'

# Load Backup Configuration Helpers
include Backup::Configuration::Helpers

# Load in User Configured Backup Procedures if the file exists
if File.exist?(File.join(RAILS_ROOT, 'config', 'backup.rb'))
  require File.join(RAILS_ROOT, 'config', 'backup.rb')
end

# Backup Module
module Backup
  class Setup
  
    attr_accessor :trigger, :procedures, :procedure
  
    def initialize(trigger, procedures)
      self.trigger    = trigger
      self.procedures = procedures
      self.procedure  = find_triggered_procedure
    end
    
    def initialize_adapter
      case procedure.adapter_name.to_sym
        when :mysql   then Backup::Adapters::MySQL.new(trigger, procedure)
        when :archive then Backup::Adapters::Archive.new(trigger, procedure)
        else raise "Unknown Adapter: \"#{procedure.adapter_name}\""
      end
    end
    
    def find_triggered_procedure
      procedures.each do |procedure|
        if procedure.trigger.eql?(trigger)
          return procedure
        end
      end
      available_triggers = procedures.each.map {|procedure| "- #{procedure.trigger}\n" }
      raise "Could not find a backup procedure with the trigger \"#{trigger}\". \nHere's a list of available triggers:\n#{available_triggers}"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
backup-2.1.1 lib/backup.rb
backup-2.1.0 lib/backup.rb
backup-2.0.0 lib/backup.rb