Sha256: 066d4a3b096fa8990c8f123d8a82e8822472ac99f660c0e2b3d74ebd4b110521

Contents?: true

Size: 870 Bytes

Versions: 22

Compression:

Stored size: 870 Bytes

Contents

module Pansophy
  class Synchronizer
    def initialize(bucket_name, remote_directory, local_directory)
      @remote_dir = Remote::Directory.new(bucket_name, remote_directory)
      @local_dir  = Local::Directory.new(local_directory)
    end

    def pull(options = {})
      synchronize(@remote_dir, @local_dir, options)
    end

    def push(options = {})
      synchronize(@local_dir, @remote_dir, options)
    end

    def merge(options = {})
      synchronize(@remote_dir, @local_dir, options.merge(merge: true))
    end

    private

    def synchronize(source_dir, destination_dir, options)
      destination_dir.create(options) unless options[:merge]
      source_dir.files.each do |file|
        file_path = Helpers::PathBuilder.new(file, source_dir).relative_path
        destination_dir.create_file(file_path, file.body, options)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
pansophy-1.3.0 lib/pansophy/synchronizer.rb
pansophy-1.2.0 lib/pansophy/synchronizer.rb
pansophy-1.1.0 lib/pansophy/synchronizer.rb
pansophy-1.0.0 lib/pansophy/synchronizer.rb
pansophy-1.0.0.pre.alpha.0 lib/pansophy/synchronizer.rb
pansophy-0.6.0 lib/pansophy/synchronizer.rb
pansophy-0.5.6 lib/pansophy/synchronizer.rb
pansophy-0.5.5 lib/pansophy/synchronizer.rb
pansophy-0.5.4 lib/pansophy/synchronizer.rb
pansophy-0.5.3 lib/pansophy/synchronizer.rb
pansophy-0.5.2 lib/pansophy/synchronizer.rb
pansophy-0.5.1 lib/pansophy/synchronizer.rb
pansophy-0.5.0 lib/pansophy/synchronizer.rb
pansophy-0.4.0 lib/pansophy/synchronizer.rb
pansophy-0.3.0 lib/pansophy/synchronizer.rb
pansophy-0.2.6 lib/pansophy/synchronizer.rb
pansophy-0.2.5 lib/pansophy/synchronizer.rb
pansophy-0.2.4 lib/pansophy/synchronizer.rb
pansophy-0.2.3 lib/pansophy/synchronizer.rb
pansophy-0.2.1 lib/pansophy/synchronizer.rb