Sha256: bd14c6d6e7ed27c6b0abc59dbba396996aa7b622af401fce911d1309ed6c5cea

Contents?: true

Size: 752 Bytes

Versions: 8

Compression:

Stored size: 752 Bytes

Contents

require 'rhet-butler/stasis'
module RhetButler
  module Stasis
    class Writer
      def initialize(root)
        @root = root
      end
      attr_accessor :store_log

      def write(path, content)
        store_log.puts "Writing: #{path}" if store_log.respond_to? :puts
        store(path, content)
      end

      def store(path, content)
        File::open(File::join(@root, path), "w") do |file|
          file.write(content)
        end
      end
    end

    class ValiseWriter < Writer
      def initialize(valise)
        @target_valise = valise
      end

      attr_reader :target_valise

      def store(path, content)
        target = target_valise.get(path).writable.first
        target.contents = content
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rhet-butler-0.14.1 lib/rhet-butler/stasis/writer.rb
rhet-butler-0.14.0 lib/rhet-butler/stasis/writer.rb
rhet-butler-0.13.0 lib/rhet-butler/stasis/writer.rb
rhet-butler-0.12.1 lib/rhet-butler/stasis/writer.rb
rhet-butler-0.11.1 lib/rhet-butler/stasis/writer.rb
rhet-butler-0.11.0 lib/rhet-butler/stasis/writer.rb
rhet-butler-0.10.0 lib/rhet-butler/stasis/writer.rb
rhet-butler-0.9.0 lib/rhet-butler/stasis/writer.rb