rumble 0.5.1 → 0.5.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f03e3edbc9e2b37f248b11bec2941f6d4a261e81b5f16801ce70d3bb87211f20
4
- data.tar.gz: b95d41c24c2be68d9adfa328ae3499226a767a798f9e14d0ac2bbd7beffa9e09
3
+ metadata.gz: 8e909a68082518ee20778ffba50461fdb99ce0a0e050c3663cd8a3a2eb02db2b
4
+ data.tar.gz: d3f2b07df66e4667aa433b911dcaec42a1276bfb019aa09b68008406b7c94f39
5
5
  SHA512:
6
- metadata.gz: 0c5e549ea1f92e4160f5ca81942877bbd962488cfda61b7e9d9e49ea06375670c3e8f4b36c0ec46864af3f947fcd1de26008c36594c5a80db0491aaf518a1e03
7
- data.tar.gz: 17118c0c04c50f6c7951a38c103d33e276621abd7f28506cac957a6138a38c5f7b34f73172368d395a90f0223f2f6b690fefc798b578ff295206e08a81f59b7e
6
+ metadata.gz: b79225adf5112676fe8c71528a2196a60b70d51367414bc9df7717adff4ab4650caa9f50e7318f8938c6e88ea90bcdcdcdb926b849c1ea66cf0fe4e0638053ad
7
+ data.tar.gz: 85d41d802f8b5014b1a943bf26c10c408f57f815a752574b36bd1f299e19e1b8a822c81d76a999eb7db9b58479c4cdb61e962c9079f04638627d17957123f934
@@ -5,6 +5,8 @@ AllCops:
5
5
  DisplayCopNames: true
6
6
  TargetRubyVersion: 2.3
7
7
 
8
+ Layout/EndOfLine:
9
+ EnforcedStyle: lf
8
10
  Metrics/CyclomaticComplexity:
9
11
  Max: 20
10
12
  Metrics/MethodLength:
@@ -21,3 +23,5 @@ Style/MultilineTernaryOperator:
21
23
  Enabled: false
22
24
  Layout/EmptyLineAfterGuardClause:
23
25
  Enabled: false
26
+ Style/ClassAndModuleChildren:
27
+ Enabled: false
data/README.md CHANGED
@@ -7,8 +7,7 @@
7
7
  [![Build status](https://ci.appveyor.com/api/projects/status/orvfo2qgmd1d7a2i?svg=true)](https://ci.appveyor.com/project/yegor256/rumble)
8
8
  [![PDD status](http://www.0pdd.com/svg?name=yegor256/rumble)](http://www.0pdd.com/p?name=yegor256/rumble)
9
9
  [![Gem Version](https://badge.fury.io/rb/rumble.svg)](http://badge.fury.io/rb/rumble)
10
- [![Dependency Status](https://gemnasium.com/yegor256/rumble.svg)](https://gemnasium.com/yegor256/rumble)
11
- [![Code Climate](http://img.shields.io/codeclimate/github/yegor256/rumble.svg)](https://codeclimate.com/github/yegor256/rumble)
10
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a3fee65d42a9cf6397ea/maintainability)](https://codeclimate.com/github/yegor256/rumble/maintainability)
12
11
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/rumble.svg)](https://codecov.io/github/yegor256/rumble?branch=master)
13
12
 
14
13
  ## What this is for?
data/bin/rumble CHANGED
@@ -26,6 +26,7 @@ require 'mail'
26
26
  require 'net/smtp/proxy'
27
27
  require_relative '../lib/rumble'
28
28
  require_relative '../lib/rumble/version'
29
+ require_relative '../lib/rumble/cli'
29
30
 
30
31
  begin
31
32
  args = []
@@ -34,7 +35,8 @@ begin
34
35
  body = File.read(config)
35
36
  extra = body.split(/[\r\n]+/).map(&:strip)
36
37
  args += extra
37
- puts "Found #{body.split(/\n/).length} lines in #{config}"
38
+ puts "Found #{body.split(/\n/).length} lines in #{config}:
39
+ #{extra.join("\n ")}"
38
40
  else
39
41
  puts "Default config file #{config} not found"
40
42
  end
@@ -95,18 +97,24 @@ begin
95
97
  raise '--port is required' unless opts[:port]
96
98
  raise '--user is required' unless opts[:user]
97
99
  raise '--password is required' unless opts[:password]
100
+ from = Mail::Address.new(opts[:from])
98
101
  if opts[:proxy]
99
102
  scheme, host, port = opts[:proxy].strip.split(':')
100
103
  delivery_method Net::SMTP::Proxy::DeliveryMethod, {
104
+ domain: from.domain,
101
105
  address: opts[:host],
102
106
  port: opts[:port],
103
107
  proxy_address: "#{scheme}://#{host}",
104
108
  proxy_port: port.to_i,
109
+ authentication: 'plain',
105
110
  openssl_verify_mode: OpenSSL::SSL::VERIFY_NONE,
106
- enable_starttls_auto: true
111
+ enable_starttls_auto: true,
112
+ user_name: opts[:user],
113
+ password: opts[:password]
107
114
  }
108
115
  else
109
116
  delivery_method :smtp, {
117
+ domain: from.domain,
110
118
  address: opts[:host],
111
119
  port: opts[:port],
112
120
  user_name: opts[:user],
@@ -20,105 +20,10 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- require 'mail'
24
- require 'uuidtools'
25
- require 'liquid'
26
- require 'csv'
27
- require 'redcarpet'
28
- require 'redcarpet/render_strip'
29
- require 'rainbow'
30
- require_relative 'rumble/version'
31
-
32
- # Rumble main script.
23
+ # Rumble module.
33
24
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
34
25
  # Copyright:: Copyright (c) 2018-2019 Yegor Bugayenko
35
26
  # License:: MIT
36
27
  module Rumble
37
- # Command line interface.
38
- class CLI
39
- def initialize(opts)
40
- @opts = opts
41
- end
42
-
43
- def send
44
- letter = Liquid::Template.parse(
45
- File.read(File.expand_path(@opts[:letter]))
46
- )
47
- skip = @opts[:skip] ? File.readlines(@opts[:skip]).map(&:strip) : []
48
- if @opts[:test]
49
- rcpt = []
50
- rcpt[@opts['col-first'].to_i] = 'John'
51
- rcpt[@opts['col-last'].to_i] = 'Doe'
52
- rcpt[@opts['col-email'].to_i] = @opts[:test]
53
- emails = [rcpt]
54
- else
55
- raise '--csv is required' unless @opts[:csv]
56
- emails = CSV.read(@opts[:csv])
57
- end
58
- total = 0
59
- sent = []
60
- ignore = !@opts[:resume].nil? && !@opts[:test]
61
- from = @opts[:from].strip
62
- puts "Sending #{emails.length} email(s) as #{from}"
63
- domain = from.strip.gsub(/^.+@|>$/)
64
- emails.each do |array|
65
- email = array[@opts['col-email'].to_i]
66
- unless email
67
- puts "Email is #{Rainbow('absent').red} \
68
- at the column ##{@opts['col-email'].to_i}: #{array}"
69
- next
70
- end
71
- email = email.strip.downcase
72
- if sent.include?(email)
73
- puts "#{Rainbow('Duplicate').red} at: #{array}"
74
- next
75
- end
76
- sent.push(email)
77
- first = (array[@opts['col-first'].to_i] || '').strip
78
- last = (array[@opts['col-last'].to_i] || '').strip
79
- first, last = first.split(' ', 2) if last.empty? && first.include?(' ')
80
- name = "#{first.strip} #{last.strip}".strip
81
- address = email
82
- address = "#{name} <#{email}>" unless name.empty?
83
- print "Sending to #{address}... "
84
- markdown = letter.render(
85
- 'email' => email, 'first' => first, 'last' => last
86
- )
87
- html = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
88
- .render(markdown)
89
- text = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
90
- .render(markdown)
91
- if ignore
92
- if @opts[:resume].downcase != email
93
- puts "#{Rainbow('ignored').orange}, waiting for #{@opts[:resume]}"
94
- next
95
- end
96
- ignore = false
97
- end
98
- if skip.include?(email)
99
- puts Rainbow('skipped').red
100
- next
101
- end
102
- subject = @opts[:subject]
103
- mail = Mail.new do
104
- from from
105
- to address
106
- subject subject
107
- message_id "<#{UUIDTools::UUID.random_create}@#{domain}>"
108
- text_part do
109
- content_type 'text/plain; charset=UTF-8'
110
- body text
111
- end
112
- html_part do
113
- content_type 'text/html; charset=UTF-8'
114
- body html
115
- end
116
- end
117
- mail.deliver! unless @opts[:dry]
118
- total += 1
119
- puts "#{Rainbow('done').green} ##{total}"
120
- end
121
- puts "Processed #{sent.size} emails"
122
- end
123
- end
28
+ # Nothing
124
29
  end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018-2019 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'mail'
24
+ require 'uuidtools'
25
+ require 'liquid'
26
+ require 'csv'
27
+ require 'redcarpet'
28
+ require 'redcarpet/render_strip'
29
+ require 'rainbow'
30
+ require_relative 'version'
31
+
32
+ # Rumble main script.
33
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
34
+ # Copyright:: Copyright (c) 2018-2019 Yegor Bugayenko
35
+ # License:: MIT
36
+ class Rumble::CLI
37
+ # Make an instance.
38
+ def initialize(opts)
39
+ @opts = opts
40
+ end
41
+
42
+ # Send a letter, reading options from the opts.
43
+ def send
44
+ letter = Liquid::Template.parse(
45
+ File.read(File.expand_path(@opts[:letter]))
46
+ )
47
+ skip = @opts[:skip] ? File.readlines(@opts[:skip]).map(&:strip) : []
48
+ if @opts[:test]
49
+ rcpt = []
50
+ rcpt[@opts['col-first'].to_i] = 'John'
51
+ rcpt[@opts['col-last'].to_i] = 'Doe'
52
+ rcpt[@opts['col-email'].to_i] = @opts[:test]
53
+ emails = [rcpt]
54
+ else
55
+ raise '--csv is required' unless @opts[:csv]
56
+ emails = CSV.read(@opts[:csv])
57
+ end
58
+ total = 0
59
+ sent = []
60
+ ignore = !@opts[:resume].nil? && !@opts[:test]
61
+ from = @opts[:from].strip
62
+ puts "Sending #{emails.length} email(s) as #{from}"
63
+ domain = from.strip.gsub(/^.+@|>$/)
64
+ emails.each do |array|
65
+ email = array[@opts['col-email'].to_i]
66
+ unless email
67
+ puts "Email is #{Rainbow('absent').red} \
68
+ at the column ##{@opts['col-email'].to_i}: #{array}"
69
+ next
70
+ end
71
+ email = email.strip.downcase
72
+ if sent.include?(email)
73
+ puts "#{Rainbow('Duplicate').red} at: #{array}"
74
+ next
75
+ end
76
+ sent.push(email)
77
+ first = (array[@opts['col-first'].to_i] || '').strip
78
+ last = (array[@opts['col-last'].to_i] || '').strip
79
+ first, last = first.split(' ', 2) if last.empty? && first.include?(' ')
80
+ name = "#{first.strip} #{last.strip}".strip
81
+ address = email
82
+ address = "#{name} <#{email}>" unless name.empty?
83
+ print "Sending to #{address}... "
84
+ markdown = letter.render(
85
+ 'email' => email, 'first' => first, 'last' => last
86
+ )
87
+ html = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
88
+ .render(markdown)
89
+ text = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
90
+ .render(markdown)
91
+ if ignore
92
+ if @opts[:resume].downcase != email
93
+ puts "#{Rainbow('ignored').orange}, waiting for #{@opts[:resume]}"
94
+ next
95
+ end
96
+ ignore = false
97
+ end
98
+ if skip.include?(email)
99
+ puts Rainbow('skipped').red
100
+ next
101
+ end
102
+ subject = @opts[:subject]
103
+ mail = Mail.new do
104
+ from from
105
+ to address
106
+ subject subject
107
+ message_id "<#{UUIDTools::UUID.random_create}@#{domain}>"
108
+ text_part do
109
+ content_type 'text/plain; charset=UTF-8'
110
+ body text
111
+ end
112
+ html_part do
113
+ content_type 'text/html; charset=UTF-8'
114
+ body html
115
+ end
116
+ end
117
+ mail.deliver! unless @opts[:dry]
118
+ total += 1
119
+ puts "#{Rainbow('done').green} ##{total}"
120
+ end
121
+ puts "Processed #{sent.size} emails"
122
+ end
123
+ end
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2018-2019 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Rumble
28
- VERSION = '0.5.1'
28
+ VERSION = '0.5.2'
29
29
  end
@@ -24,6 +24,7 @@ require 'minitest/autorun'
24
24
  require 'tmpdir'
25
25
  require 'slop'
26
26
  require_relative '../lib/rumble'
27
+ require_relative '../lib/rumble/cli'
27
28
 
28
29
  # Rumble main module test.
29
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumble
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-21 00:00:00.000000000 Z
11
+ date: 2019-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -251,6 +251,7 @@ files:
251
251
  - features/step_definitions/steps.rb
252
252
  - features/support/env.rb
253
253
  - lib/rumble.rb
254
+ - lib/rumble/cli.rb
254
255
  - lib/rumble/version.rb
255
256
  - rumble.gemspec
256
257
  - test/test__helper.rb