postgarnet 1.0.3 → 1.0.4
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 +4 -4
- data/lib/postgarnet.rb +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9941e185008d258ea17607ab5b40881c84fa288f0fa2048d7eaefed20394d1d7
|
4
|
+
data.tar.gz: 1b4b5c7d7cf62df9722044838e4f0ce1de792ed7080c09ebe98d621219b2da26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df75d7317b258d8d3e6a14a6c04fe9714298febfaad36931b90898146271755e7859f40184600e5e679afe4127bc8ac11d7c0bc89cd3212e536285d35bbd1954
|
7
|
+
data.tar.gz: 26c445b1b0b2eb82d02e469f995f78bcedffbe79b4657c81ab50bf578ad311a180970647eec554f326646f245a3257e0fe448b17bea0e9d1df4e5c772971c2bb
|
data/lib/postgarnet.rb
CHANGED
@@ -13,7 +13,7 @@ class TransactionError < StandardError
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class Postgarnet
|
16
|
-
@@version = "1.0.
|
16
|
+
@@version = "1.0.4"
|
17
17
|
|
18
18
|
def initialize(username:, password:)
|
19
19
|
@username, @password, @subject, @content, @recipient, @author = @username, @smtp = nil
|
@@ -103,6 +103,9 @@ class Postgarnet
|
|
103
103
|
begin
|
104
104
|
@smtp = Net::SMTP.new(host, port)
|
105
105
|
@smtp.enable_starttls
|
106
|
+
if block_given?
|
107
|
+
block.call
|
108
|
+
end
|
106
109
|
rescue Exception => e
|
107
110
|
raise TransactionError, "Error when connecting: #{e}"
|
108
111
|
else
|
@@ -137,7 +140,7 @@ class Postgarnet
|
|
137
140
|
return @smtp
|
138
141
|
end
|
139
142
|
|
140
|
-
def send(client="localhost")
|
143
|
+
def send(client="localhost", &block)
|
141
144
|
if [@username, @password, @author, @recipient, @subject, @content].any?(&:nil?)
|
142
145
|
raise FormatError, "Incomplete parameters"
|
143
146
|
end
|
@@ -148,6 +151,9 @@ class Postgarnet
|
|
148
151
|
message = self.create_msg
|
149
152
|
@smtp.start(client, @username, @password, :plain) do
|
150
153
|
@smtp.send_message(message, @username, @recipient)
|
154
|
+
if block_given?
|
155
|
+
block.call
|
156
|
+
end
|
151
157
|
end
|
152
158
|
rescue Exception => e
|
153
159
|
raise TransactionError, "Error when sending: #{e}"
|