Sha256: b8d7c0224f0223ee2c34ff69fb9a38a947a275b8602d7174eb8a320ad6f0f93e

Contents?: true

Size: 978 Bytes

Versions: 9

Compression:

Stored size: 978 Bytes

Contents

module WebTranslateIt

  module Safe

    class Source < Stream

      attr_accessor :id

      def initialize(id, config)
        @id = id.to_s
        @config = 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

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

    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
webtranslateit-safe-0.4.11 lib/web_translate_it/safe/source.rb
webtranslateit-safe-0.4.10 lib/web_translate_it/safe/source.rb
webtranslateit-safe-0.4.9 lib/web_translate_it/safe/source.rb
webtranslateit-safe-0.4.8 lib/web_translate_it/safe/source.rb
webtranslateit-safe-0.4.7 lib/web_translate_it/safe/source.rb
webtranslateit-safe-0.4.6 lib/web_translate_it/safe/source.rb
webtranslateit-safe-0.4.5 lib/webtranslateit/safe/source.rb
webtranslateit-safe-0.4.4 lib/webtranslateit/safe/source.rb
webtranslateit-safe-0.4.0 lib/webtranslateit/safe/source.rb