Sha256: 3ca48578ece1a479d1cef01f6045229eb1f75bd69945fd233a52261d025384f4

Contents?: true

Size: 903 Bytes

Versions: 8

Compression:

Stored size: 903 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, connection_info]
    end

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

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotivecms_wagon-3.2.0.alpha2 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.2.0.alpha1 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.1.1 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.1.0 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.1.0.beta1 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.0.5 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.0.4 lib/locomotive/wagon/commands/clone_command.rb
locomotivecms_wagon-3.0.3 lib/locomotive/wagon/commands/clone_command.rb