class Wco::Publisher

def self.list

def self.list
  [[nil,nil]] + all.map { |p| [p, p.id] }
end

def do_run

def do_run
  @site    = site
  @headers = {}
  @ctx     = OpenStruct.new
  puts! context_eval, 'context_eval'
  eval( context_eval )
  puts! @ctx, '@ctx'
  tmpl = ERB.new post_body_tmpl
  body = JSON.parse tmpl.result(binding)
  puts! body, 'body'
  out = Wco::HTTParty.post( "#{@site.origin}#{post_path}", {
    body: body.to_json,
    headers: @headers,
    basic_auth: { username: @site.username, password: @site.password },
  })
  puts! out.response, 'publisher httparty response'
  puts! out.body,     'publisher httparty body'
  if out.code != 201
    puts! out.body, "publisher#do_run non-201 status"
    ::ExceptionNotifier.notify_exception(
      Exception.new,
      data: {
        httparty_body: out.body,
        httparty: out,
        label: "publisher#do_run non-201 status",
      } )
    raise out.body
  end
  eval( after_eval ) if after_eval.present?
end

def to_s

def to_s
  "#{slug}: #{kind} => #{site}"
end