facets 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +331 -35
- data/MANIFEST +685 -826
- data/{doc/guide/notes.rd → NOTES} +0 -0
- data/README.rdoc +73 -25
- data/Rakefile +245 -2
- data/TODO +5 -0
- data/demo/hook.rd +47 -0
- data/demo/scenario_require.rd +9 -0
- data/doc/README.more +24 -6
- data/doc/manual/about.rb +47 -0
- data/doc/manual/annotations.rdoc +60 -0
- data/doc/manual/associations.rdoc +55 -0
- data/doc/manual/blockups.rdoc +101 -0
- data/doc/manual/capsule.rdoc +34 -0
- data/doc/manual/command.rdoc +177 -0
- data/doc/manual/core.rdoc +37 -0
- data/doc/manual/faq.rdoc +32 -0
- data/doc/manual/typecast.html +112 -0
- data/lib/core/facets.rb +359 -11
- data/lib/core/facets/array/combination.rb +3 -3
- data/lib/core/facets/array/index.rb +4 -1
- data/lib/core/facets/array/permutation.rb +2 -2
- data/lib/core/facets/array/product.rb +1 -1
- data/lib/core/facets/binding/eval.rb +1 -1
- data/lib/core/facets/denumerable.rb +76 -0
- data/lib/core/facets/duplicable.rb +34 -0
- data/lib/core/facets/enumerable/count.rb +10 -4
- data/lib/core/facets/enumerable/defer.rb +77 -0
- data/lib/core/facets/enumerable/each_by.rb +1 -1
- data/lib/core/facets/enumerable/every.rb +35 -0
- data/lib/{more/facets/elementwise.rb → core/facets/enumerable/ewise.rb} +0 -0
- data/lib/core/facets/enumerable/filter.rb +25 -0
- data/lib/core/facets/enumerable/group_by.rb +1 -1
- data/lib/core/facets/enumerable/none.rb +3 -2
- data/lib/core/facets/enumerable/one.rb +3 -2
- data/lib/core/facets/enumerable/per.rb +61 -0
- data/lib/core/facets/exception/raised.rb +14 -0
- data/lib/core/facets/integer/odd.rb +5 -1
- data/lib/core/facets/kernel/__dir__.rb +13 -3
- data/lib/core/facets/kernel/__here__.rb +14 -0
- data/lib/core/facets/kernel/__method__.rb +9 -3
- data/lib/core/facets/kernel/ask.rb +1 -0
- data/lib/core/facets/kernel/equate.rb +13 -0
- data/lib/core/facets/kernel/extension.rb +9 -0
- data/lib/core/facets/kernel/identical.rb +4 -0
- data/lib/core/facets/kernel/instance_exec.rb +2 -1
- data/lib/core/facets/kernel/method.rb +49 -0
- data/lib/core/facets/kernel/object_send.rb +2 -2
- data/lib/core/facets/kernel/{state.rb → object_state.rb} +23 -12
- data/lib/core/facets/kernel/require_all.rb +6 -1
- data/lib/core/facets/kernel/require_local.rb +8 -1
- data/lib/core/facets/kernel/require_relative.rb +52 -0
- data/lib/core/facets/kernel/source_location.rb +13 -0
- data/lib/core/facets/kernel/tap.rb +13 -6
- data/lib/core/facets/module/attr_setter.rb +57 -0
- data/lib/core/facets/module/instance_method.rb +24 -0
- data/lib/core/facets/module/module_load.rb +60 -44
- data/lib/core/facets/module/module_require.rb +1 -0
- data/lib/core/facets/nilclass/to_f.rb +1 -1
- data/lib/core/facets/objectspace/op_fetch.rb +3 -0
- data/lib/core/facets/proc/curry.rb +4 -3
- data/lib/core/facets/string/bytes.rb +10 -4
- data/lib/core/facets/string/camelcase.rb +6 -5
- data/lib/core/facets/string/chars.rb +5 -1
- data/lib/core/facets/string/each_char.rb +1 -1
- data/lib/core/facets/string/each_word.rb +1 -1
- data/lib/core/facets/string/lines.rb +11 -4
- data/lib/core/facets/string/start_with.rb +9 -2
- data/lib/core/facets/string/unfold.rb +27 -0
- data/lib/core/facets/symbol/succ.rb +3 -3
- data/lib/core/facets/symbol/thrown.rb +20 -0
- data/lib/core/facets/symbol/to_proc.rb +3 -2
- data/lib/core/facets/time/to_time.rb +1 -1
- data/lib/core/facets/to_hash.rb +41 -100
- data/lib/core/facets/unboundmethod/name.rb +20 -23
- data/lib/more/facets/ansicode.rb +1 -10
- data/lib/more/facets/autoarray.rb +3 -31
- data/lib/more/facets/basicobject.rb +73 -0
- data/lib/more/facets/blankslate.rb +2 -66
- data/lib/{lore → more}/facets/cgi.rb +0 -0
- data/lib/more/facets/class_extend.rb +1 -0
- data/lib/{lore → more}/facets/continuation.rb +0 -0
- data/lib/{lore → more}/facets/date.rb +3 -3
- data/lib/more/facets/enumargs.rb +192 -0
- data/lib/more/facets/enumerablepass.rb +2 -216
- data/lib/more/facets/enumerator.rb +62 -0
- data/lib/more/facets/{equatable.rb → equitable.rb} +11 -11
- data/lib/more/facets/expirable.rb +13 -41
- data/lib/{lore → more}/facets/fileutils.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/head.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/safe_ln.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/slice.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/tail.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/wc.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/whereis.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/which.rb +0 -0
- data/lib/{lore → more}/facets/getoptlong.rb +0 -0
- data/lib/more/facets/hook.rb +2 -29
- data/lib/more/facets/inheritor.rb +2 -2
- data/lib/more/facets/instance_eval.rb +50 -0
- data/lib/more/facets/instance_function.rb +78 -0
- data/lib/more/facets/main.rb +20 -15
- data/lib/more/facets/memoize.rb +1 -113
- data/lib/more/facets/module/attr.rb +83 -0
- data/lib/more/facets/module/attr_tester.rb +44 -0
- data/lib/more/facets/module/attr_toggler.rb +59 -0
- data/lib/more/facets/module/attr_validator.rb +34 -0
- data/lib/more/facets/{class_extension.rb → module/class_extend.rb} +21 -13
- data/lib/more/facets/once.rb +59 -0
- data/lib/more/facets/openmodule.rb +1 -0
- data/lib/more/facets/orderedhash.rb +1 -33
- data/lib/{lore → more}/facets/ostruct.rb +0 -0
- data/lib/more/facets/ostructable.rb +1 -4
- data/lib/more/facets/partial.rb +18 -16
- data/lib/{lore → more}/facets/pathname.rb +0 -0
- data/lib/more/facets/preinitialize.rb +157 -0
- data/lib/{lore → more}/facets/rbconfig.rb +0 -0
- data/lib/more/facets/recorder.rb +1 -2
- data/lib/{lore → more}/facets/set.rb +0 -0
- data/lib/{lore → more}/facets/shellwords.rb +0 -0
- data/lib/{lore → more}/facets/uri.rb +0 -0
- data/lib/{lore → more}/facets/yaml.rb +0 -0
- data/lib/{lore → more}/facets/zlib.rb +0 -0
- data/meta/loadpath +0 -1
- data/meta/sitemap +4 -0
- data/meta/version +1 -1
- data/test/core/enumerable/test_count.rb +1 -1
- data/test/{more/test_filter.rb → core/enumerable/test_defer.rb} +24 -22
- data/test/{more/test_elementor.rb → core/enumerable/test_every.rb} +2 -15
- data/test/core/enumerable/test_ewise.rb +23 -0
- data/test/core/enumerable/test_per.rb +18 -0
- data/test/core/enumerable/test_take.rb +13 -0
- data/test/core/kernel/test_deepcopy.rb +1 -1
- data/test/{more/test_1stclassmethod.rb → core/kernel/test_method.rb} +2 -7
- data/test/core/kernel/test_tap.rb +1 -1
- data/test/core/proc/test_curry.rb +11 -0
- data/test/core/string/test_bytes.rb +1 -1
- data/test/core/string/test_camelcase.rb +23 -6
- data/test/core/string/test_lines.rb +1 -1
- data/test/core/string/test_unfold.rb +14 -0
- data/test/{more → core}/test_blank.rb +0 -0
- data/test/{more → core}/test_boolean.rb +0 -0
- data/test/{more → core}/test_functor.rb +0 -0
- data/test/{lore → more}/test_basicobject.rb +0 -0
- data/test/more/{test_class_extension.rb → test_class_extend.rb} +6 -6
- data/test/{lore → more}/test_continuation.rb +0 -0
- data/test/{lore → more}/test_date.rb +0 -0
- data/test/more/{test_enumerablepass.rb → test_enumargs.rb} +2 -4
- data/test/more/{test_equatable.rb → test_equitable.rb} +2 -2
- data/test/more/{test_instantise.rb → test_instance_function.rb} +3 -2
- data/test/more/test_memoize.rb +1 -1
- data/test/{lore → more}/test_ostruct.rb +0 -0
- metadata +865 -1016
- data/RELEASE +0 -38
- data/doc/README.lore +0 -51
- data/doc/log/basic_stats/index.html +0 -39
- data/doc/log/changelog.html +0 -648
- data/doc/log/changelog.txt +0 -217
- data/doc/log/stats/index.html +0 -39
- data/doc/log/testlog.txt +0 -278
- data/doc/notes/CHANGES +0 -2529
- data/doc/rdoc/lore/classes/Array.html +0 -176
- data/doc/rdoc/lore/classes/CGI.html +0 -191
- data/doc/rdoc/lore/classes/Config.html +0 -135
- data/doc/rdoc/lore/classes/Continuation.html +0 -113
- data/doc/rdoc/lore/classes/Date.html +0 -631
- data/doc/rdoc/lore/classes/DateTime.html +0 -583
- data/doc/rdoc/lore/classes/Enumerable.html +0 -89
- data/doc/rdoc/lore/classes/Enumerable/Enumerator.html +0 -147
- data/doc/rdoc/lore/classes/File.html +0 -128
- data/doc/rdoc/lore/classes/FileUtils.html +0 -434
- data/doc/rdoc/lore/classes/GetoptLong.html +0 -118
- data/doc/rdoc/lore/classes/GetoptLong/DSL.html +0 -208
- data/doc/rdoc/lore/classes/Kernel.html +0 -135
- data/doc/rdoc/lore/classes/Logger.html +0 -229
- data/doc/rdoc/lore/classes/Logger/Ansicolor.html +0 -277
- data/doc/rdoc/lore/classes/Logger/LogDevice.html +0 -121
- data/doc/rdoc/lore/classes/NilClass.html +0 -119
- data/doc/rdoc/lore/classes/OpenStruct.html +0 -432
- data/doc/rdoc/lore/classes/Pathname.html +0 -353
- data/doc/rdoc/lore/classes/Set.html +0 -117
- data/doc/rdoc/lore/classes/Shellwords.html +0 -111
- data/doc/rdoc/lore/classes/String.html +0 -140
- data/doc/rdoc/lore/classes/Time.html +0 -154
- data/doc/rdoc/lore/classes/URI.html +0 -454
- data/doc/rdoc/lore/classes/URI/Hash.html +0 -105
- data/doc/rdoc/lore/classes/URI/Kernel.html +0 -122
- data/doc/rdoc/lore/classes/Zlib.html +0 -188
- data/doc/rdoc/lore/created.rid +0 -1
- data/doc/rdoc/lore/files/README.html +0 -286
- data/doc/rdoc/lore/files/doc/README_lore.html +0 -155
- data/doc/rdoc/lore/files/lib/lore/facets/basicobject_rb.html +0 -118
- data/doc/rdoc/lore/files/lib/lore/facets/cgi_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/continuation_rb.html +0 -147
- data/doc/rdoc/lore/files/lib/lore/facets/date_rb.html +0 -97
- data/doc/rdoc/lore/files/lib/lore/facets/enumerator_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/head_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/safe_ln_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/slice_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/tail_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/wc_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/whereis_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/which_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils_rb.html +0 -131
- data/doc/rdoc/lore/files/lib/lore/facets/getoptlong_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/logger_rb.html +0 -142
- data/doc/rdoc/lore/files/lib/lore/facets/ostruct_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/pathname_rb.html +0 -145
- data/doc/rdoc/lore/files/lib/lore/facets/rbconfig_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/set_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/shellwords_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/uri_rb.html +0 -125
- data/doc/rdoc/lore/files/lib/lore/facets/yaml_rb.html +0 -146
- data/doc/rdoc/lore/files/lib/lore/facets/zlib_rb.html +0 -97
- data/doc/rdoc/lore/fr_class_index.html +0 -73
- data/doc/rdoc/lore/fr_file_index.html +0 -71
- data/doc/rdoc/lore/fr_method_index.html +0 -177
- data/doc/rdoc/lore/index.html +0 -26
- data/doc/rdoc/lore/rdoc-style.css +0 -177
- data/doc/release-notes/RELEASE-2.0.5 +0 -8
- data/doc/release-notes/RELEASE-2.1.0 +0 -9
- data/doc/release-notes/RELEASE-2.1.1 +0 -5
- data/doc/release-notes/RELEASE-2.1.2 +0 -6
- data/doc/release-notes/RELEASE-2.1.3 +0 -5
- data/doc/release-notes/RELEASE-2.2.0 +0 -14
- data/doc/release-notes/RELEASE-2.2.1 +0 -4
- data/doc/release-notes/RELEASE-2.3.0 +0 -6
- data/doc/release-notes/RELEASE-2.4.0 +0 -70
- data/doc/release-notes/RELEASE-2.4.1 +0 -8
- data/doc/release-notes/RELEASE-2.4.2 +0 -4
- data/doc/release-notes/RELEASE-2.4.3 +0 -78
- data/doc/release-notes/RELEASE-2.4.4 +0 -38
- data/doc/release-notes/RELEASE-2.4.5 +0 -37
- data/doc/release-notes/RELEASE-2.5.0 +0 -83
- data/lib/core/facets/kernel/instance.rb +0 -19
- data/lib/lore/facets/basicobject.rb +0 -14
- data/lib/lore/facets/enumerator.rb +0 -67
- data/lib/lore/facets/logger.rb +0 -291
- data/lib/more/facets/1stclassmethod.rb +0 -140
- data/lib/more/facets/advisable.rb +0 -162
- data/lib/more/facets/association.rb +0 -210
- data/lib/more/facets/attr.rb +0 -209
- data/lib/more/facets/basex.rb +0 -37
- data/lib/more/facets/bbcode.rb +0 -397
- data/lib/more/facets/bicrypt.rb +0 -265
- data/lib/more/facets/binreadable.rb +0 -221
- data/lib/more/facets/censor.rb +0 -97
- data/lib/more/facets/classmethods.rb +0 -199
- data/lib/more/facets/consoleutils.rb +0 -99
- data/lib/more/facets/crypt.rb +0 -166
- data/lib/more/facets/dependency.rb +0 -151
- data/lib/more/facets/downloader.rb +0 -281
- data/lib/more/facets/duplicable.rb +0 -43
- data/lib/more/facets/elementor.rb +0 -133
- data/lib/more/facets/filter.rb +0 -121
- data/lib/more/facets/heap.rb +0 -22
- data/lib/more/facets/infinity.rb +0 -193
- data/lib/more/facets/ini.rb +0 -264
- data/lib/more/facets/instantise.rb +0 -1
- data/lib/more/facets/instantize.rb +0 -95
- data/lib/more/facets/interval.rb +0 -282
- data/lib/more/facets/iteration.rb +0 -65
- data/lib/more/facets/linkedlist.rb +0 -222
- data/lib/more/facets/lrucache.rb +0 -157
- data/lib/more/facets/matcher.rb +0 -140
- data/lib/more/facets/memoizer.rb +0 -74
- data/lib/more/facets/minitar.rb +0 -1063
- data/lib/more/facets/nackclass.rb +0 -41
- data/lib/more/facets/net/smtp_tls.rb +0 -131
- data/lib/more/facets/nilstatus.rb +0 -48
- data/lib/more/facets/overload.rb +0 -94
- data/lib/more/facets/paramix.rb +0 -202
- data/lib/more/facets/pool.rb +0 -91
- data/lib/more/facets/pqueue.rb +0 -449
- data/lib/more/facets/pry.rb +0 -32
- data/lib/more/facets/reflection.rb +0 -145
- data/lib/more/facets/semaphore.rb +0 -92
- data/lib/more/facets/settings.rb +0 -248
- data/lib/more/facets/snapshot.rb +0 -209
- data/lib/more/facets/sparse_array.rb +0 -809
- data/lib/more/facets/string/mask.rb +0 -278
- data/lib/more/facets/string/obfuscate.rb +0 -65
- data/lib/more/facets/string/stylize.rb +0 -169
- data/lib/more/facets/string/words.rb +0 -167
- data/lib/more/facets/syncarray.rb +0 -114
- data/lib/more/facets/synchash.rb +0 -157
- data/lib/more/facets/typecast.rb +0 -261
- data/lib/more/facets/uninheritable.rb +0 -50
- data/lib/more/facets/xmlhash.rb +0 -112
- data/lib/more/facets/xoxo.rb +0 -259
- data/lib/more/facets/ziputils.rb +0 -490
- data/task/conflicts +0 -63
- data/task/coverage.rake +0 -37
- data/task/methods +0 -49
- data/task/rdoc.rake +0 -17
- data/task/setup.rake +0 -38
- data/task/test.rake +0 -145
- data/test/more/test_advisable.rb +0 -71
- data/test/more/test_association.rb +0 -38
- data/test/more/test_bbcode.rb +0 -21
- data/test/more/test_binreadable.rb +0 -50
- data/test/more/test_buildable.rb +0 -73
- data/test/more/test_classmethods.rb +0 -56
- data/test/more/test_crypt.rb +0 -32
- data/test/more/test_dependency.rb +0 -69
- data/test/more/test_elementwise.rb +0 -25
- data/test/more/test_infinity.rb +0 -40
- data/test/more/test_interval.rb +0 -151
- data/test/more/test_linkedlist.rb +0 -41
- data/test/more/test_lrucache.rb +0 -14
- data/test/more/test_overload.rb +0 -160
- data/test/more/test_paramix.rb +0 -170
- data/test/more/test_prototype.rb +0 -35
- data/test/more/test_snapshot.rb +0 -21
- data/test/more/test_sparsearray.rb +0 -279
- data/test/more/test_syncarray.rb +0 -15
- data/test/more/test_synchash.rb +0 -16
- data/test/more/test_typecast.rb +0 -54
- data/test/more/test_uninheritable.rb +0 -31
- data/test/more/test_xoxo.rb +0 -274
- data/test/test_facets.rb +0 -9
@@ -1,41 +0,0 @@
|
|
1
|
-
# = NackClass
|
2
|
-
#
|
3
|
-
# Not Acknowledge. An alternatice to NilClass is cases where
|
4
|
-
# nil is a valid option, but an non-option still needs to
|
5
|
-
# be recorgnized.
|
6
|
-
#
|
7
|
-
# == Authors
|
8
|
-
#
|
9
|
-
# * Thomas Sawyer
|
10
|
-
#
|
11
|
-
# == Copying
|
12
|
-
#
|
13
|
-
# Copyright (c) 2004 Thomas Sawyer
|
14
|
-
#
|
15
|
-
# Ruby License
|
16
|
-
#
|
17
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
18
|
-
# software under the same terms as Ruby.
|
19
|
-
#
|
20
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
21
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
22
|
-
# FOR A PARTICULAR PURPOSE.
|
23
|
-
|
24
|
-
|
25
|
-
# = NackClass
|
26
|
-
#
|
27
|
-
# Not Acknowledge. An alternatice to NilClass is cases where
|
28
|
-
# nil is a valid option, but an non-option still needs to
|
29
|
-
# be recorgnized.
|
30
|
-
#
|
31
|
-
class NackClass < Exception
|
32
|
-
end
|
33
|
-
|
34
|
-
module Kernel
|
35
|
-
# This is a light version of NackClass intended
|
36
|
-
# for minor usecases. See mega/nack for a complete version.
|
37
|
-
#
|
38
|
-
def nack
|
39
|
-
NackClass.new
|
40
|
-
end
|
41
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
# TITLE:
|
2
|
-
#
|
3
|
-
# SMTP/TLS
|
4
|
-
#
|
5
|
-
# SUMMARY:
|
6
|
-
#
|
7
|
-
# SMTP with TLS support.
|
8
|
-
#
|
9
|
-
# COPYRIGHT:
|
10
|
-
#
|
11
|
-
# Copyright (c) 2006 Kyle Maxwell
|
12
|
-
#
|
13
|
-
# LICENSE:
|
14
|
-
#
|
15
|
-
# Ruby License
|
16
|
-
#
|
17
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
18
|
-
# software under the same terms as Ruby.
|
19
|
-
#
|
20
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
21
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
22
|
-
# FOR A PARTICULAR PURPOSE.
|
23
|
-
#
|
24
|
-
# HISTORY:
|
25
|
-
#
|
26
|
-
# Original code seems to be public domain. Modifications made by Kyle Maxwell were
|
27
|
-
# picked up from ar_mailer's version. Until someone else step foward, we'll give
|
28
|
-
# copyrights to Kyle.
|
29
|
-
#
|
30
|
-
# AUTHORS:
|
31
|
-
#
|
32
|
-
# - Kyle Maxwell
|
33
|
-
|
34
|
-
require "openssl"
|
35
|
-
require "net/smtp"
|
36
|
-
|
37
|
-
|
38
|
-
class Net::SMTP
|
39
|
-
|
40
|
-
class << self
|
41
|
-
send :remove_method, :start
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.start(address, port=nil, helo='localhost.localdomain', user=nil, secret=nil, authtype=nil, use_tls=false, &block) # :yield: smtp
|
45
|
-
new(address, port).start(helo, user, secret, authtype, use_tls, &block)
|
46
|
-
end
|
47
|
-
|
48
|
-
alias tls_old_start start
|
49
|
-
|
50
|
-
def start(helo='localhost.localdomain', user=nil, secret=nil, authtype=nil, use_tls=false) # :yield: smtp
|
51
|
-
start_method = use_tls ? :do_tls_start : :do_start
|
52
|
-
if block_given?
|
53
|
-
begin
|
54
|
-
send start_method, helo, user, secret, authtype
|
55
|
-
return yield(self)
|
56
|
-
ensure
|
57
|
-
do_finish
|
58
|
-
end
|
59
|
-
else
|
60
|
-
send start_method, helo, user, secret, authtype
|
61
|
-
return self
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def do_tls_start(helodomain, user, secret, authtype)
|
68
|
-
raise IOError, 'SMTP session already started' if @started
|
69
|
-
check_auth_args user, secret, authtype if user or secret
|
70
|
-
|
71
|
-
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
|
72
|
-
@socket = Net::InternetMessageIO.new(sock)
|
73
|
-
@socket.read_timeout = 60 #@read_timeout
|
74
|
-
@socket.debug_output = STDERR if $DEBUG #@debug_output
|
75
|
-
|
76
|
-
check_response(critical { recv_response() })
|
77
|
-
do_helo(helodomain)
|
78
|
-
|
79
|
-
raise 'openssl library not installed' unless defined?(OpenSSL)
|
80
|
-
starttls
|
81
|
-
ssl = OpenSSL::SSL::SSLSocket.new(sock)
|
82
|
-
ssl.sync_close = true
|
83
|
-
ssl.connect
|
84
|
-
@socket = Net::InternetMessageIO.new(ssl)
|
85
|
-
@socket.read_timeout = 60 #@read_timeout
|
86
|
-
@socket.debug_output = STDERR if $DEBUG #@debug_output
|
87
|
-
do_helo(helodomain)
|
88
|
-
|
89
|
-
authenticate user, secret, authtype if user
|
90
|
-
@started = true
|
91
|
-
ensure
|
92
|
-
unless @started
|
93
|
-
# authentication failed, cancel connection.
|
94
|
-
@socket.close if not @started and @socket and not @socket.closed?
|
95
|
-
@socket = nil
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def do_helo(helodomain)
|
100
|
-
begin
|
101
|
-
if @esmtp
|
102
|
-
ehlo helodomain
|
103
|
-
else
|
104
|
-
helo helodomain
|
105
|
-
end
|
106
|
-
rescue Net::ProtocolError
|
107
|
-
if @esmtp
|
108
|
-
@esmtp = false
|
109
|
-
@error_occured = false
|
110
|
-
retry
|
111
|
-
end
|
112
|
-
raise
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def starttls
|
117
|
-
getok('STARTTLS')
|
118
|
-
end
|
119
|
-
|
120
|
-
alias tls_old_quit quit
|
121
|
-
|
122
|
-
def quit
|
123
|
-
begin
|
124
|
-
getok('QUIT')
|
125
|
-
rescue EOFError
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
end unless Net::SMTP.private_method_defined? :do_tls_start or
|
130
|
-
Net::SMTP.method_defined? :tls?
|
131
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
class NilClass
|
2
|
-
|
3
|
-
# Nil#status makes it possible to pass messages
|
4
|
-
# through a "failure" chain.
|
5
|
-
#
|
6
|
-
# def foo
|
7
|
-
# return nil.status("failed foo!")
|
8
|
-
# end
|
9
|
-
#
|
10
|
-
# result = foo
|
11
|
-
# if result.nil?
|
12
|
-
# result.status? #=> true
|
13
|
-
# result.status #=> "failed foo!"
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# CREDIT: Trans
|
17
|
-
|
18
|
-
def status(status=nil)
|
19
|
-
if status
|
20
|
-
@status = status
|
21
|
-
self
|
22
|
-
else
|
23
|
-
@status
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Check status.
|
28
|
-
#
|
29
|
-
# def foo
|
30
|
-
# return nil.status("failed foo!")
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# result = foo
|
34
|
-
# if result.nil?
|
35
|
-
# result.status? #=> true
|
36
|
-
# result.status #=> "failed foo!"
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# CREDIT: Trans
|
40
|
-
|
41
|
-
def status?
|
42
|
-
return unless @status
|
43
|
-
return false if @status.empty?
|
44
|
-
return true
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
data/lib/more/facets/overload.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# = Overload
|
2
|
-
#
|
3
|
-
# Write methods with signitures.
|
4
|
-
#
|
5
|
-
# == Copying
|
6
|
-
#
|
7
|
-
# Copyright (c) 2005 Thomas Sawyer
|
8
|
-
#
|
9
|
-
# Ruby License
|
10
|
-
#
|
11
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
12
|
-
# software under the same terms as Ruby.
|
13
|
-
#
|
14
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
15
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
16
|
-
# FOR A PARTICULAR PURPOSE.
|
17
|
-
#
|
18
|
-
# == Authors
|
19
|
-
#
|
20
|
-
# * Thomas Sawyer
|
21
|
-
|
22
|
-
#
|
23
|
-
class Module
|
24
|
-
|
25
|
-
def method_overloads
|
26
|
-
@method_overloads ||= {}
|
27
|
-
end
|
28
|
-
|
29
|
-
# Overload methods.
|
30
|
-
#
|
31
|
-
# class X
|
32
|
-
# def x
|
33
|
-
# "hello"
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
# overload :x, Integer do |i|
|
37
|
-
# i
|
38
|
-
# end
|
39
|
-
#
|
40
|
-
# overload :x, String, String do |s1, s2|
|
41
|
-
# [s1, s2]
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
#
|
45
|
-
def overload( name, *signiture, &block )
|
46
|
-
raise ArgumentError unless signiture.all?{|s| s.instance_of?(Class)}
|
47
|
-
|
48
|
-
name = name.to_sym
|
49
|
-
|
50
|
-
if method_overloads.key?( name )
|
51
|
-
method_overloads[name][signiture] = block
|
52
|
-
|
53
|
-
else
|
54
|
-
method_overloads[name] = {}
|
55
|
-
method_overloads[name][signiture] = block
|
56
|
-
|
57
|
-
if method_defined?( name )
|
58
|
-
#method_overloads[name][nil] = instance_method( name ) #true
|
59
|
-
alias_method( "#{name}Generic", name )
|
60
|
-
has_generic = true
|
61
|
-
else
|
62
|
-
has_generic = false
|
63
|
-
end
|
64
|
-
|
65
|
-
define_method( name ) do |*args|
|
66
|
-
ovr = self.class.method_overloads["#{name}".to_sym]
|
67
|
-
sig = args.collect{ |a| a.class }
|
68
|
-
hit = nil
|
69
|
-
faces = ovr.keys #.sort { |a,b| b.size <=> a.size }
|
70
|
-
faces.each do |cmp|
|
71
|
-
next unless cmp.size == sig.size
|
72
|
-
if (0...cmp.size).all?{ |i| cmp[i] >= sig[i] }
|
73
|
-
break hit = cmp
|
74
|
-
end
|
75
|
-
end
|
76
|
-
if hit
|
77
|
-
ovr[hit].call(*args)
|
78
|
-
else
|
79
|
-
if has_generic #ovr[nil]
|
80
|
-
send( "#{name}Generic", *args )
|
81
|
-
#ovr[nil].bind(self).call(*args)
|
82
|
-
else
|
83
|
-
raise NoMethodError
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
data/lib/more/facets/paramix.rb
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
# TITLE:
|
2
|
-
#
|
3
|
-
# Parametric Mixins
|
4
|
-
#
|
5
|
-
# SUMMARY:
|
6
|
-
#
|
7
|
-
# Parametric Mixins provides parameters for mixin modules.
|
8
|
-
#
|
9
|
-
# COPYRIGHT:
|
10
|
-
#
|
11
|
-
# Copyright (c) 2008 T. Sawyer
|
12
|
-
#
|
13
|
-
# LICENSE:
|
14
|
-
#
|
15
|
-
# Ruby License
|
16
|
-
#
|
17
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
18
|
-
# software under the same terms as Ruby.
|
19
|
-
#
|
20
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
21
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
22
|
-
# FOR A PARTICULAR PURPOSE.
|
23
|
-
#
|
24
|
-
# AUTHORS:
|
25
|
-
#
|
26
|
-
# - Thomas Sawyer
|
27
|
-
|
28
|
-
require 'facets/module/basename'
|
29
|
-
require 'facets/module/modspace'
|
30
|
-
|
31
|
-
# = Parametric Mixin
|
32
|
-
#
|
33
|
-
# Parametric Mixins provides parameters for mixin modules.
|
34
|
-
# Module parameters can be set at the time of inclusion
|
35
|
-
# or extension using Module#[] method, then parameters
|
36
|
-
# can be accessed via the #mixin_parameters method.
|
37
|
-
#
|
38
|
-
# module MyMixin
|
39
|
-
# include Paramix
|
40
|
-
#
|
41
|
-
# def hello
|
42
|
-
# puts "Hello from #{mixin_parameters[MyMixin][:name]}!"
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# class MyClass
|
47
|
-
# include MyMixin[:name => 'Ruby']
|
48
|
-
# end
|
49
|
-
#
|
50
|
-
# m = MyClass.new
|
51
|
-
# m.hello #=> 'Hello from Ruby!'
|
52
|
-
#
|
53
|
-
# You can view the full set of parameters via the #mixin_parameters
|
54
|
-
# class method, which returns a hash keyed on the included modules.
|
55
|
-
#
|
56
|
-
# MyClass.mixin_parameters #=> {MyMixin=>{:name=>'Ruby'}}
|
57
|
-
# MyClass.mixin_parameters[MyMixin] #=> {:name=>'ruby'}
|
58
|
-
#
|
59
|
-
# The include Paramix is equivalent to:
|
60
|
-
#
|
61
|
-
# def [](parameters)
|
62
|
-
# Paramix.new(self, parameters)
|
63
|
-
# end
|
64
|
-
#
|
65
|
-
# Paramix.new can also take a block that injects code into the class
|
66
|
-
# or module including the parametric mixin. This is useful as an
|
67
|
-
# alternative to using the #included callback for creating dynamic
|
68
|
-
# mixins. For example:
|
69
|
-
#
|
70
|
-
# def self.[](parameters)
|
71
|
-
# Paramix.new(self, parameters) do
|
72
|
-
# attr_accessor mixin_params[MyMixin][:name]
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
#
|
76
|
-
# As opposed to:
|
77
|
-
#
|
78
|
-
# module Mixin
|
79
|
-
# def self.included(base)
|
80
|
-
# base.class_eval do
|
81
|
-
# attr_accessor mixin_params[MyMixin][:name]
|
82
|
-
# end
|
83
|
-
# end
|
84
|
-
# end
|
85
|
-
#
|
86
|
-
#--
|
87
|
-
# More conveniently a new callback has been added, #included_with_parameters,
|
88
|
-
# which passes in the parameters in addition to the base class/module.
|
89
|
-
#
|
90
|
-
# module Mixin
|
91
|
-
# def self.included_with_parameters( base, parms )
|
92
|
-
# base.class_eval {
|
93
|
-
# def hello
|
94
|
-
# puts "Hello from #{mixin_parameters[Mixin][:name]}"
|
95
|
-
# end
|
96
|
-
# }
|
97
|
-
# end
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# We would prefer to have passed the parameters through the #included callback
|
101
|
-
# method itself, but implementation of such a feature is much more complicated.
|
102
|
-
# If a reasonable solution presents itself in the future however, we will fix.
|
103
|
-
#++
|
104
|
-
|
105
|
-
module Paramix # or PatrametricMixin ?
|
106
|
-
|
107
|
-
def self.append_features(base)
|
108
|
-
(class << base; self; end).class_eval do
|
109
|
-
define_method(:[]) do |parameters| # TODO until 1.9 no &block
|
110
|
-
Delegator.new(base, parameters)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# It you want to define the module's ::[] method by hand. You
|
116
|
-
# can use Paramix.new instead of Paramix::Delegator.new.
|
117
|
-
|
118
|
-
def self.new(delegate_module, parameters={}, &base_block)
|
119
|
-
Delegator.new(delegate_module, parameters, &base_block)
|
120
|
-
end
|
121
|
-
|
122
|
-
#
|
123
|
-
|
124
|
-
class Delegator < Module
|
125
|
-
|
126
|
-
attr :module_delegate
|
127
|
-
attr :parameters
|
128
|
-
attr :base_block
|
129
|
-
|
130
|
-
#
|
131
|
-
|
132
|
-
def initialize(module_delegate, parameters={}, &base_block)
|
133
|
-
@module_delegate = module_delegate
|
134
|
-
@parameters = parameters
|
135
|
-
@base_block = base_block
|
136
|
-
end
|
137
|
-
|
138
|
-
#
|
139
|
-
|
140
|
-
def append_features(base)
|
141
|
-
base.mixin_parameters[module_delegate] = parameters
|
142
|
-
|
143
|
-
base.module_eval do
|
144
|
-
define_method(:mixin_parameters) do
|
145
|
-
base.mixin_parameters
|
146
|
-
end
|
147
|
-
alias_method :mixin_params, :mixin_parameters
|
148
|
-
end
|
149
|
-
|
150
|
-
base.module_eval(&@base_block) if base_block
|
151
|
-
|
152
|
-
base.__send__(:include, module_delegate)
|
153
|
-
end
|
154
|
-
|
155
|
-
#
|
156
|
-
|
157
|
-
def extend_object(base)
|
158
|
-
baseclass = (class << base; self; end)
|
159
|
-
|
160
|
-
baseclass.mixin_parameters[module_delegate] = parameters
|
161
|
-
|
162
|
-
baseclass.module_eval do
|
163
|
-
define_method(:mixin_parameters) do
|
164
|
-
baseclass.mixin_parameters
|
165
|
-
end
|
166
|
-
alias_method :mixin_params, :mixin_parameters
|
167
|
-
end
|
168
|
-
|
169
|
-
baseclass.module_eval(&@base_block) if base_block
|
170
|
-
|
171
|
-
base.__send__(:extend, module_delegate)
|
172
|
-
end
|
173
|
-
|
174
|
-
def [](name)
|
175
|
-
@parameters[name]
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
class Module
|
184
|
-
|
185
|
-
# Store for parametric mixin parameters.
|
186
|
-
#
|
187
|
-
# Returns a hash, the keys of which are the parametric mixin module
|
188
|
-
# and the values are the parameters associacted with this module/class.
|
189
|
-
#
|
190
|
-
# class C
|
191
|
-
# include P(:x=>1)
|
192
|
-
# end
|
193
|
-
#
|
194
|
-
# C.mixin_parameters[P] #=> {:x=>1}
|
195
|
-
#
|
196
|
-
def mixin_parameters
|
197
|
-
@mixin_parameters ||= {}
|
198
|
-
end
|
199
|
-
alias_method :mixin_params, :mixin_parameters
|
200
|
-
|
201
|
-
end
|
202
|
-
|