Sha256: aed61e7983277cb99e41ec1837e8f9ac521d09426f7595eada71b9536e30bace

Contents?: true

Size: 947 Bytes

Versions: 1

Compression:

Stored size: 947 Bytes

Contents

require 'fog'
require 'lazily'
require 'virtus'
require 'pathname'
require 'celluloid'
require 'multi_sync/mixins/log_helper'

module MultiSync
  class Target
    include Virtus
    include Celluloid
    include MultiSync::Mixins::LogHelper

    attribute :connection
    attribute :target_dir, Pathname
    attribute :destination_dir, Pathname
    attribute :credentials, Hash, default: :default_credentials

    # Initialize a new Target object
    #
    # @param options [Hash]
    def initialize(options = {})
      fail(ArgumentError, 'target_dir must be present') unless options[:target_dir]
      self.target_dir = Pathname.new(options.fetch(:target_dir, ''))
      self.destination_dir = Pathname.new(options.fetch(:destination_dir, ''))
      credentials.merge!(options.fetch(:credentials, {}))
    end

    def default_credentials
      # deep clone just in case
      Marshal.load(Marshal.dump(MultiSync.credentials))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_sync-0.0.1 lib/multi_sync/target.rb