crontab_rb 0.2.1 → 0.2.3
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 +4 -4
- data/lib/crontab_rb.rb +0 -1
- data/lib/crontab_rb/cron.rb +1 -1
- data/lib/crontab_rb/parse.rb +18 -16
- data/lib/crontab_rb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b60c0a525c46f023908c26bbe2ea37089d5716e
|
4
|
+
data.tar.gz: 2f15e35e88fd24da38870480787bfd13786fed87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b83653cf9035dd3cdc15bf4726bb30c145ee9302c20ffa17efbd2bd767e97351ab22b2354d633fa7a2e44161eb13582744ed2f52fde70480d178f04967c6f75
|
7
|
+
data.tar.gz: 16492f6abce8b3a0e993fc149ed1d41208cb32cb90f50e236618419bcdc075ee1de168b8e65fb04f0f23d3619673adac218fb48b5ebb4825e8aaa39e5eaf02e5
|
data/lib/crontab_rb.rb
CHANGED
data/lib/crontab_rb/cron.rb
CHANGED
data/lib/crontab_rb/parse.rb
CHANGED
@@ -5,7 +5,8 @@ module CrontabRb
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@
|
8
|
+
@template = "cd :path && bundle exec bin/rails runner -e production ':command'"
|
9
|
+
@job_template = "/bin/bash -l -c ':job'"
|
9
10
|
@path = Dir.pwd
|
10
11
|
end
|
11
12
|
|
@@ -18,30 +19,31 @@ module CrontabRb
|
|
18
19
|
options[:type] = record[:time]
|
19
20
|
options[:time] = Template::EVERY[options[:time]]
|
20
21
|
options[:path] = @path
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
job = process_template(@template, options)
|
23
|
+
task = process_template(@job_template, options.merge(:job => job))
|
24
|
+
timer = process_timer(options)
|
25
|
+
contents << timer + " " + task + "\n"
|
24
26
|
end
|
25
27
|
contents.join("\n")
|
26
28
|
end
|
27
29
|
|
28
30
|
protected
|
29
31
|
|
32
|
+
def process_timer(options)
|
33
|
+
options[:time].gsub(/:\w+/) do |key|
|
34
|
+
if options[:type].to_i/60 <= 1
|
35
|
+
options[:at].to_i
|
36
|
+
else
|
37
|
+
t = options[:at].to_i*60
|
38
|
+
Time.at(t).utc.strftime("%M %H")
|
39
|
+
end
|
40
|
+
end.gsub(/\s+/m, " ").strip
|
41
|
+
end
|
42
|
+
|
30
43
|
def process_template(template, options)
|
31
44
|
template.gsub(/:\w+/) do |key|
|
32
45
|
before_and_after = [$`[-1..-1], $'[0..0]]
|
33
|
-
|
34
|
-
option = ''
|
35
|
-
if key_symbol === :at
|
36
|
-
if options[:type].to_i/60 <= 1
|
37
|
-
option = options[:at].to_i
|
38
|
-
else
|
39
|
-
t = options[:at].to_i*60
|
40
|
-
option = Time.at(t).utc.strftime("%M %H")
|
41
|
-
end
|
42
|
-
else
|
43
|
-
option = options[key_symbol] || key
|
44
|
-
end
|
46
|
+
option = options[key.sub(':', '').to_sym] || key
|
45
47
|
|
46
48
|
if before_and_after.all? { |c| c == "'" }
|
47
49
|
escape_single_quotes(option)
|
data/lib/crontab_rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crontab_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nguyen Anh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|