Method: Supply::Uploader#upload_metadata

Defined in:
supply/lib/supply/uploader.rb

#upload_metadata(language, listing) ⇒ Object



265
266
267
268
269
270
271
272
273
274
275
276
# File 'supply/lib/supply/uploader.rb', line 265

def (language, listing)
  Supply::AVAILABLE_METADATA_FIELDS.each do |key|
    path = File.join(, language, "#{key}.txt")
    listing.send("#{key}=".to_sym, File.read(path, encoding: 'UTF-8')) if File.exist?(path)
  end
  begin
    listing.save
  rescue Encoding::InvalidByteSequenceError => ex
    message = (ex.message || '').capitalize
    UI.user_error!("Metadata must be UTF-8 encoded. #{message}")
  end
end