rumble 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -3
- data/README.md +14 -0
- data/bin/rumble +5 -1
- data/lib/rumble.rb +21 -6
- data/lib/rumble/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d297d43a8e26ba75dce04f181b4acdf865c26f6
|
4
|
+
data.tar.gz: dee37b3ff7a7ceb4a620e4107e945802bc65aec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e75d73844b1525eca315dc2e94ec296efb2be1afd35f5c94b496ca68034c69a3c9b5ee16c0f04776e06d28a54af86035b4e34ff4a82c85f3605986828fd6b47c
|
7
|
+
data.tar.gz: c7df34bfb7b3ad162897304c1276897c57f33d7866877d287317905a1b3be887cf08c751c7299306844099841478b1583602afddfe99813a0e598346e04a8952
|
data/.rubocop.yml
CHANGED
@@ -6,7 +6,7 @@ AllCops:
|
|
6
6
|
TargetRubyVersion: 2.2
|
7
7
|
|
8
8
|
Metrics/CyclomaticComplexity:
|
9
|
-
Max:
|
9
|
+
Max: 20
|
10
10
|
Metrics/MethodLength:
|
11
11
|
Enabled: false
|
12
12
|
Style/MultilineMethodCallIndentation:
|
@@ -14,8 +14,8 @@ Style/MultilineMethodCallIndentation:
|
|
14
14
|
Metrics/AbcSize:
|
15
15
|
Enabled: false
|
16
16
|
Metrics/BlockLength:
|
17
|
-
Max:
|
17
|
+
Max: 100
|
18
18
|
Metrics/PerceivedComplexity:
|
19
|
-
Max:
|
19
|
+
Max: 20
|
20
20
|
Style/MultilineTernaryOperator:
|
21
21
|
Enabled: false
|
data/README.md
CHANGED
@@ -31,6 +31,20 @@ Run it locally and read its output:
|
|
31
31
|
$ rumble --help
|
32
32
|
```
|
33
33
|
|
34
|
+
Simple liquid letter looks like this:
|
35
|
+
|
36
|
+
```
|
37
|
+
{{ first }},
|
38
|
+
|
39
|
+
How are you?
|
40
|
+
|
41
|
+
Best,
|
42
|
+
Yegor
|
43
|
+
```
|
44
|
+
|
45
|
+
The list of emails must contain three columns separated by a comma: first
|
46
|
+
name, last name, and email.
|
47
|
+
|
34
48
|
## How to contribute?
|
35
49
|
|
36
50
|
Just submit a pull request. Make sure `rake` passes.
|
data/bin/rumble
CHANGED
@@ -60,10 +60,13 @@ begin
|
|
60
60
|
o.string '--password', 'SMTP password', required: true
|
61
61
|
o.string '--subject', 'Email subject', required: true
|
62
62
|
o.string '--letter', 'File name with Liquid template', required: true
|
63
|
-
o.string '--
|
63
|
+
o.string '--csv', 'CSV file with first name, last name, and email cols'
|
64
64
|
o.string '--resume', 'Email address from which we should resume'
|
65
65
|
o.string '--skip', 'File name with emails that opted-out (black list)'
|
66
66
|
o.string '--test', 'Email address to use instead of the real user list'
|
67
|
+
o.string '--col0', 'First name columm', default: 0
|
68
|
+
o.string '--col1', 'Last name columm', default: 1
|
69
|
+
o.string '--col2', 'Email columm', default: 2
|
67
70
|
end
|
68
71
|
rescue Slop::Error => ex
|
69
72
|
raise StandardError, "#{ex.message}, try --help"
|
@@ -86,5 +89,6 @@ begin
|
|
86
89
|
|
87
90
|
rescue StandardError => ex
|
88
91
|
puts "#{Rainbow('ERROR').red} (#{ex.class.name}): #{ex.message}"
|
92
|
+
puts ex.backtrace
|
89
93
|
exit(255)
|
90
94
|
end
|
data/lib/rumble.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
require 'mail'
|
22
22
|
require 'uuidtools'
|
23
23
|
require 'liquid'
|
24
|
+
require 'csv'
|
24
25
|
require 'redcarpet'
|
25
26
|
require 'redcarpet/render_strip'
|
26
27
|
require 'rainbow'
|
@@ -42,19 +43,33 @@ module Rumble
|
|
42
43
|
File.read(File.expand_path(@opts[:letter]))
|
43
44
|
)
|
44
45
|
skip = @opts[:skip] ? File.readlines(@opts[:skip]).map(&:strip) : []
|
45
|
-
|
46
|
-
[
|
47
|
-
|
46
|
+
if @opts[:test]
|
47
|
+
emails = [['John', 'Doe', @opts[:test]]]
|
48
|
+
else
|
49
|
+
raise '--csv is required' unless @opts[:csv]
|
50
|
+
emails = CSV.read(@opts[:csv])
|
51
|
+
end
|
48
52
|
total = 0
|
49
53
|
sent = []
|
50
54
|
ignore = !@opts[:resume].nil?
|
51
55
|
from = @opts[:from].strip
|
52
56
|
puts "Sending #{emails.length} email(s) as #{from}"
|
53
57
|
domain = from.strip.gsub(/^.+@|>$/)
|
54
|
-
emails.each do |
|
55
|
-
first
|
58
|
+
emails.each do |array|
|
59
|
+
first = array[@opts[:col0].to_i].strip
|
60
|
+
last = array[@opts[:col1].to_i]
|
61
|
+
unless last
|
62
|
+
puts Rainbow('last name is absent').red
|
63
|
+
next
|
64
|
+
end
|
65
|
+
last = last.strip
|
66
|
+
email = array[@opts[:col2].to_i]
|
67
|
+
unless email
|
68
|
+
puts Rainbow('email is absent').red
|
69
|
+
next
|
70
|
+
end
|
56
71
|
email = email.strip.downcase
|
57
|
-
name = "#{first} #{last}"
|
72
|
+
name = "#{first.strip} #{last.strip}"
|
58
73
|
address = email
|
59
74
|
address = "#{name} <#{email}>" unless name.empty?
|
60
75
|
print "Sending to #{address}... "
|
data/lib/rumble/version.rb
CHANGED