lazylead 0.11.4 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.0pdd.yml +3 -0
  3. data/.circleci/config.yml +0 -12
  4. data/.docs/accuracy.sql +35 -0
  5. data/.github/workflows/build.yml +39 -0
  6. data/.github/workflows/release.yml +15 -0
  7. data/.rubocop.yml +11 -2
  8. data/.rultor.yml +2 -2
  9. data/Gemfile +1 -1
  10. data/Rakefile +17 -9
  11. data/bin/lazylead +5 -5
  12. data/lazylead.gemspec +22 -25
  13. data/lib/lazylead/allocated.rb +1 -1
  14. data/lib/lazylead/cc.rb +1 -1
  15. data/lib/lazylead/cli/app.rb +3 -3
  16. data/lib/lazylead/confluence.rb +4 -3
  17. data/lib/lazylead/email.rb +1 -1
  18. data/lib/lazylead/exchange.rb +3 -3
  19. data/lib/lazylead/home.rb +2 -2
  20. data/lib/lazylead/log.rb +1 -1
  21. data/lib/lazylead/model.rb +4 -3
  22. data/lib/lazylead/opts.rb +1 -1
  23. data/lib/lazylead/os.rb +2 -1
  24. data/lib/lazylead/postman.rb +8 -7
  25. data/lib/lazylead/requires.rb +1 -1
  26. data/lib/lazylead/salt.rb +1 -1
  27. data/lib/lazylead/schedule.rb +5 -9
  28. data/lib/lazylead/smtp.rb +1 -1
  29. data/lib/lazylead/system/empty.rb +1 -1
  30. data/lib/lazylead/system/fake.rb +1 -1
  31. data/lib/lazylead/system/jira.rb +5 -3
  32. data/lib/lazylead/system/synced.rb +1 -1
  33. data/lib/lazylead/task/accuracy/accuracy.rb +3 -3
  34. data/lib/lazylead/task/accuracy/affected_build.rb +1 -1
  35. data/lib/lazylead/task/accuracy/attachment.rb +1 -1
  36. data/lib/lazylead/task/accuracy/environment.rb +1 -1
  37. data/lib/lazylead/task/accuracy/has_label.rb +1 -1
  38. data/lib/lazylead/task/accuracy/logs.rb +1 -1
  39. data/lib/lazylead/task/accuracy/logs_link.rb +1 -1
  40. data/lib/lazylead/task/accuracy/memes.rb +1 -1
  41. data/lib/lazylead/task/accuracy/onlyll.rb +1 -1
  42. data/lib/lazylead/task/accuracy/records.rb +9 -2
  43. data/lib/lazylead/task/accuracy/records_link.rb +1 -1
  44. data/lib/lazylead/task/accuracy/required.rb +1 -1
  45. data/lib/lazylead/task/accuracy/requirement.rb +1 -1
  46. data/lib/lazylead/task/accuracy/screenshots.rb +1 -1
  47. data/lib/lazylead/task/accuracy/servers.rb +1 -1
  48. data/lib/lazylead/task/accuracy/stacktrace.rb +2 -2
  49. data/lib/lazylead/task/accuracy/testcase.rb +1 -1
  50. data/lib/lazylead/task/accuracy/wiki.rb +1 -1
  51. data/lib/lazylead/task/accuracy/wiki_url.rb +1 -1
  52. data/lib/lazylead/task/alert/alert.rb +1 -1
  53. data/lib/lazylead/task/alert/alertif.rb +1 -1
  54. data/lib/lazylead/task/alert/changed_to.rb +1 -1
  55. data/lib/lazylead/task/assignment.rb +1 -1
  56. data/lib/lazylead/task/confluence_ref.rb +1 -1
  57. data/lib/lazylead/task/echo.rb +2 -2
  58. data/lib/lazylead/task/fix_version.rb +1 -1
  59. data/lib/lazylead/task/git/git.rb +82 -0
  60. data/lib/lazylead/task/loading.rb +2 -3
  61. data/lib/lazylead/task/micromanager.rb +1 -1
  62. data/lib/lazylead/task/missing_comment.rb +1 -1
  63. data/lib/lazylead/task/propagate_down.rb +3 -3
  64. data/lib/lazylead/task/savepoint.rb +1 -1
  65. data/lib/lazylead/task/svn/diff.rb +1 -1
  66. data/lib/lazylead/task/svn/grep.rb +1 -1
  67. data/lib/lazylead/task/svn/svn.rb +1 -1
  68. data/lib/lazylead/task/svn/touch.rb +42 -14
  69. data/lib/lazylead/version.rb +2 -2
  70. data/lib/lazylead.rb +1 -1
  71. data/license.txt +1 -1
  72. data/readme.md +20 -15
  73. data/test/lazylead/allocated_test.rb +1 -1
  74. data/test/lazylead/cc_test.rb +7 -7
  75. data/test/lazylead/cli/app_test.rb +1 -1
  76. data/test/lazylead/confluence_test.rb +1 -1
  77. data/test/lazylead/exchange_test.rb +10 -10
  78. data/test/lazylead/file_postman_test.rb +47 -0
  79. data/test/lazylead/model_test.rb +2 -2
  80. data/test/lazylead/opts_test.rb +1 -1
  81. data/test/lazylead/postman_test.rb +7 -39
  82. data/test/lazylead/retry_test.rb +12 -1
  83. data/test/lazylead/salt_test.rb +1 -1
  84. data/test/lazylead/smoke_test.rb +2 -2
  85. data/test/lazylead/smtp_test.rb +7 -7
  86. data/test/lazylead/stdout_postman_test.rb +48 -0
  87. data/test/lazylead/system/jira_test.rb +53 -54
  88. data/test/lazylead/task/accuracy/accuracy_test.rb +11 -11
  89. data/test/lazylead/task/accuracy/affected_build_test.rb +1 -1
  90. data/test/lazylead/task/accuracy/attachment_test.rb +4 -4
  91. data/test/lazylead/task/accuracy/environment_test.rb +1 -1
  92. data/test/lazylead/task/accuracy/has_label_test.rb +1 -1
  93. data/test/lazylead/task/accuracy/logs_link_test.rb +1 -1
  94. data/test/lazylead/task/accuracy/logs_test.rb +1 -1
  95. data/test/lazylead/task/accuracy/memes_test.rb +1 -1
  96. data/test/lazylead/task/accuracy/onlyll_test.rb +21 -21
  97. data/test/lazylead/task/accuracy/records_llink_test.rb +1 -1
  98. data/test/lazylead/task/accuracy/records_test.rb +35 -12
  99. data/test/lazylead/task/accuracy/score_test.rb +4 -4
  100. data/test/lazylead/task/accuracy/screenshots_test.rb +3 -3
  101. data/test/lazylead/task/accuracy/servers_test.rb +1 -1
  102. data/test/lazylead/task/accuracy/stacktrace_test.rb +1 -1
  103. data/test/lazylead/task/accuracy/testcase_test.rb +1 -1
  104. data/test/lazylead/task/accuracy/wiki_test.rb +1 -1
  105. data/test/lazylead/task/accuracy/wiki_url_test.rb +1 -1
  106. data/test/lazylead/task/alert/alertif_test.rb +5 -5
  107. data/test/lazylead/task/alert/assignee_alert_test.rb +1 -1
  108. data/test/lazylead/task/alert/changed_to_test.rb +5 -5
  109. data/test/lazylead/task/assignment_test.rb +5 -5
  110. data/test/lazylead/task/confluence_ref_test.rb +8 -8
  111. data/test/lazylead/task/created_recently_test.rb +4 -4
  112. data/test/lazylead/task/duedate_test.rb +14 -14
  113. data/test/lazylead/task/echo_test.rb +1 -1
  114. data/test/lazylead/task/fix_version_test.rb +6 -5
  115. data/test/lazylead/task/loading_test.rb +7 -7
  116. data/test/lazylead/task/micromanager_test.rb +5 -5
  117. data/test/lazylead/task/missing_comment_test.rb +4 -4
  118. data/test/lazylead/task/propagate_down_test.rb +1 -1
  119. data/test/lazylead/task/savepoint_test.rb +1 -1
  120. data/test/lazylead/task/svn/diff_test.rb +14 -15
  121. data/test/lazylead/task/svn/grep_test.rb +4 -3
  122. data/test/lazylead/task/svn/touch_test.rb +74 -6
  123. data/test/lazylead/version_test.rb +1 -1
  124. data/test/sqlite_test.rb +1 -1
  125. data/test/test.rb +10 -3
  126. metadata +49 -107
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -41,23 +41,23 @@ module Lazylead
41
41
  end
42
42
 
43
43
  def run(_, postman, opts)
44
- files = opts.slice("files", ",")
45
- commits = touch(files, opts)
44
+ commits = touch(opts)
46
45
  postman.send(opts.merge(entries: commits)) unless commits.empty?
47
46
  end
48
47
 
49
48
  # Return all svn commits for a particular date range, which are touching
50
49
  # somehow the critical files within the svn repo.
51
- def touch(files, opts)
52
- xpath = files.map { |f| "contains(text(),\"#{f}\")" }.join(" or ")
53
- svn_log(opts).xpath("//logentry[paths/path[#{xpath}]]")
54
- .map { |xml| to_entry(xml) }
55
- .each do |e|
50
+ def touch(opts)
51
+ files = opts.slice("files", ",")
52
+ branches = opts.slice("branches", ",")
53
+ svn_log(opts)
54
+ .select { |e| branches.empty? || branches.any? { |b| e.paths.path.start_with? b } }
55
+ .each do |e|
56
56
  e.paths.path.delete_if { |p| files.none? { |f| p.include? f } } if e.paths.path.respond_to? :delete_if
57
57
  end
58
58
  end
59
59
 
60
- # Return all svn commits for particular date range in repo
60
+ # Return svn commits history for file(s) within particular date range in repo
61
61
  def svn_log(opts)
62
62
  now = if opts.key? "now"
63
63
  DateTime.parse(opts["now"])
@@ -65,11 +65,15 @@ module Lazylead
65
65
  DateTime.now
66
66
  end
67
67
  start = (now.to_time - opts["period"].to_i).to_datetime
68
- raw = OS.new.run "svn log --no-auth-cache",
69
- "--username #{opts.decrypt('svn_user', 'svn_salt')}",
70
- "--password #{opts.decrypt('svn_password', 'svn_salt')}",
71
- "--xml -v -r {#{start}}:{#{now}} #{opts['svn_url']}"
72
- Nokogiri.XML(raw, nil, "UTF-8")
68
+ locations(opts).flat_map do |file|
69
+ raw = OS.new.run "svn log --no-auth-cache",
70
+ "--username #{opts.decrypt('svn_user', 'svn_salt')}",
71
+ "--password #{opts.decrypt('svn_password', 'svn_salt')}",
72
+ "--xml -v -r {#{start}}:{#{now}} #{opts['svn_url']}/#{file}"
73
+ Nokogiri.XML(raw, nil, "UTF-8")
74
+ .xpath("//logentry[paths/path]")
75
+ .map { |xml| to_entry(xml) }
76
+ end
73
77
  end
74
78
 
75
79
  # Convert single revision(XML text) to entry object.
@@ -91,6 +95,30 @@ module Lazylead
91
95
  hsh.transform_values { |v| v.is_a?(Hash) ? to_struct(v) : v }
92
96
  )
93
97
  end
98
+
99
+ # Return for each file all his locations considering branches
100
+ # > locations('readme.md')
101
+ # branches/0.13.x/readme.md
102
+ # trunk/readme.md
103
+ #
104
+ # @todo #567/DEV Performance: improve the glob pattern to support multiple files.
105
+ # Right now in order to find all branches for a particular file we are using glob pattern
106
+ # - https://en.wikipedia.org/wiki/Glob_(programming)
107
+ # - https://stackoverflow.com/a/70950401/6916890
108
+ # - https://globster.xyz
109
+ # Right now for each file we initiate a separate search request, thus we need to think
110
+ # how to avoid this and send only one search request
111
+ def locations(opts)
112
+ opts.slice("files", ",").flat_map do |file|
113
+ raw = OS.new.run "svn ls --no-auth-cache ",
114
+ "--username #{opts.decrypt('svn_user', 'svn_salt')}",
115
+ "--password #{opts.decrypt('svn_password', 'svn_salt')}",
116
+ "--xml -R --search \"#{file}\" #{opts['svn_url']}"
117
+ Nokogiri.XML(raw, nil, "UTF-8")
118
+ .xpath("/lists/list/entry/name/text()")
119
+ .map { |f| f.to_s.strip }
120
+ end
121
+ end
94
122
  end
95
123
  end
96
124
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -23,5 +23,5 @@
23
23
  # OR OTHER DEALINGS IN THE SOFTWARE.
24
24
 
25
25
  module Lazylead
26
- VERSION = "0.11.4"
26
+ VERSION = "0.13.0"
27
27
  end
data/lib/lazylead.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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/license.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2019-2021 Yurii Dubinka
3
+ Copyright (c) 2019-2022 Yurii Dubinka
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"),
data/readme.md CHANGED
@@ -1,33 +1,37 @@
1
1
  [![Versions](https://img.shields.io/badge/semver-2.0-green)](https://semver.org/spec/v2.0.0.html)
2
2
  [![Gem Version](https://badge.fury.io/rb/lazylead.svg)](https://rubygems.org/gems/lazylead)
3
- [![Downloads](https://ruby-gem-downloads-badge.herokuapp.com/lazylead?type=total)](https://rubygems.org/gems/lazylead)
3
+
4
+ [![Downloads](https://img.shields.io/gem/dt/lazylead)](https://rubygems.org/gems/lazylead)
4
5
  [![](https://img.shields.io/docker/pulls/dgroup/lazylead.svg)](https://hub.docker.com/r/dgroup/lazylead "Image pulls")
5
6
  [![](https://images.microbadger.com/badges/image/dgroup/lazylead.svg)](https://microbadger.com/images/dgroup/lazylead "Image layers")
6
7
  [![Commit activity](https://img.shields.io/github/commit-activity/y/dgroup/lazylead.svg?style=flat-square)](https://github.com/dgroup/lazylead/graphs/commit-activity)
7
8
  [![Hits-of-Code](https://hitsofcode.com/github/dgroup/lazylead)](https://hitsofcode.com/view/github/dgroup/lazylead)
8
9
  [![License: MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](./license.txt)
9
10
 
10
- [![Build status circleci](https://circleci.com/gh/dgroup/lazylead/tree/master.svg?style=shield)](https://circleci.com/gh/dgroup/lazylead/tree/master)
11
+ [![CI](https://github.com/dgroup/lazylead/actions/workflows/build.yml/badge.svg)](https://github.com/dgroup/lazylead/actions/workflows/build.yml)
11
12
  [![0pdd](http://www.0pdd.com/svg?name=dgroup/lazylead)](http://www.0pdd.com/p?name=dgroup/lazylead)
12
- [![Dependency Status](https://requires.io/github/dgroup/lazylead/requirements.svg?branch=master)](https://requires.io/github/dgroup/lazylead/requirements/?branch=master)
13
13
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dgroup_lazylead&metric=alert_status)](https://sonarcloud.io/dashboard?id=dgroup_lazylead)
14
14
  [![codebeat badge](https://codebeat.co/badges/f3bc8c19-5986-413f-89c4-c869b1e9b705)](https://codebeat.co/projects/github-com-dgroup-lazylead-master)
15
15
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/e1ec2d63ff9040d99c934e3c05c24abe)](https://www.codacy.com/manual/dgroup/lazylead?utm_source=github.com&utm_medium=referral&utm_content=dgroup/lazylead&utm_campaign=Badge_Grade)
16
16
  [![Maintainability](https://api.codeclimate.com/v1/badges/e873a41b1c76d7b2d6ae/maintainability)](https://codeclimate.com/github/dgroup/lazylead/maintainability)
17
17
  [![codecov](https://codecov.io/gh/dgroup/lazylead/branch/master/graph/badge.svg)](https://codecov.io/gh/dgroup/lazylead)
18
18
 
19
- [![DevOps By Rultor.com](http://www.rultor.com/b/dgroup/lazylead)](http://www.rultor.com/p/dgroup/lazylead)
20
- [![EO badge](http://www.elegantobjects.org/badge.svg)](http://www.elegantobjects.org/#principles)
21
-
22
19
  ### Overview
23
20
  Ticketing systems (Github, Jira, etc.) are strongly integrated into our processes and everyone understands their necessity. As soon as a developer becomes a lead/technical manager, he or she faces a set of routine tasks that are related to ticketing work. On large projects this becomes a problem, more and more you spend time running around on dashboards and tickets, looking for incorrect deviations in tickets and performing routine tasks instead of solving technical problems.
24
21
 
25
- The idea of automatic management is not new, for example [Zerocracy](https://www.zerocracy.com/) is available on the market.
26
- I like this idea, but large companies/projects are not ready yet for such a decisive breakthrough and need step-by-step solutions such as [lazylead](https://github.com/dgroup/lazylead).
27
- I think you remember how [static code analysis](https://en.wikipedia.org/wiki/Static_program_analysis) treated at in the past; today we have a huge toolkit (pmd, checkstyle, qulice, rubocop, peon, etc) for each language that allows you to avoid routine issues and remove from the code reviewer the unnecessary load.
22
+ The idea of automatic management is not new, but large companies/projects are not ready yet for such a decisive breakthrough and need step-by-step solutions such as [lazylead](https://github.com/dgroup/lazylead).
23
+ I think you remember how [static code analysis](https://en.wikipedia.org/wiki/Static_program_analysis) treated at in the past; today we have a huge toolkit (pmd, checkstyle, qulice, rubocop, peon, etc) for each language that allows you to avoid routine issues and remove from the code reviewer the unnecessary load. The same logic we can apply to our day-to-day ticket management activities - let's reduce or even remove unnecessary routine actions.
28
24
 
29
25
  Join our telegram chat [lazylead](https://t.me/lazyleads) for discussions.
30
26
 
27
+ Legend:
28
+
29
+ - 🚴🏽 in-progress
30
+ - ⌛ planned
31
+ - ✅ implemented
32
+ - 🌵 implemented, but not tested
33
+ - ❌ not supported/planned
34
+
31
35
  | Daily annoying task | Jira | Github | Trello | SVN | Git |
32
36
  | :---------------------------------------------------------------------------------- | :---: | :----: | :----: | :----: | :----: |
33
37
  | [Notify ticket's assignee](lib/lazylead/task/alert/alert.rb) | ✅ | ⌛ | ⌛ | ❌ | ❌ |
@@ -50,9 +54,9 @@ Join our telegram chat [lazylead](https://t.me/lazyleads) for discussions.
50
54
  | Notify about tickets matches predefined multiple conditions | ✅ | ⌛ | ⌛ | ❌ | ❌ |
51
55
  | Link automatically the ticket and Confluence page if link found in ticket's comments/description | ✅ | ⌛ | ⌛ | ❌ | ❌ |
52
56
  | Notify about tickets assigned to your team members not by effective managers| ✅ | ⌛ | ⌛ | ❌ | ❌ |
53
- | Notify about modifications of important files in VCS | ❌ | ⌛ | ❌ | ✅ | |
54
- | Notify about diff changes for past X period in VCS | ❌ | ⌛ | ❌ | ✅ | |
55
- | Notify about changes with some text for past X period in VCS | ❌ | ⌛ | ❌ | ✅ | |
57
+ | Notify about modifications of important files in VCS | ❌ | ⌛ | ❌ | ✅ | 🚴 |
58
+ | Notify about diff changes for past X period in VCS | ❌ | ⌛ | ❌ | ✅ | 🚴 |
59
+ | Notify about changes with some text for past X period in VCS | ❌ | ⌛ | ❌ | ✅ | 🚴 |
56
60
  | [Notify when someone outside of your team changed the due date on tickets for your team](lib/lazylead/task/micromanager.rb)| ✅ | ⌛ | ❌ | ❌ | ❌ |
57
61
  | [Notify when someone outside of your team assigned a ticket directly to the developer](lib/lazylead/task/assignment.rb)| ✅ | ⌛ | ❌ | ❌ | ❌ |
58
62
 
@@ -64,8 +68,9 @@ Join our telegram chat [lazylead](https://t.me/lazyleads) for discussions.
64
68
  | [mail.google.com](lib/lazylead/postman.rb) | Emails | 🌵 |
65
69
  | calendar.google.com | Calendar | ⌛ |
66
70
  | slack.com | Notifications | ⌛ |
67
-
68
- - implemented, - planned, 🌵 - implemented, but not tested, ❌ - not supported/planned.
71
+ | GitHub | VCS + CI/CD | ⌛ |
72
+ | GitLab | VCS + CI/CD | |
73
+ | BitBucket | VCS + CI/CD | ⌛ |
69
74
 
70
75
  New ideas, bugs, suggestions or questions are welcome [via GitHub issues](https://github.com/dgroup/lazylead/issues/new)!
71
76
 
@@ -176,7 +181,7 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
176
181
 
177
182
  <a href="https://www.buymeacoffee.com/lazylead" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
178
183
 
179
- [Pull requests](http://www.elegantobjects.org/#principles) are welcome! Don't forget to add your name to contribution section and run this, beforehand:
184
+ Pull requests are welcome! Don't forget to add your name to contribution section and run this, beforehand:
180
185
  ```ruby
181
186
  rake -A
182
187
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -115,18 +115,18 @@ module Lazylead
115
115
  # lead's email, thus, its took few minutes for huge projects.
116
116
  test "cc by component is found" do
117
117
  skip "Disabled due to performance issue with Jira API"
118
- assert_equal ENV["cc_email"],
118
+ assert_equal ENV.fetch("cc_email", nil),
119
119
  ComponentCC.new(
120
- ENV["cc_project"],
120
+ ENV.fetch("cc_project", nil),
121
121
  Jira.new(
122
122
  {
123
- username: ENV["JIRA_USER"],
124
- password: ENV["JIRA_PASS"],
125
- site: ENV["JIRA_URL"],
123
+ username: ENV.fetch("JIRA_USER", nil),
124
+ password: ENV.fetch("JIRA_PASS", nil),
125
+ site: ENV.fetch("JIRA_URL", nil),
126
126
  context_path: ""
127
127
  }
128
128
  )
129
- ).cc(ENV["cc_component"])
129
+ ).cc(ENV.fetch("cc_component", nil))
130
130
  end
131
131
 
132
132
  test "detect plain cc" do
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -39,7 +39,7 @@ module Lazylead
39
39
  "exchange_to"
40
40
  Exchange.new(Log.new, NoSalt.new).send(
41
41
  Opts.new(
42
- to: ENV["exchange_to"],
42
+ to: ENV.fetch("exchange_to", nil),
43
43
  tickets: NoAuthJira.new("https://jira.spring.io")
44
44
  .issues("key = DATAJDBC-480"),
45
45
  "subject" => "[DD] PDTN!",
@@ -57,12 +57,12 @@ module Lazylead
57
57
  Exchange.new(
58
58
  Log.new,
59
59
  Salt.new("exchange_salt"),
60
- "exchange_url" => ENV["exchange_url"],
61
- "exchange_user" => ENV["enc_exchange_usr"],
62
- "exchange_password" => ENV["enc_exchange_psw"]
60
+ "exchange_url" => ENV.fetch("exchange_url", nil),
61
+ "exchange_user" => ENV.fetch("enc_exchange_usr", nil),
62
+ "exchange_password" => ENV.fetch("enc_exchange_psw", nil)
63
63
  ).send(
64
64
  Opts.new(
65
- to: ENV["exchange_to"],
65
+ to: ENV.fetch("exchange_to", nil),
66
66
  tickets: NoAuthJira.new("https://jira.spring.io")
67
67
  .issues("key = DATAJDBC-480"),
68
68
  "subject" => "[DD] Enc PDTN!",
@@ -79,12 +79,12 @@ module Lazylead
79
79
  Exchange.new(
80
80
  Log.new,
81
81
  Salt.new("exchange_salt"),
82
- "exchange_url" => ENV["exchange_url"],
83
- "exchange_user" => ENV["enc_exchange_usr"],
84
- "exchange_password" => ENV["enc_exchange_psw"]
82
+ "exchange_url" => ENV.fetch("exchange_url", nil),
83
+ "exchange_user" => ENV.fetch("enc_exchange_usr", nil),
84
+ "exchange_password" => ENV.fetch("enc_exchange_psw", nil)
85
85
  ).send(
86
86
  Opts.new(
87
- to: ENV["exchange_to"],
87
+ to: ENV.fetch("exchange_to", nil),
88
88
  "attachments" => "readme.md",
89
89
  "subject" => "[LL] Attachments",
90
90
  "template" => "lib/messages/savepoint.erb"
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2019-2022 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 "../test"
26
+ require_relative "../../lib/lazylead/log"
27
+ require_relative "../../lib/lazylead/opts"
28
+ require_relative "../../lib/lazylead/salt"
29
+ require_relative "../../lib/lazylead/smtp"
30
+ require_relative "../../lib/lazylead/postman"
31
+
32
+ module Lazylead
33
+ class FilePostmanTest < Lazylead::Test
34
+ test "send email to html file" do
35
+ assert_path_exists FilePostman.new(Log.new, "file_postman_dir" => "test/resources")
36
+ .send(
37
+ Opts.new(
38
+ "to" => "to@email.com",
39
+ "from" => "from@email.com",
40
+ "attachments" => ["readme.md"],
41
+ "subject" => "[LL] FilePostmanTest attachment",
42
+ "template" => "lib/messages/savepoint.erb"
43
+ )
44
+ )
45
+ end
46
+ end
47
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -80,7 +80,7 @@ module Lazylead
80
80
  vcs4sql: "upgrades/sqlite",
81
81
  testdata: true
82
82
  )
83
- refute ORM::Task.find(260).to_h?
83
+ refute_predicate ORM::Task.find(260), :to_h?
84
84
  end
85
85
 
86
86
  test "second ticketing system is found" do
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -41,15 +41,15 @@ module Lazylead
41
41
  Smtp.new(
42
42
  Log.new,
43
43
  NoSalt.new,
44
- smtp_host: ENV["LL_SMTP_HOST"],
45
- smtp_port: ENV["LL_SMTP_PORT"],
46
- smtp_user: ENV["LL_SMTP_USER"],
47
- smtp_pass: ENV["LL_SMTP_PASS"]
44
+ smtp_host: ENV.fetch("LL_SMTP_HOST", nil),
45
+ smtp_port: ENV.fetch("LL_SMTP_PORT", nil),
46
+ smtp_user: ENV.fetch("LL_SMTP_USER", nil),
47
+ smtp_pass: ENV.fetch("LL_SMTP_PASS", nil)
48
48
  ).enable
49
49
  Postman.new.send(
50
50
  Opts.new(
51
- "to" => ENV["LL_SMTP_TO"],
52
- "from" => ENV["LL_SMTP_FROM"],
51
+ "to" => ENV.fetch("LL_SMTP_TO", nil),
52
+ "from" => ENV.fetch("LL_SMTP_FROM", nil),
53
53
  "attachments" => ["readme.md"],
54
54
  "subject" => "[LL] Attachments",
55
55
  "template" => "lib/messages/savepoint.erb"
@@ -57,36 +57,4 @@ module Lazylead
57
57
  )
58
58
  end
59
59
  end
60
-
61
- class StdoutPostmanTest < Lazylead::Test
62
- # @todo #495/DEV Find way to capture the STDOUT in order to test the email sending.
63
- # Right now its just visual verification.
64
- test "send email to stdout" do
65
- StdoutPostman.new.send(
66
- Opts.new(
67
- "to" => "to@email.com",
68
- "from" => "from@email.com",
69
- "attachments" => ["readme.md"],
70
- "subject" => "[LL] Attachments",
71
- "template" => "lib/messages/savepoint.erb"
72
- )
73
- )
74
- end
75
- end
76
-
77
- class FilePostmanTest < Lazylead::Test
78
- # @todo #/DEV add new assert method which consume the file name and check existence on the disk
79
- test "send email to html file" do
80
- FilePostman.new(Log.new, "file_postman_dir" => "test/resources")
81
- .send(
82
- Opts.new(
83
- "to" => "to@email.com",
84
- "from" => "from@email.com",
85
- "attachments" => ["readme.md"],
86
- "subject" => "[LL] Attachments",
87
- "template" => "lib/messages/savepoint.erb"
88
- )
89
- )
90
- end
91
- end
92
60
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -81,5 +81,16 @@ module Lazylead
81
81
  )
82
82
  ).exec.attempts
83
83
  end
84
+
85
+ test "throw error" do
86
+ assert_raises(RuntimeError, "network issue") do
87
+ ORM::Retry.new(
88
+ FakeTask.new(
89
+ proc { raise "network issue" },
90
+ { "rethrow" => "true" }
91
+ )
92
+ ).exec
93
+ end
94
+ end
84
95
  end
85
96
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -41,7 +41,7 @@ module Lazylead
41
41
  f << "EnvTest=value"
42
42
  f.flush
43
43
  IniFile.new(filename: f).each { |_, k, v| ENV[k] = v }
44
- assert_equal "value", ENV["EnvTest"]
44
+ assert_equal "value", ENV.fetch("EnvTest", nil)
45
45
  end
46
46
  end
47
47
  test "ini file not found" do
@@ -2,7 +2,7 @@
2
2
 
3
3
  # The MIT License
4
4
  #
5
- # Copyright (c) 2019-2021 Yurii Dubinka
5
+ # Copyright (c) 2019-2022 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"),
@@ -46,14 +46,14 @@ module Lazylead
46
46
  skip "Not implemented yet" unless env? "LL_SMTP_HOST", "LL_SMTP_USER"
47
47
  Smtp.new(
48
48
  Log.new, NoSalt.new,
49
- smtp_host: ENV["LL_SMTP_HOST"],
50
- smtp_port: ENV["LL_SMTP_PORT"],
51
- smtp_user: ENV["LL_SMTP_USER"],
52
- smtp_pass: ENV["LL_SMTP_PASS"]
49
+ smtp_host: ENV.fetch("LL_SMTP_HOST", nil),
50
+ smtp_port: ENV.fetch("LL_SMTP_PORT", nil),
51
+ smtp_user: ENV.fetch("LL_SMTP_USER", nil),
52
+ smtp_pass: ENV.fetch("LL_SMTP_PASS", nil)
53
53
  ).enable
54
54
  Mail.deliver do
55
- from ENV["LL_SMTP_FROM"]
56
- to ENV["LL_SMTP_TO"]
55
+ from ENV.fetch("LL_SMTP_FROM", nil)
56
+ to ENV.fetch("LL_SMTP_TO", nil)
57
57
  subject "Testing"
58
58
  body "Good, it works"
59
59
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2019-2022 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 "../test"
26
+ require_relative "../../lib/lazylead/log"
27
+ require_relative "../../lib/lazylead/opts"
28
+ require_relative "../../lib/lazylead/salt"
29
+ require_relative "../../lib/lazylead/smtp"
30
+ require_relative "../../lib/lazylead/postman"
31
+
32
+ module Lazylead
33
+ class StdoutPostmanTest < Lazylead::Test
34
+ # @todo #495/DEV Find way to capture the STDOUT in order to test the email sending.
35
+ # Right now its just visual verification.
36
+ test "send email to stdout" do
37
+ StdoutPostman.new.send(
38
+ Opts.new(
39
+ "to" => "to@email.com",
40
+ "from" => "from@email.com",
41
+ "attachments" => ["readme.md"],
42
+ "subject" => "[LL] Attachments",
43
+ "template" => "lib/messages/savepoint.erb"
44
+ )
45
+ )
46
+ end
47
+ end
48
+ end