class AtCoderFriends::Verifier

marks and checks if the source has been verified.

Attributes

file[R]
path[R]
vdir[R]
vpath[R]

Public Class Methods

new(ctx) click to toggle source
# File lib/at_coder_friends/verifier.rb, line 12
def initialize(ctx)
  @path, _dir, @file = ctx.path_info.components
  @vdir = ctx.path_info.tmp_dir
  @vpath = File.join(vdir, "#{file}.verified")
end

Public Instance Methods

unverify() click to toggle source
# File lib/at_coder_friends/verifier.rb, line 25
def unverify
  return unless File.exist?(vpath)

  File.delete(vpath)
end
verified?() click to toggle source
# File lib/at_coder_friends/verifier.rb, line 31
def verified?
  return false unless File.exist?(vpath)
  return false if File.mtime(vpath) < File.mtime(path)

  true
end
verify() click to toggle source
# File lib/at_coder_friends/verifier.rb, line 18
def verify
  return unless File.exist?(path)

  makedirs_unless(vdir)
  FileUtils.touch(vpath)
end