Sha256: 1780e52cb44341762bf5adfa537bbdf5e4a354304047a72ea854061502efed08

Contents?: true

Size: 921 Bytes

Versions: 14

Compression:

Stored size: 921 Bytes

Contents

module Astrails
  module Safe
    class Source < Stream

      attr_accessor :id
      def initialize(id, config)
        @id, @config = id.to_s, config
      end

      def timestamp
        Time.now.strftime("%y%m%d-%H%M")
      end

      def kind
        self.class.human_name
      end

      def filename
        @filename ||= expand(":kind-:id.:timestamp")
      end

      def backup
        return @backup if @backup
        @backup = Backup.new(
          :id        => @id,
          :kind      => kind,
          :extension => extension,
          :command   => command,
          :timestamp => timestamp
        )
        # can't do this in the initializer hash above since
        # filename() calls expand() which requires @backup
        @backup.filename = filename
        @backup
      end

      protected

      def self.human_name
        name.split('::').last.downcase
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
astrails-safe-0.1.10 lib/astrails/safe/source.rb
astrails-safe-0.1.7 lib/astrails/safe/source.rb
astrails-safe-0.1.8 lib/astrails/safe/source.rb
astrails-safe-0.1.9 lib/astrails/safe/source.rb
astrails-safe-0.2.0 lib/astrails/safe/source.rb
astrails-safe-0.2.1 lib/astrails/safe/source.rb
astrails-safe-0.2.2 lib/astrails/safe/source.rb
astrails-safe-0.2.3 lib/astrails/safe/source.rb
bostonlogic-safe-0.3.0 lib/astrails/safe/source.rb
astrails-safe-0.2.7 lib/astrails/safe/source.rb
astrails-safe-0.2.6 lib/astrails/safe/source.rb
astrails-safe-0.2.5 lib/astrails/safe/source.rb
webbynode-safe-0.2.5 lib/astrails/safe/source.rb
astrails-safe-0.2.4 lib/astrails/safe/source.rb