lazylead 0.6.2 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +7 -2
  3. data/.docker/Dockerfile +17 -6
  4. data/.docs/duedate_expired.md +1 -1
  5. data/.rubocop.yml +119 -3
  6. data/.simplecov +1 -1
  7. data/Gemfile +1 -1
  8. data/Guardfile +2 -2
  9. data/Rakefile +7 -4
  10. data/bin/lazylead +4 -2
  11. data/lazylead.gemspec +33 -29
  12. data/lib/lazylead.rb +2 -2
  13. data/lib/lazylead/allocated.rb +1 -1
  14. data/lib/lazylead/cc.rb +22 -21
  15. data/lib/lazylead/cli/app.rb +3 -3
  16. data/lib/lazylead/confluence.rb +10 -3
  17. data/lib/lazylead/email.rb +1 -1
  18. data/lib/lazylead/exchange.rb +1 -1
  19. data/lib/lazylead/home.rb +1 -1
  20. data/lib/lazylead/log.rb +1 -1
  21. data/lib/lazylead/model.rb +25 -17
  22. data/lib/lazylead/opts.rb +22 -4
  23. data/lib/lazylead/postman.rb +1 -1
  24. data/lib/lazylead/requires.rb +38 -0
  25. data/lib/lazylead/salt.rb +2 -1
  26. data/lib/lazylead/schedule.rb +1 -1
  27. data/lib/lazylead/smtp.rb +1 -1
  28. data/lib/lazylead/system/empty.rb +1 -1
  29. data/lib/lazylead/system/fake.rb +1 -1
  30. data/lib/lazylead/system/jira.rb +28 -20
  31. data/lib/lazylead/system/synced.rb +1 -1
  32. data/lib/lazylead/task/accuracy/accuracy.rb +26 -32
  33. data/lib/lazylead/task/accuracy/affected_build.rb +1 -1
  34. data/lib/lazylead/task/accuracy/attachment.rb +3 -7
  35. data/lib/lazylead/task/accuracy/environment.rb +1 -1
  36. data/lib/lazylead/task/accuracy/logs.rb +9 -6
  37. data/lib/lazylead/task/accuracy/onlyll.rb +147 -0
  38. data/lib/lazylead/task/accuracy/records.rb +2 -2
  39. data/lib/lazylead/task/accuracy/requirement.rb +1 -1
  40. data/lib/lazylead/task/accuracy/servers.rb +17 -8
  41. data/lib/lazylead/task/accuracy/stacktrace.rb +2 -2
  42. data/lib/lazylead/task/accuracy/testcase.rb +3 -3
  43. data/lib/lazylead/task/accuracy/wiki.rb +1 -1
  44. data/lib/lazylead/task/{alert.rb → alert/alert.rb} +6 -6
  45. data/lib/lazylead/task/alert/alertif.rb +75 -0
  46. data/lib/lazylead/task/alert/changed_to.rb +58 -0
  47. data/lib/lazylead/task/assignment.rb +1 -1
  48. data/lib/lazylead/task/confluence_ref.rb +1 -1
  49. data/lib/lazylead/task/echo.rb +1 -1
  50. data/lib/lazylead/task/fix_version.rb +1 -1
  51. data/lib/lazylead/task/loading.rb +94 -0
  52. data/lib/lazylead/task/missing_comment.rb +1 -1
  53. data/lib/lazylead/task/propagate_down.rb +4 -4
  54. data/lib/lazylead/task/savepoint.rb +1 -1
  55. data/lib/lazylead/task/svn/diff.rb +2 -2
  56. data/lib/lazylead/task/svn/grep.rb +27 -20
  57. data/lib/lazylead/task/svn/touch.rb +3 -5
  58. data/lib/lazylead/version.rb +2 -2
  59. data/lib/messages/accuracy.erb +1 -1
  60. data/lib/messages/alertif.erb +134 -0
  61. data/lib/messages/created_recently.erb +110 -0
  62. data/lib/messages/loading.erb +117 -0
  63. data/lib/messages/only_ll.erb +107 -0
  64. data/readme.md +26 -18
  65. data/test/lazylead/allocated_test.rb +1 -1
  66. data/test/lazylead/cc_test.rb +2 -1
  67. data/test/lazylead/cli/app_test.rb +2 -2
  68. data/test/lazylead/confluence_test.rb +1 -1
  69. data/test/lazylead/exchange_test.rb +1 -1
  70. data/test/lazylead/model_test.rb +11 -1
  71. data/test/lazylead/opts_test.rb +13 -1
  72. data/test/lazylead/postman_test.rb +1 -1
  73. data/test/lazylead/salt_test.rb +1 -1
  74. data/test/lazylead/smoke_test.rb +14 -1
  75. data/test/lazylead/smtp_test.rb +2 -5
  76. data/test/lazylead/system/jira_test.rb +10 -1
  77. data/test/lazylead/task/accuracy/accuracy_test.rb +1 -1
  78. data/test/lazylead/task/accuracy/affected_build_test.rb +1 -1
  79. data/test/lazylead/task/accuracy/attachment_test.rb +2 -2
  80. data/test/lazylead/task/accuracy/environment_test.rb +1 -1
  81. data/test/lazylead/task/accuracy/logs_test.rb +13 -1
  82. data/test/lazylead/task/accuracy/onlyll_test.rb +138 -0
  83. data/test/lazylead/task/accuracy/records_test.rb +1 -1
  84. data/test/lazylead/task/accuracy/score_test.rb +29 -2
  85. data/test/lazylead/task/accuracy/servers_test.rb +3 -3
  86. data/test/lazylead/task/accuracy/stacktrace_test.rb +1 -1
  87. data/test/lazylead/task/accuracy/testcase_test.rb +28 -1
  88. data/test/lazylead/task/accuracy/wiki_test.rb +1 -1
  89. data/test/lazylead/task/alert/alertif_test.rb +54 -0
  90. data/test/lazylead/task/{assignee_alert_test.rb → alert/assignee_alert_test.rb} +10 -10
  91. data/test/lazylead/task/alert/changed_to_test.rb +42 -0
  92. data/test/lazylead/task/assignment_test.rb +1 -1
  93. data/test/lazylead/task/confluence_ref_test.rb +1 -1
  94. data/test/lazylead/task/created_recently_test.rb +53 -0
  95. data/test/lazylead/task/duedate_test.rb +5 -12
  96. data/test/lazylead/task/echo_test.rb +1 -1
  97. data/test/lazylead/task/fix_version_test.rb +1 -1
  98. data/test/lazylead/task/loading_test.rb +54 -0
  99. data/test/lazylead/task/missing_comment_test.rb +1 -1
  100. data/test/lazylead/task/propagate_down_test.rb +5 -4
  101. data/test/lazylead/task/savepoint_test.rb +3 -3
  102. data/test/lazylead/task/svn/diff_test.rb +1 -1
  103. data/test/lazylead/task/svn/grep_test.rb +1 -1
  104. data/test/lazylead/task/svn/touch_test.rb +1 -1
  105. data/test/lazylead/version_test.rb +1 -1
  106. data/test/sqlite_test.rb +1 -1
  107. data/test/test.rb +8 -9
  108. data/upgrades/sqlite/001-install-main-lazylead-tables.sql +1 -1
  109. data/upgrades/sqlite/999.testdata.sql +3 -2
  110. metadata +133 -58
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2020 Yurii Dubinka
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-2020 Yurii Dubinka
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
- Dir[File.join(__dir__, "*.rb")].sort.each { |f| require f }
47
- rules = opts.slice("rules", ",")
48
- .map(&:constantize)
49
- .map(&:new)
50
- raised = sys.issues(opts["jql"], opts.jira_defaults)
51
- .map { |i| Score.new(i, opts, rules) }
52
- .each(&:evaluate)
53
- .each(&:post)
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, :total, :score, :accuracy
61
+ attr_reader :issue, :score, :accuracy
62
62
 
63
- def initialize(issue, opts, rules)
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
- @total = @rules.map(&:score).sum
74
- @score = @rules.select { |r| r.passed(@issue) }
75
- .map(&:score)
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,18 +101,16 @@ module Lazylead
105
101
 
106
102
  # Link to ticket formatting rules
107
103
  def docs_link
108
- if @link.nil? || @link.blank?
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|#{@link}]."
108
+ "[here|#{@opts['docs']}]."
113
109
  end
114
110
  end
115
111
 
116
112
  def color
117
- if colors.nil? || !defined?(@score) || !@score.is_a?(Numeric)
118
- return "#061306"
119
- end
113
+ return "#061306" if colors.nil? || !defined?(@score) || !@score.is_a?(Numeric)
120
114
  colors.reverse_each do |color|
121
115
  return color.last if @accuracy >= color.first
122
116
  end
@@ -125,12 +119,12 @@ module Lazylead
125
119
 
126
120
  def colors
127
121
  @colors ||= begin
128
- JSON.parse(@opts["colors"])
129
- .to_h
130
- .to_a
131
- .each { |e| e[0] = e[0].to_i }
132
- .sort_by { |e| e[0] }
133
- end
122
+ JSON.parse(@opts["colors"])
123
+ .to_h
124
+ .to_a
125
+ .each { |e| e[0] = e[0].to_i }
126
+ .sort_by { |e| e[0] }
127
+ end
134
128
  end
135
129
 
136
130
  # Calculate grade for accuracy
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2020 Yurii Dubinka
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-2020 Yurii Dubinka
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,17 +27,13 @@ require_relative "requirement"
27
27
  module Lazylead
28
28
  # Check that ticket has an attachment.
29
29
  class Attachment < Lazylead::Requirement
30
- def initialize(desc, score, field)
31
- super(desc, score, field)
32
- end
33
-
34
30
  def passed(issue)
35
- issue.attachments.any?(&method(:matching))
31
+ issue.attachments.any? { |a| matches?(a) }
36
32
  end
37
33
 
38
34
  # Check a single attachment from ticket.
39
35
  # Potential extension point for custom verification logic.
40
- def matching(attachment)
36
+ def matches?(attachment)
41
37
  !attachment.nil?
42
38
  end
43
39
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2020 Yurii Dubinka
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-2020 Yurii Dubinka
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,17 +27,20 @@ require_relative "attachment"
27
27
  module Lazylead
28
28
  # Check that ticket has log file(s) in attachment.
29
29
  class Logs < Lazylead::Attachment
30
- def initialize
30
+ def initialize(files = %w[log.zip logs.zip log.gz logs.gz log.tar.gz
31
+ logs.tar.gz log.7z logs.7z log.tar logs.tar])
31
32
  super("Log files", 2, "Attachments")
33
+ @files = files
32
34
  end
33
35
 
34
36
  # Ensure that ticket has a '*.log' file more '5KB'
35
- def matching(attachment)
37
+ def matches?(attachment)
36
38
  name = attachment.attrs["filename"].downcase
37
39
  return false unless attachment.attrs["size"].to_i > 5120
38
- return true if File.extname(name).start_with?(".log", ".txt")
39
- %w[.log.zip .log.gz .log.tar.gz logs.7z log.7z].any? do |l|
40
- name.end_with? l
40
+ return true if File.extname(name).start_with? ".log", ".txt", ".out"
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")
41
44
  end
42
45
  end
43
46
  end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2019-2021 Yurii Dubinka
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"),
9
+ # to deal in the Software without restriction, including without limitation
10
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
+ # and/or sell copies of the Software, and to permit persons to whom
12
+ # the Software is furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included
15
+ # in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
23
+ # OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+ require_relative "../../log"
26
+ require_relative "../../opts"
27
+
28
+ module Lazylead
29
+ module Task
30
+ #
31
+ # Ensure that ticket accuracy evaluation labels are set only by LL, not by
32
+ # some person.
33
+ #
34
+ # The task supports the following features:
35
+ # - fetch issues from remote ticketing system by query
36
+ # - check the history of labels modification
37
+ # - remove evaluation labels if they set not by LL
38
+ class OnlyLL
39
+ def initialize(log = Log.new)
40
+ @log = log
41
+ end
42
+
43
+ def run(sys, postman, opts)
44
+ found = sys.issues(opts["jql"],
45
+ opts.jira_defaults.merge(expand: "changelog"))
46
+ .map { |i| Labels.new(i, opts) }
47
+ .select(&:exists?)
48
+ .reject(&:valid?)
49
+ .each(&:remove)
50
+ postman.send opts.merge(tickets: found) unless found.empty?
51
+ end
52
+ end
53
+ end
54
+
55
+ # The ticket with grid labels
56
+ class Labels
57
+ attr_reader :issue
58
+
59
+ def initialize(issue, opts)
60
+ @issue = issue
61
+ @opts = opts
62
+ end
63
+
64
+ # Ensure that issue has evaluation labels for accuracy rules
65
+ def exists?
66
+ return false if @issue.labels.nil? || @issue.labels.empty?
67
+ return false unless @issue.labels.is_a? Array
68
+ grid.any? { |g| @issue.labels.any? { |l| g.eql? l } }
69
+ end
70
+
71
+ # Compare the score evaluated by LL and current ticket score.
72
+ # @return true if current score equal to LL evaluation
73
+ def valid?
74
+ score.eql?(@issue.labels.sort.find { |l| grid.any? { |g| l.eql? g } })
75
+ end
76
+
77
+ # Find expected ticket score evaluated by LL.
78
+ # If LL evaluated the same ticket several times (no matter why),
79
+ # then the last score would be returned.
80
+ def score
81
+ to_l(
82
+ @issue.history
83
+ .select { |h| h["author"]["key"].eql? @opts["author"] }
84
+ .reverse
85
+ .find { |h| to_l(h) }
86
+ ).fetch("toString", "").split.find { |l| grid.any? { |g| l.eql? g } }
87
+ end
88
+
89
+ # Find history record with labels changes.
90
+ def to_l(history)
91
+ return {} if history.nil? || history.empty?
92
+ history["items"].find { |f| f["field"].eql? "labels" }
93
+ end
94
+
95
+ # Detect the percentage grid for tickets, by default its 0%, 10%, 20%, etc.
96
+ def grid
97
+ @grid ||= begin
98
+ if @opts.key? "grid"
99
+ @opts.slice("grid", ",")
100
+ else
101
+ %w[0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%]
102
+ end
103
+ end
104
+ end
105
+
106
+ # Remove score labels from the ticket.
107
+ def remove
108
+ @issue.labels!(@issue.labels - grid)
109
+ end
110
+
111
+ # Detect the violators with their changes.
112
+ # .violators => ["Tom Hhhh set 40%", "Bob Mmmm set 50%"]
113
+ def violators
114
+ @issue.history
115
+ .reject { |h| h["author"]["key"].eql? @opts["author"] }
116
+ .select { |h| grid?(h) }
117
+ .group_by { |h| h["author"]["key"] }
118
+ .map do |a|
119
+ "#{a.last.first['author']['displayName']} set #{hacked(a.last)}"
120
+ end
121
+ end
122
+
123
+ # Ensure that history record has label change related to LL grid labels.
124
+ # @return true if LL grid labels added
125
+ def grid?(record)
126
+ diff(record).any? { |d| d.find { |l| grid.any? { |g| l.eql? g } } }
127
+ end
128
+
129
+ # Detect label diff in single history record from ticket's history.
130
+ def diff(record)
131
+ record["items"].select { |f| f["field"].eql? "labels" }
132
+ .reject { |f| f["toString"].nil? || f["toString"].blank? }
133
+ .map do |f|
134
+ from = []
135
+ from = f["fromString"].split unless f["fromString"].nil?
136
+ f["toString"].split - from
137
+ end
138
+ end
139
+
140
+ # Hacked score by violator in ticket's history.
141
+ def hacked(record)
142
+ diff(record.first)
143
+ .first
144
+ .find { |l| grid.any? { |g| l.eql? g } }
145
+ end
146
+ end
147
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2020 Yurii Dubinka
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"),
@@ -38,7 +38,7 @@ module Lazylead
38
38
  end
39
39
 
40
40
  # Ensure that ticket has an attachment with video-file extension
41
- def matching(attach)
41
+ def matches?(attach)
42
42
  @ext.any? { |e| e.eql? File.extname(attach.attrs["filename"]).downcase }
43
43
  end
44
44
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2020 Yurii Dubinka
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-2020 Yurii Dubinka
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"),
@@ -38,13 +38,22 @@ module Lazylead
38
38
 
39
39
  def passed(issue)
40
40
  return true if @envs.empty?
41
- lines = issue["environment"].to_s + "\n" + issue.description
42
- lines.split("\n")
43
- .reject(&:blank?)
44
- .map(&:strip)
45
- .flat_map { |l| l.split(" ").map(&:strip) }
46
- .select { |w| w.include?("http://") || w.include?("https://") }
47
- .any? { |u| @envs.any? { |e| u.match? e } }
41
+ "#{issue['environment']}\n#{issue.description}".split("\n")
42
+ .reject(&:blank?)
43
+ .map(&:strip)
44
+ .flat_map { |l| l.split.map(&:strip) }
45
+ .select { |u| url?(u) }
46
+ .any? { |u| match?(u) }
47
+ end
48
+
49
+ # Ensure that particular text contains web url
50
+ def url?(text)
51
+ text.include?("http://") || text.include?("https://")
52
+ end
53
+
54
+ # Ensure that particular url matches expected servers urls
55
+ def match?(url)
56
+ @envs.any? { |e| url.match? e }
48
57
  end
49
58
  end
50
59
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2020 Yurii Dubinka
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"),
@@ -60,7 +60,7 @@ module Lazylead
60
60
  words = desc.gsub(/{(c|C)(o|O)(d|D)(e|E)/, " {code")
61
61
  .gsub("}", "} ")
62
62
  .gsub("Caused by:", "Caused_by:")
63
- .split(" ")
63
+ .split
64
64
  .map(&:strip)
65
65
  .reject(&:blank?)
66
66
  pairs(words, "{code").map { |s| words[s.first..s.last].join("\n") }