Class: Locomotive::Wagon::SyncSiteCommand

Inherits:
PullSiteCommand show all
Includes:
BaseConcern
Defined in:
lib/locomotive/wagon/commands/sync_sub_commands/sync_site_command.rb

Constant Summary

Constants included from AssetsConcern

AssetsConcern::REGEX

Instance Attribute Summary

Attributes inherited from PullBaseCommand

#api_client, #current_site, #env, #path

Instance Method Summary collapse

Methods included from BaseConcern

#instrument_base_name, #resource_name, #sync

Methods inherited from PullSiteCommand

#_pull

Methods inherited from PullBaseCommand

#_pull_with_timezone, #clean_attributes, #default_locale, #dump, #instrument, #instrument_base_name, #is_default_locale?, #locales, pull, #pull, #reset_file, #resource_name, #write_to_file

Methods included from AssetsConcern

#replace_asset_urls, #replace_asset_urls_in_hash

Instance Method Details

#_syncObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/locomotive/wagon/commands/sync_sub_commands/sync_site_command.rb', line 7

def _sync
  attributes = current_site.attributes.slice('name', 'timezone', 'seo_title', 'meta_keywords', 'meta_description', 'robots_txt', 'metafields', 'sections_content')

  locales.each_with_index do |locale, index|
    if index == 0
      transform_in_default_locale(attributes, locale)
    else
      add_other_locale(attributes, locale)
    end
  end if locales.size > 1

  decode_metafields(attributes)
  decode_sections_content(attributes)

  write_to_file(site_filepath, replace_asset_urls(JSON.neat_generate(attributes, {
    sort: true, short: false, padding: 1, object_padding: 1, after_colon: 1, after_comma: 1, wrap: 20, aligned: false
  })))
end