lazylead 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +49 -1
  3. data/.simplecov +1 -1
  4. data/Guardfile +1 -1
  5. data/Rakefile +4 -3
  6. data/bin/lazylead +9 -5
  7. data/lazylead.gemspec +20 -15
  8. data/lib/lazylead/cc.rb +21 -20
  9. data/lib/lazylead/cli/app.rb +13 -5
  10. data/lib/lazylead/confluence.rb +8 -1
  11. data/lib/lazylead/email.rb +0 -20
  12. data/lib/lazylead/exchange.rb +16 -28
  13. data/lib/lazylead/log.rb +2 -1
  14. data/lib/lazylead/model.rb +31 -16
  15. data/lib/lazylead/opts.rb +65 -2
  16. data/lib/lazylead/postman.rb +18 -16
  17. data/lib/lazylead/salt.rb +1 -0
  18. data/lib/lazylead/smtp.rb +3 -1
  19. data/lib/lazylead/system/jira.rb +31 -6
  20. data/lib/lazylead/task/accuracy/accuracy.rb +8 -10
  21. data/lib/lazylead/task/accuracy/attachment.rb +0 -4
  22. data/lib/lazylead/task/accuracy/logs.rb +8 -4
  23. data/lib/lazylead/task/accuracy/onlyll.rb +148 -0
  24. data/lib/lazylead/task/accuracy/records.rb +1 -1
  25. data/lib/lazylead/task/accuracy/servers.rb +16 -7
  26. data/lib/lazylead/task/accuracy/stacktrace.rb +50 -10
  27. data/lib/lazylead/task/accuracy/testcase.rb +23 -6
  28. data/lib/lazylead/task/assignment.rb +96 -0
  29. data/lib/lazylead/task/fix_version.rb +6 -0
  30. data/lib/lazylead/task/propagate_down.rb +1 -1
  31. data/lib/lazylead/task/svn/diff.rb +77 -0
  32. data/lib/lazylead/task/svn/grep.rb +139 -0
  33. data/lib/lazylead/task/svn/touch.rb +99 -0
  34. data/lib/lazylead/version.rb +1 -1
  35. data/lib/messages/illegal_assignee_change.erb +123 -0
  36. data/lib/messages/illegal_fixversion_change.erb +8 -0
  37. data/lib/messages/only_ll.erb +107 -0
  38. data/lib/messages/svn_diff.erb +110 -0
  39. data/lib/messages/{svn_log.erb → svn_diff_attachment.erb} +19 -9
  40. data/lib/messages/svn_grep.erb +114 -0
  41. data/test/lazylead/cc_test.rb +1 -0
  42. data/test/lazylead/model_test.rb +20 -0
  43. data/test/lazylead/opts_test.rb +47 -0
  44. data/test/lazylead/postman_test.rb +8 -5
  45. data/test/lazylead/smoke_test.rb +13 -0
  46. data/test/lazylead/system/jira_test.rb +6 -7
  47. data/test/lazylead/task/accuracy/logs_test.rb +62 -2
  48. data/test/lazylead/task/accuracy/onlyll_test.rb +138 -0
  49. data/test/lazylead/task/accuracy/servers_test.rb +2 -2
  50. data/test/lazylead/task/accuracy/stacktrace_test.rb +227 -0
  51. data/test/lazylead/task/accuracy/testcase_test.rb +49 -0
  52. data/test/lazylead/task/assignment_test.rb +53 -0
  53. data/test/lazylead/task/fix_version_test.rb +1 -0
  54. data/test/lazylead/task/propagate_down_test.rb +4 -3
  55. data/test/lazylead/task/savepoint_test.rb +7 -4
  56. data/test/lazylead/task/svn/diff_test.rb +97 -0
  57. data/test/lazylead/task/svn/grep_test.rb +103 -0
  58. data/test/lazylead/task/{touch_test.rb → svn/touch_test.rb} +7 -34
  59. data/test/test.rb +7 -6
  60. data/upgrades/sqlite/999.testdata.sql +3 -1
  61. metadata +120 -34
  62. data/lib/lazylead/task/touch.rb +0 -119
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b58ee14de8c573012698a15d145941155e6c282249bc2938bf4938c4e677d7cd
4
- data.tar.gz: 34bed5a73b2186b9e229a121973ad11891037d604faa0134fe31d5a9380ead6a
3
+ metadata.gz: e5a5b0412fc9cb5796b066940c57e50785b64920718a09ecd4ef8794fc8b3908
4
+ data.tar.gz: 148b21d628c91d27abee8fb1bb86aeaf78cfdc96b01f9cbed16c9f4f8b5c7ef3
5
5
  SHA512:
6
- metadata.gz: f1a8e4032492f97b2672078c908f37599f3d32a01bf31d7a67911732b90f682410123fb1234e07315b9ccd6d4e675e4b9d4867e06f265c06ace44f33c7d1cb1f
7
- data.tar.gz: 22f2d3fb9b3ed8a8bb9e2e8f6f29393f65e2ab6bea033c9f0f82741775032098383614f280433f64fcd16dbd6ab6c4c46115b197307c684a9c03ffc736b95714
6
+ metadata.gz: 58539cbff1ccdc9c392aaa67af4e6dc0ade92311cbf2118202392b069de15f3872f833d2081b59d97439029901b569fe72e6a54e22ddfe011c06cddef576b6e2
7
+ data.tar.gz: 658f24b1dde5272d17c6cdd77f570f71de818f83a7acda9c5b3cdebf497f514e7f890862963caa49e577f2c566829be7d247bee1e236ec1248cdf0fbc4a58de2
@@ -16,10 +16,13 @@ Layout/LineLength:
16
16
  - "test/**/*"
17
17
 
18
18
  Metrics/AbcSize:
19
- Max: 20
19
+ Max: 21
20
20
  Exclude:
21
21
  - "test/**/*"
22
22
 
23
+ Metrics/CyclomaticComplexity:
24
+ Max: 8
25
+
23
26
  Metrics/BlockLength:
24
27
  Exclude:
25
28
  - "*.gemspec"
@@ -91,3 +94,48 @@ Lint/StructNewOverride:
91
94
 
92
95
  # @todo #/DEV Add violation regarding methods without documentation using RDoc
93
96
  # https://stackoverflow.com/questions/1681467/how-to-document-ruby-code
97
+
98
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
99
+ Enabled: true
100
+ Lint/AmbiguousAssignment: # (new in 1.7)
101
+ Enabled: true
102
+ Lint/DeprecatedConstants: # (new in 1.8)
103
+ Enabled: true
104
+ Lint/DuplicateBranch: # (new in 1.3)
105
+ Enabled: true
106
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
107
+ Enabled: true
108
+ Lint/EmptyBlock: # (new in 1.1)
109
+ Enabled: true
110
+ Lint/EmptyClass: # (new in 1.3)
111
+ Enabled: true
112
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
113
+ Enabled: true
114
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
115
+ Enabled: true
116
+ Lint/RedundantDirGlobSort: # (new in 1.8)
117
+ Enabled: true
118
+ Lint/ToEnumArguments: # (new in 1.1)
119
+ Enabled: true
120
+ Lint/UnexpectedBlockArity: # (new in 1.5)
121
+ Enabled: true
122
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
123
+ Enabled: true
124
+ Style/ArgumentsForwarding: # (new in 1.1)
125
+ Enabled: true
126
+ Style/CollectionCompact: # (new in 1.2)
127
+ Enabled: true
128
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
129
+ Enabled: true
130
+ Style/EndlessMethod: # (new in 1.8)
131
+ Enabled: true
132
+ Style/HashExcept: # (new in 1.7)
133
+ Enabled: true
134
+ Style/NegatedIfElseCondition: # (new in 1.2)
135
+ Enabled: true
136
+ Style/NilLambda: # (new in 1.3)
137
+ Enabled: true
138
+ Style/RedundantArgument: # (new in 1.4)
139
+ Enabled: true
140
+ Style/SwapValues: # (new in 1.1)
141
+ Enabled: true
data/.simplecov CHANGED
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
4
4
  [SimpleCov::Formatter::HTMLFormatter]
data/Guardfile CHANGED
@@ -25,7 +25,7 @@
25
25
  # Guardfile for Lazylead
26
26
  guard :minitest, all_after_pass: false, all_on_start: false do
27
27
  # with Minitest::Unit
28
- watch(%r{^test/(.*)\/?test_(.*)\.rb$})
28
+ watch(%r{^test/(.*)/?test_(.*)\.rb$})
29
29
  watch(%r{^test/test\.rb$}) { "test" }
30
30
  watch(%r{^lib/lazylead/(.*/)?([^/]+)\.rb$}) do |m|
31
31
  "test/#{m[1]}test_#{m[2]}.rb"
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ require "rubygems"
26
26
  require "rake"
27
27
  require "date"
28
28
  require "rdoc"
29
- require "rainbow"
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 "#{Rainbow(total).red} SQL violations found."
115
+ abort "#{total.colorize(:red)} SQL violations found."
116
116
  else
117
- puts "#{src.size} files inspected, #{Rainbow('no offenses').green} detected"
117
+ puts "#{src.size} files inspected, #{'no offenses'.colorize(:green)} " \
118
+ "detected"
118
119
  end
119
120
  end
120
121
 
@@ -25,11 +25,12 @@
25
25
 
26
26
  # When sync mode is true, all output is immediately flushed
27
27
  # to the underlying operating system and is not buffered internally.
28
- STDOUT.sync = true
28
+ $stdout.sync = true
29
29
 
30
30
  require "slop"
31
31
  require "sqlite3"
32
- require "rainbow"
32
+ require "colorize"
33
+ require "inifile"
33
34
  require "logging"
34
35
  require "backtrace"
35
36
  require "memory_profiler"
@@ -77,9 +78,11 @@ Available options:"
77
78
  exit
78
79
  end
79
80
  end
80
- log.debug("Version: #{Lazylead::VERSION}")
81
- log.debug("Memory footprint at start is #{Lazylead::Allocated.new}")
81
+ log.debug "Version: #{Lazylead::VERSION.colorize(:green)}"
82
+ log.debug "Memory footprint at start is " \
83
+ "#{Lazylead::Allocated.new.to_s.colorize(:light_blue)}."
82
84
  cmd = lambda do
85
+ IniFile.new(filename: "lazylead.ini").each { |_, k, v| ENV[k] = v }
83
86
  Lazylead::CLI::App.new(
84
87
  log,
85
88
  Lazylead::Schedule.new(log: log),
@@ -103,5 +106,6 @@ if opts["memory-dump"]
103
106
  else
104
107
  code = cmd.call
105
108
  end
106
- log.debug("Memory footprint at the end is #{Lazylead::Allocated.new}")
109
+ log.debug "Memory footprint at the end is " \
110
+ "#{Lazylead::Allocated.new.to_s.colorize(:light_blue)}."
107
111
  exit(code) unless code.zero?
@@ -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.5.1"
35
+ s.version = "0.7.0"
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.5.1!
48
+ s.post_install_message = "Thanks for installing Lazylead v0.7.0!
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
@@ -55,41 +55,46 @@ tasks instead of solving technical problems."
55
55
  s.test_files = s.files.grep(%r{^(test|features)/})
56
56
  s.rdoc_options = ["--charset=UTF-8"]
57
57
  s.extra_rdoc_files = %w[readme.md license.txt]
58
- s.add_runtime_dependency "activerecord", "6.0.3"
58
+ s.add_runtime_dependency "activerecord", "6.1.1"
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
- s.add_runtime_dependency "get_process_mem", "0.2.5"
62
+ s.add_runtime_dependency "get_process_mem", "0.2.7"
63
+ s.add_runtime_dependency "inifile", "3.0.0"
62
64
  s.add_runtime_dependency "jira-ruby", "1.7.1"
63
- s.add_runtime_dependency "json", "2.3.0"
64
- s.add_runtime_dependency "logging", "2.2.2"
65
+ s.add_runtime_dependency "json", "2.5.1"
66
+ s.add_runtime_dependency "logging", "2.3.0"
65
67
  s.add_runtime_dependency "mail", "2.7.1"
66
68
  s.add_runtime_dependency "memory_profiler", "0.9.13"
67
69
  s.add_runtime_dependency "openssl", "2.1.2"
68
- s.add_runtime_dependency "rainbow", "3.0.0"
70
+ s.add_runtime_dependency "railties", "6.1.1"
69
71
  s.add_runtime_dependency "require_all", "3.0.0"
70
72
  s.add_runtime_dependency "rufus-scheduler", "3.6.0"
71
73
  s.add_runtime_dependency "slop", "4.4"
72
74
  s.add_runtime_dependency "sqlite3", "1.4.2"
75
+ s.add_runtime_dependency "tempfile", "0.1.0"
73
76
  s.add_runtime_dependency "tilt", "2.0.10"
74
- s.add_runtime_dependency "tzinfo", "1.1"
75
- s.add_runtime_dependency "tzinfo-data", "1.2019.3"
76
- s.add_runtime_dependency "vcs4sql", "0.1.0"
77
+ s.add_runtime_dependency "tzinfo", "2.0.4"
78
+ s.add_runtime_dependency "tzinfo-data", "1.2020.6"
79
+ s.add_runtime_dependency "vcs4sql", "0.1.1"
77
80
  s.add_runtime_dependency "viewpoint", "1.1.0"
78
- s.add_development_dependency "codecov", "0.2.3"
81
+ s.add_development_dependency "codecov", "0.2.15"
79
82
  s.add_development_dependency "guard", "2.15.0"
80
83
  s.add_development_dependency "guard-minitest", "2.4.6"
81
- s.add_development_dependency "minitest", "5.11.3"
84
+ s.add_development_dependency "minitest", "5.14.3"
82
85
  s.add_development_dependency "minitest-fail-fast", "0.1.0"
83
86
  s.add_development_dependency "minitest-hooks", "1.5.0"
84
87
  s.add_development_dependency "minitest-reporters", "1.3.6"
85
88
  s.add_development_dependency "net-ping", "2.0.8"
86
89
  s.add_development_dependency "rake", "12.3.3"
87
90
  s.add_development_dependency "random-port", "0.3.1"
88
- s.add_development_dependency "rdoc", "6.1.1"
89
- s.add_development_dependency "rubocop", "0.82"
91
+ s.add_development_dependency "rdoc", "6.3.0"
92
+ s.add_development_dependency "rubocop", "1.8.1"
90
93
  s.add_development_dependency "rubocop-minitest", "0.5.1"
91
94
  s.add_development_dependency "rubocop-performance", "1.5.2"
95
+ s.add_development_dependency "rubocop-rake", "0.5.1"
92
96
  s.add_development_dependency "rubocop-rspec", "1.33.0"
93
97
  s.add_development_dependency "sqlint", "0.1.10"
94
- s.add_development_dependency "xcop", "0.6"
98
+ s.add_development_dependency "tempfile", "0.1.0"
99
+ s.add_development_dependency "xcop", "0.6.2"
95
100
  end
@@ -81,12 +81,12 @@ module Lazylead
81
81
 
82
82
  def cc
83
83
  @cc ||= begin
84
- if @text.include? ","
85
- @text.split(",").map(&:strip).select { |e| e[@regxp] }
86
- elsif @text[@regxp]
87
- [@text.strip]
88
- end
89
- end
84
+ if @text.include? ","
85
+ @text.split(",").map(&:strip).select { |e| e[@regxp] }
86
+ elsif @text[@regxp]
87
+ [@text.strip]
88
+ end
89
+ end
90
90
  end
91
91
 
92
92
  def each(&block)
@@ -126,14 +126,14 @@ module Lazylead
126
126
 
127
127
  def to_h
128
128
  @to_h ||= begin
129
- if @orig.is_a? Hash
130
- @orig.each_with_object({}) do |i, o|
131
- o[i.first] = Lazylead::PlainCC.new(i.last).cc
132
- end
133
- else
134
- {}
135
- end
136
- end
129
+ if @orig.is_a? Hash
130
+ @orig.each_with_object({}) do |i, o|
131
+ o[i.first] = Lazylead::PlainCC.new(i.last).cc
132
+ end
133
+ else
134
+ {}
135
+ end
136
+ end
137
137
  end
138
138
  end
139
139
 
@@ -145,18 +145,19 @@ module Lazylead
145
145
  # License:: MIT
146
146
  class ComponentCC < Lazylead::PredefinedCC
147
147
  def initialize(prj, jira)
148
+ super({})
148
149
  @prj = prj
149
150
  @jira = jira
150
151
  end
151
152
 
152
153
  def to_h
153
154
  @to_h ||= begin
154
- components.each_with_object({}) do |c, h|
155
- email = lead(c.attrs["id"])
156
- next if email.nil? || email.blank?
157
- h[c.attrs["name"]] = email
158
- end
159
- end
155
+ components.each_with_object({}) do |c, h|
156
+ email = lead(c.attrs["id"])
157
+ next if email.nil? || email.blank?
158
+ h[c.attrs["name"]] = email
159
+ end
160
+ end
160
161
  end
161
162
 
162
163
  private
@@ -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"
@@ -56,11 +57,13 @@ module Lazylead
56
57
  private
57
58
 
58
59
  def apply_vcs_migration(opts)
59
- @db = File.expand_path(opts[:home]) + "/" + opts[:sqlite]
60
- vcs = File.expand_path(opts[:home]) + "/" + opts[:vcs4sql]
61
- @log.debug "Database: '#{@db}', sql migration dir: '#{vcs}'"
60
+ @db = "#{File.expand_path(opts[:home])}/#{opts[:sqlite]}"
61
+ vcs = "#{File.expand_path(opts[:home])}/#{opts[:vcs4sql]}"
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 #{vcs}"
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)
@@ -78,7 +81,12 @@ module Lazylead
78
81
  @log.warn "ll-001: No tasks found."
79
82
  else
80
83
  todo.find_each do |task|
81
- @schedule.register task
84
+ if task.to_h?
85
+ @schedule.register task
86
+ else
87
+ @log.warn "ll-011: Scheduling skipped due to configuration " \
88
+ "mistake in #{task}"
89
+ end
82
90
  end
83
91
  @schedule.join
84
92
  end
@@ -104,16 +104,23 @@ module Lazylead
104
104
  end
105
105
 
106
106
  # Detect links mentioned in ticket comments
107
+ # @todo #/DEV Refactor this method in order to make it more human-readable and remove the
108
+ # suppresion below
109
+ #
110
+ # rubocop:disable Metrics/CyclomaticComplexity
111
+ # rubocop:disable Metrics/PerceivedComplexity
107
112
  def mentioned_links(ticket)
108
113
  ticket.comments
109
114
  .map { |cmnt| cmnt.attrs["body"] }
110
115
  .select { |cmnt| @confl.any? { |c| cmnt.include? c.url } }
111
- .flat_map { |cmnt| cmnt.split " " }
116
+ .flat_map(&:split)
112
117
  .select { |cmnt| @confl.any? { |c| cmnt.start_with? c.url } }
113
118
  .map(&method(:to_page_id))
114
119
  .reject(&:blank?)
115
120
  .uniq
116
121
  end
122
+ # rubocop:enable Metrics/CyclomaticComplexity
123
+ # rubocop:enable Metrics/PerceivedComplexity
117
124
 
118
125
  # Convert confluence page url to the following format:
119
126
  # http://confluence.com/pages/viewpage.action?pageId=xxxxx
@@ -25,26 +25,6 @@
25
25
  require "tilt"
26
26
 
27
27
  module Lazylead
28
- # Email notifications utilities.
29
- module Emailing
30
- # Construct html document from template and binds.
31
- def make_body(opts)
32
- Email.new(
33
- opts["template"],
34
- opts.merge(version: Lazylead::VERSION)
35
- ).render
36
- end
37
-
38
- # Split text with email addresses by ',' and trim all elements if needed.
39
- def split(type, opts)
40
- if opts[type].include? ","
41
- opts[type].split(",").map(&:strip).reject(&:empty?)
42
- else
43
- [opts[type]]
44
- end
45
- end
46
- end
47
-
48
28
  # An email regarding tickets based on file with markup.
49
29
  #
50
30
  # The 'tilt' gem was used as a template engine.
@@ -39,8 +39,6 @@ module Lazylead
39
39
  # Copyright:: Copyright (c) 2019-2020 Yurii Dubinka
40
40
  # License:: MIT
41
41
  class Exchange
42
- include Emailing
43
-
44
42
  def initialize(
45
43
  log = Log.new, salt = Salt.new("exchange_salt"), opts = ENV.to_h
46
44
  )
@@ -52,38 +50,28 @@ module Lazylead
52
50
  # Send an email.
53
51
  # :opts :: the mail configuration like from, cc, subject, template.
54
52
  def send(opts)
55
- to = opts["to"] || opts[:to]
56
- to = [to] unless to.is_a? Array
57
- if to.reject { |e| e.nil? || e.blank? }.empty?
58
- @log.warn "Email can't be sent to '#{to}, more: '#{opts}'"
59
- return
53
+ if opts.msg_to.empty?
54
+ @log.warn "ll-012: Email can't be sent to '#{opts.msg_to}," \
55
+ " more: '#{opts}'"
56
+ else
57
+ msg = make_msg opts
58
+ cli.send_message msg
59
+ msg[:file_attachments].each(&:close) unless opts.msg_attachments.empty?
60
+ @log.debug "#{__FILE__} sent '#{opts['subject']}' to '#{opts.msg_to}'."
60
61
  end
61
- msg = make_msg(to, opts)
62
- msg.update(cc_recipients: opts["cc"]) if opts.key? "cc"
63
- add_attachments(msg, opts)
64
- cli.send_message msg
65
- close_attachments msg
66
- @log.debug "#{__FILE__} sent email based on #{opts}."
67
62
  end
68
63
 
69
- def make_msg(to, opts)
70
- {
64
+ def make_msg(opts)
65
+ msg = {
71
66
  subject: opts["subject"],
72
- body: make_body(opts),
67
+ body: opts.msg_body,
73
68
  body_type: "HTML",
74
- to_recipients: to
69
+ to_recipients: opts.msg_to
75
70
  }
76
- end
77
-
78
- def add_attachments(msg, opts)
79
- return unless opts.key? "attachments"
80
- files = split("attachments", opts).map { |f| File.open(f, "r") }
81
- msg[:file_attachments] = files
82
- end
83
-
84
- def close_attachments(msg)
85
- return if msg[:file_attachments].nil? || msg[:file_attachments].empty?
86
- msg[:file_attachments].each(&:close)
71
+ files = opts.msg_attachments.map { |f| File.open(f, "r") }
72
+ msg[:file_attachments] = files unless files.empty?
73
+ msg[:cc_recipients] = opts["cc"] if opts.key? "cc"
74
+ msg
87
75
  end
88
76
 
89
77
  private