mnc 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d20ca1d293059095ac75f26f8b4f77e3bfc969f2fd4e03707a203ef64f43ab8
4
- data.tar.gz: '08853762747f1afb9cfc5a64a9988839b4dd790518942c8895866c173cecd889'
3
+ metadata.gz: d433cb0d7408bb4c4ad1ccacdfaa2d9604c48f0f6b3c45a0251e17ac8f3eb6ef
4
+ data.tar.gz: fba06709179621e34f3db761376a7f2e5a76bf2e0b2d668c244126067d063955
5
5
  SHA512:
6
- metadata.gz: 19dcb1203a508e8ca27bf5cb547bed2f2fdc217331a458918dc60caabe06cd2a6ba42e56419ccdea62f81ea6ef8cf573de57cb9b18cf8019fd105a2732b146ad
7
- data.tar.gz: 82acfbbdf767ffc6465e804eb6e693e88dd6cfdd0d0b9104964afee2ee649ed08171566414dda6863206868b870f016af243ac66050393fa943671edb9d92710
6
+ metadata.gz: c8882535c5ca4a7e8b0d6a8070f8658af59ca4e222fcb04f296aaf426a04f3a9d723ab260d6c2a3a6857c41749573cb389716ceaf00dae2de1d36decc68a58ee
7
+ data.tar.gz: ee2661269a0044419f05f56f56d9397dddf6c5be17d05c0a5baeca4ca768a86acecc7fcb65ed8c127d9b21c1b335d55abf7fd26c3165af95fb5a354ce56b201b
data/.rubocop.yml CHANGED
@@ -21,3 +21,5 @@ Style/BlockDelimiters:
21
21
  Enabled: false
22
22
  Style/Documentation:
23
23
  Enabled: false
24
+ Style/MultilineBlockChain:
25
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mnc (0.1.0)
4
+ mnc (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/mnc.rb CHANGED
@@ -4,20 +4,36 @@ require_relative 'mnc/version'
4
4
  require 'time'
5
5
 
6
6
  module MNC
7
- def self.[](now = Time.now)
7
+ def self.[](now: Time.now, crontab: `crontab -l`)
8
8
  Integer(
9
- `crontab -l`
9
+ crontab
10
10
  .lines
11
- .select { |l| l =~ /^(?:[0-9*]+\s+){5}\S+/ }
11
+ .select { |l| l =~ /^(?:[0-9,*]+\s+){5}\S+/ }
12
12
  .map { |l| l.split.zip %w[%M %H %d %m %w] }
13
13
  .map { |a| a[0..4].reject { |b| b[0] == '*' } }
14
14
  .map { |a|
15
- t = a.map { |b| b[0] }.join(' ')
16
- f = a.map { |b| b[1] }.join(' ')
17
- now += 60 while (r = (Time.strptime t, f, now)) < Time.now
18
- r
15
+ a.map { |b|
16
+ b[0].split(',').map { |c| [c, b[1]] }
17
+ }
19
18
  }
20
- .min - Time.now
19
+ .map { |a|
20
+ (a[0] || [nil]).map { |b|
21
+ (a[1] || [nil]).map { |c|
22
+ (a[2] || [nil]).map { |d|
23
+ (a[3] || [nil]).map { |e|
24
+ (a[4] || [nil]).map { |f|
25
+ g = [b, c, d, e, f].compact
26
+ t = g.map { |h| h[0] }.join(' ')
27
+ f = g.map { |h| h[1] }.join(' ')
28
+ n = now
29
+ n += 60 while (r = (Time.strptime t, f, n)) < n
30
+ r
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }.flatten.min - now
21
37
  )
22
38
  end
23
39
  end
data/lib/mnc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MNC
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mnc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank J. Cameron
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-19 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: