cron_swanson 0.3.0 → 0.3.4

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
  SHA256:
3
- metadata.gz: 9c4d87324b0351bbf60e5cc586833282618dba613694fd57b22e0e9a7afce9a5
4
- data.tar.gz: f64d0020a6be996393b40040d506d880ad5d2a0315a530205ec8d834abdeb273
3
+ metadata.gz: 774b4cc23d01f0a3659e55c4d76c889f563dafdad67099568485ecf63772c8e1
4
+ data.tar.gz: fbdbcb9c0bd490d67baf8a0fb48d54573db09eaa008093ec2e63a199dc969f60
5
5
  SHA512:
6
- metadata.gz: 13473ea070dfe8f19fde8f9e0439ab571abbc0eb8274499df442fa21c43da86e5bd26942510156250ac8d474aed73725f1ac510c437da92e9cf855ccf95a6a94
7
- data.tar.gz: 990e1e3eb6fb5027111646583ecda830c45a38117b1035f748dd553161b8f3bdfacee1bad1e9e5b21d68baf69bc39db4d47fbe4b6599a664f1e90c1711b4c607
6
+ metadata.gz: 4fd63d57a96485ba5a6f31120324cbfeff992dd58c92e4b278c63efc5c54b4d419a447635dbfa9f00f4e8232bff7abd65fae597ad18975a2da6c2d003ca44e16
7
+ data.tar.gz: 725cadac1de63e915bd43f5d0f7c57b16bb9351e8c01f9b1f19e09cdf4675337bb4b39e2b56b7063c25541fa76bcaddcb10898b6f4d865f004ea196a3df278a9
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: rspec
9
+
10
+ on:
11
+ push:
12
+ branches: '**'
13
+
14
+ jobs:
15
+ test:
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: ['2.5', '2.6', '2.7']
20
+
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby
26
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
27
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ - name: Install dependencies
32
+ run: bundle install
33
+ - name: Run tests
34
+ run: bundle exec rake spec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.4 : "Dear frozen yogurt, you are the celery of desserts. Be ice cream or be nothing." : Jan 1, 2021
4
+
5
+ Note that gem doesn't currently work with ruby 3.
6
+
7
+ ## 0.3.3 : "There has never been a sadness that can’t been cured by breakfast food." : May 13, 2020
8
+
9
+ Remove 1 annoying `puts` statement.
10
+
11
+ ## 0.3.2 : "I regret nothing. The end." : November 4, 2019
12
+
13
+ Important bugfix: Previous versions would generate invalid schedule strings
14
+ for intervals less than 1 hour in length.
15
+
3
16
  ## 0.3.0 : "Any dog under 50 pounds is a cat and cats are useless." : November 4, 2019
4
17
 
5
18
  New feature:
data/README.md CHANGED
@@ -12,7 +12,7 @@ random) but which are fuzzed/shifted depending on some input.
12
12
 
13
13
  ## Build Status
14
14
 
15
- [![Build Status](https://travis-ci.org/alexdean/cron_swanson.svg?branch=master)](https://travis-ci.org/alexdean/cron_swanson)
15
+ [![Test Suite](https://github.com/alexdean/cron_swanson/actions/workflows/rspec.yml/badge.svg)](https://github.com/alexdean/cron_swanson/actions/workflows/rspec.yml)
16
16
 
17
17
  ## Installation
18
18
 
data/cron_swanson.gemspec CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.17"
26
- spec.add_development_dependency "rake", "~> 10.0"
25
+ # https://github.com/alexdean/cron_swanson/issues/2
26
+ spec.required_ruby_version = ['>= 2.5.0', '< 3.0.0']
27
+
28
+ spec.add_development_dependency "rake", ">= 12.3.3"
27
29
  end
@@ -1,3 +1,3 @@
1
1
  module CronSwanson
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -13,7 +13,7 @@ module CronSwanson
13
13
  end
14
14
 
15
15
  @whenever_job_list = whenever_job_list
16
- @seed = seed
16
+ @seed = seed.to_s
17
17
  @in_schedule_method = false
18
18
  @whenever_jobs = []
19
19
  end
data/lib/cron_swanson.rb CHANGED
@@ -5,7 +5,8 @@ require 'digest/sha2'
5
5
  # CronSwanson is a utility to generate run times for cron jobs which are
6
6
  # regular, but which vary per job.
7
7
  module CronSwanson
8
- SECONDS_PER_HOUR = 60 * 60
8
+ SECONDS_PER_MINUTE = 60
9
+ SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60
9
10
  SECONDS_PER_DAY = SECONDS_PER_HOUR * 24
10
11
 
11
12
  def self.default_interval
@@ -54,16 +55,31 @@ module CronSwanson
54
55
  "divisible by the given interval."
55
56
  end
56
57
 
57
- # figure out how many times job will happen in a day
58
- runs_per_day = SECONDS_PER_DAY / interval
58
+ job_offset = offset(job_identifier, interval: interval)
59
59
 
60
- run_at = Time.at(offset(job_identifier, interval: interval)).utc
60
+ if interval >= SECONDS_PER_HOUR
61
+ # figure out how many times job will happen in a day
62
+ runs_per_day = SECONDS_PER_DAY / interval
61
63
 
62
- hours = []
63
- runs_per_day.times do |i|
64
- hours << run_at.hour + (i * interval / SECONDS_PER_HOUR)
65
- end
64
+ run_at = Time.at(job_offset).utc
65
+ hours = []
66
+ runs_per_day.times do |i|
67
+ hours << run_at.hour + (i * interval / SECONDS_PER_HOUR)
68
+ end
69
+
70
+ "#{run_at.min} #{hours.join(',')} * * *"
71
+ else
72
+ minutes = []
73
+
74
+ job_offset_minutes = job_offset / SECONDS_PER_MINUTE
75
+ interval_minutes = interval / SECONDS_PER_MINUTE
66
76
 
67
- "#{run_at.min} #{hours.join(',')} * * *"
77
+ runs_per_hour = SECONDS_PER_HOUR / interval
78
+ runs_per_hour.times do |i|
79
+ minutes << job_offset_minutes + (i * interval_minutes)
80
+ end
81
+
82
+ "#{minutes.join(',')} * * * *"
83
+ end
68
84
  end
69
85
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cron_swanson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dean
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-04 00:00:00.000000000 Z
11
+ date: 2022-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.17'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.17'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '10.0'
19
+ version: 12.3.3
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '10.0'
26
+ version: 12.3.3
41
27
  description: easily schedule multiple apps to run the same job at different times
42
28
  email:
43
29
  - github@mostlyalex.com
@@ -45,11 +31,11 @@ executables: []
45
31
  extensions: []
46
32
  extra_rdoc_files: []
47
33
  files:
34
+ - ".github/workflows/rspec.yml"
48
35
  - ".gitignore"
49
36
  - ".rspec"
50
37
  - ".rubocop.yml"
51
38
  - ".ruby-version"
52
- - ".travis.yml"
53
39
  - CHANGELOG.md
54
40
  - Gemfile
55
41
  - Guardfile
@@ -68,7 +54,7 @@ files:
68
54
  homepage: https://github.com/alexdean/cron_swanson
69
55
  licenses: []
70
56
  metadata: {}
71
- post_install_message:
57
+ post_install_message:
72
58
  rdoc_options: []
73
59
  require_paths:
74
60
  - lib
@@ -76,15 +62,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
62
  requirements:
77
63
  - - ">="
78
64
  - !ruby/object:Gem::Version
79
- version: '0'
65
+ version: 2.5.0
66
+ - - "<"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
80
69
  required_rubygems_version: !ruby/object:Gem::Requirement
81
70
  requirements:
82
71
  - - ">="
83
72
  - !ruby/object:Gem::Version
84
73
  version: '0'
85
74
  requirements: []
86
- rubygems_version: 3.0.3
87
- signing_key:
75
+ rubygems_version: 3.1.4
76
+ signing_key:
88
77
  specification_version: 4
89
78
  summary: distribute common cron jobs so they don't all start at the same moment
90
79
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4
4
- - 2.5
5
- - 2.6
6
- script:
7
- - bundle exec rake spec