cronex 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e6f8daf70eaa89830eec06d7c7368292dcf846d
4
- data.tar.gz: a0c6845cfa574085f21e8dc5ecb1e73fcc210918
3
+ metadata.gz: b071e718281eae3aa398857c94a82313f7c86cbc
4
+ data.tar.gz: 11072364556f0d7b2649dca6d4ddde874facba88
5
5
  SHA512:
6
- metadata.gz: 31b31f7c5933aa622962e5c321c94205bbc968c8c56682955175dae4e2e8e9e375c3577cef6a6c42067506236ea0e0f433a8f4eb48b5c3117ddaa915069da4ff
7
- data.tar.gz: c88a9490b5b66c82cbad4498373aafbfa4822ff2debbe1f7466044a07d9b8cb6e3f477cd53a735db97df1ebefe15f53d538be818e2b4f80fe6db8ba75bf28c2a
6
+ metadata.gz: b17652914797dde9564a267cc9fe9a98355299a17850646a0a97f40bd0d4df08e95ed1646a46ec24098262cad567a1fbef0df597e1ad068fd603ef186fffe61c
7
+ data.tar.gz: 272be7fae9d337fde1e20e2e6e1e10b4d52b578df067b03a7add886b5b5d20264f06dc6efb8ca6d651d6c0fc3fc9e75ca08bd962dadd0748996d5fca41b96fd5
@@ -1,3 +1,6 @@
1
+ ### [0.10.0] - 2020-05-26
2
+ * Move locale and timezone arguments to options
3
+
1
4
  ### [0.9.2] - 2020-04-24
2
5
  * Add italian locale
3
6
 
data/README.md CHANGED
@@ -61,12 +61,12 @@ Or install it yourself as:
61
61
 
62
62
  #### Localization
63
63
 
64
- Cronex::ExpressionDescriptor.new('30 2 * 2 1-5', {}, 'fr').description
64
+ Cronex::ExpressionDescriptor.new('30 2 * 2 1-5', locale: 'fr').description
65
65
  => À 2:30 AM, lundi à vendredi, seulement en février
66
66
 
67
67
  #### Timezones
68
68
 
69
- Cronex::ExpressionDescriptor.new('0-10 11 * * *', {}, 'en', 'America/Los_Angeles').description
69
+ Cronex::ExpressionDescriptor.new('0-10 11 * * *', timezone: 'America/Los_Angeles').description
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
 
@@ -12,19 +12,21 @@ module Cronex
12
12
  verbose: false,
13
13
  zero_based_dow: true,
14
14
  use_24_hour_time_format: false,
15
- throw_exception_on_parse_error: true
15
+ throw_exception_on_parse_error: true,
16
+ locale: nil,
17
+ timezone: nil
16
18
  }
17
19
 
18
20
  class ExpressionDescriptor
19
21
  attr_accessor :expression, :expression_parts, :options, :parsed, :resources, :timezone
20
22
 
21
- def initialize(expression, options = {}, locale = nil, timezone = 'UTC')
23
+ def initialize(expression, options = {})
22
24
  @expression = expression
23
25
  @options = CRONEX_OPTS.merge(options)
24
26
  @expression_parts = []
25
27
  @parsed = false
26
- @resources = Cronex::Resource.new(locale)
27
- @timezone = timezone
28
+ @resources = Cronex::Resource.new(@options[:locale])
29
+ @timezone = @options[:timezone] || 'UTC'
28
30
  end
29
31
 
30
32
  def to_hash
@@ -1,3 +1,3 @@
1
1
  module Cronex
2
- VERSION = '0.9.2'
2
+ VERSION = '0.10.0'
3
3
  end
@@ -4,8 +4,9 @@ require 'cronex'
4
4
  module Cronex
5
5
  describe ExpressionDescriptor do
6
6
 
7
- def desc(expression, opts = {}, timezone = 'UTC')
8
- Cronex::ExpressionDescriptor.new(expression, opts, 'de', timezone).description
7
+ def desc(expression, opts = {})
8
+ opts[:locale] = 'de'
9
+ Cronex::ExpressionDescriptor.new(expression, opts).description
9
10
  end
10
11
 
11
12
  let(:opts) { { zero_based_dow: false } }
@@ -4,8 +4,9 @@ require 'cronex'
4
4
  module Cronex
5
5
  describe ExpressionDescriptor do
6
6
 
7
- def desc(expression, opts = {}, timezone = 'UTC')
8
- Cronex::ExpressionDescriptor.new(expression, opts, 'en', timezone).description
7
+ def desc(expression, opts = {})
8
+ opts[:locale] = 'en'
9
+ Cronex::ExpressionDescriptor.new(expression, opts).description
9
10
  end
10
11
 
11
12
  let(:opts) { { zero_based_dow: false } }
@@ -383,19 +384,19 @@ module Cronex
383
384
  it 'minute span' do
384
385
  tz = TZInfo::Timezone.get('America/Los_Angeles')
385
386
  hour = tz.period_for_local(Time.now).zone_identifier.to_s == 'PDT' ? 4 : 3
386
- expect(desc('0-10 11 * * *', {}, 'America/Los_Angeles')).to eq("Every minute between #{hour}:00 AM and #{hour}:10 AM")
387
+ expect(desc('0-10 11 * * *', timezone: 'America/Los_Angeles')).to eq("Every minute between #{hour}:00 AM and #{hour}:10 AM")
387
388
  end
388
389
 
389
390
  it 'twice a day' do
390
391
  tz = TZInfo::Timezone.get('America/Los_Angeles')
391
392
  hour = tz.period_for_local(Time.now).zone_identifier.to_s == 'PDT' ? 5 : 4
392
- expect(desc('0 0,12 * * *', {}, 'America/Los_Angeles')).to eq("At #{hour}:00 PM and #{hour}:00 AM")
393
+ expect(desc('0 0,12 * * *', timezone: 'America/Los_Angeles')).to eq("At #{hour}:00 PM and #{hour}:00 AM")
393
394
  end
394
395
 
395
396
  it 'ahead of GMT' do
396
397
  tz = TZInfo::Timezone.get('Europe/Vienna')
397
398
  hour = tz.period_for_local(Time.now).zone_identifier.to_s == 'CEST' ? 1 : 12
398
- expect(desc('0-10 11 * * *', {}, 'Europe/Vienna')).to eq("Every minute between #{hour}:00 PM and #{hour}:10 PM")
399
+ expect(desc('0-10 11 * * *', timezone: 'Europe/Vienna')).to eq("Every minute between #{hour}:00 PM and #{hour}:10 PM")
399
400
  end
400
401
  end
401
402
  end
@@ -5,7 +5,8 @@ module Cronex
5
5
  describe ExpressionDescriptor do
6
6
 
7
7
  def desc(expression, opts = {})
8
- Cronex::ExpressionDescriptor.new(expression, opts, 'fr').description
8
+ opts[:locale] = 'fr'
9
+ Cronex::ExpressionDescriptor.new(expression, opts).description
9
10
  end
10
11
 
11
12
  let(:opts) { { zero_based_dow: false } }
@@ -4,8 +4,9 @@ require 'cronex'
4
4
  module Cronex
5
5
  describe ExpressionDescriptor do
6
6
 
7
- def desc(expression, opts = {}, timezone = 'UTC')
8
- Cronex::ExpressionDescriptor.new(expression, opts, 'it', timezone).description
7
+ def desc(expression, opts = {})
8
+ opts[:locale] = 'it'
9
+ Cronex::ExpressionDescriptor.new(expression, opts).description
9
10
  end
10
11
 
11
12
  let(:opts) { { zero_based_dow: false } }
@@ -378,25 +379,5 @@ module Cronex
378
379
  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')
379
380
  end
380
381
  end
381
-
382
- context 'timezone' do
383
- it 'minute span' do
384
- tz = TZInfo::Timezone.get('America/Los_Angeles')
385
- hour = tz.period_for_local(Time.now).zone_identifier.to_s == 'PDT' ? 4 : 3
386
- expect(desc('0-10 11 * * *', {}, 'America/Los_Angeles')).to eq("Ogni minuto tra le #{hour}:00 AM e le #{hour}:10 AM")
387
- end
388
-
389
- it 'twice a day' do
390
- tz = TZInfo::Timezone.get('America/Los_Angeles')
391
- hour = tz.period_for_local(Time.now).zone_identifier.to_s == 'PDT' ? 5 : 4
392
- expect(desc('0 0,12 * * *', {}, 'America/Los_Angeles')).to eq("Alle(ai) #{hour}:00 PM e #{hour}:00 AM")
393
- end
394
-
395
- it 'ahead of GMT' do
396
- tz = TZInfo::Timezone.get('Europe/Vienna')
397
- hour = tz.period_for_local(Time.now).zone_identifier.to_s == 'CEST' ? 1 : 12
398
- expect(desc('0-10 11 * * *', {}, 'Europe/Vienna')).to eq("Ogni minuto tra le #{hour}:00 PM e le #{hour}:10 PM")
399
- end
400
- end
401
382
  end
402
383
  end
@@ -5,7 +5,8 @@ module Cronex
5
5
  describe ExpressionDescriptor do
6
6
 
7
7
  def desc(expression, opts = {})
8
- Cronex::ExpressionDescriptor.new(expression, opts, 'pt_BR').description
8
+ opts[:locale] = 'pt_BR'
9
+ Cronex::ExpressionDescriptor.new(expression, opts).description
9
10
  end
10
11
 
11
12
  let(:opts) { { zero_based_dow: false } }
@@ -5,7 +5,8 @@ module Cronex
5
5
  describe ExpressionDescriptor do
6
6
 
7
7
  def desc(expression, opts = {})
8
- Cronex::ExpressionDescriptor.new(expression, opts, 'ro').description
8
+ opts[:locale] = 'ro'
9
+ Cronex::ExpressionDescriptor.new(expression, opts).description
9
10
  end
10
11
 
11
12
  let(:opts) { { zero_based_dow: false } }
@@ -5,7 +5,8 @@ module Cronex
5
5
  describe ExpressionDescriptor do
6
6
 
7
7
  def desc(expression, opts = {})
8
- Cronex::ExpressionDescriptor.new(expression, opts, 'ru').description
8
+ opts[:locale] = 'ru'
9
+ Cronex::ExpressionDescriptor.new(expression, opts).description
9
10
  end
10
11
 
11
12
  let(:opts) { { zero_based_dow: false } }
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.9.2
4
+ version: 0.10.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: 2020-04-24 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo