Sha256: 92db49ac7cbc0ca99196dc134626dbea085923633657e657b7f7f1eea82918e5

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

require 'active_support'
require 'active_support/core_ext'

module Locomotive::Wagon

  class CloneCommand < Struct.new(:name, :path, :options, :shell)

    def self.clone(name, path, options, shell)
      new(name, path, options, shell).clone
    end

    def clone
      # create an empty site with the minimal settings
      create_site

      # pull the pages, content_types, basically any resources from the remote site
      pull_site
    end

    def connection_info
      options.symbolize_keys.slice(:host, :handle, :email, :api_key, :password)
    end

    private

    def create_site
      require 'locomotive/wagon/generators/site'
      generator = Locomotive::Wagon::Generators::Site::Cloned
      generator.start [name, path, 'true', connection_info]
    end

    def pull_site
      Locomotive::Wagon.pull('production', File.join(path, name), options.symbolize_keys, shell)
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotivecms_wagon-3.0.2 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.0.0 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.0.0.rc0 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.0.0.beta2 lib/locomotive/wagon/commands/clone_command.rb