class ErrandBoy::Request

Attributes

action[R]
destination[R]
path[R]
provider[R]
register[R]
sender[R]

Public Class Methods

dir() click to toggle source
# File lib/errand_boy/request.rb, line 7
def self.dir
  File.expand_path 'requests'
end
new(path) click to toggle source
# File lib/errand_boy/request.rb, line 11
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

Public Instance Methods

delete() click to toggle source
# File lib/errand_boy/request.rb, line 25
def delete
  File.delete path
end
rename() click to toggle source
# File lib/errand_boy/request.rb, line 19
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

Private Instance Methods

request() click to toggle source
# File lib/errand_boy/request.rb, line 31
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