Skip to content

Commit

Permalink
Support Crystal 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erdnaxeli committed Apr 18, 2021
1 parent 298702a commit c4ade7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: marmot
version: 0.3.1
version: 0.4.0

authors:
- Alexandre Morignot <[email protected]>

crystal: 0.35.1
crystal: ">=0.35.1,<2"

license: MIT

Expand Down
16 changes: 8 additions & 8 deletions src/marmot.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ require "./tasks"
# * when a value is available on a channel (`Marmot.on`)
#
# Tasks are all executed on the same fiber.
# This means two things: first, you don't have to worry about concurrency
# (your tasks can share objects which does not support concurrency, like
# This means two things: first, you don't have to worry about concurrency
# (your tasks can share objects which do not support concurrency, like
# `HTTP::Client`), and second, they must not block (too much).
# If you want to execute jobs concurrently, you must spawn a new fiber inside your
# tasks.
Expand All @@ -38,7 +38,7 @@ require "./tasks"
# Their next runs will be triggered at the time before the clock changes, but the
# next ones will be correctly scheduled.
module Marmot
VERSION = "0.3.1"
VERSION = "0.4.0"

alias Callback = Proc(Task, Nil)

Expand Down Expand Up @@ -75,10 +75,10 @@ module Marmot
# Runs a task every *span* at the given *day*, *hour*, *minute* and *second*.
#
# ```
# Marmot.every(:hour, hour: 16, minute: 30, second: 30) # will run every hour at 30:30 (the hour parameter is ignored)
# Marmot.every(:day, hour: 15) { ... } # will run every day at 15:00:00
# Marmot.every(:month, day: 15) { ... } # will run every month at midnight
# Marmot.every(:month, day: 31) { ... } # will run every month THAT HAVE a 31th day at midnight
# Marmot.every(:hour, hour: 16, minute: 30, second: 30) # will run every hour at 30:30 (the hour parameter is ignored)
# Marmot.every(:day, hour: 15) { ... } # will run every day at 15:00:00
# Marmot.every(:month, day: 15) { ... } # will run every month at midnight
# Marmot.every(:month, day: 31) { ... } # will run every month THAT HAVE a 31th day at midnight
# ```
def every(span : Symbol, *, day = 1, hour = 0, minute = 0, second = 0, &block : Callback) : Task
Log.debug { "New task to run every #{span} at #{hour}:#{minute}:#{second}" }
Expand Down Expand Up @@ -115,7 +115,7 @@ module Marmot
remove_canceled_tasks

if @@tasks.size == 0
Log.debug { "No task to run! Stopping." }
Log.debug { "No task to run! Stopping." }
return
end

Expand Down
2 changes: 1 addition & 1 deletion src/tasks.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Marmot
@callback.call(self)
rescue ex : Exception
self.cancel
Log.error(exception: ex) { "An error occurred in task #{self}. The task have been canceled." }
Log.error(exception: ex) { "An error occurred in task #{self}. The task has been canceled." }
end

protected def start : Nil
Expand Down

0 comments on commit c4ade7b

Please sign in to comment.