Sha256: 7529a946bc61602d23302fe505e1f8a7c34e5070f88637c0b219b38342f51d60

Contents?: true

Size: 1.57 KB

Versions: 7

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, env)
      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

7 entries across 7 versions & 1 rubygems

Version Path
locomotivecms_wagon-3.0.5 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-3.0.4 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-3.0.3 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-3.0.2 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-3.0.0 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-3.0.0.rc0 lib/locomotive/wagon/commands/pull_command.rb
locomotivecms_wagon-3.0.0.beta2 lib/locomotive/wagon/commands/pull_command.rb