cronex 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +20 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +6 -0
- data/README.md +7 -2
- data/lib/cronex/description/base.rb +5 -3
- data/lib/cronex/exp_descriptor.rb +1 -0
- data/lib/cronex/parser.rb +1 -0
- data/lib/cronex/version.rb +1 -1
- data/spec/exp_descriptor_de_spec.rb +4 -0
- data/spec/exp_descriptor_en_spec.rb +10 -0
- data/spec/exp_descriptor_fr_spec.rb +4 -0
- data/spec/exp_descriptor_it_spec.rb +4 -0
- data/spec/exp_descriptor_pt_BR_spec.rb +4 -0
- data/spec/exp_descriptor_ro_spec.rb +4 -0
- data/spec/exp_descriptor_ru_spec.rb +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e7637c0b490441441238824af2bd3a54c6f263e88acc9490ee20190c852258
|
4
|
+
data.tar.gz: bc2e41a12f8a15f21d50cffa2fef998647b8cc7e3429e2b4b5b7297d83d02c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a73574bad6da9bfa391897a9a34f86ec3353718406da131faaa2af8f7b63a5f6f7694a45f67f47b24ff352179798c9342e21966f9104ed423c00dae41e144539
|
7
|
+
data.tar.gz: '081dbbc263ed70ab9f6f514f3359f17df56c270ff1eea91a72b197426c31b6403bd10d4020e7289b6b9f7cc64069714d3decd1e43481e6a6384ec0601472169f'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: Test
|
3
|
+
|
4
|
+
on: [push, pull_request]
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
ruby-version: [2.5, 2.6, 2.7]
|
12
|
+
name: Ruby ${{ matrix.ruby-version }}
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Setup Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby-version }}
|
19
|
+
- run: bundle install
|
20
|
+
- run: bundle exec rake
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### [0.12.0] - 2023-04-16
|
2
|
+
* Add "strict_quartz" option for Java Quartz implementation (quartz-scheduler)
|
3
|
+
|
4
|
+
### [0.11.1] - 2020-10-21
|
5
|
+
* Fix two consecutive commas in interval expressions
|
6
|
+
|
1
7
|
### [0.11.0] - 2020-10-05
|
2
8
|
* Fix handling L in day of month expressions
|
3
9
|
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Cronex
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/cronex.svg)](https://badge.fury.io/rb/cronex)
|
4
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/alpinweis/cronex/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/alpinweis/cronex/actions/workflows/test.yml?query=branch%3Amaster)
|
5
5
|
|
6
6
|
A Ruby library that converts cron expressions into human readable strings.
|
7
7
|
Translated to Ruby from [cron-expression-descriptor](https://github.com/bradyholt/cron-expression-descriptor) (C#) via
|
@@ -18,7 +18,7 @@ Original Author & Credit: Brady Holt (http://www.geekytidbits.com).
|
|
18
18
|
* Supports printing to locale specific human readable format
|
19
19
|
* Supports displaying times in specific timezones
|
20
20
|
|
21
|
-
For a quick intro to cron see Quartz [Cron Tutorial](http://www.quartz-scheduler.org/documentation/quartz-
|
21
|
+
For a quick intro to cron see Quartz [Cron Tutorial](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html).
|
22
22
|
|
23
23
|
## Available Locales
|
24
24
|
|
@@ -70,6 +70,11 @@ Or install it yourself as:
|
|
70
70
|
=> Every minute between 4:00 AM and 4:10 AM # PDT or
|
71
71
|
=> Every minute between 3:00 AM and 3:10 AM # PST
|
72
72
|
|
73
|
+
### Strict quartz-scheduler implementation support
|
74
|
+
|
75
|
+
Cronex::ExpressionDescriptor.new('* * * * *', strict_quartz: true).description
|
76
|
+
=> Cronex::ExpressionError (Error: Expression only has 5 parts. For 'strict_quartz' option, at least 6 parts are required)
|
77
|
+
|
73
78
|
See spec tests for more examples.
|
74
79
|
|
75
80
|
### Contributing
|
@@ -12,11 +12,11 @@ module Cronex
|
|
12
12
|
['/', '-', ',']
|
13
13
|
end
|
14
14
|
|
15
|
-
def segment_description(expression,
|
15
|
+
def segment_description(expression, all_values_description)
|
16
16
|
if expression.empty? || expression == '0'
|
17
17
|
desc = ''
|
18
18
|
elsif expression == '*'
|
19
|
-
desc =
|
19
|
+
desc = all_values_description
|
20
20
|
elsif !Cronex::Utils.include_any?(expression, special_chars)
|
21
21
|
desc = format(description_format(expression), single_item_description(expression))
|
22
22
|
elsif expression.include?('/')
|
@@ -26,10 +26,12 @@ module Cronex
|
|
26
26
|
if segments[0].include?('-')
|
27
27
|
between_segment_of_interval = segments[0]
|
28
28
|
between_segments = between_segment_of_interval.split('-')
|
29
|
-
|
29
|
+
between = format(
|
30
30
|
between_description_format(between_segment_of_interval),
|
31
31
|
single_item_description(between_segments[0]),
|
32
32
|
single_item_description(between_segments[1]).gsub(':00', ':59'))
|
33
|
+
desc += ', ' if !between.start_with?(', ')
|
34
|
+
desc += between
|
33
35
|
elsif !Cronex::Utils.include_any?(segments[0], special_chars + ['*'])
|
34
36
|
desc += ', ' + format(starting_description_format(segments[0]), single_item_description(segments[0]))
|
35
37
|
end
|
data/lib/cronex/parser.rb
CHANGED
@@ -27,6 +27,7 @@ module Cronex
|
|
27
27
|
if len < 5
|
28
28
|
fail ExpressionError, "Error: Expression only has #{len} parts. At least 5 parts are required"
|
29
29
|
elsif len == 5
|
30
|
+
fail ExpressionError, "Error: Expression only has 5 parts. For 'strict_quartz' option, at least 6 parts are required" if options[:strict_quartz]
|
30
31
|
# 5 part CRON so shift array past seconds element
|
31
32
|
parsed_parts.insert(1, *parts)
|
32
33
|
elsif len == 6
|
data/lib/cronex/version.rb
CHANGED
@@ -298,6 +298,10 @@ module Cronex
|
|
298
298
|
'Alle 2 Minuten, Minuten 00 bis 30 nach der vergangenen Stunde, um 5:00 PM, Montag bis Freitag')
|
299
299
|
end
|
300
300
|
|
301
|
+
it 'every x days with interval' do
|
302
|
+
expect(desc('30 7 1-L/2 * *')).to eq('Um 7:30 AM, Alle 2 Tagen, zwischen Tag 1 und der letzte Tag des Monats')
|
303
|
+
end
|
304
|
+
|
301
305
|
it 'one year only with seconds' do
|
302
306
|
expect(desc('* * * * * * 2013')).to eq('Jede Sekunde, nur in 2013')
|
303
307
|
end
|
@@ -298,6 +298,10 @@ module Cronex
|
|
298
298
|
'Every 2 minutes, minutes 00 through 30 past the hour, at 5:00 PM, Monday through Friday')
|
299
299
|
end
|
300
300
|
|
301
|
+
it 'every x days with interval' do
|
302
|
+
expect(desc('30 7 1-L/2 * *')).to eq('At 7:30 AM, every 2 days, between day 1 and the last day of the month')
|
303
|
+
end
|
304
|
+
|
301
305
|
it 'one year only with seconds' do
|
302
306
|
expect(desc('* * * * * * 2013')).to eq('Every second, only in 2013')
|
303
307
|
end
|
@@ -386,6 +390,12 @@ module Cronex
|
|
386
390
|
end
|
387
391
|
end
|
388
392
|
|
393
|
+
context 'strict_quartz' do
|
394
|
+
it '5 part cron fails' do
|
395
|
+
expect { desc('* * * * *', strict_quartz: true) }.to raise_error(Cronex::ExpressionError)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
389
399
|
context 'timezone' do
|
390
400
|
it 'minute span' do
|
391
401
|
tz = TZInfo::Timezone.get('America/Los_Angeles')
|
@@ -298,6 +298,10 @@ module Cronex
|
|
298
298
|
"Tous les 2 minutes, minutes 00 à 30 après l'heure, à 5:00 PM, lundi à vendredi")
|
299
299
|
end
|
300
300
|
|
301
|
+
it 'every x days with interval' do
|
302
|
+
expect(desc('30 7 1-L/2 * *')).to eq('À 7:30 AM, tous les 2 jours, entre le jour 1 et le dernier jour du mois')
|
303
|
+
end
|
304
|
+
|
301
305
|
it 'one year only with seconds' do
|
302
306
|
expect(desc('* * * * * * 2013')).to eq('Chaque seconde, seulement en 2013')
|
303
307
|
end
|
@@ -298,6 +298,10 @@ module Cronex
|
|
298
298
|
'Ogni 2 minuti, dal minuto 00 al 30 dopo l\'ora, alle(ai) 5:00 PM, da lunedì a venerdì')
|
299
299
|
end
|
300
300
|
|
301
|
+
it 'every x days with interval' do
|
302
|
+
expect(desc('30 7 1-L/2 * *')).to eq('Alle(ai) 7:30 AM, ogni 2 giorni, tra il giorno 1 e il ultimo giorno del mese')
|
303
|
+
end
|
304
|
+
|
301
305
|
it 'one year only with seconds' do
|
302
306
|
expect(desc('* * * * * * 2013')).to eq('Ogni secondo, solo a(nel) 2013')
|
303
307
|
end
|
@@ -298,6 +298,10 @@ module Cronex
|
|
298
298
|
'A cada 2 minutos, entre 00 e 30 minutos após a hora, 5:00 PM, de segunda-feira a sexta-feira')
|
299
299
|
end
|
300
300
|
|
301
|
+
it 'every x days with interval' do
|
302
|
+
expect(desc('30 7 1-L/2 * *')).to eq('Às 7:30 AM, a cada 2 dias, entre os dias 1 e último dia do mês')
|
303
|
+
end
|
304
|
+
|
301
305
|
it 'one year only with seconds' do
|
302
306
|
expect(desc('* * * * * * 2013')).to eq('A cada segundo, em 2013')
|
303
307
|
end
|
@@ -298,6 +298,10 @@ module Cronex
|
|
298
298
|
'La fiecare 2 minute, între minutele 00 și 30, la 5:00 PM, de luni până vineri')
|
299
299
|
end
|
300
300
|
|
301
|
+
it 'every x days with interval' do
|
302
|
+
expect(desc('30 7 1-L/2 * *')).to eq('La 7:30 AM, la fiecare 2 zile, între zilele 1 și ultima zi a lunii')
|
303
|
+
end
|
304
|
+
|
301
305
|
it 'one year only with seconds' do
|
302
306
|
expect(desc('* * * * * * 2013')).to eq('În fiecare secundă, numai în 2013')
|
303
307
|
end
|
@@ -298,6 +298,10 @@ module Cronex
|
|
298
298
|
'Каждые 2 минут, минуты с 00 по 30, в 5:00 PM, понедельник - пятница')
|
299
299
|
end
|
300
300
|
|
301
|
+
it 'every x days with interval' do
|
302
|
+
expect(desc('30 7 1-L/2 * *')).to eq('В 7:30 AM, каждые 2 дня(ей), между 1 днем и последним днем месяца')
|
303
|
+
end
|
304
|
+
|
301
305
|
it 'one year only with seconds' do
|
302
306
|
expect(desc('* * * * * * 2013')).to eq('Каждую секунду, только 2013')
|
303
307
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Kazaku
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -87,6 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".github/workflows/test.yml"
|
90
91
|
- ".gitignore"
|
91
92
|
- ".rspec"
|
92
93
|
- ".rubocop.yml"
|
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
149
|
- !ruby/object:Gem::Version
|
149
150
|
version: '0'
|
150
151
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
152
|
+
rubygems_version: 3.1.4
|
152
153
|
signing_key:
|
153
154
|
specification_version: 4
|
154
155
|
summary: Ruby library that converts cron expressions into human readable strings
|