lazylead 0.7.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +7 -2
- data/.docker/Dockerfile +17 -6
- data/.docs/duedate_expired.md +1 -1
- data/.rubocop.yml +71 -2
- data/Gemfile +1 -1
- data/Rakefile +7 -4
- data/bin/lazylead +1 -1
- data/lazylead.gemspec +26 -25
- data/lib/lazylead.rb +2 -2
- data/lib/lazylead/allocated.rb +1 -1
- data/lib/lazylead/cc.rb +17 -23
- data/lib/lazylead/cli/app.rb +1 -1
- data/lib/lazylead/confluence.rb +2 -2
- data/lib/lazylead/email.rb +1 -1
- data/lib/lazylead/exchange.rb +1 -1
- data/lib/lazylead/home.rb +1 -1
- data/lib/lazylead/log.rb +1 -1
- data/lib/lazylead/model.rb +6 -8
- data/lib/lazylead/opts.rb +6 -3
- data/lib/lazylead/postman.rb +1 -1
- data/{Guardfile → lib/lazylead/requires.rb} +13 -8
- data/lib/lazylead/salt.rb +1 -1
- data/lib/lazylead/schedule.rb +1 -1
- data/lib/lazylead/smtp.rb +1 -1
- data/lib/lazylead/system/empty.rb +1 -1
- data/lib/lazylead/system/fake.rb +1 -1
- data/lib/lazylead/system/jira.rb +20 -18
- data/lib/lazylead/system/synced.rb +1 -1
- data/lib/lazylead/task/accuracy/accuracy.rb +24 -30
- data/lib/lazylead/task/accuracy/affected_build.rb +1 -1
- data/lib/lazylead/task/accuracy/attachment.rb +3 -3
- data/lib/lazylead/task/accuracy/environment.rb +1 -1
- data/lib/lazylead/task/accuracy/logs.rb +6 -3
- data/lib/lazylead/task/accuracy/onlyll.rb +7 -10
- data/lib/lazylead/task/accuracy/records.rb +2 -2
- data/lib/lazylead/task/accuracy/requirement.rb +1 -1
- data/lib/lazylead/task/accuracy/screenshots.rb +51 -0
- data/lib/lazylead/task/accuracy/servers.rb +3 -3
- data/lib/lazylead/task/accuracy/stacktrace.rb +1 -1
- data/lib/lazylead/task/accuracy/testcase.rb +3 -3
- data/lib/lazylead/task/accuracy/wiki.rb +1 -1
- data/lib/lazylead/task/{alert.rb → alert/alert.rb} +6 -6
- data/lib/lazylead/task/alert/alertif.rb +75 -0
- data/lib/lazylead/task/alert/changed_to.rb +58 -0
- data/lib/lazylead/task/assignment.rb +1 -1
- data/lib/lazylead/task/confluence_ref.rb +1 -1
- data/lib/lazylead/task/echo.rb +1 -1
- data/lib/lazylead/task/fix_version.rb +1 -1
- data/lib/lazylead/task/loading.rb +94 -0
- data/lib/lazylead/task/missing_comment.rb +1 -1
- data/lib/lazylead/task/propagate_down.rb +3 -3
- data/lib/lazylead/task/savepoint.rb +1 -1
- data/lib/lazylead/task/svn/diff.rb +29 -7
- data/lib/lazylead/task/svn/grep.rb +2 -2
- data/lib/lazylead/task/svn/touch.rb +2 -2
- data/lib/lazylead/version.rb +2 -2
- data/lib/messages/accuracy.erb +1 -1
- data/lib/messages/alertif.erb +134 -0
- data/lib/messages/created_recently.erb +110 -0
- data/lib/messages/loading.erb +117 -0
- data/readme.md +26 -18
- data/test/lazylead/allocated_test.rb +1 -1
- data/test/lazylead/cc_test.rb +1 -1
- data/test/lazylead/cli/app_test.rb +2 -2
- data/test/lazylead/confluence_test.rb +1 -1
- data/test/lazylead/exchange_test.rb +1 -1
- data/test/lazylead/model_test.rb +1 -1
- data/test/lazylead/opts_test.rb +1 -1
- data/test/lazylead/postman_test.rb +1 -1
- data/test/lazylead/salt_test.rb +1 -1
- data/test/lazylead/smoke_test.rb +1 -1
- data/test/lazylead/smtp_test.rb +2 -5
- data/test/lazylead/system/jira_test.rb +10 -1
- data/test/lazylead/task/accuracy/accuracy_test.rb +1 -1
- data/test/lazylead/task/accuracy/affected_build_test.rb +1 -1
- data/test/lazylead/task/accuracy/attachment_test.rb +2 -2
- data/test/lazylead/task/accuracy/environment_test.rb +1 -1
- data/test/lazylead/task/accuracy/logs_test.rb +13 -1
- data/test/lazylead/task/accuracy/onlyll_test.rb +1 -1
- data/test/lazylead/task/accuracy/records_test.rb +1 -1
- data/test/lazylead/task/accuracy/score_test.rb +29 -2
- data/test/lazylead/task/accuracy/screenshots_test.rb +84 -0
- data/test/lazylead/task/accuracy/servers_test.rb +1 -1
- data/test/lazylead/task/accuracy/stacktrace_test.rb +1 -1
- data/test/lazylead/task/accuracy/testcase_test.rb +28 -1
- data/test/lazylead/task/accuracy/wiki_test.rb +1 -1
- data/test/lazylead/task/alert/alertif_test.rb +54 -0
- data/test/lazylead/task/{assignee_alert_test.rb → alert/assignee_alert_test.rb} +10 -10
- data/test/lazylead/task/alert/changed_to_test.rb +42 -0
- data/test/lazylead/task/assignment_test.rb +1 -1
- data/test/lazylead/task/confluence_ref_test.rb +1 -1
- data/test/lazylead/task/created_recently_test.rb +53 -0
- data/test/lazylead/task/duedate_test.rb +5 -12
- data/test/lazylead/task/echo_test.rb +1 -1
- data/test/lazylead/task/fix_version_test.rb +1 -1
- data/test/lazylead/task/loading_test.rb +54 -0
- data/test/lazylead/task/missing_comment_test.rb +1 -1
- data/test/lazylead/task/propagate_down_test.rb +1 -1
- data/test/lazylead/task/savepoint_test.rb +3 -3
- data/test/lazylead/task/svn/diff_test.rb +8 -4
- data/test/lazylead/task/svn/grep_test.rb +1 -1
- data/test/lazylead/task/svn/touch_test.rb +1 -1
- data/test/lazylead/version_test.rb +1 -1
- data/test/sqlite_test.rb +1 -1
- data/test/test.rb +15 -5
- data/upgrades/sqlite/001-install-main-lazylead-tables.sql +1 -1
- data/upgrades/sqlite/999.testdata.sql +1 -1
- metadata +82 -51
data/lib/lazylead/exchange.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/home.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/log.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/model.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -135,13 +135,11 @@ module Lazylead
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def props
|
138
|
-
@props ||=
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
end
|
144
|
-
end
|
138
|
+
@props ||= if team.nil?
|
139
|
+
Opts.new(env(to_hash))
|
140
|
+
else
|
141
|
+
Opts.new(env(team.to_hash.merge(to_hash)))
|
142
|
+
end
|
145
143
|
end
|
146
144
|
|
147
145
|
def postman
|
data/lib/lazylead/opts.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -34,8 +34,7 @@ module Lazylead
|
|
34
34
|
# License:: MIT
|
35
35
|
class Opts
|
36
36
|
extend Forwardable
|
37
|
-
def_delegators :@origin, :[], :[]=, :to_s, :key?, :fetch, :except, :each,
|
38
|
-
:each_pair, :sort_by
|
37
|
+
def_delegators :@origin, :[], :[]=, :to_s, :key?, :fetch, :except, :each, :each_pair, :sort_by
|
39
38
|
|
40
39
|
def initialize(origin = {})
|
41
40
|
@origin = origin
|
@@ -139,5 +138,9 @@ module Lazylead
|
|
139
138
|
def numeric?(key)
|
140
139
|
to_h[key].to_i.positive?
|
141
140
|
end
|
141
|
+
|
142
|
+
def construct(field, delim: ",")
|
143
|
+
slice(field, delim).map(&:constantize).map(&:new)
|
144
|
+
end
|
142
145
|
end
|
143
146
|
end
|
data/lib/lazylead/postman.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -22,12 +22,17 @@
|
|
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
|
-
|
26
|
-
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
module Lazylead
|
26
|
+
#
|
27
|
+
# Allows to load all ruby files within particular dir.
|
28
|
+
#
|
29
|
+
class Requires
|
30
|
+
def initialize(dir)
|
31
|
+
@dir = dir
|
32
|
+
end
|
33
|
+
|
34
|
+
def load
|
35
|
+
Dir[File.join(@dir, "*.rb")].sort.each { |f| require f }
|
36
|
+
end
|
32
37
|
end
|
33
38
|
end
|
data/lib/lazylead/salt.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/schedule.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/smtp.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/system/fake.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/system/jira.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -26,10 +26,15 @@ require "jira-ruby"
|
|
26
26
|
require "forwardable"
|
27
27
|
require_relative "../salt"
|
28
28
|
require_relative "../opts"
|
29
|
+
require_relative "../log"
|
29
30
|
|
30
31
|
module Lazylead
|
31
32
|
# Jira system for manipulation with issues.
|
32
33
|
#
|
34
|
+
# Jira official documentation:
|
35
|
+
# - https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/issue-getIssue
|
36
|
+
# - https://developer.atlassian.com/server/jira/platform/rest-apis/
|
37
|
+
#
|
33
38
|
# Author:: Yurii Dubinka (yurii.dubinka@gmail.com)
|
34
39
|
# Copyright:: Copyright (c) 2019-2020 Yurii Dubinka
|
35
40
|
# License:: MIT
|
@@ -82,22 +87,7 @@ module Lazylead
|
|
82
87
|
@opts[:auth_type] = :basic if @opts[:auth_type].nil?
|
83
88
|
@opts["username"] = @salt.decrypt(@opts["username"]) if @salt.specified?
|
84
89
|
@opts["password"] = @salt.decrypt(@opts["password"]) if @salt.specified?
|
85
|
-
|
86
|
-
cp("username", :username)
|
87
|
-
cp("password", :password)
|
88
|
-
cp("context_path", :context_path)
|
89
|
-
@client = JIRA::Client.new(@opts)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Copy the required/mandatory parameter(s) for Jira client which can't
|
93
|
-
# be specified/defined at database level.
|
94
|
-
#
|
95
|
-
# @todo #/DEV Jira.cp - find a way how to avoid this method.
|
96
|
-
# Potentially, hash with indifferent access might be used.
|
97
|
-
# http://jocellyn.cz/2014/05/03/hash-with-indifferent-access.html
|
98
|
-
# key.kind_of?(Symbol) ? key.to_s : key
|
99
|
-
def cp(act, exp)
|
100
|
-
@opts[exp] = @opts[act] if @opts.key? act
|
90
|
+
@client = JIRA::Client.new(@opts.symbolize_keys)
|
101
91
|
end
|
102
92
|
end
|
103
93
|
|
@@ -313,7 +303,19 @@ module Lazylead
|
|
313
303
|
|
314
304
|
# Check that comment has expected text
|
315
305
|
def include?(text)
|
316
|
-
|
306
|
+
to_s.include? text
|
307
|
+
end
|
308
|
+
|
309
|
+
def to_s
|
310
|
+
@comment.attrs["body"]
|
311
|
+
end
|
312
|
+
|
313
|
+
def lines
|
314
|
+
to_s.split("\n").reject(&:blank?)
|
315
|
+
end
|
316
|
+
|
317
|
+
def author
|
318
|
+
@comment.attrs["author"]["displayName"]
|
317
319
|
end
|
318
320
|
end
|
319
321
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -27,6 +27,7 @@ require_relative "../../opts"
|
|
27
27
|
require_relative "../../email"
|
28
28
|
require_relative "../../version"
|
29
29
|
require_relative "../../postman"
|
30
|
+
require_relative "../../requires"
|
30
31
|
|
31
32
|
module Lazylead
|
32
33
|
module Task
|
@@ -43,45 +44,40 @@ module Lazylead
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def run(sys, postman, opts)
|
46
|
-
|
47
|
-
rules = opts.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
postman.send opts.merge(tickets: raised) unless raised.empty?
|
47
|
+
Requires.new(__dir__).load
|
48
|
+
opts[:rules] = opts.construct("rules")
|
49
|
+
opts[:total] = opts[:rules].sum(&:score)
|
50
|
+
opts[:tickets] = sys.issues(opts["jql"], opts.jira_defaults)
|
51
|
+
.map { |i| Score.new(i, opts) }
|
52
|
+
.each(&:evaluate)
|
53
|
+
.each(&:post)
|
54
|
+
postman.send(opts) unless opts[:tickets].empty?
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
# The ticket score based on fields content.
|
60
60
|
class Score
|
61
|
-
attr_reader :issue, :
|
61
|
+
attr_reader :issue, :score, :accuracy
|
62
62
|
|
63
|
-
def initialize(issue, opts
|
63
|
+
def initialize(issue, opts)
|
64
64
|
@issue = issue
|
65
|
-
@link = opts["docs"]
|
66
65
|
@opts = opts
|
67
|
-
@rules = rules
|
68
66
|
end
|
69
67
|
|
70
68
|
# Estimate the ticket score and accuracy.
|
71
69
|
# Accuracy is a percentage between current score and maximum possible value.
|
72
70
|
def evaluate(digits = 2)
|
73
|
-
@
|
74
|
-
@
|
75
|
-
|
76
|
-
.sum
|
77
|
-
@accuracy = (score / @total * 100).round(digits)
|
71
|
+
@score = @opts[:rules].select { |r| r.passed(@issue) }.sum(&:score)
|
72
|
+
@accuracy = (score / @opts[:total] * 100).round(digits)
|
73
|
+
self
|
78
74
|
end
|
79
75
|
|
80
76
|
# Post the comment with score and accuracy to the ticket.
|
81
77
|
def post
|
82
78
|
return if @opts.key? "silent"
|
83
79
|
@issue.post comment
|
84
|
-
@issue.add_label "LL.accuracy", "#{grade(@accuracy)}%"
|
80
|
+
@issue.add_label "LL.accuracy", "#{grade(@accuracy)}%", "#{@accuracy}%"
|
85
81
|
end
|
86
82
|
|
87
83
|
# The jira comment in markdown format
|
@@ -93,7 +89,7 @@ module Lazylead
|
|
93
89
|
" (~{color:#{color}}#{@accuracy}%{color}), here are the reasons why:",
|
94
90
|
"|| Ticket requirement || Status || Field ||"
|
95
91
|
]
|
96
|
-
@rules.each do |r|
|
92
|
+
@opts[:rules].each do |r|
|
97
93
|
comment << "|#{r.desc}|#{r.passed(@issue) ? '(/)' : '(-)'}|#{r.field}|"
|
98
94
|
end
|
99
95
|
comment << docs_link
|
@@ -105,11 +101,11 @@ module Lazylead
|
|
105
101
|
|
106
102
|
# Link to ticket formatting rules
|
107
103
|
def docs_link
|
108
|
-
if @
|
104
|
+
if @opts["docs"].nil? || @opts["docs"].blank?
|
109
105
|
""
|
110
106
|
else
|
111
107
|
"The requirements/examples of ticket formatting rules you may find " \
|
112
|
-
"[here|#{@
|
108
|
+
"[here|#{@opts['docs']}]."
|
113
109
|
end
|
114
110
|
end
|
115
111
|
|
@@ -122,13 +118,11 @@ module Lazylead
|
|
122
118
|
end
|
123
119
|
|
124
120
|
def colors
|
125
|
-
@colors ||=
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
.sort_by { |e| e[0] }
|
131
|
-
end
|
121
|
+
@colors ||= JSON.parse(@opts["colors"])
|
122
|
+
.to_h
|
123
|
+
.to_a
|
124
|
+
.each { |e| e[0] = e[0].to_i }
|
125
|
+
.sort_by { |e| e[0] }
|
132
126
|
end
|
133
127
|
|
134
128
|
# Calculate grade for accuracy
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -28,12 +28,12 @@ module Lazylead
|
|
28
28
|
# Check that ticket has an attachment.
|
29
29
|
class Attachment < Lazylead::Requirement
|
30
30
|
def passed(issue)
|
31
|
-
issue.attachments.any?(
|
31
|
+
issue.attachments.any? { |a| matches?(a) }
|
32
32
|
end
|
33
33
|
|
34
34
|
# Check a single attachment from ticket.
|
35
35
|
# Potential extension point for custom verification logic.
|
36
|
-
def
|
36
|
+
def matches?(attachment)
|
37
37
|
!attachment.nil?
|
38
38
|
end
|
39
39
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -34,11 +34,14 @@ module Lazylead
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# Ensure that ticket has a '*.log' file more '5KB'
|
37
|
-
def
|
37
|
+
def matches?(attachment)
|
38
38
|
name = attachment.attrs["filename"].downcase
|
39
39
|
return false unless attachment.attrs["size"].to_i > 5120
|
40
40
|
return true if File.extname(name).start_with? ".log", ".txt", ".out"
|
41
|
-
@files.any? { |l| name.end_with? l }
|
41
|
+
return true if @files.any? { |l| name.end_with? l }
|
42
|
+
%w[.zip .7z .gz tar.gz].any? do |l|
|
43
|
+
name.end_with?(l) && name.split(/(?:[^a-zA-Z0-9](?<![^\x00-\x7F]))+/).include?("logs")
|
44
|
+
end
|
42
45
|
end
|
43
46
|
end
|
44
47
|
end
|