Sha256: 02326bce7d57175e90589259199cf1e8fa917d3b081d91d32ccba4c345c7ed20

Contents?: true

Size: 1.57 KB

Versions: 16

Compression:

Stored size: 1.57 KB

Contents

require 'locomotive/common'

require_relative '../tools/styled_yaml'

require_relative 'loggers/pull_logger'

require_relative_all  'concerns'

require_relative      'pull_sub_commands/pull_base_command'
require_relative_all  'pull_sub_commands'

module Locomotive::Wagon

  class PullCommand < Struct.new(:env, :path, :options, :shell)

    RESOURCES = %w(site pages content_types content_entries snippets theme_assets translations content_assets).freeze

    include ApiConcern
    include DeployFileConcern
    include InstrumentationConcern
    include SpinnerConcern

    def self.pull(env, path, options, shell)
      self.new(env, path, options, shell).pull
    end

    def pull
      if options[:verbose]
        PullLogger.new
        _pull
      else
        show_wait_spinner('Pulling...') { _pull }
      end
    end

    private

    def _pull
      api_client = api_site_client(connection_information)

      site = api_client.current_site.get

      each_resource do |klass|
        klass.pull(api_client, site, path)
      end

      print_result_message
    end

    def each_resource
      RESOURCES.each do |name|
        next if !options[:resources].blank? && !options[:resources].include?(name)

        klass = "Locomotive::Wagon::Pull#{name.camelcase}Command".constantize

        yield klass
      end
    end

    def connection_information
      read_deploy_settings(self.env, self.path)
    end

    def print_result_message
      shell.try(:say, "\n\nThe templates, theme assets and content have been pulled from the remote version.", :green)
      true
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
locomotivecms_wagon-2.4.1 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.4.0 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.4.0.rc2 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.4.0.rc1 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.3.0 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.3.0.rc1 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.2.0 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.2.0.rc3 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.2.0.rc2 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.2.0.rc1 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.2.0.beta1 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.1.1 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.1.0 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.1.0.rc5 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.1.0.rc4 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-2.1.0.rc3 lib/locomotive/wagon/commands/pull_command.rb