require 'toml' module ErrandBoy class Request attr_reader :sender, :provider, :action, :register, :destination, :path def self.dir File.expand_path 'requests' end def initialize(path) @path = path.to_s request.each do |key, value| instance_variable_set("@#{key}", value) end @sender = '' unless instance_variable_defined? :@sender end def rename timestamp = Time.now.strftime '%y%m%d%H%M%S' index = path.index('.toml') File.rename path, path.dup.insert(index, "_#{timestamp}") end def delete File.delete path end private def request TOML.load_file(path) rescue Errno::ENOENT raise NoRequestError, 'No such request file in this commit. ' \ 'You should add a request file to `requests/` folder.' end end end