maillinks 0.1.4 → 0.1.5
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/file_checking.rb +49 -49
- data/lib/logging.rb +67 -67
- data/lib/translating.rb +52 -52
- data/maillinks.gemspec +4 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9ddd8c146601f10b5eeaecac7b4506a0209d63edf79bd3d99ac5d412052f256
|
4
|
+
data.tar.gz: 3a1fffa950cd72207d112cfc04f26e9ed320385fd607da88ab0b0cae3e229f8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a2256ca4aaede437a9ab20c2271486fcf6f69d9d7f33121ba93b11e59481d29f42e957763a782cad55b8d43123708edf9ed836d4d2c42ad4f0fa23cf07efda5
|
7
|
+
data.tar.gz: a3c84d3358e05df4000b343a4ff3443af715bb85bb06f4bdf6d68a6e169d411f05c2552eaf5760c1ee954c0a571f53134fe64c1a4ee056a0709d3a9b77a96a71
|
data/lib/file_checking.rb
CHANGED
@@ -26,57 +26,57 @@ file-system objects
|
|
26
26
|
=end
|
27
27
|
module File_Checking
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
@@text_messages = {
|
30
|
+
:exist? => "does not exist!",
|
31
|
+
:exist => "does not exist!",
|
32
|
+
:readable? => "is not readable!",
|
33
|
+
:readable => "is not readable!",
|
34
|
+
:executable? => "is not executable!",
|
35
|
+
:executable => "is not executable!",
|
36
|
+
:writable? => "is not writable!",
|
37
|
+
:writable => "is not writable!",
|
38
|
+
:directory? => "is not a directory!",
|
39
|
+
:directory => "is not a directory!",
|
40
|
+
:file? => "is not a file!",
|
41
|
+
:file => "is not a file!",
|
42
|
+
}
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
44
|
+
# Checks if the file with the name from the first
|
45
|
+
# parameter has the properties, listed in the second.
|
46
|
+
# The messages parameter is an array of one or several
|
47
|
+
# of :exist?, :readable?, :writable?, :directory? or
|
48
|
+
# their string-representations, respectively.
|
49
|
+
# Returns nil in case of success, otherwise an
|
50
|
+
# informative message, describing the first negative
|
51
|
+
# test-result.
|
52
|
+
def file_check(file, *messages)
|
53
|
+
File_Checking.file_check(file, *messages)
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
56
|
+
# Checks if the file with the name from the first
|
57
|
+
# parameter has the properties, listed in the second.
|
58
|
+
# The messages parameter is an array of one or all
|
59
|
+
# of :exist?, :readable?, :writable?, :directory? or
|
60
|
+
# their string-representations, respectively.
|
61
|
+
# Returns nil in case of success, otherwise an
|
62
|
+
# informative message, describing the first negative
|
63
|
+
# test-result.
|
64
|
+
def self.file_check(file, *messages)
|
65
|
+
msg = nil
|
66
|
+
if(file && messages.respond_to?(:to_ary) && !messages.empty?)
|
67
|
+
messages.each do |k|
|
68
|
+
if(! k.to_s.end_with?('?'))
|
69
|
+
k = (k.to_s << '?').to_sym
|
70
|
+
end
|
71
|
+
@log.debug ('checking ' << k.to_s) if @log
|
72
|
+
if(msg == nil && File.respond_to?(k) && ! File.send(k, file.to_s))
|
73
|
+
msg = "#{file} #{@@text_messages[k.to_sym]}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
msg
|
78
|
+
end
|
79
|
+
alias :check_file :file_check
|
80
80
|
end
|
81
81
|
|
82
82
|
=begin
|
data/lib/logging.rb
CHANGED
@@ -25,80 +25,80 @@ require_relative 'translating'
|
|
25
25
|
# Creates for each implementing object a member @log and precede its
|
26
26
|
# output with the name of the class of the object.
|
27
27
|
module Logging
|
28
|
-
|
29
|
-
|
28
|
+
include Translating
|
29
|
+
include File_Checking
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
@@have_log = false
|
32
|
+
@@LOG_CONF = File.dirname(File.absolute_path(__FILE__)) << File::Separator << 'log.conf'
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
39
|
|
40
|
-
|
41
|
-
|
40
|
+
@level ||= level
|
41
|
+
@target ||= target
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
@log = Logger.new(@target)
|
44
|
+
@log.level = @level
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
54
|
|
55
|
-
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
104
|
end
|
data/lib/translating.rb
CHANGED
@@ -31,59 +31,59 @@ require_relative 'file_checking'
|
|
31
31
|
# A way to produce translated text in a ruby-program.
|
32
32
|
# Translations are read from a file "translations" in the program folder.
|
33
33
|
module Translating
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
39
|
+
@@lang = nil
|
40
|
+
@@lang_file = format("%s%s", RD, 'LANG')
|
41
|
+
@@tr = YAML::load_file("#{RD}translations")
|
56
42
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
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
|
81
56
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
89
|
end
|
data/maillinks.gemspec
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'maillinks'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '
|
5
|
+
s.version = '0.1.5'
|
6
|
+
s.date = Date.today.strftime('%Y-%m-%d')
|
5
7
|
s.summary = "runtime requirements, URLs better parsed, because the whole Quoted Printable decoding is done correctly, now."
|
6
8
|
s.description = "Marks in an email HTMl-links and creates a list of all links at the bottom of the mail-text. Best used with the Mutt MUA"
|
7
9
|
s.authors = ["Michael Uplawski"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maillinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Uplawski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -111,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements:
|
113
113
|
- Linux, text-browser W3M
|
114
|
-
|
115
|
-
rubygems_version: 2.7.6
|
114
|
+
rubygems_version: 3.2.0.rc.2
|
116
115
|
signing_key:
|
117
116
|
specification_version: 4
|
118
117
|
summary: runtime requirements, URLs better parsed, because the whole Quoted Printable
|