Sha256: 54fdf7ee5a83f41c10a02fb07e4f551d8eb9df6b4c5022cdbf936d2c2708add1
Contents?: true
Size: 931 Bytes
Versions: 2
Compression:
Stored size: 931 Bytes
Contents
# frozen_string_literal: true require 'date' module StrictTodo class Checker class << self def perform(line:) delete_index = line.index('TODO') || line.index('FIXME') return nil if delete_index.nil? parse_line = line.slice(delete_index..) unless delete_index.zero? line.slice!(0..delete_index-1) end if check_format(line: parse_line).nil? return "フォーマットエラー" end date = parse_line.match(/[0-9]{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])/)[0] if check_date(date: date) return "期限を過ぎています" end nil end private def check_format(line:) line =~ /\A(TODO|FIXME)\((\w|-)*:[0-9]{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\).*\Z/ end def check_date(date:) Date.parse(date) < Date.today end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
strict-todo-0.0.2 | lib/strict_todo/checker.rb |
strict-todo-0.0.1 | lib/strict_todo/checker.rb |