lib/kobot/engine.rb in kobot-1.1.0 vs lib/kobot/engine.rb in kobot-1.2.0
- old
+ new
@@ -24,15 +24,19 @@
#
# System errors or any unknown exceptions occurred if any are
# to be popped up and should be handled by the outside caller.
def start
if weekend?
- Kobot.logger.info("Today=#{@today} is weekend.")
- return
+ if Config.force
+ Kobot.logger.info("[Force] should have exited: today=#{@today} is weekend")
+ else
+ Kobot.logger.info("Today=#{@today} is weekend")
+ return
+ end
end
if holiday?
- Kobot.logger.info("Today=#{@today} is holiday.")
+ Kobot.logger.info("Today=#{@today} is holiday")
return
end
unless %i[in out].include? Config.clock
Kobot.logger.warn("Invalid clock operation: #{Config.clock}")
return
@@ -145,12 +149,32 @@
break
end
end
def verify_today_record!
- raise KotRecordError, "Today=#{@today} is not found on kot." if @kot_today.strip.empty?
- raise KotRecordError, "Today=#{@today} is marked as weekend on kot: #{@kot_today}" if kot_weekend?
- raise KotRecordError, "Today=#{@today} is marked as public holiday on kot: #{@kot_today}" if kot_public_holiday?
+ raise KotRecordError, "Today=#{@today} is not found on kot" if @kot_today.strip.empty?
+
+ if kot_weekend?
+ unless Config.force
+ raise KotRecordError,
+ "Today=#{@today} is marked as weekend on kot: #{@kot_today}"
+ end
+
+ Kobot.logger.info(
+ "[Force] should have exited: today=#{@today} is marked as weekend on kot: #{@kot_today}"
+ )
+ end
+
+ if kot_public_holiday?
+ unless Config.force
+ raise KotRecordError,
+ "Today=#{@today} is marked as public holiday on kot: #{@kot_today}"
+ end
+
+ Kobot.logger.info(
+ "[Force] should have exited: today=#{@today} is marked as public holiday on kot: #{@kot_today}"
+ )
+ end
end
def clock_in!
Kobot.logger.warn("Clock in during the afternoon: #{@now}") if @now.hour > 12
if @kot_today_clock_in.strip.empty?