maillinks 0.1.5 → 0.2.1

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/lib/log.conf DELETED
@@ -1,53 +0,0 @@
1
- #encoding: UTF-8
2
- =begin
3
- /***************************************************************************
4
- * ©2013 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
- * *
6
- * This program is free software; you can redistribute it and/or modify *
7
- * it under the terms of the GNU General Public License as published by *
8
- * the Free Software Foundation; either version 3 of the License, or *
9
- * (at your option) any later version. *
10
- * *
11
- * This program is distributed in the hope that it will be useful, *
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
- * GNU General Public License for more details. *
15
- * *
16
- * You should have received a copy of the GNU General Public License *
17
- * along with this program; if not, write to the *
18
- * Free Software Foundation, Inc., *
19
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
- ***************************************************************************/
21
-
22
- A simplified logger configuration. Set the level for each individual logger
23
- below. Choose a different log-device or log-file if you like. Keep the
24
- formatting intact. Do not change other sections of this file.
25
- =end
26
-
27
- # Do not touch from here ----->
28
- require 'logger'
29
-
30
- debug = Logger::DEBUG
31
- info = Logger::INFO
32
- error = Logger::ERROR
33
- fatal = Logger::FATAL
34
- warn = Logger::WARN
35
- unknown = Logger::UNKNOWN
36
- {
37
- # <---------------- to here !
38
-
39
- # Enter your settings here, but take into consideration that not all
40
- # the named classes will really produce readable output. Well, you can
41
- # always try... Either name just the log-level or make the log-level
42
- # precede the output-device or output-file like in the examples.
43
-
44
- # Example: naming a log-file
45
- # :HtmlBuilder => [info, 'C:\temp\htmlbuilder.log']
46
- # :HtmlBuilder => [debug, '/tmp/htmlbuilder.log'],
47
-
48
- :MailLinks => info,
49
-
50
- # And ignore the remainder, too.
51
- }
52
-
53
- #eof
data/lib/logging.rb DELETED
@@ -1,104 +0,0 @@
1
- #encoding: UTF-8
2
- =begin
3
- /***************************************************************************
4
- * ©2011-2014 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
- * *
6
- * This program is free software; you can redistribute it and/or modify *
7
- * it under the terms of the GNU General Public License as published by *
8
- * the Free Software Foundation; either version 3 of the License, or *
9
- * (at your option) any later version. *
10
- * *
11
- * This program is distributed in the hope that it will be useful, *
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
- * GNU General Public License for more details. *
15
- * *
16
- * You should have received a copy of the GNU General Public License *
17
- * along with this program; if not, write to the *
18
- * Free Software Foundation, Inc., *
19
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
- ***************************************************************************/
21
- =end
22
- require 'logger'
23
- require_relative 'translating'
24
-
25
- # Creates for each implementing object a member @log and precede its
26
- # output with the name of the class of the object.
27
- module Logging
28
- include Translating
29
- include File_Checking
30
-
31
- @@have_log = false
32
- @@LOG_CONF = File.dirname(File.absolute_path(__FILE__)) << File::Separator << 'log.conf'
33
-
34
- def init_logger(target = STDOUT, level = Logger::INFO)
35
- # allow to override the set log-levels with an
36
- # external configuration (log.conf).
37
- log_conf
38
- # Or use the defaults as set here or elsewhere...
39
-
40
- @level ||= level
41
- @target ||= target
42
-
43
- @log = Logger.new(@target)
44
- @log.level = @level
45
-
46
- @log.formatter = proc do |severity, datetime, progname, msg|
47
- t = Time.now
48
- "#{self.class.name}: #{severity} #{t.hour}-#{t.min}-#{t.sec}: #{msg}\n"
49
- end
50
- if ! @@have_log
51
- @log.debug self.class.name.dup << ' reading logging-configuration from ' << @@LOG_CONF
52
- @@have_log = true
53
- end
54
-
55
- end
56
-
57
- def log_target=(target)
58
- @target = target
59
- @log = Logger.new(@@target)
60
- @log.level = @level
61
- end
62
- def log_level=(level)
63
- @level = level
64
- @log.level = @level
65
- end
66
-
67
- private
68
- # Override or set the log-level and target-device, as set in a file 'log.conf'.
69
- # I do not like the look of this, but it works just the way I want it to.
70
- # "HEAVANS! Isn't there a standard way to do this in Ruby, for Christ's sake?", you say.
71
- # Heck, I don't care. <= Read that again, I say.
72
- def log_conf
73
- config = level = target = nil
74
- if(File.exist?(@@LOG_CONF) )
75
- begin
76
- conf = File.read(@@LOG_CONF)
77
- config = instance_eval(conf)
78
- rescue Exception => ex
79
- STDERR.puts trl("WARNING! Cannot evaluate the logger-configuration!") << ' ' << ex.message
80
- STDERR.puts trl("Default log-levels apply.")
81
- end
82
- else
83
- puts trl("Default log-levels apply.")
84
- end
85
-
86
- if(config && config.respond_to?(:to_hash) )
87
- config.default = nil
88
- config = config[self.class.name.to_sym]
89
- if(config )
90
- if(config.respond_to?(:to_ary) && config.size == 2)
91
- @level, @target = config
92
- logdir = File.dirname(@target)
93
- msg = file_check(logdir, :exist?, :directory?, :writable?)
94
- if(msg)
95
- STDERR.puts trl("WARNING! A logfile for '%s' cannot be written to %s (%s)!") %[self.class.name, logdir, msg]
96
- @target = nil
97
- end
98
- else
99
- @level = config
100
- end
101
- end
102
- end
103
- end
104
- end
data/lib/translating.rb DELETED
@@ -1,89 +0,0 @@
1
- #encoding: UTF-8
2
- =begin
3
- /***************************************************************************
4
- * ©2011-2014, Michael Uplawski *
5
- * <michael.uplawski@uplawski.eu> *
6
- * *
7
- * This program is free software; you can redistribute it and/or modify *
8
- * it under the terms of the GNU General Public License as published by *
9
- * the Free Software Foundation; either version 3 of the License, or *
10
- * (at your option) any later version. *
11
- * *
12
- * This program is distributed in the hope that it will be useful, *
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
- * GNU General Public License for more details. *
16
- * *
17
- * You should have received a copy of the GNU General Public License *
18
- * along with this program; if not, write to the *
19
- * Free Software Foundation, Inc., *
20
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
- ***************************************************************************/
22
- =end
23
-
24
-
25
- RD = File.expand_path(File.dirname(__FILE__) ) + File::SEPARATOR if !defined?(RD)
26
-
27
- require 'yaml'
28
- require_relative 'file_checking'
29
-
30
-
31
- # A way to produce translated text in a ruby-program.
32
- # Translations are read from a file "translations" in the program folder.
33
- module Translating
34
- # There are better ways to extend a translated
35
- # string, but I keep the 'wild-card' for
36
- # historical reasons.
37
- @@awild = 'XX'
38
-
39
- @@lang = nil
40
- @@lang_file = format("%s%s", RD, 'LANG')
41
- @@tr = YAML::load_file("#{RD}translations")
42
-
43
- # find the current language-setting and return it.
44
- def self.language()
45
- if @@lang == nil
46
- r = ENV['LANG']
47
- if(r)
48
- @@lang = r[0, 2]
49
- elsif( !File_Checking::file_check(@@lang_file, [:exist?, :readable?]) && File::size(@@lang_file) >= 2)
50
- File::open(@@lang_file, 'r') {|f| @@lang = f.readline}
51
- @@lang.chomp!.downcase! if @@lang
52
- end
53
- end
54
- @@lang = 'en' if !@@lang
55
- end
56
-
57
- # Translate a string to the currently set langage.
58
- # The args parameter may contain replacement-text which
59
- # will appear at the positions indicated by wildcard-characters
60
- # in the original string.
61
- def self.trl(t, *args)
62
- Translating::language()
63
- lt = @@tr[t]
64
- if(lt)
65
- lt = lt[@@lang]
66
- else
67
- # File.open('/tmp/mtf', 'a+') {|f| f << t << "\n"}
68
- puts "\nTRANSLATION MISSING: \"" << t << "\""
69
- end
70
- lt ||= t
71
- if(args && !args.empty?)
72
- i = -1
73
- lt = lt.gsub(@@awild) do |a|
74
- i += 1
75
- args.flatten[i]
76
- end
77
- lt += args[i + 1, args.length].join
78
- end
79
- return lt
80
- end
81
-
82
- # Translate a string to the currently set langage.
83
- # The args parameter may contain replacement-text which
84
- # will appear at the positions indicated by wildcard-characters
85
- # in the original string.
86
- def trl(t, *args )
87
- Translating::trl(t, args)
88
- end
89
- end
data/lib/translations DELETED
@@ -1,24 +0,0 @@
1
- # Copyright (c) 2011, Michael Uplawski <michael.uplawski@uplawski.eu>
2
- # This program is free software; you can redistribute it and/or modify
3
- # it under the terms of the GNU General Public License as published by
4
- # the Free Software Foundation; either version 3 of the License, or
5
- # (at your option) any later version.
6
- #
7
- # This program is distributed in the hope that it will be useful,
8
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- # GNU General Public License for more details.
11
- #
12
- # You should have received a copy of the GNU General Public License
13
- # along with this program; if not, write to the
14
- # Free Software Foundation, Inc.,
15
- # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
- # =========================================================================
17
- # These are the messages printed by Crème Fraîche. The first line of each
18
- # block is the original english message, the following lines contain the
19
- # translations for different locales.
20
-
21
- # Keep this key 'MailLinks' as it is
22
-
23
- MailLinks:
24
-