Sha256: 2930fe9f3f46b38eecd904fcece5421f375e914ec7eed50c84ab8bb255267450
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
module Siringa class SiringaController < ApplicationController def load Siringa.load_definition(params['definition'].to_sym) resp = { :text => "Definition #{params['definition']} loaded.", :status => :created } rescue ArgumentError => exception resp = { :text => exception.to_s, :status => :method_not_allowed } rescue => exception resp = { :text => exception.to_s, :status => :internal_server_error } ensure render resp end def dump Siringa.keep_five_dumps(Siringa.ordered_dumps) result = Siringa.dump_to(Siringa.dump_file_name) if result[:status] resp = { :text => "DB dumped at #{result[:dump_path]}", :status => :created } else resp = { :text => "DB dump FAILED!\nError:\n#{result[:error]}", :status => :internal_server_error } end render resp end def restore last_dump = Siringa.ordered_dumps.last if last_dump result = Siringa.restore_from(last_dump) if result[:status] resp = { :text => "DB restored from #{result[:dump_path]}", :status => :accepted } else resp = { :text => "DB restore FAILED!\nError:\n#{result[:error]}", :status => :internal_server_error } end else resp = { :text => "DB restore FAILED!\nThere is no dump to restore from.", :status => :method_not_allowed } end render resp end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
siringa-0.0.5 | app/controllers/siringa/siringa_controller.rb |
siringa-0.0.4 | app/controllers/siringa/siringa_controller.rb |
siringa-0.0.3 | app/controllers/siringa/siringa_controller.rb |