markdown_gmail_sender 0.1.2 → 0.1.3

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: 1db6de1feeb1a6c264c568214911439260533f6d
4
- data.tar.gz: 528e0c2dbf39984af97fd36320f3644dfc07fc42
3
+ metadata.gz: 6c6634629622b785adfb7629f8664b7aaa6f629b
4
+ data.tar.gz: 7aeec7461c016d95c7391d92002243780e3f7bee
5
5
  SHA512:
6
- metadata.gz: 10364fb7d8b30944b175b05c7dfba4d09a243fe8223f7dd3cbf3529508031d9de2be3571518e230b3519bbc4625a7f9c8b95a7e36a9a1e7bedde70bbe549ce33
7
- data.tar.gz: 537a35e0dc5d4d1c0211072c555d982ba2262c0f3bbab14445cf6fa7a81f7c18327c340fca9d84e68fdb5ff4018a8a97deae994eecb4a05192d29a5beefd7220
6
+ metadata.gz: e180dd4c66981c5bd9645dde2ff2e6744a10633706a95861f8eb3972b8bebfc0c6c9f8e00a356c69d6bb9ef3617aa6736358217ad051da6f64db101d1a3616d1
7
+ data.tar.gz: f084bbeb2cf4c836f403b6ac7b7255d2b6192d21abc444cc1906f119c0d273a0960d27bfb22341d2ec60c077190686da4140418121734106d47dc918cf16af53
checksums.yaml.gz.sig CHANGED
Binary file
@@ -20,16 +20,29 @@ class MarkdownGmailSender
20
20
 
21
21
  # scan the compose directory for email files to deliver
22
22
 
23
- @messages = Dir.glob(File.join(compose_dirpath, '*.md')).map do |filepath|
23
+ @messages = Dir.glob(File.join(compose_dirpath, '*.md')).map do |mdfile|
24
24
 
25
- s = File.read filepath
25
+ s = File.read mdfile
26
+
27
+ regex = %r{
28
+
29
+ (?<email>(?:.*<)?\w+(?:\.\w+)?@\S+>?){0}
30
+ (?<filepath>\s*[\w\/\.]+\s+){0}
26
31
 
27
- /from: (?<from>[\S]+)/ =~ s; /to: (?<to>[\S]+)/ =~ s
28
- /subject: (?<subject>[^\n]+)\n(?<body>.*)/m =~ s
32
+ from:\s(?<from>\g<email>)\s+
33
+ to:\s(?<to>\g<email>)\s+
34
+ (?:attachments?:\s+(?<attachments>\g<filepath>*))?
35
+ subject:\s+(?<subject> [^\n]+)\n
36
+ (?<body> .*)
37
+
38
+ }xm =~ s
39
+
40
+ files = attachments.nil? ? [] : attachments.split.map(&:strip)
29
41
 
30
42
  {
31
- filepath: filepath, from: from, to: to, subject: subject,
32
- body_txt: body, body_html: RDiscount.new(body).to_html
43
+ filepath: mdfile, from: from, to: to, attachments: files,
44
+ subject: subject, body_txt: body,
45
+ body_html: RDiscount.new(body).to_html
33
46
  }
34
47
 
35
48
  end
@@ -56,6 +69,10 @@ class MarkdownGmailSender
56
69
  content_type 'text/html; charset=UTF-8'
57
70
  body x[:body_html]
58
71
  end
72
+
73
+ x[:attachments].each do |attachment|
74
+ add_file attachment.strip
75
+ end
59
76
 
60
77
  end
61
78
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_gmail_sender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  OLGmpGkaE9Sobz20K+IVp5+s3z06CrVYK7TN2gXYiGZRGAxmnd3sd0F8Aewu4uWI
32
32
  HiWyElQDGz9Bjw==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-05-31 00:00:00.000000000 Z
34
+ date: 2016-06-28 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: gmail
metadata.gz.sig CHANGED
Binary file