Class: Locomotive::Wagon::PullContentEntriesCommand

Inherits:
PullBaseCommand
  • Object
show all
Defined in:
lib/locomotive/wagon/commands/pull_sub_commands/pull_content_entries_command.rb

Direct Known Subclasses

SyncContentEntriesCommand

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
# File 'lib/locomotive/wagon/commands/pull_sub_commands/pull_content_entries_command.rb', line 5

def _pull
  fetch_content_types do |content_type|
    # delete the previous file
    reset_file(content_entry_filepath(content_type))

    instrument :writing, label: content_type.name

    fetch_content_entries(content_type) do |entries|
      # entries is a list of max 10 elements (pagination)
      write_content_entries(content_type, entries)
    end

    instrument :write_with_success
  end
end

#write_content_entries(content_type, entries) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/locomotive/wagon/commands/pull_sub_commands/pull_content_entries_command.rb', line 21

def write_content_entries(content_type, entries)
  _entries = entries.map do |entry|
    yaml_attributes(content_type, entry)
  end

  write_to_file(content_entry_filepath(content_type), dump(_entries), 'a')
end