From 38caafcccbf18e6d0f3f87ed7eecadac64e69d2e Mon Sep 17 00:00:00 2001 From: Led Date: Sat, 3 Sep 2016 17:21:27 +0300 Subject: [PATCH 01/30] move ecrn_test.erl to test/ --- {src => test}/ecrn_test.erl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {src => test}/ecrn_test.erl (100%) diff --git a/src/ecrn_test.erl b/test/ecrn_test.erl similarity index 100% rename from src/ecrn_test.erl rename to test/ecrn_test.erl From 494f2817fdf8b75097a054ca3815ff0afadebbc4 Mon Sep 17 00:00:00 2001 From: Led Date: Sat, 22 Jul 2017 22:37:48 +0300 Subject: [PATCH 02/30] remove internal.hrl --- src/ecrn_agent.erl | 2 -- src/ecrn_control.erl | 2 -- src/internal.hrl | 5 ----- 3 files changed, 9 deletions(-) delete mode 100644 src/internal.hrl diff --git a/src/ecrn_agent.erl b/src/ecrn_agent.erl index 55a14e2..42b18ca 100644 --- a/src/ecrn_agent.erl +++ b/src/ecrn_agent.erl @@ -21,8 +21,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("internal.hrl"). - -record(state, {job, alarm_ref, referenced_seconds, diff --git a/src/ecrn_control.erl b/src/ecrn_control.erl index 4ebd79e..e3ee0e4 100644 --- a/src/ecrn_control.erl +++ b/src/ecrn_control.erl @@ -22,8 +22,6 @@ -define(SERVER, ?MODULE). --include("internal.hrl"). - -record(state, {reference_datetime :: calendar:datetime(), datetime_at_reference :: erlcron:seconds()}). diff --git a/src/internal.hrl b/src/internal.hrl deleted file mode 100644 index 29de9ae..0000000 --- a/src/internal.hrl +++ /dev/null @@ -1,5 +0,0 @@ -%%% @copyright Erlware, LLC. All Rights Reserved. -%%% -%%% This file is provided to you under the BSD License; you may not use -%%% this file except in compliance with the License. --define(ONE_DAY, (24 * 60 * 60)). From b74c44e0123e8eec00ea39dbf0a167f761e7fd3c Mon Sep 17 00:00:00 2001 From: Led Date: Sat, 22 Jul 2017 22:53:09 +0300 Subject: [PATCH 03/30] ecrn_agent: fix monthly and weekly cron jobs parsing --- src/ecrn_agent.erl | 60 ++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/src/ecrn_agent.erl b/src/ecrn_agent.erl index 42b18ca..277bc03 100644 --- a/src/ecrn_agent.erl +++ b/src/ecrn_agent.erl @@ -210,35 +210,11 @@ until_next_time(State, {{once, Period}, _What}) -> until_next_time(State, {{daily, Period}, _What}) -> until_next_daytime(State, Period); until_next_time(State, {{weekly, DoW, Period}, _What}) -> - OnDay = resolve_dow(DoW), - {Date, _} = current_date(State), - Today = calendar:day_of_the_week(Date), - case Today of - OnDay -> - until_next_daytime_or_days_from_now(State, Period, 7); - Today when Today < OnDay -> - until_days_from_now(State, Period, OnDay - Today); - Today when Today > OnDay -> - until_days_from_now(State, Period, (OnDay+7) - Today) - end; + {ThisDate, ThisTime} = current_date(State), + until_days_from_now(calendar:day_of_the_week(ThisDate), resolve_dow(DoW), ThisTime, Period, 7); until_next_time(State, {{monthly, DoM, Period}, _What}) -> - {{ThisYear, ThisMonth, Today}, _} = current_date(State), - {NextYear, NextMonth} = - case ThisMonth of - 12 -> - {ThisYear + 1, 1}; - _ -> - {ThisYear, ThisMonth + 1} - end, - D1 = calendar:date_to_gregorian_days(ThisYear, ThisMonth, Today), - D2 = calendar:date_to_gregorian_days(NextYear, NextMonth, DoM), - Days = D2 - D1, - case Today of - DoM -> - until_next_daytime_or_days_from_now(State, Period, Days); - _ -> - until_days_from_now(State, Period, Days) - end. + {{ThisYear, ThisMonth, Today}, ThisTime} = current_date(State), + until_days_from_now(Today, DoM, ThisTime, Period, calendar:last_day_of_the_month(ThisYear, ThisMonth)). %% @doc Calculates the duration in seconds until the next time this %% period is to occur during the day. @@ -348,23 +324,17 @@ until_tomorrow(State, StartTime) -> %% @doc Calculates the duration in seconds until the given period %% occurs several days from now. --spec until_days_from_now(state(), erlcron:period(), integer()) -> - erlcron:seconds(). -until_days_from_now(State, Period, Days) -> - Days * 24 * 3600 + until_next_daytime(State, Period). - -%% @doc Calculates the duration in seconds until the given period -%% occurs, which may be today or several days from now. --spec until_next_daytime_or_days_from_now(state(), erlcron:period(), integer()) -> - erlcron:seconds(). -until_next_daytime_or_days_from_now(State, Period, Days) -> - CurrentTime = current_time(State), - case last_time(Period) of - T when T < CurrentTime -> - until_days_from_now(State, Period, Days-1); - _ -> - until_next_daytime(State, Period) - end. +-spec until_days_from_now(Today::1..7|1..31, Day::1..7|1..31, ThisTime::calendar:time(), + Period::erlcron:period(), Days::7|28..31) -> + erlcron:seconds(). +until_days_from_now(Today, Day, ThisTime, Period, Days) -> + ThisSeconds = calendar:time_to_seconds(ThisTime), + PeriodSeconds = resolve_time(Period), + if + Today =:= Day, ThisSeconds < PeriodSeconds -> 0; + Today < Day -> Day - Today; + true -> Days + Day - Today + end * (24 * 3600) + PeriodSeconds - ThisSeconds. set_internal_time(State, RefDate, CurrentSeconds) -> NewSeconds = calendar:datetime_to_gregorian_seconds(RefDate), From 29ad65833ee4f13bec7ec5a6056cb522b09d2d24 Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 16 Jun 2015 14:11:57 +0300 Subject: [PATCH 04/30] erlcron.app: set VSN --- src/erlcron.app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/erlcron.app.src b/src/erlcron.app.src index f227562..bff6fdb 100644 --- a/src/erlcron.app.src +++ b/src/erlcron.app.src @@ -1,6 +1,6 @@ {application,erlcron, [{description,"Erlang Implementation of cron"}, - {vsn,"semver"}, + {vsn,"0.3.0"}, {modules,[]}, {registered,[ecrn_agent]}, {applications,[kernel,stdlib]}, From 5006395da5ca25e20d1a0880c72d67b3296a10df Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 16 Jun 2015 14:12:45 +0300 Subject: [PATCH 05/30] rebar.config: remove deps --- rebar.config | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rebar.config b/rebar.config index 9818237..97d0253 100644 --- a/rebar.config +++ b/rebar.config @@ -1,8 +1,6 @@ %% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*- %% Dependencies ================================================================ -{deps, [{rebar_vsn_plugin, ".*", - {git, "https://github.com/erlware/rebar_vsn_plugin.git", - {tag, "master"}}}]}. +{deps, []}. %% Rebar Plugins ============================================================== {plugins, [rebar_vsn_plugin]}. From b75bea215e1277e2487c97bdd7ec8ec4dcdd698f Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 16 Jun 2015 14:15:16 +0300 Subject: [PATCH 06/30] rebar.config: remove plugins --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 97d0253..5129c17 100644 --- a/rebar.config +++ b/rebar.config @@ -3,7 +3,7 @@ {deps, []}. %% Rebar Plugins ============================================================== -{plugins, [rebar_vsn_plugin]}. +{plugins, []}. %% Compiler Options ============================================================ {erl_opts, From 65d1eaebc1c130d3395977189430b2cb9fc85ff4 Mon Sep 17 00:00:00 2001 From: Led Date: Sun, 23 Jul 2017 02:00:41 +0300 Subject: [PATCH 07/30] update .travis.yml --- .travis.yml | 20 +++++++------------- src/erlcron.app.src | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f9909c..aaad695 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,9 @@ -sudo: false language: erlang +notifications: + email: false otp_release: - - R15B03 - - R16B03-1 - - 17.5 - - 18.0 - - 18.1 - - 19.0 - -before_script: "make get-deps" -script: "make test" -branches: - only: - - master + - 20.0 + - 19.3 + - 18.3 + - 17.5 + - R16B03-1 diff --git a/src/erlcron.app.src b/src/erlcron.app.src index bff6fdb..0e231b7 100644 --- a/src/erlcron.app.src +++ b/src/erlcron.app.src @@ -1,6 +1,6 @@ {application,erlcron, [{description,"Erlang Implementation of cron"}, - {vsn,"0.3.0"}, + {vsn,"0.3.1"}, {modules,[]}, {registered,[ecrn_agent]}, {applications,[kernel,stdlib]}, From 86de4b3dfb563c9ee10252d7b42644a097a5920d Mon Sep 17 00:00:00 2001 From: Led Date: Sun, 23 Jul 2017 02:04:23 +0300 Subject: [PATCH 08/30] README.md: add travis-ci icon --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9fd17ad..75a9a0f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Erlcron ======= +[![Build Status](https://secure.travis-ci.org/Ledest/erlcron.png)](http://travis-ci.org/Ledest/erlcron) + Erlcron provides testable cron like functionality for Erlang systems, with the ability to arbitrarily set the time and place along with fastforwarding through tests. See erlcron.erl for more From 9a6a08bdb9f71b334907a8dd8ce427bde685e15f Mon Sep 17 00:00:00 2001 From: Led Date: Wed, 26 Jul 2017 17:37:22 +0300 Subject: [PATCH 09/30] ecrn_agent: update until_days_from_now/5 --- src/ecrn_agent.erl | 8 ++++---- src/erlcron.app.src | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ecrn_agent.erl b/src/ecrn_agent.erl index 277bc03..4875e21 100644 --- a/src/ecrn_agent.erl +++ b/src/ecrn_agent.erl @@ -331,10 +331,10 @@ until_days_from_now(Today, Day, ThisTime, Period, Days) -> ThisSeconds = calendar:time_to_seconds(ThisTime), PeriodSeconds = resolve_time(Period), if - Today =:= Day, ThisSeconds < PeriodSeconds -> 0; - Today < Day -> Day - Today; - true -> Days + Day - Today - end * (24 * 3600) + PeriodSeconds - ThisSeconds. + Today =:= Day, ThisSeconds < PeriodSeconds -> PeriodSeconds; + Today < Day -> (Day - Today) * (24 * 3600) + PeriodSeconds; + true -> (Days + Day - Today) * (24 * 3600) + PeriodSeconds + end - ThisSeconds. set_internal_time(State, RefDate, CurrentSeconds) -> NewSeconds = calendar:datetime_to_gregorian_seconds(RefDate), diff --git a/src/erlcron.app.src b/src/erlcron.app.src index 0e231b7..87e2f09 100644 --- a/src/erlcron.app.src +++ b/src/erlcron.app.src @@ -1,6 +1,6 @@ {application,erlcron, [{description,"Erlang Implementation of cron"}, - {vsn,"0.3.1"}, + {vsn,"0.3.2"}, {modules,[]}, {registered,[ecrn_agent]}, {applications,[kernel,stdlib]}, From 218aa21c4ad23b21ff6b2acbaf7353534ba57090 Mon Sep 17 00:00:00 2001 From: Led Date: Sat, 16 Dec 2017 22:27:57 +0200 Subject: [PATCH 10/30] update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index aaad695..5afa964 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: erlang notifications: email: false otp_release: - - 20.0 + - 20.1 - 19.3 - 18.3 - 17.5 From 6d17edef94f4db216023ff26da9377a2cf105bf4 Mon Sep 17 00:00:00 2001 From: Led Date: Sat, 16 Dec 2017 22:45:23 +0200 Subject: [PATCH 11/30] update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5afa964..855b6ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,4 @@ otp_release: - 18.3 - 17.5 - R16B03-1 +script: rebar compile && rebar eunit From 6b9d5077ac9a2207b5ee6987dca1f674c870af16 Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 20 Mar 2018 16:14:38 +0200 Subject: [PATCH 12/30] update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 855b6ab..645a9a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: erlang notifications: email: false otp_release: - - 20.1 + - 20.2 - 19.3 - 18.3 - 17.5 From 28b7bd5730a0b4d73a8d93b6198c08418e0a6433 Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 20 Mar 2018 16:36:41 +0200 Subject: [PATCH 13/30] improve specs --- src/ecrn_agent.erl | 40 ++++++++++++++++++---------------------- src/ecrn_control.erl | 12 ++++++------ src/ecrn_cron_sup.erl | 4 ++-- src/ecrn_reg.erl | 8 ++++---- src/ecrn_sup.erl | 2 +- src/erlcron.erl | 16 ++++++++-------- 6 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/ecrn_agent.erl b/src/ecrn_agent.erl index 4875e21..0091eb7 100644 --- a/src/ecrn_agent.erl +++ b/src/ecrn_agent.erl @@ -43,30 +43,29 @@ %% @doc %% Starts the server with the apropriate job and the appropriate ref --spec start_link(erlcron:job_ref(), erlcron:job()) -> - ignore | {error, Reason::term()} | {ok, pid()}. +-spec start_link(JobRef::erlcron:job_ref(), Job::erlcron:job()) -> ignore | {error, term()} | {ok, pid()}. start_link(JobRef, Job) -> gen_server:start_link(?MODULE, [JobRef, Job], []). --spec get_datetime(pid()) -> calendar:datetime(). +-spec get_datetime(Pid::pid()) -> calendar:datetime(). get_datetime(Pid) -> gen_server:call(Pid, get_datetime). --spec cancel(pid()) -> ok. +-spec cancel(Pid::pid()) -> ok. cancel(Pid) -> gen_server:cast(Pid, shutdown). --spec set_datetime(pid(), calendar:datetime(), erlcron:seconds()) -> ok. +-spec set_datetime(Pid::pid(), DateTime::calendar:datetime(), Actual::erlcron:seconds()) -> ok. set_datetime(Pid, DateTime, Actual) -> gen_server:cast(Pid, {set_datetime, DateTime, Actual}). --spec recalculate(pid()) -> ok. +-spec recalculate(Pid::pid()) -> ok. recalculate(Pid) -> gen_server:cast(Pid, recalculate). %% @doc %% Validate that a run_when spec specified is correct. --spec validate(erlcron:run_when()) -> valid | invalid. +-spec validate(Spec::erlcron:run_when()) -> valid | invalid. validate(Spec) -> State = #state{job=undefined, alarm_ref=undefined}, @@ -162,9 +161,9 @@ do_job_run(State, {_, {M, F, A}}) proc_lib:spawn(M, F, A). %% @doc Returns the current time, in seconds past midnight. --spec current_time(state()) -> erlcron:seconds(). +-spec current_time(State::state()) -> erlcron:seconds(). current_time(State) -> - {_, {H,M,S}} = current_date(State), + {_, {H, M, S}} = current_date(State), S + M * 60 + H * 3600. current_date(State = #state{fast_forward=true}) -> @@ -176,8 +175,8 @@ current_date(State) -> %% @doc Calculates the duration in milliseconds until the next time %% a job is to be run. --spec until_next_milliseconds(state(), erlcron:job()) -> - {ok, erlcron:seconds()} | {error, invalid_one_exception}. +-spec until_next_milliseconds(State::state(), Job::erlcron:job()) -> + {ok, erlcron:seconds()} | {error, invalid_one_exception}. until_next_milliseconds(State, Job) -> try Millis = until_next_time(State, Job) * ?MILLISECONDS, @@ -198,14 +197,12 @@ normalize_seconds(State, Seconds) -> %% @doc Calculates the duration in seconds until the next time %% a job is to be run. --spec until_next_time(state(), {erlcron:run_when(), term()}) -> - erlcron:seconds(). +-spec until_next_time(State::state(), {erlcron:run_when(), term()}) -> erlcron:seconds(). until_next_time(_State, {{once, Seconds}, _What}) when is_integer(Seconds) -> Seconds; -until_next_time(State, {{once, {H, M, S}}, _What}) - when is_integer(H), is_integer(M), is_integer(S) -> +until_next_time(State, {{once, {H, M, S}}, _What}) when is_integer(H), is_integer(M), is_integer(S) -> normalize_seconds(State, S + (M + (H * 60)) * 60); -until_next_time(State, {{once, Period}, _What}) -> +until_next_time(State, {{once, Period}, _What}) -> normalize_seconds(State, resolve_time(Period)); until_next_time(State, {{daily, Period}, _What}) -> until_next_daytime(State, Period); @@ -218,7 +215,7 @@ until_next_time(State, {{monthly, DoM, Period}, _What}) -> %% @doc Calculates the duration in seconds until the next time this %% period is to occur during the day. --spec until_next_daytime(state(), erlcron:period()) -> erlcron:seconds(). +-spec until_next_daytime(State::state(), Period::erlcron:period()) -> erlcron:seconds(). until_next_daytime(State, Period) -> StartTime = first_time(Period), EndTime = last_time(Period), @@ -230,18 +227,17 @@ until_next_daytime(State, Period) -> end. %% @doc Calculates the last time in a given period. --spec last_time(erlcron:period()) -> erlcron:seconds(). +-spec last_time(Period::erlcron:period()) -> erlcron:seconds(). last_time(Period) -> hd(lists:reverse(lists:sort(resolve_period(Period)))). - %% @doc Calculates the first time in a given period. --spec first_time(erlcron:period()) -> erlcron:seconds(). +-spec first_time(Period::erlcron:period()) -> erlcron:seconds(). first_time(Period) -> hd(lists:sort(resolve_period(Period))). %% @doc Calculates the first time in the given period after the given time. --spec next_time(erlcron:period(), erlcron:seconds()) -> erlcron:seconds(). +-spec next_time(Period::erlcron:period(), Time::erlcron:seconds()) -> erlcron:seconds(). next_time(Period, Time) -> R = lists:sort(resolve_period(Period)), lists:foldl(fun(X, A) -> @@ -318,7 +314,7 @@ resolve_dow(sun) -> %% @doc Calculates the duration in seconds until the given time occurs %% tomorrow. --spec until_tomorrow(state(), erlcron:seconds()) -> erlcron:seconds(). +-spec until_tomorrow(State::state(), StartTime::erlcron:seconds()) -> erlcron:seconds(). until_tomorrow(State, StartTime) -> (StartTime + 24*3600) - current_time(State). diff --git a/src/ecrn_control.erl b/src/ecrn_control.erl index e3ee0e4..2d978b9 100644 --- a/src/ecrn_control.erl +++ b/src/ecrn_control.erl @@ -29,11 +29,11 @@ %%% API %%%=================================================================== --spec start_link() -> {ok, pid()} | ignore | {error, Error::term()}. +-spec start_link() -> {ok, pid()} | ignore | {error, term()}. start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). --spec cancel(erlcron:job_ref()) -> ok | undefined. +-spec cancel(AlarmRef::erlcron:job_ref()) -> ok | undefined. cancel(AlarmRef) -> gen_server:call(?SERVER, {cancel, AlarmRef}). @@ -42,13 +42,13 @@ datetime() -> gen_server:call(?SERVER, get_datetime). %% @doc sets the date-time for the erlcron --spec set_datetime(calendar:datetime()) -> ok. -set_datetime(DateTime={_,_}) -> +-spec set_datetime(DateTime::calendar:datetime()) -> ok. +set_datetime({_, _} = DateTime) -> gen_server:call(?SERVER, {set_datetime, DateTime}, infinity). %% @doc sets the date-time with the erlcron on all nodes --spec multi_set_datetime([node()], calendar:datetime()) -> ok. -multi_set_datetime(Nodes, DateTime={_,_}) -> +-spec multi_set_datetime(Nodes::[node()], DateTime::calendar:datetime()) -> ok. +multi_set_datetime(Nodes, {_, _} = DateTime) -> gen_server:multi_call(Nodes, ?SERVER, {set_datetime, DateTime}). %%%=================================================================== diff --git a/src/ecrn_cron_sup.erl b/src/ecrn_cron_sup.erl index ba29d29..6ccc038 100644 --- a/src/ecrn_cron_sup.erl +++ b/src/ecrn_cron_sup.erl @@ -22,14 +22,14 @@ %%% API functions %%%=================================================================== --spec start_link() -> {ok, pid()} | ignore | {error, Error::term()}. +-spec start_link() -> {ok, pid()} | ignore | {error, term()}. start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). %% @doc %% Add a chron job to be supervised --spec add_job(erlcron:job_ref(), erlcron:job()) -> erlcron:job_ref(). +-spec add_job(JobRef::erlcron:job_ref(), Task::erlcron:job()) -> erlcron:job_ref(). add_job(JobRef, Task) -> {ok, _} = supervisor:start_child(?SERVER, [JobRef, Task]), JobRef. diff --git a/src/ecrn_reg.erl b/src/ecrn_reg.erl index 299e9d1..501306a 100644 --- a/src/ecrn_reg.erl +++ b/src/ecrn_reg.erl @@ -31,13 +31,13 @@ %%% API %%%=================================================================== --spec start_link() -> {ok, Pid::pid()} | ignore | {error, Error::term()}. +-spec start_link() -> {ok, pid()} | ignore | {error, term()}. start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). %% @doc %% Register an arbitrary value with the system, under a set of keys --spec register(term() | [term()], term()) -> ok | {discarded_keys, [term()]}. +-spec register(Keys::term()|[term()], Body::term()) -> ok | {discarded_keys, [term()]}. register(Keys, Body) when is_list(Keys) -> gen_server:call(?SERVER, {register, Keys, Body}); register(Key, Body) -> @@ -45,7 +45,7 @@ register(Key, Body) -> %% @doc %% Remove the value registered under a que or set of keys --spec unregister(term() | [term()]) -> ok. +-spec unregister(Keys::term()|[term()]) -> ok. unregister(Keys) when is_list(Keys) -> gen_server:call(?SERVER, {unregister, Keys}); unregister(Key) -> @@ -53,7 +53,7 @@ unregister(Key) -> %% @doc %% Get a value buy key. --spec get(term()) -> {ok, term()} | undefined. +-spec get(Keys::term()) -> {ok, term()} | undefined. get(Key) -> gen_server:call(?SERVER, {get, Key}). diff --git a/src/ecrn_sup.erl b/src/ecrn_sup.erl index 2544f4e..69fd0fe 100644 --- a/src/ecrn_sup.erl +++ b/src/ecrn_sup.erl @@ -18,7 +18,7 @@ %%% API functions %%%=================================================================== --spec start_link() -> {ok, Pid::term()} | ignore | {error, Error::term()}. +-spec start_link() -> {ok, term()} | ignore | {error, term()}. start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). diff --git a/src/erlcron.erl b/src/erlcron.erl index 7279a64..6058610 100644 --- a/src/erlcron.erl +++ b/src/erlcron.erl @@ -60,7 +60,7 @@ %% @doc %% Check that the spec specified is valid or invalid --spec validate(run_when()) -> valid | invalid. +-spec validate(Spec::run_when()) -> valid | invalid. validate(Spec) -> ecrn_agent:validate(Spec). @@ -69,28 +69,28 @@ validate(Spec) -> %% spec. It returns the JobRef that can be used to manipulate the job %% after it is created. --spec cron(job()) -> job_ref(). +-spec cron(Job::job()) -> job_ref(). cron(Job) -> JobRef = make_ref(), ecrn_cron_sup:add_job(JobRef, Job). %% @doc %% Convienience method to specify a job run to run on a daily basis %% at a specific time. --spec at(cron_time() | seconds(), function()) -> job_ref(). +-spec at(When::cron_time()|seconds(), Fun::function()) -> job_ref(). at(When, Fun) -> Job = {{daily, When}, Fun}, cron(Job). %% @doc %% Run the specified job once after the amount of time specifed. --spec once(cron_time() | seconds(), function()) -> job_ref(). +-spec once(When::cron_time()|seconds(), Fun::function()) -> job_ref(). once(When, Fun) -> Job = {{once, When}, Fun}, cron(Job). %% @doc %% Cancel the job specified by the jobref. --spec cancel(job_ref()) -> ok | undefined. +-spec cancel(JobRef::job_ref()) -> ok | undefined. cancel(JobRef) -> ecrn_control:cancel(JobRef). @@ -102,19 +102,19 @@ datetime() -> %% @doc %% Set the current date time of the running erlcron system. --spec set_datetime(calendar:datetime()) -> ok. +-spec set_datetime(DateTime::calendar:datetime()) -> ok. set_datetime(DateTime) -> ecrn_control:set_datetime(DateTime). %% @doc %% Set the current date time of the erlcron system running on different nodes. --spec multi_set_datetime(calendar:datetime()) -> ok. +-spec multi_set_datetime(DateTime::calendar:datetime()) -> ok. multi_set_datetime(DateTime) -> ecrn_control:multi_set_datetime([node()|nodes()], DateTime). %% @doc %% Set the current date time of the erlcron system running on the %% specified nodes --spec multi_set_datetime([node()], calendar:datetime()) -> ok. +-spec multi_set_datetime(Nodes::[node()], DateTime::calendar:datetime()) -> ok. multi_set_datetime(Nodes, DateTime) when is_list(Nodes) -> ecrn_control:multi_set_datetime(Nodes, DateTime). From 93382a55936d1368e1faeda403411f71d192ebd6 Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 20 Mar 2018 16:37:07 +0200 Subject: [PATCH 14/30] .gitignore: add doc --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 32c7afb..1f2c6ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ ebin/*.beam ebin/*.app .* -deps/* \ No newline at end of file +deps/* +doc From 6213a03a81a17a4bafa3057e38ea4cf576b931bf Mon Sep 17 00:00:00 2001 From: Led Date: Fri, 23 Mar 2018 01:17:43 +0200 Subject: [PATCH 15/30] update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 645a9a5..2d577ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: erlang notifications: email: false otp_release: - - 20.2 + - 20.3 - 19.3 - 18.3 - 17.5 From 7f3bab2a3f87b1a1641027062ed13e4c3c5ad47d Mon Sep 17 00:00:00 2001 From: Led Date: Mon, 2 Apr 2018 14:31:37 +0300 Subject: [PATCH 16/30] 0.3.3 --- src/erlcron.app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/erlcron.app.src b/src/erlcron.app.src index 87e2f09..88c8221 100644 --- a/src/erlcron.app.src +++ b/src/erlcron.app.src @@ -1,6 +1,6 @@ {application,erlcron, [{description,"Erlang Implementation of cron"}, - {vsn,"0.3.2"}, + {vsn,"0.3.3"}, {modules,[]}, {registered,[ecrn_agent]}, {applications,[kernel,stdlib]}, From 8c007fc88ac5b0eb6fd62af8bd9d911ada923b22 Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 17 Apr 2018 20:08:15 +0300 Subject: [PATCH 17/30] erlcron.app: add ecrn_control, ecrn_cron_sup, ecrn_reg, ecrn_sup to registered --- src/erlcron.app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/erlcron.app.src b/src/erlcron.app.src index 88c8221..9dd05c2 100644 --- a/src/erlcron.app.src +++ b/src/erlcron.app.src @@ -2,6 +2,6 @@ [{description,"Erlang Implementation of cron"}, {vsn,"0.3.3"}, {modules,[]}, - {registered,[ecrn_agent]}, + {registered,[ecrn_agent,ecrn_control,ecrn_cron_sup,ecrn_reg,ecrn_sup]}, {applications,[kernel,stdlib]}, {mod,{ecrn_app,[]}}]}. From 006c4b9f488438497fa17056940e304a142f8efc Mon Sep 17 00:00:00 2001 From: Led Date: Fri, 23 Nov 2018 11:07:22 +0200 Subject: [PATCH 18/30] ecrn_agent: remove unneeded stacktrace displaying --- src/ecrn_agent.erl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ecrn_agent.erl b/src/ecrn_agent.erl index 0091eb7..2ce032d 100644 --- a/src/ecrn_agent.erl +++ b/src/ecrn_agent.erl @@ -191,7 +191,6 @@ normalize_seconds(State, Seconds) -> Value when Value >= 0 -> Value; _ -> - erlang:display(erlang:get_stacktrace()), throw(invalid_once_exception) end. From d8649107c323b2f1353f723e227ed813367b33c0 Mon Sep 17 00:00:00 2001 From: Led Date: Fri, 23 Nov 2018 11:07:56 +0200 Subject: [PATCH 19/30] update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2d577ae..98cd2bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: erlang notifications: email: false otp_release: + - 21.1 - 20.3 - 19.3 - 18.3 From a2047f75c54b41b3443f17a1748b63e1630e4387 Mon Sep 17 00:00:00 2001 From: Led Date: Fri, 23 Nov 2018 11:10:33 +0200 Subject: [PATCH 20/30] 0.3.4 --- src/erlcron.app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/erlcron.app.src b/src/erlcron.app.src index 9dd05c2..908d8c4 100644 --- a/src/erlcron.app.src +++ b/src/erlcron.app.src @@ -1,6 +1,6 @@ {application,erlcron, [{description,"Erlang Implementation of cron"}, - {vsn,"0.3.3"}, + {vsn,"0.3.4"}, {modules,[]}, {registered,[ecrn_agent,ecrn_control,ecrn_cron_sup,ecrn_reg,ecrn_sup]}, {applications,[kernel,stdlib]}, From 31205c0e7ef8847901ef5cd23300a534fb47af3e Mon Sep 17 00:00:00 2001 From: Led Date: Mon, 13 May 2019 02:01:09 +0300 Subject: [PATCH 21/30] update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98cd2bc..e8d3d2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: erlang notifications: email: false otp_release: - - 21.1 + - 21.3 - 20.3 - 19.3 - 18.3 From bb6b384b085c8b209a686272f9ed7fd9a6ae8107 Mon Sep 17 00:00:00 2001 From: Led Date: Wed, 5 Jun 2019 16:11:48 +0300 Subject: [PATCH 22/30] .travis.yml add 22.0 to otp_release --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e8d3d2b..0b9dede 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: erlang notifications: email: false otp_release: + - 22.0 - 21.3 - 20.3 - 19.3 From ce6cb82c4682e7e61fb57f654036ebe63f3a9777 Mon Sep 17 00:00:00 2001 From: Led Date: Mon, 2 Jan 2023 15:02:06 +0200 Subject: [PATCH 23/30] remove .travis.yml --- .travis.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0b9dede..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: erlang -notifications: - email: false -otp_release: - - 22.0 - - 21.3 - - 20.3 - - 19.3 - - 18.3 - - 17.5 - - R16B03-1 -script: rebar compile && rebar eunit From 2afb99d70c8f175fbeeac0d516468035bdc255c2 Mon Sep 17 00:00:00 2001 From: Led Date: Mon, 2 Jan 2023 15:02:22 +0200 Subject: [PATCH 24/30] Update .gitignore --- .gitignore | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1f2c6ca..bfbb67b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -ebin/*.beam -ebin/*.app -.* -deps/* -doc +/.rebar +/.eunit +/ebin +/deps +/doc From 887ae33f715d3beb9b7d472f5d72894de540a635 Mon Sep 17 00:00:00 2001 From: Led Date: Mon, 2 Jan 2023 15:02:50 +0200 Subject: [PATCH 25/30] Add .github/workflows/ --- .github/workflows/erlang.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/erlang.yml diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml new file mode 100644 index 0000000..31d32c8 --- /dev/null +++ b/.github/workflows/erlang.yml @@ -0,0 +1,27 @@ +name: Erlang CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-20.04 + strategy: + matrix: + version: ["25.2", "25.1", "25.0", "24.3", "24.2", "24.1", "24.0", "23.3", "23.2", "23.1", "23.0", "22", "21", "20", "19.3", "18.3"] + rebar: [rebar, rebar3] + container: + image: erlang:${{ matrix.version }} + steps: + - uses: actions/checkout@v2 + - name: Compile + run: ${{ matrix.rebar }} compile + - name: XRef + run: ${{ matrix.rebar }} xref + - name: Tests + run: ${{ matrix.rebar }} eunit From 531b6eba026ad79b0383bc55d20446793482dd13 Mon Sep 17 00:00:00 2001 From: Led Date: Mon, 2 Jan 2023 15:09:41 +0200 Subject: [PATCH 26/30] rebar.config: add xref_checks --- rebar.config | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rebar.config b/rebar.config index 5129c17..d07b99b 100644 --- a/rebar.config +++ b/rebar.config @@ -16,3 +16,9 @@ {cover_enabled, true}. {cover_print_enabled, true}. + +{xref_checks, [undefined_function_calls, + undefined_functions, + locals_not_used, + deprecated_function_calls, + deprecated_functions]}. From 584e7b5a908ecdecef03e474bce3a15a2618a888 Mon Sep 17 00:00:00 2001 From: Led Date: Mon, 2 Jan 2023 15:13:13 +0200 Subject: [PATCH 27/30] erlang.yml: update actions/checkout version --- .github/workflows/erlang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 31d32c8..af1a552 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -18,7 +18,7 @@ jobs: container: image: erlang:${{ matrix.version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Compile run: ${{ matrix.rebar }} compile - name: XRef From 5f46175f553825c7e2523405388a2cce8f16da4d Mon Sep 17 00:00:00 2001 From: Led Date: Sat, 20 May 2023 22:40:14 +0300 Subject: [PATCH 28/30] erlang.yml: update version --- .github/workflows/erlang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index af1a552..3e86ecc 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - version: ["25.2", "25.1", "25.0", "24.3", "24.2", "24.1", "24.0", "23.3", "23.2", "23.1", "23.0", "22", "21", "20", "19.3", "18.3"] + version: [26.0, 25.3, 25.2, 25.1, 25.0, 24.3, 24.2, 24.1, 24.0, 23.3, 23.2, 23.1, 23.0, 22, 21, 20, 19.3, 18.3] rebar: [rebar, rebar3] container: image: erlang:${{ matrix.version }} From c612aacfe80cf785f0bae45dd6c9c40e49d4353f Mon Sep 17 00:00:00 2001 From: Led Date: Sun, 21 May 2023 03:36:08 +0300 Subject: [PATCH 29/30] README: update build status badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75a9a0f..e9c5024 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Erlcron ======= -[![Build Status](https://secure.travis-ci.org/Ledest/erlcron.png)](http://travis-ci.org/Ledest/erlcron) +[![Build Status](https://github.com/Ledest/erlcron/actions/workflows/erlang.yml/badge.svg)](https://github.com/Ledest/erlcron/actions/workflows/erlang.yml/badge.svg) Erlcron provides testable cron like functionality for Erlang systems, with the ability to arbitrarily set the time and place along From 3dd39474e50954f526e282fba748e08bc184e27b Mon Sep 17 00:00:00 2001 From: Serge Aleynikov Date: Sun, 21 May 2023 01:16:12 -0400 Subject: [PATCH 30/30] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bfbb67b..8783987 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /ebin /deps /doc +/_build