Skip to content

Commit

Permalink
update to fixing consecutive commas in interval expressions (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
alpinweis authored Oct 21, 2020
1 parent 3e80efc commit fdbf8b3
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### [0.11.1] - 2020-10-21
* Fix two consecutive commas in interval expressions

### [0.11.0] - 2020-10-05
* Fix handling L in day of month expressions

Expand Down
4 changes: 2 additions & 2 deletions lib/cronex/description/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def special_chars
['/', '-', ',']
end

def segment_description(expression, all_description)
def segment_description(expression, all_values_description)
if expression.empty? || expression == '0'
desc = ''
elsif expression == '*'
desc = all_description
desc = all_values_description
elsif !Cronex::Utils.include_any?(expression, special_chars)
desc = format(description_format(expression), single_item_description(expression))
elsif expression.include?('/')
Expand Down
8 changes: 4 additions & 4 deletions spec/exp_descriptor_de_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def desc(expression, opts = {})
'Alle 2 Minuten, Minuten 00 bis 30 nach der vergangenen Stunde, um 5:00 PM, Montag bis Freitag')
end

it 'every x days with interval' do
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')
end

it 'one year only with seconds' do
expect(desc('* * * * * * 2013')).to eq('Jede Sekunde, nur in 2013')
end
Expand Down Expand Up @@ -385,9 +389,5 @@ def desc(expression, opts = {})
expect(desc('0 0 0 1 MAR * 2010/5')).to eq('Um 12:00 AM, am 1 Tag des Monats, nur in März, Alle 5 Jahren, beginnend in 2010')
end
end

it 'every few days' do
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')
end
end
end
8 changes: 4 additions & 4 deletions spec/exp_descriptor_en_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def desc(expression, opts = {})
'Every 2 minutes, minutes 00 through 30 past the hour, at 5:00 PM, Monday through Friday')
end

it 'every x days with interval' do
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')
end

it 'one year only with seconds' do
expect(desc('* * * * * * 2013')).to eq('Every second, only in 2013')
end
Expand Down Expand Up @@ -405,9 +409,5 @@ def desc(expression, opts = {})
expect(desc('0-10 11 * * *', timezone: 'Europe/Vienna')).to eq("Every minute between #{hour}:00 PM and #{hour}:10 PM")
end
end

it 'every few days' do
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')
end
end
end
8 changes: 4 additions & 4 deletions spec/exp_descriptor_fr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def desc(expression, opts = {})
"Tous les 2 minutes, minutes 00 à 30 après l'heure, à 5:00 PM, lundi à vendredi")
end

it 'every x days with interval' do
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')
end

it 'one year only with seconds' do
expect(desc('* * * * * * 2013')).to eq('Chaque seconde, seulement en 2013')
end
Expand Down Expand Up @@ -385,9 +389,5 @@ def desc(expression, opts = {})
expect(desc('0 0 0 1 MAR * 2010/5')).to eq('À 12:00 AM, le 1 de chaque mois, seulement en mars, tous les 5 ans, commence en 2010')
end
end

it 'every few days' do
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')
end
end
end
8 changes: 4 additions & 4 deletions spec/exp_descriptor_it_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def desc(expression, opts = {})
'Ogni 2 minuti, dal minuto 00 al 30 dopo l\'ora, alle(ai) 5:00 PM, da lunedì a venerdì')
end

it 'every x days with interval' do
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')
end

it 'one year only with seconds' do
expect(desc('* * * * * * 2013')).to eq('Ogni secondo, solo a(nel) 2013')
end
Expand Down Expand Up @@ -385,9 +389,5 @@ def desc(expression, opts = {})
expect(desc('0 0 0 1 MAR * 2010/5')).to eq('Alle(ai) 12:00 AM, il giorno 1 del mese, solo a(nel) marzo, ogni 5 anni, a partire da 2010')
end
end

it 'every few days' do
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')
end
end
end
8 changes: 4 additions & 4 deletions spec/exp_descriptor_pt_BR_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def desc(expression, opts = {})
'A cada 2 minutos, entre 00 e 30 minutos após a hora, 5:00 PM, de segunda-feira a sexta-feira')
end

it 'every x days with interval' do
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')
end

it 'one year only with seconds' do
expect(desc('* * * * * * 2013')).to eq('A cada segundo, em 2013')
end
Expand Down Expand Up @@ -385,9 +389,5 @@ def desc(expression, opts = {})
expect(desc('0 0 0 1 MAR * 2010/5')).to eq('Às 12:00 AM, no dia 1 do mês, em março, a cada 5 anos, iniciando em 2010')
end
end

it 'every few days' do
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')
end
end
end
8 changes: 4 additions & 4 deletions spec/exp_descriptor_ro_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def desc(expression, opts = {})
'La fiecare 2 minute, între minutele 00 și 30, la 5:00 PM, de luni până vineri')
end

it 'every x days with interval' do
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')
end

it 'one year only with seconds' do
expect(desc('* * * * * * 2013')).to eq('În fiecare secundă, numai în 2013')
end
Expand Down Expand Up @@ -385,9 +389,5 @@ def desc(expression, opts = {})
expect(desc('0 0 0 1 MAR * 2010/5')).to eq('La 12:00 AM, în a 1-a zi a lunii, numai în martie, la fiecare 5 ani, pornire în 2010')
end
end

it 'every few days' do
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')
end
end
end
8 changes: 4 additions & 4 deletions spec/exp_descriptor_ru_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def desc(expression, opts = {})
'Каждые 2 минут, минуты с 00 по 30, в 5:00 PM, понедельник - пятница')
end

it 'every x days with interval' do
expect(desc('30 7 1-L/2 * *')).to eq('В 7:30 AM, каждые 2 дня(ей), между 1 днем и последним днем месяца')
end

it 'one year only with seconds' do
expect(desc('* * * * * * 2013')).to eq('Каждую секунду, только 2013')
end
Expand Down Expand Up @@ -385,9 +389,5 @@ def desc(expression, opts = {})
expect(desc('0 0 0 1 MAR * 2010/5')).to eq('В 12:00 AM, 1 день месяца, только март, каждые 5 лет, начало в 2010')
end
end

it 'every few days' do
expect(desc('30 7 1-L/2 * *')).to eq('В 7:30 AM, каждые 2 дня(ей), между 1 днем и последним днем месяца')
end
end
end

0 comments on commit fdbf8b3

Please sign in to comment.