Sha256: 7e175ec578d2d5465349827b618a2107be1b53c7097aecd2f10d1f9e6504454c

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'locomotive/common'

require_relative '../tools/styled_yaml'

require_relative 'loggers/sync_logger'

require_relative_all  'concerns'
require_relative      'sync_sub_commands/concerns/base_concern'

require_relative      'pull_sub_commands/pull_base_command'
require_relative_all  'pull_sub_commands'
require_relative_all  'sync_sub_commands'

module Locomotive::Wagon

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

    RESOURCES = %w(pages content_entries translations).freeze

    include ApiConcern
    include DeployFileConcern
    include InstrumentationConcern

    def self.sync(env, path, options)
      self.new(env, path, options).sync
    end

    def sync
      SyncLogger.new if options[:verbose]

      api_client = api_site_client(connection_information)
      site = api_client.current_site.get

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

    private

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

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

        yield klass
      end
    end

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

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotivecms_wagon-2.0.0.rc2 lib/locomotive/wagon/commands/sync_command.rb
locomotivecms_wagon-2.0.0.rc1 lib/locomotive/wagon/commands/sync_command.rb
locomotivecms_wagon-2.0.0.pre.beta.2 lib/locomotive/wagon/commands/sync_command.rb
locomotivecms_wagon-2.0.0.pre.beta.1 lib/locomotive/wagon/commands/sync_command.rb