erikhansson-emailer 0.1.1 → 0.1.2
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.
- data/VERSION +1 -1
- data/emailer.gemspec +3 -2
- data/lib/emailer/mail_queue.rb +1 -1
- data/lib/emailer/smtp_facade.rb +1 -1
- data/lib/emailer/string_utilities.rb +50 -0
- data/lib/emailer.rb +1 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/emailer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{emailer}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Erik Hansson"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-09-01}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{erik@bits2life.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/emailer/mail_queue.rb",
|
30
30
|
"lib/emailer/mock_smtp_facade.rb",
|
31
31
|
"lib/emailer/smtp_facade.rb",
|
32
|
+
"lib/emailer/string_utilities.rb",
|
32
33
|
"spec/emailer/authsmtp_facade_spec.rb",
|
33
34
|
"spec/emailer/mail_queue_spec.rb",
|
34
35
|
"spec/emailer/smtp_facade_spec.rb",
|
data/lib/emailer/mail_queue.rb
CHANGED
data/lib/emailer/smtp_facade.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
module Emailer
|
2
|
+
module StringUtilities
|
3
|
+
|
4
|
+
def q_encode_char(n)
|
5
|
+
hex = n.to_s 16
|
6
|
+
hex = "0#{hex}" if hex.length == 1
|
7
|
+
"=#{hex}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def q_char(n)
|
11
|
+
# We can escape SPACE (0x20) with '_'
|
12
|
+
return '_' if n == 32
|
13
|
+
|
14
|
+
# We can use ASCII 33 to 126, except '=', '?' and '_' (see above).
|
15
|
+
# All other byte values will be encoded with =XX
|
16
|
+
(n < 33 || n == 61 || n == 63 || n == 95 || n > 126) ? q_encode_char(n) : n.chr
|
17
|
+
end
|
18
|
+
|
19
|
+
def q_encode_bytes(str)
|
20
|
+
str.bytes.map { |b| q_char(b) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def q_word(encoding, encoded_str)
|
24
|
+
"=?#{encoding}?Q?#{encoded_str}?="
|
25
|
+
end
|
26
|
+
|
27
|
+
def string_to_q(str)
|
28
|
+
max_word_length = 76 - "=?#{str.encoding.to_s}?Q??=".length
|
29
|
+
lines = split_string q_encode_bytes(str), max_word_length
|
30
|
+
lines.map { |l| q_word(str.encoding.to_s, l) }.join("\r\n ")
|
31
|
+
end
|
32
|
+
|
33
|
+
def split_string(parts, maxlen)
|
34
|
+
result = ['']
|
35
|
+
while parts.length > 0
|
36
|
+
if (result[-1].length + parts[0].length <= maxlen)
|
37
|
+
result[-1] += parts.shift
|
38
|
+
else
|
39
|
+
result << parts.shift
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# require 'lib/emailer/string_utilities'
|
50
|
+
# extend Emailer::StringUtilities
|
data/lib/emailer.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erikhansson-emailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Hansson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -44,13 +44,13 @@ files:
|
|
44
44
|
- lib/emailer/mail_queue.rb
|
45
45
|
- lib/emailer/mock_smtp_facade.rb
|
46
46
|
- lib/emailer/smtp_facade.rb
|
47
|
+
- lib/emailer/string_utilities.rb
|
47
48
|
- spec/emailer/authsmtp_facade_spec.rb
|
48
49
|
- spec/emailer/mail_queue_spec.rb
|
49
50
|
- spec/emailer/smtp_facade_spec.rb
|
50
51
|
- spec/spec_helper.rb
|
51
52
|
has_rdoc: true
|
52
53
|
homepage: http://github.com/erikhansson/emailer
|
53
|
-
licenses:
|
54
54
|
post_install_message:
|
55
55
|
rdoc_options:
|
56
56
|
- --charset=UTF-8
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements: []
|
72
72
|
|
73
73
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.2.0
|
75
75
|
signing_key:
|
76
76
|
specification_version: 2
|
77
77
|
summary: A really simple way to send emails...
|