ruboty-sendmail 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: ab8642a98a034d4931dcb7009b4601694f29538b
4
- data.tar.gz: 59aa0ee2b2f334341ae7e71c57757e6f3e417691
3
+ metadata.gz: d617e331904ddb0e665f8cd3d764d9f80f2cda59
4
+ data.tar.gz: f493fec59ed57eb8f417b95491a40cbff70a2360
5
5
  SHA512:
6
- metadata.gz: 4bee7a849e76788765f32ca36215adbc26bc8f22473f1b956ac584402c20d74cee41ce9b94697a4c4352b69b9d8d5e3736cb655f6995bf46748d2212369d65ee
7
- data.tar.gz: df49a62fc15e79d0fb58480e80ea79e1f5c8e500adf24e43af6e9e3ce8ffd56d200e0160727a08b60d4b2b47c801b2e441e39bdf14f5e45973ff409379635668
6
+ metadata.gz: fd688b46cec8645d905c77d63ceedf593a424189ed5133f497dfe5e4aec67a4031157ebacc138ff9b4081f6f7b593ef321857611d84d4a25ea05568091823e57
7
+ data.tar.gz: 1cfe5fbcd6760cadff99139cf2c80ac521cc1a17a24a2d6321221ed8a973b6ef9f6045f85eac6e1073d0d7a58df350a8d1b6e3e6b66a35b99f0d3b348bf1e12b
@@ -10,11 +10,14 @@ module Ruboty
10
10
  def sendmail(message)
11
11
  mail_config = YAML.load_file("#{ENV['HOME']}/.ruboty-sendmail.yml")
12
12
 
13
+ address = trim_address(message[:address])
14
+ body = message[:body]
15
+
13
16
  mail = Mail.new do |config|
14
- config.subject mail_config['subject'] || 'Send by ruboty-sendmail'
15
17
  config.from mail_config['from']
16
- config.to message[:address]
17
- config.body message[:body]
18
+ config.to address
19
+ config.subject mail_config['subject'] || 'Send by ruboty-sendmail'
20
+ config.body body
18
21
  end
19
22
 
20
23
  method = mail_config['method'] || :smtp
@@ -42,6 +45,13 @@ module Ruboty
42
45
  end
43
46
  end
44
47
 
48
+ private
49
+
50
+ def trim_address(string)
51
+ match_data = string.match(/(?<address>\w+[\w\.-]*@\w+[\w\.-]+)/)
52
+ match_data[:address]
53
+ end
54
+
45
55
  def symbolize_keys(hash)
46
56
  hash.each_with_object({}) do |(k, v), retval|
47
57
  retval[k.to_sym] = v
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Sendmail
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-sendmail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaihar4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-09 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruboty