clutil 2010.132.1 → 2010.141.0
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/cl/util/smtp.rb +18 -3
- metadata +17 -9
- data/cl/util/test/nettest.rb +0 -13
- data/cl/util/util.rb +0 -10
- data/cl/util/version.rb +0 -115
data/cl/util/smtp.rb
CHANGED
@@ -54,11 +54,16 @@ module ClUtil
|
|
54
54
|
|
55
55
|
class Smtp
|
56
56
|
attr_reader :attachments
|
57
|
-
attr_accessor :from, :subj, :body, :extra_headers
|
57
|
+
attr_accessor :from, :subj, :body, :extra_headers, :username, :password, :auth_type, :enable_starttls, :port
|
58
58
|
|
59
|
-
def initialize(smtpsrv='localhost')
|
59
|
+
def initialize(smtpsrv='localhost', port=25)
|
60
60
|
@smtpsrv = smtpsrv
|
61
|
+
@port = port
|
61
62
|
@attachments = []
|
63
|
+
@username = nil
|
64
|
+
@password = nil
|
65
|
+
@auth_type = :login
|
66
|
+
@enable_starttls = false
|
62
67
|
end
|
63
68
|
|
64
69
|
def to
|
@@ -71,11 +76,21 @@ module ClUtil
|
|
71
76
|
|
72
77
|
def sendmail
|
73
78
|
msg = build_message
|
74
|
-
Net::SMTP.
|
79
|
+
@smtp = Net::SMTP.new(@smtpsrv, @port)
|
80
|
+
start_tls_if_needed
|
81
|
+
@smtp.start('localhost.localdomain', @username, @password, @auth_type) do |smtp|
|
75
82
|
smtp.sendmail(msg, @from, @to)
|
76
83
|
end
|
77
84
|
end
|
78
85
|
|
86
|
+
def start_tls_if_needed
|
87
|
+
return if !@enable_starttls
|
88
|
+
require 'rubygems'
|
89
|
+
gem 'smtp_tls'
|
90
|
+
require 'smtp_tls'
|
91
|
+
@smtp.enable_starttls
|
92
|
+
end
|
93
|
+
|
79
94
|
def build_message
|
80
95
|
msg = format_headers
|
81
96
|
boundary = create_boundary
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 2010
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 2010.
|
7
|
+
- 141
|
8
|
+
- 0
|
9
|
+
version: 2010.141.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- chrismo
|
@@ -14,10 +14,21 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-21 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: smtp_tls
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
21
32
|
description: a mish-mash of spare utility libs for Ruby. All BSD license.
|
22
33
|
email:
|
23
34
|
- chrismo@clabs.org
|
@@ -42,15 +53,12 @@ files:
|
|
42
53
|
- cl/util/string.rb
|
43
54
|
- cl/util/test.rb
|
44
55
|
- cl/util/time.rb
|
45
|
-
- cl/util/util.rb
|
46
|
-
- cl/util/version.rb
|
47
56
|
- cl/util/win.rb
|
48
57
|
- cl/util/doc/License
|
49
58
|
- cl/util/doc/Readme
|
50
59
|
- cl/util/test/dirsizetest.rb
|
51
60
|
- cl/util/test/filetest.rb
|
52
61
|
- cl/util/test/installtest.rb
|
53
|
-
- cl/util/test/nettest.rb
|
54
62
|
- cl/util/test/progresstest.rb
|
55
63
|
- cl/util/test/stringtest.rb
|
56
64
|
- cl/util/test/versiontest.rb
|
data/cl/util/test/nettest.rb
DELETED
data/cl/util/util.rb
DELETED
data/cl/util/version.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
# $Id: version.rb,v 1.6 2005/06/02 03:39:31 chrismo Exp $
|
2
|
-
=begin
|
3
|
-
--------------------------------------------------------------------------
|
4
|
-
Copyright (c) 2002-2005, Chris Morris
|
5
|
-
All rights reserved.
|
6
|
-
|
7
|
-
Redistribution and use in source and binary forms, with or without modification,
|
8
|
-
are permitted provided that the following conditions are met:
|
9
|
-
|
10
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
11
|
-
list of conditions and the following disclaimer.
|
12
|
-
|
13
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
14
|
-
this list of conditions and the following disclaimer in the documentation and/or
|
15
|
-
other materials provided with the distribution.
|
16
|
-
|
17
|
-
3. Neither the names Chris Morris, cLabs nor the names of contributors to this
|
18
|
-
software may be used to endorse or promote products derived from this software
|
19
|
-
without specific prior written permission.
|
20
|
-
|
21
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
|
22
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
24
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
|
25
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
26
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
27
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
29
|
-
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
30
|
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
--------------------------------------------------------------------------------
|
32
|
-
Contributors: Dan Butler
|
33
|
-
=end
|
34
|
-
begin
|
35
|
-
require 'cl/xmlserial'
|
36
|
-
rescue LoadError
|
37
|
-
$NO_XMLS = true
|
38
|
-
end
|
39
|
-
|
40
|
-
module CLabs
|
41
|
-
class Version
|
42
|
-
include Comparable
|
43
|
-
include XmlSerialization if !$NO_XMLS
|
44
|
-
|
45
|
-
attr_accessor :major, :minor, :release
|
46
|
-
|
47
|
-
def initialize(maj=0, min=0, rel=0)
|
48
|
-
@major = maj
|
49
|
-
@minor = min
|
50
|
-
@release = rel
|
51
|
-
end
|
52
|
-
|
53
|
-
def <=>(other_ver)
|
54
|
-
res = (@major <=> other_ver.major)
|
55
|
-
res = (@minor <=> other_ver.minor) if res == 0
|
56
|
-
res = (@release <=> other_ver.release) if res == 0
|
57
|
-
res
|
58
|
-
end
|
59
|
-
|
60
|
-
def Version.header_start
|
61
|
-
'# VERSION auto generated section'
|
62
|
-
end
|
63
|
-
|
64
|
-
def Version.header_end
|
65
|
-
'# END_VERSION'
|
66
|
-
end
|
67
|
-
|
68
|
-
def version_header_code(indent=0)
|
69
|
-
' ' * indent + Version.header_start + "\n" +
|
70
|
-
' ' * indent + "begin \n" +
|
71
|
-
' ' * indent + " require 'cl/util/version' \n" +
|
72
|
-
' ' * indent + " VERSION = CLabs::Version.new('#{@major}', '#{@minor}', '#{@release}')\n" +
|
73
|
-
' ' * indent + "rescue LoadError \n" +
|
74
|
-
' ' * indent + " VERSION = '#{to_s}' \n" +
|
75
|
-
' ' * indent + "end \n" +
|
76
|
-
' ' * indent + Version.header_end + "\n"
|
77
|
-
end
|
78
|
-
|
79
|
-
def write_version_header(fn)
|
80
|
-
newfn = fn + '.new'
|
81
|
-
File.open(fn, 'r') do |fin|
|
82
|
-
File.open(newfn, 'w+') do |fout|
|
83
|
-
lines = fin.readlines
|
84
|
-
begindex = nil; endindex = nil; indent = 0
|
85
|
-
lines.each do |ln|
|
86
|
-
if ln =~ /^\s*#{Version.header_start}/
|
87
|
-
begindex = lines.index(ln)
|
88
|
-
indent = ln.scan(/^\s*/).to_s.length
|
89
|
-
end
|
90
|
-
endindex = lines.index(ln) if ln =~ /^\s*#{Version.header_end}/
|
91
|
-
end
|
92
|
-
if begindex && endindex
|
93
|
-
lines = lines[0..begindex-1] <<
|
94
|
-
version_header_code(indent) <<
|
95
|
-
lines[endindex+1..-1]
|
96
|
-
else
|
97
|
-
raise 'VERSION section not found in ' + fn
|
98
|
-
end
|
99
|
-
fout.puts lines
|
100
|
-
end
|
101
|
-
end
|
102
|
-
File.delete(fn)
|
103
|
-
File.rename(newfn, fn)
|
104
|
-
end
|
105
|
-
|
106
|
-
def to_s
|
107
|
-
@major.to_s + '.' + @minor.to_s + '.' + @release.to_s
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
if __FILE__ == $0
|
113
|
-
v = CLabs::Version.new
|
114
|
-
puts v.version_header_code
|
115
|
-
end
|