rumble 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32a5250ec7ec28274e94ab016b9e547ed3060231
4
- data.tar.gz: 8137684571e870ce3c7cee92f7ea663fc5e1e169
3
+ metadata.gz: 2d297d43a8e26ba75dce04f181b4acdf865c26f6
4
+ data.tar.gz: dee37b3ff7a7ceb4a620e4107e945802bc65aec7
5
5
  SHA512:
6
- metadata.gz: 2191d5a14f74f4279eff43b12b0585b2880c7d00cbe7e5584d9fa04101498ea8c87105669ac65cbf424898fb977a1757862c63f0f359d1174abc3cf23c354874
7
- data.tar.gz: e7beeb971cb67d5db7df0f3e7450592c00d6cc887dd67e4179d928f527383b53f9772aa113a08e383554dd827155f9112e3ce838983a9a35d3fc1ec016cf72aa
6
+ metadata.gz: e75d73844b1525eca315dc2e94ec296efb2be1afd35f5c94b496ca68034c69a3c9b5ee16c0f04776e06d28a54af86035b4e34ff4a82c85f3605986828fd6b47c
7
+ data.tar.gz: c7df34bfb7b3ad162897304c1276897c57f33d7866877d287317905a1b3be887cf08c751c7299306844099841478b1583602afddfe99813a0e598346e04a8952
@@ -6,7 +6,7 @@ AllCops:
6
6
  TargetRubyVersion: 2.2
7
7
 
8
8
  Metrics/CyclomaticComplexity:
9
- Max: 10
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: 50
17
+ Max: 100
18
18
  Metrics/PerceivedComplexity:
19
- Max: 10
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 '--targets', 'File name with emails and names'
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
@@ -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
- emails = @opts[:test] ?
46
- ["John,Doe,#{@opts[:test]}"]
47
- : File.readlines(@opts[:targets]).map(&:strip).reject(&:empty?)
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 |line|
55
- first, last, email = line.split(',')
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}".strip
72
+ name = "#{first.strip} #{last.strip}"
58
73
  address = email
59
74
  address = "#{name} <#{email}>" unless name.empty?
60
75
  print "Sending to #{address}... "
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Rumble
26
- VERSION = '0.1'.freeze
26
+ VERSION = '0.2'.freeze
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumble
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko