Sha256: 6e00ffe9d4039721f62a2b2215cde23b3491713227ea9a88d9c2c4fe39a0e67b

Contents?: true

Size: 1011 Bytes

Versions: 3

Compression:

Stored size: 1011 Bytes

Contents

module WebTranslateIt
  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
        # FIXME: move expansion to the backup (last step in ctor) assign :tags here
        @backup.filename = filename
        @backup
      end

      protected

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

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webtranslateit-safe-0.4.3 lib/webtranslateit/safe/source.rb
webtranslateit-safe-0.4.2 lib/webtranslateit/safe/source.rb
webtranslateit-safe-0.4.1 lib/webtranslateit/safe/source.rb