lazylead 0.4.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.docs/accuracy.md +2 -2
- data/.docs/duedate_expired.md +3 -3
- data/.docs/propagate_down.md +3 -3
- data/.gitattributes +1 -0
- data/.github/dependabot.yml +6 -0
- data/Rakefile +6 -3
- data/bin/lazylead +7 -5
- data/lazylead.gemspec +4 -3
- data/lib/lazylead/cli/app.rb +5 -2
- data/lib/lazylead/exchange.rb +15 -9
- data/lib/lazylead/log.rb +2 -1
- data/lib/lazylead/model.rb +36 -2
- data/lib/lazylead/opts.rb +13 -1
- data/lib/lazylead/postman.rb +9 -4
- data/lib/lazylead/schedule.rb +16 -15
- data/lib/lazylead/smtp.rb +3 -1
- data/lib/lazylead/system/jira.rb +44 -0
- data/lib/lazylead/task/accuracy/accuracy.rb +13 -8
- data/lib/lazylead/task/accuracy/affected_build.rb +2 -6
- data/lib/lazylead/task/accuracy/attachment.rb +44 -0
- data/lib/lazylead/task/accuracy/environment.rb +39 -0
- data/lib/lazylead/task/accuracy/logs.rb +40 -0
- data/lib/lazylead/task/accuracy/records.rb +45 -0
- data/lib/lazylead/task/accuracy/requirement.rb +9 -0
- data/lib/lazylead/task/accuracy/servers.rb +50 -0
- data/lib/lazylead/task/accuracy/stacktrace.rb +63 -0
- data/lib/lazylead/task/accuracy/testcase.rb +85 -0
- data/lib/lazylead/task/accuracy/wiki.rb +41 -0
- data/lib/lazylead/task/echo.rb +18 -0
- data/lib/lazylead/task/fix_version.rb +9 -2
- data/lib/lazylead/task/touch.rb +28 -11
- data/lib/lazylead/version.rb +1 -1
- data/lib/messages/svn_log.erb +117 -0
- data/lib/messages/svn_touch.erb +1 -1
- data/license.txt +1 -1
- data/readme.md +5 -5
- data/test/lazylead/cli/app_test.rb +11 -11
- data/test/lazylead/opts_test.rb +4 -0
- data/test/lazylead/system/jira_test.rb +38 -0
- data/test/lazylead/task/accuracy/accuracy_test.rb +1 -1
- data/test/lazylead/task/accuracy/affected_build_test.rb +2 -2
- data/test/lazylead/task/accuracy/attachment_test.rb +50 -0
- data/test/lazylead/task/accuracy/environment_test.rb +42 -0
- data/test/lazylead/task/accuracy/logs_test.rb +78 -0
- data/test/lazylead/task/accuracy/records_test.rb +60 -0
- data/test/lazylead/task/accuracy/score_test.rb +46 -0
- data/test/lazylead/task/accuracy/servers_test.rb +66 -0
- data/test/lazylead/task/accuracy/stacktrace_test.rb +113 -0
- data/test/lazylead/task/accuracy/testcase_test.rb +215 -0
- data/test/lazylead/task/accuracy/wiki_test.rb +40 -0
- data/test/lazylead/task/touch_test.rb +48 -23
- data/test/test.rb +25 -0
- data/upgrades/sqlite/001-install-main-lazylead-tables.sql +1 -5
- data/upgrades/sqlite/999.testdata.sql +12 -17
- metadata +59 -18
- data/.travis.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa4ef974cb7b4799fb96acf04912513098f53c9adbb7f2bff4ea5bd8b498fb7e
|
4
|
+
data.tar.gz: e9d8aea4a9fe5da7a63e35062cd7c0ff6c7670e1645d031dc27b6cf599d71608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 897ee5e71b3eb970246cdeca00179b27d0d906e8e457dc384a2b79e25ed1a746f785ebb5981a7deb458aaef78428c6ae63025e42579daea160f3463eb611b455
|
7
|
+
data.tar.gz: 39850bcbb8e33239d8a5ab74a291f4ec4332067573ee3287775ad3c33c0210faf801358472ff9fc7b1dd531e6aedafc90e5393cf57ee04b32d5a6af120c02bc0
|
data/.docs/accuracy.md
CHANGED
@@ -66,7 +66,7 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
|
|
66
66
|
values (1,'{"type":"Lazylead::Jira", "username":"${jira_user}", "password":"${jira_password}", "site":"${jira_url}", "context_path":""}');
|
67
67
|
insert into tasks (name, cron, enabled, id, system, team_id, action, properties)
|
68
68
|
values ('Post ticket score and accuracy to the tickets',
|
69
|
-
'0 8 * * 1-5',
|
69
|
+
'cron:0 8 * * 1-5',
|
70
70
|
'true',
|
71
71
|
1, 1, 1,
|
72
72
|
'Lazylead::Task::Accuracy',
|
@@ -82,7 +82,7 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
|
|
82
82
|
}
|
83
83
|
');
|
84
84
|
```
|
85
|
-
Yes, for task scheduling we are using [cron](https://crontab.guru).
|
85
|
+
Yes, for task scheduling we are using [cron](https://crontab.guru) here, but you may use other scheduling types from [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler).
|
86
86
|
|
87
87
|
4. Once you changed `./ll.db`, please restart the container using `docker-compose -f .github/tasks.yml restart`
|
88
88
|
```bash
|
data/.docs/duedate_expired.md
CHANGED
@@ -68,16 +68,16 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
|
|
68
68
|
values (1, 'Dream team with lazylead', '{}');
|
69
69
|
insert into systems(id, properties)
|
70
70
|
values (1,'{"type":"Lazylead::Jira", "username":"${jira_user}", "password":"${jira_password}", "site":"${jira_url}", "context_path":""}');
|
71
|
-
insert into tasks (name,
|
71
|
+
insert into tasks (name, schedule, enabled, id, system, team_id, action, properties)
|
72
72
|
values ('Expired due dates',
|
73
|
-
'0 8 * * 1-5',
|
73
|
+
'cron:0 8 * * 1-5',
|
74
74
|
'true',
|
75
75
|
1, 1, 1,
|
76
76
|
'Lazylead::Task::AssigneeAlert',
|
77
77
|
'{"sql":"filter=222", "cc":"<youremail.com>", "subject":"[LL] Expired due dates", "template":"lib/messages/due_date_expired.erb", "postman":"Lazylead::Exchange"}');
|
78
78
|
|
79
79
|
```
|
80
|
-
Yes, for task scheduling we are using [cron](https://crontab.guru).
|
80
|
+
Yes, for task scheduling we are using [cron](https://crontab.guru) here, but you may use other scheduling types from [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler).
|
81
81
|
|
82
82
|
4. Once you changed `./ll.db`, please restart the container using `docker-compose -f .github/tasks.yml restart`
|
83
83
|
```bash
|
data/.docs/propagate_down.md
CHANGED
@@ -58,16 +58,16 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
|
|
58
58
|
values (1, 'Dream team with lazylead', '{}');
|
59
59
|
insert into systems(id, properties)
|
60
60
|
values (1,'{"type":"Lazylead::Jira", "username":"${jira_user}", "password":"${jira_password}", "site":"${jira_url}", "context_path":""}');
|
61
|
-
insert into tasks (name,
|
61
|
+
insert into tasks (name, schedule, enabled, id, system, team_id, action, properties)
|
62
62
|
values ('Propagate customfield_1 (External ID) to sub-tasks',
|
63
|
-
'0 8 * * 1-5',
|
63
|
+
'cron:0 8 * * 1-5',
|
64
64
|
'true',
|
65
65
|
1, 1, 1,
|
66
66
|
'Lazylead::Task::PropagateDown',
|
67
67
|
'{"jql":"filter=222", "propagate":"customfield_1"}');
|
68
68
|
|
69
69
|
```
|
70
|
-
Yes, for task scheduling we are using [cron](https://crontab.guru).
|
70
|
+
Yes, for task scheduling we are using [cron](https://crontab.guru) here, but you may use other scheduling types from [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler).
|
71
71
|
|
72
72
|
4. Once you changed `./ll.db`, please restart the container using `docker-compose -f .github/tasks.yml restart`
|
73
73
|
```bash
|
data/.gitattributes
CHANGED
data/Rakefile
CHANGED
@@ -26,7 +26,7 @@ require "rubygems"
|
|
26
26
|
require "rake"
|
27
27
|
require "date"
|
28
28
|
require "rdoc"
|
29
|
-
require "
|
29
|
+
require "colorize"
|
30
30
|
require "rake/clean"
|
31
31
|
|
32
32
|
# @todo #/DEV Investigate the possibility of using migrations from active_record
|
@@ -112,9 +112,10 @@ task :sqlint do
|
|
112
112
|
total += violations.count { |lint| lint.type == :error }
|
113
113
|
end
|
114
114
|
if total.positive?
|
115
|
-
abort "#{
|
115
|
+
abort "#{total.colorize(:red)} SQL violations found."
|
116
116
|
else
|
117
|
-
puts "#{src.size} files inspected, #{
|
117
|
+
puts "#{src.size} files inspected, #{'no offenses'.colorize(:green)} " \
|
118
|
+
"detected"
|
118
119
|
end
|
119
120
|
end
|
120
121
|
|
@@ -127,4 +128,6 @@ task :docker do
|
|
127
128
|
system "docker-compose -f .docker/docker-compose.yml build "\
|
128
129
|
" --build-arg release_tags='latest 1.0'"\
|
129
130
|
" --build-arg version=1.0"
|
131
|
+
system "docker-compose -f .docker/docker-compose.yml rm --force -s lazylead"
|
132
|
+
system "docker-compose -f .docker/docker-compose.yml up"
|
130
133
|
end
|
data/bin/lazylead
CHANGED
@@ -29,7 +29,7 @@ STDOUT.sync = true
|
|
29
29
|
|
30
30
|
require "slop"
|
31
31
|
require "sqlite3"
|
32
|
-
require "
|
32
|
+
require "colorize"
|
33
33
|
require "logging"
|
34
34
|
require "backtrace"
|
35
35
|
require "memory_profiler"
|
@@ -77,12 +77,13 @@ Available options:"
|
|
77
77
|
exit
|
78
78
|
end
|
79
79
|
end
|
80
|
-
log.debug
|
81
|
-
log.debug
|
80
|
+
log.debug "Version: #{Lazylead::VERSION.colorize(:green)}"
|
81
|
+
log.debug "Memory footprint at start is " \
|
82
|
+
"#{Lazylead::Allocated.new.to_s.colorize(:light_blue)}."
|
82
83
|
cmd = lambda do
|
83
84
|
Lazylead::CLI::App.new(
|
84
85
|
log,
|
85
|
-
Lazylead::Schedule.new(log),
|
86
|
+
Lazylead::Schedule.new(log: log),
|
86
87
|
Lazylead::Smtp.new(
|
87
88
|
log, Lazylead::Salt.new("smtp_salt"),
|
88
89
|
smtp_host: ENV["smtp_host"],
|
@@ -103,5 +104,6 @@ if opts["memory-dump"]
|
|
103
104
|
else
|
104
105
|
code = cmd.call
|
105
106
|
end
|
106
|
-
log.debug
|
107
|
+
log.debug "Memory footprint at the end is " \
|
108
|
+
"#{Lazylead::Allocated.new.to_s.colorize(:light_blue)}."
|
107
109
|
exit(code) unless code.zero?
|
data/lazylead.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.rubygems_version = "2.2"
|
33
33
|
s.required_ruby_version = ">=2.6.5"
|
34
34
|
s.name = "lazylead"
|
35
|
-
s.version = "0.
|
35
|
+
s.version = "0.5.2"
|
36
36
|
s.license = "MIT"
|
37
37
|
s.summary = "Eliminate the annoying work within bug-trackers."
|
38
38
|
s.description = "Ticketing systems (Github, Jira, etc.) are strongly
|
@@ -45,7 +45,7 @@ tasks instead of solving technical problems."
|
|
45
45
|
s.authors = ["Yurii Dubinka"]
|
46
46
|
s.email = "yurii.dubinka@gmail.com"
|
47
47
|
s.homepage = "http://github.com/dgroup/lazylead"
|
48
|
-
s.post_install_message = "Thanks for installing Lazylead v0.
|
48
|
+
s.post_install_message = "Thanks for installing Lazylead v0.5.2!
|
49
49
|
Read our blog posts: https://lazylead.org
|
50
50
|
Stay in touch with the community in Telegram: https://t.me/lazylead
|
51
51
|
Follow us on Twitter: https://twitter.com/lazylead
|
@@ -57,6 +57,7 @@ tasks instead of solving technical problems."
|
|
57
57
|
s.extra_rdoc_files = %w[readme.md license.txt]
|
58
58
|
s.add_runtime_dependency "activerecord", "6.0.3"
|
59
59
|
s.add_runtime_dependency "backtrace", "0.3"
|
60
|
+
s.add_runtime_dependency "colorize", "0.8.1"
|
60
61
|
s.add_runtime_dependency "faraday", "1.0.1"
|
61
62
|
s.add_runtime_dependency "get_process_mem", "0.2.5"
|
62
63
|
s.add_runtime_dependency "jira-ruby", "1.7.1"
|
@@ -65,7 +66,6 @@ tasks instead of solving technical problems."
|
|
65
66
|
s.add_runtime_dependency "mail", "2.7.1"
|
66
67
|
s.add_runtime_dependency "memory_profiler", "0.9.13"
|
67
68
|
s.add_runtime_dependency "openssl", "2.1.2"
|
68
|
-
s.add_runtime_dependency "rainbow", "3.0.0"
|
69
69
|
s.add_runtime_dependency "require_all", "3.0.0"
|
70
70
|
s.add_runtime_dependency "rufus-scheduler", "3.6.0"
|
71
71
|
s.add_runtime_dependency "slop", "4.4"
|
@@ -82,6 +82,7 @@ tasks instead of solving technical problems."
|
|
82
82
|
s.add_development_dependency "minitest-fail-fast", "0.1.0"
|
83
83
|
s.add_development_dependency "minitest-hooks", "1.5.0"
|
84
84
|
s.add_development_dependency "minitest-reporters", "1.3.6"
|
85
|
+
s.add_development_dependency "net-ping", "2.0.8"
|
85
86
|
s.add_development_dependency "rake", "12.3.3"
|
86
87
|
s.add_development_dependency "random-port", "0.3.1"
|
87
88
|
s.add_development_dependency "rdoc", "6.1.1"
|
data/lib/lazylead/cli/app.rb
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
23
|
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
|
25
|
+
require "colorize"
|
25
26
|
require "vcs4sql/sqlite/migration"
|
26
27
|
require_relative "../smtp"
|
27
28
|
require_relative "../schedule"
|
@@ -58,9 +59,11 @@ module Lazylead
|
|
58
59
|
def apply_vcs_migration(opts)
|
59
60
|
@db = File.expand_path(opts[:home]) + "/" + opts[:sqlite]
|
60
61
|
vcs = File.expand_path(opts[:home]) + "/" + opts[:vcs4sql]
|
61
|
-
@log.debug "Database: '#{@db}',
|
62
|
+
@log.debug "Database: '#{@db.colorize(:light_blue)}', "\
|
63
|
+
"sql migration dir: '#{vcs.colorize(:light_blue)}'"
|
62
64
|
Vcs4sql::Sqlite::Migration.new(@db).upgrade vcs, opts[:testdata]
|
63
|
-
@log.debug "Migration applied to #{@db} from
|
65
|
+
@log.debug "Migration applied to '#{@db.colorize(:light_blue)}' from " \
|
66
|
+
"'#{vcs.colorize(:light_blue)}'"
|
64
67
|
end
|
65
68
|
|
66
69
|
def enable_active_record(opts)
|
data/lib/lazylead/exchange.rb
CHANGED
@@ -54,19 +54,25 @@ module Lazylead
|
|
54
54
|
def send(opts)
|
55
55
|
to = opts["to"] || opts[:to]
|
56
56
|
to = [to] unless to.is_a? Array
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
to_recipients: to
|
63
|
-
}
|
57
|
+
if to.reject { |e| e.nil? || e.blank? }.empty?
|
58
|
+
@log.warn "Email can't be sent to '#{to}, more: '#{opts}'"
|
59
|
+
return
|
60
|
+
end
|
61
|
+
msg = make_msg(to, opts)
|
64
62
|
msg.update(cc_recipients: opts["cc"]) if opts.key? "cc"
|
65
63
|
add_attachments(msg, opts)
|
66
64
|
cli.send_message msg
|
67
65
|
close_attachments msg
|
68
|
-
@log.debug "
|
69
|
-
|
66
|
+
@log.debug "#{__FILE__} sent '#{opts['subject']}' to '#{to}'."
|
67
|
+
end
|
68
|
+
|
69
|
+
def make_msg(to, opts)
|
70
|
+
{
|
71
|
+
subject: opts["subject"],
|
72
|
+
body: make_body(opts),
|
73
|
+
body_type: "HTML",
|
74
|
+
to_recipients: to
|
75
|
+
}
|
70
76
|
end
|
71
77
|
|
72
78
|
def add_attachments(msg, opts)
|
data/lib/lazylead/log.rb
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
|
25
25
|
require "logging"
|
26
|
+
require "colorize"
|
26
27
|
require "forwardable"
|
27
28
|
|
28
29
|
module Lazylead
|
@@ -68,7 +69,7 @@ module Lazylead
|
|
68
69
|
Logging.appenders.stdout(
|
69
70
|
"stdout",
|
70
71
|
layout: Logging.layouts.pattern(
|
71
|
-
pattern: "[%d] %-5l [%X{tid}] %m\n",
|
72
|
+
pattern: "[%d] %-5l #{'[%X{tid}]'.colorize(:light_green)} %m\n",
|
72
73
|
color_scheme: "bright"
|
73
74
|
)
|
74
75
|
)
|
data/lib/lazylead/model.rb
CHANGED
@@ -94,11 +94,31 @@ module Lazylead
|
|
94
94
|
belongs_to :team, foreign_key: "team_id"
|
95
95
|
belongs_to :system, foreign_key: "system"
|
96
96
|
|
97
|
+
# Execute task
|
97
98
|
def exec
|
98
99
|
sys = system.connect
|
99
100
|
opts = props
|
100
101
|
opts = detect_cc(sys) if opts.key? "cc"
|
101
|
-
action.constantize.new
|
102
|
+
action.constantize.new.run(sys, postman, opts)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Scheduling type.
|
106
|
+
# Current implementation is based on 'rufus-scheduler' gem and supports
|
107
|
+
# the following types: 'cron', 'interval', 'in', 'at', 'every'
|
108
|
+
def type
|
109
|
+
trigger.first
|
110
|
+
end
|
111
|
+
|
112
|
+
# Scheduling unit.
|
113
|
+
# Current implementation is based on 'rufus-scheduler' gem thus each
|
114
|
+
# scheduling type has own arguments:
|
115
|
+
# 1. Scheduling type 'cron' has 'unit' = '00 09 * * *'
|
116
|
+
# 2. Scheduling type 'interval' has 'unit' = '2h'
|
117
|
+
# 3. Scheduling type 'every' has 'unit' = '3h'
|
118
|
+
# 4. Scheduling type 'in' has 'unit' = '10d'
|
119
|
+
# 5. Scheduling type 'at' has 'unit' = '2014/12/24 2000'
|
120
|
+
def unit
|
121
|
+
trigger.last
|
102
122
|
end
|
103
123
|
|
104
124
|
def detect_cc(sys)
|
@@ -125,13 +145,27 @@ module Lazylead
|
|
125
145
|
Postman.new
|
126
146
|
end
|
127
147
|
end
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
# Parse scheduling #type and #unit
|
152
|
+
def trigger
|
153
|
+
@trigger ||= begin
|
154
|
+
trg = schedule.split(":")
|
155
|
+
unless trg.size == 2
|
156
|
+
raise "ll-007: illegal schedule format '#{schedule}'"
|
157
|
+
end
|
158
|
+
trg.map(&:strip).map(&:chomp)
|
159
|
+
end
|
160
|
+
end
|
128
161
|
end
|
129
162
|
|
130
163
|
# A task with extended logging
|
131
164
|
# @see Lazylead::ORM::Task
|
132
165
|
class VerboseTask
|
133
166
|
extend Forwardable
|
134
|
-
def_delegators :@orig, :id, :name, :team, :to_s, :inspect, :props
|
167
|
+
def_delegators :@orig, :id, :name, :team, :to_s, :inspect, :props, :type,
|
168
|
+
:unit
|
135
169
|
|
136
170
|
def initialize(orig, log = Log.new)
|
137
171
|
@orig = orig
|
data/lib/lazylead/opts.rb
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
|
25
25
|
require "forwardable"
|
26
|
+
require_relative "salt"
|
26
27
|
|
27
28
|
module Lazylead
|
28
29
|
#
|
@@ -33,7 +34,7 @@ module Lazylead
|
|
33
34
|
# License:: MIT
|
34
35
|
class Opts
|
35
36
|
extend Forwardable
|
36
|
-
def_delegators :@origin, :[], :[]=, :to_s, :key?, :fetch, :merge
|
37
|
+
def_delegators :@origin, :[], :[]=, :to_s, :key?, :fetch, :merge, :except
|
37
38
|
|
38
39
|
def initialize(origin = {})
|
39
40
|
@origin = origin
|
@@ -64,5 +65,16 @@ module Lazylead
|
|
64
65
|
def jira_fields
|
65
66
|
to_h.fetch("fields", "").split(",").map(&:to_sym)
|
66
67
|
end
|
68
|
+
|
69
|
+
# Decrypt particular option using cryptography salt
|
70
|
+
# @param key option to be decrypted
|
71
|
+
# @param sid the name of the salt to be used for the description
|
72
|
+
# @see Lazylead::Salt
|
73
|
+
def decrypt(key, sid)
|
74
|
+
text = to_h[key]
|
75
|
+
return text if text.blank? || text.nil?
|
76
|
+
return Salt.new(sid).decrypt(text) if ENV.key? sid
|
77
|
+
text
|
78
|
+
end
|
67
79
|
end
|
68
80
|
end
|
data/lib/lazylead/postman.rb
CHANGED
@@ -53,20 +53,25 @@ module Lazylead
|
|
53
53
|
# Send an email.
|
54
54
|
# :opts :: the mail configuration like to, from, cc, subject, template.
|
55
55
|
def send(opts)
|
56
|
-
|
56
|
+
mail = make_email(opts)
|
57
|
+
mail.deliver
|
58
|
+
@log.debug "#{__FILE__} sent '#{mail.subject}' to '#{mail.to}'."
|
59
|
+
end
|
60
|
+
|
61
|
+
# Construct an email based on input arguments
|
62
|
+
def make_email(opts)
|
57
63
|
mail = Mail.new
|
58
64
|
mail.to opts[:to] || opts["to"]
|
59
65
|
mail.from opts["from"]
|
60
66
|
mail.cc opts["cc"] if opts.key? "cc"
|
61
67
|
mail.subject opts["subject"]
|
68
|
+
html = make_body(opts)
|
62
69
|
mail.html_part do
|
63
70
|
content_type "text/html; charset=UTF-8"
|
64
71
|
body html
|
65
72
|
end
|
66
73
|
add_attachments mail, opts
|
67
|
-
mail
|
68
|
-
@log.debug "Email was generated from #{opts} and send by #{__FILE__}. " \
|
69
|
-
"Here is the body: #{html}"
|
74
|
+
mail
|
70
75
|
end
|
71
76
|
|
72
77
|
def add_attachments(mail, opts)
|
data/lib/lazylead/schedule.rb
CHANGED
@@ -34,23 +34,18 @@ module Lazylead
|
|
34
34
|
# Copyright:: Copyright (c) 2019-2020 Yurii Dubinka
|
35
35
|
# License:: MIT
|
36
36
|
class Schedule
|
37
|
-
|
38
|
-
# The minimum time period for cron is 1 minute and it's not suitable for
|
39
|
-
# unit testing, thus its better to introduce new types which allows to
|
40
|
-
# schedule some task once or at particular time period like in next 200ms).
|
41
|
-
# For cron expressions we should define separate test suite which will test
|
42
|
-
# in parallel without blocking main CI process.
|
43
|
-
def initialize(log = Log.new, cling = true)
|
37
|
+
def initialize(log: Log.new, cling: true, trigger: Rufus::Scheduler.new)
|
44
38
|
@log = log
|
45
39
|
@cling = cling
|
46
|
-
@trigger =
|
40
|
+
@trigger = trigger
|
47
41
|
end
|
48
42
|
|
49
|
-
# @todo #/DEV error code is required for
|
50
|
-
# application.
|
43
|
+
# @todo #/DEV error code is required for each 'raise' statement within the
|
44
|
+
# application. Align the naming of existing one, the error code should be
|
45
|
+
# like ll-xxx.
|
51
46
|
def register(task)
|
52
47
|
raise "ll-002: task can't be a null" if task.nil?
|
53
|
-
@trigger.
|
48
|
+
@trigger.method(task.type).call(task.unit) do
|
54
49
|
ActiveRecord::Base.connection_pool.with_connection do
|
55
50
|
ORM::VerboseTask.new(task, @log).exec
|
56
51
|
end
|
@@ -60,7 +55,9 @@ module Lazylead
|
|
60
55
|
|
61
56
|
# @todo #/DEV inspect the current execution status. This method should
|
62
57
|
# support several format for output, by default is `json`.
|
63
|
-
def ps
|
58
|
+
def ps
|
59
|
+
@log.debug "#{self}#ps"
|
60
|
+
end
|
64
61
|
|
65
62
|
def join
|
66
63
|
@trigger.join if @cling
|
@@ -80,11 +77,15 @@ module Lazylead
|
|
80
77
|
end
|
81
78
|
|
82
79
|
def register(task)
|
83
|
-
@log.debug
|
80
|
+
@log.debug "Task registered: #{task}"
|
84
81
|
end
|
85
82
|
|
86
|
-
def ps
|
83
|
+
def ps
|
84
|
+
@log.debug "#{self}#ps"
|
85
|
+
end
|
87
86
|
|
88
|
-
def join
|
87
|
+
def join
|
88
|
+
@log.debug "#{self}#join"
|
89
|
+
end
|
89
90
|
end
|
90
91
|
end
|