Class: Locomotive::Wagon::PullPagesCommand

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

Direct Known Subclasses

SyncPagesCommand

Constant Summary

Constants included from AssetsConcern

AssetsConcern::REGEX

Instance Attribute Summary collapse

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

#fullpathsObject (readonly)

Returns the value of attribute fullpaths.



5
6
7
# File 'lib/locomotive/wagon/commands/pull_sub_commands/pull_pages_command.rb', line 5

def fullpaths
  @fullpaths
end

Instance Method Details

#_pullObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/locomotive/wagon/commands/pull_sub_commands/pull_pages_command.rb', line 7

def _pull
  @fullpaths = {}

  locales.each do |locale|
    api_client.pages.all(locale).each do |page|
      fullpaths[page._id] = page.fullpath if locale == default_locale
      write_page(page, locale)
    end
  end
end

#write_page(page, locale = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/locomotive/wagon/commands/pull_sub_commands/pull_pages_command.rb', line 18

def write_page(page, locale = nil)
  write_to_file(page_filepath(page, locale)) do
<<-EOF
#{yaml_attributes(page, locale)}---
#{replace_asset_urls(page.template)}
EOF
    .gsub(/\n$/, '')
  end
end