Module: Pressy::Command::ChangesetHelpers

Defined in:
lib/pressy/command.rb

Instance Method Summary collapse

Instance Method Details



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/pressy/command.rb', line 66

def print_changeset(changeset)
  if changeset.has_changes?
    added = changeset.changes.count {|c| c.type == :add }
    updated = changeset.changes.count {|c| c.type == :update }
    deleted = changeset.changes.count {|c| c.type == :delete }
    stderr.puts "Added #{added} posts." unless added == 0
    stderr.puts "Updated #{updated} posts." unless updated == 0
    stderr.puts "Deleted #{deleted} posts." unless deleted == 0
  else
    stderr.puts "Already up-to-date."
  end
end