Class: Nanoc::CLI::Commands::Sync

Inherits:
Nanoc::CLI::CommandRunner show all
Defined in:
lib/nanoc/cli/commands/sync.rb

Instance Method Summary (collapse)

Methods inherited from Nanoc::CLI::CommandRunner

#call, call, #debug?, #is_in_site_dir?, #load_site, #require_site, #site

Instance Method Details

- (Object) run



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nanoc/cli/commands/sync.rb', line 14

def run
  # Check arguments
  if arguments.size != 0
    raise Nanoc::Errors::GenericTrivial, "usage: #{command.usage}"
  end

  # Make sure we are in a nanoc site directory
  require_site

  # Update all syncable data sources
  site.data_sources.each do |data_source|
    unless data_source.method(:sync).owner == Nanoc::DataSource
      puts "Syncing #{data_source.config[:type]} data source: #{data_source.items_root}"
      data_source.sync
    end
  end
end