Class: Locomotive::Wagon::PullSiteCommand

Inherits:
PullBaseCommand show all
Defined in:
lib/locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb

Direct Known Subclasses

SyncSiteCommand

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 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

#_pullObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb', line 5

def _pull
  attributes = current_site.attributes.slice(
    'name', 'locales', 'domains', 'timezone', 'seo_title',
    'meta_keywords', 'meta_description', 'picture_thumbnail_url',
    'metafields', 'metafields_schema', 'metafields_ui',
    'robots_txt', 'asset_host', '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_metafields_ui(attributes)
  decode_sections_content(attributes)

  write_metafields_schema(attributes.delete('metafields_schema'))

  write_icon(attributes.delete('picture_thumbnail_url'))

  write_to_file(File.join('config', 'site.yml')) do
    dump(attributes, inline: %w(locales domains))
  end
end