pantheios-ruby 0.10.1 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pantheios/core.rb +5 -3
- data/lib/pantheios/services/null_log_service.rb +77 -0
- data/lib/pantheios/services/simple_console_log_service.rb +84 -0
- data/lib/pantheios/version.rb +1 -1
- data/test/unit/services/tc_null_log_service.rb +88 -0
- data/test/unit/services/tc_simple_console_log_service.rb +87 -0
- data/test/unit/services/ts_all.rb +12 -0
- metadata +8 -4
- data/lib/pantheios/services/simple_console_service.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f17b99ae0e63f13c7cd21b0514d223e89308c4db
|
4
|
+
data.tar.gz: 78ab9f8852effb70635b021e2d766d2334748d51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1194d7902fc8fe1989522618c2c6725d6be8828dcd023248586fe5b4fb35eeb706fc5b8f4f04398781477e3d94567d3f399d58814bae801ad844e3521623cda2
|
7
|
+
data.tar.gz: 979c17e7c5774c35e4d9558901648de1ae3ff1294f4ad68e1144524b02a7451677e5b3c87db5c8e964933ab7fdd17735776109bbe458c698448824fa32f28064
|
data/lib/pantheios/core.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
# Purpose: The Pantheios.Ruby core (::Pantheios::Core)
|
6
6
|
#
|
7
7
|
# Created: 2nd April 2011
|
8
|
-
# Updated:
|
8
|
+
# Updated: 6th January 2018
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/Pantheios-Ruby
|
11
11
|
#
|
12
12
|
# Author: Matthew Wilson
|
13
13
|
#
|
14
|
-
# Copyright (c) 2011-
|
14
|
+
# Copyright (c) 2011-2018, Matthew Wilson and Synesis Software
|
15
15
|
# All rights reserved.
|
16
16
|
#
|
17
17
|
# Redistribution and use in source and binary forms, with or without
|
@@ -213,7 +213,7 @@ module Core
|
|
213
213
|
return @@state.set_service inst
|
214
214
|
end
|
215
215
|
|
216
|
-
@@state.set_service ::Pantheios::Services::
|
216
|
+
@@state.set_service ::Pantheios::Services::SimpleConsoleLogService.new
|
217
217
|
end
|
218
218
|
|
219
219
|
# Sets the front-end that will be used to evaluate whether a given log
|
@@ -443,4 +443,6 @@ module Core
|
|
443
443
|
end # Core
|
444
444
|
end # Pantheios
|
445
445
|
|
446
|
+
# ############################## end of file ############################# #
|
447
|
+
|
446
448
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
# ######################################################################## #
|
3
|
+
# File: lib/pantheios/services/simple_console_log_service.rb
|
4
|
+
#
|
5
|
+
# Purpose: Version for Pantheios.Ruby library
|
6
|
+
#
|
7
|
+
# Created: 14th June 2015
|
8
|
+
# Updated: 6th January 2018
|
9
|
+
#
|
10
|
+
# Home: http://github.com/synesissoftware/Pantheios-Ruby
|
11
|
+
#
|
12
|
+
# Author: Matthew Wilson
|
13
|
+
#
|
14
|
+
# Copyright (c) 2015-2018, Matthew Wilson and Synesis Software
|
15
|
+
# All rights reserved.
|
16
|
+
#
|
17
|
+
# Redistribution and use in source and binary forms, with or without
|
18
|
+
# modification, are permitted provided that the following conditions are
|
19
|
+
# met:
|
20
|
+
#
|
21
|
+
# * Redistributions of source code must retain the above copyright
|
22
|
+
# notice, this list of conditions and the following disclaimer.
|
23
|
+
#
|
24
|
+
# * Redistributions in binary form must reproduce the above copyright
|
25
|
+
# notice, this list of conditions and the following disclaimer in the
|
26
|
+
# documentation and/or other materials provided with the distribution.
|
27
|
+
#
|
28
|
+
# * Neither the names of the copyright holder nor the names of its
|
29
|
+
# contributors may be used to endorse or promote products derived from
|
30
|
+
# this software without specific prior written permission.
|
31
|
+
#
|
32
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
33
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
34
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
35
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
36
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
37
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
38
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
39
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
40
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
41
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
42
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
43
|
+
#
|
44
|
+
# ######################################################################## #
|
45
|
+
|
46
|
+
|
47
|
+
=begin
|
48
|
+
=end
|
49
|
+
|
50
|
+
module Pantheios
|
51
|
+
module Services
|
52
|
+
|
53
|
+
# A class that fulfils the Pantheios *LogService* protocol that disallows all
|
54
|
+
# severities and does nothing when asked to log
|
55
|
+
#
|
56
|
+
# NOTE: The *LogService* protocol is implemented by a class that provides
|
57
|
+
# the instance methods +severity_logged?(severity : Object) : boolean+ and
|
58
|
+
# +log(severity : Object, t : Time, prefix : String, msg : String)+
|
59
|
+
class NullLogService
|
60
|
+
|
61
|
+
def severity_logged? severity
|
62
|
+
|
63
|
+
false
|
64
|
+
end
|
65
|
+
|
66
|
+
def log sev, t, pref, msg
|
67
|
+
|
68
|
+
;
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end # module Services
|
73
|
+
end # module Pantheios
|
74
|
+
|
75
|
+
# ############################## end of file ############################# #
|
76
|
+
|
77
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
# ######################################################################## #
|
3
|
+
# File: lib/pantheios/services/simple_console_log_service.rb
|
4
|
+
#
|
5
|
+
# Purpose: Version for Pantheios.Ruby library
|
6
|
+
#
|
7
|
+
# Created: 14th June 2015
|
8
|
+
# Updated: 6th January 2018
|
9
|
+
#
|
10
|
+
# Home: http://github.com/synesissoftware/Pantheios-Ruby
|
11
|
+
#
|
12
|
+
# Author: Matthew Wilson
|
13
|
+
#
|
14
|
+
# Copyright (c) 2015-2018, Matthew Wilson and Synesis Software
|
15
|
+
# All rights reserved.
|
16
|
+
#
|
17
|
+
# Redistribution and use in source and binary forms, with or without
|
18
|
+
# modification, are permitted provided that the following conditions are
|
19
|
+
# met:
|
20
|
+
#
|
21
|
+
# * Redistributions of source code must retain the above copyright
|
22
|
+
# notice, this list of conditions and the following disclaimer.
|
23
|
+
#
|
24
|
+
# * Redistributions in binary form must reproduce the above copyright
|
25
|
+
# notice, this list of conditions and the following disclaimer in the
|
26
|
+
# documentation and/or other materials provided with the distribution.
|
27
|
+
#
|
28
|
+
# * Neither the names of the copyright holder nor the names of its
|
29
|
+
# contributors may be used to endorse or promote products derived from
|
30
|
+
# this software without specific prior written permission.
|
31
|
+
#
|
32
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
33
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
34
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
35
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
36
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
37
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
38
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
39
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
40
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
41
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
42
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
43
|
+
#
|
44
|
+
# ######################################################################## #
|
45
|
+
|
46
|
+
|
47
|
+
=begin
|
48
|
+
=end
|
49
|
+
|
50
|
+
module Pantheios
|
51
|
+
module Services
|
52
|
+
|
53
|
+
# A class that fulfils the Pantheios *LogService* protocol that sallows all
|
54
|
+
# severities and logs to the console (via +$stdout+ and +$stderr+)
|
55
|
+
#
|
56
|
+
# NOTE: The *LogService* protocol is implemented by a class that provides
|
57
|
+
# the instance methods +severity_logged?(severity : Object) : boolean+ and
|
58
|
+
# +log(severity : Object, t : Time, prefix : String, msg : String)+
|
59
|
+
class SimpleConsoleLogService
|
60
|
+
|
61
|
+
def severity_logged? severity
|
62
|
+
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def log sev, t, pref, msg
|
67
|
+
|
68
|
+
stm = infer_stream sev
|
69
|
+
|
70
|
+
stm.puts "#{pref}#{msg}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def infer_stream sev
|
74
|
+
|
75
|
+
(sev.to_i < 6) ? $stderr : $stdout
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end # module Services
|
80
|
+
end # module Pantheios
|
81
|
+
|
82
|
+
# ############################## end of file ############################# #
|
83
|
+
|
84
|
+
|
data/lib/pantheios/version.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# test/unit/services/tc_null_log_service.rb
|
4
|
+
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), '../../..', 'lib')
|
6
|
+
|
7
|
+
require 'pantheios/services/null_log_service'
|
8
|
+
|
9
|
+
require 'pantheios/application_layer/stock_severity_levels'
|
10
|
+
|
11
|
+
require 'xqsr3/extensions/test/unit'
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
|
15
|
+
require 'stringio'
|
16
|
+
|
17
|
+
class Test_NullLogservice < Test::Unit::TestCase
|
18
|
+
|
19
|
+
include ::Pantheios::Services
|
20
|
+
|
21
|
+
def test_NullLogService_type_exists
|
22
|
+
|
23
|
+
assert defined? NullLogService
|
24
|
+
end
|
25
|
+
|
26
|
+
if defined?(NullLogService)
|
27
|
+
|
28
|
+
def test_NullLogService_type_is_a_class
|
29
|
+
|
30
|
+
assert_kind_of(::Class, NullLogService)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_NullLogService_type_has_expected_instance_methods
|
34
|
+
|
35
|
+
assert_type_has_instance_methods NullLogService, [ :severity_logged?, :log ]
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_severity_logged_false_with_large_range_of_integers
|
39
|
+
|
40
|
+
svc = NullLogService.new
|
41
|
+
|
42
|
+
(-10000 .. 10000).each do |sev|
|
43
|
+
|
44
|
+
assert_false(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was logged")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_severity_logged_false_with_stock_severity_levels
|
49
|
+
|
50
|
+
svc = NullLogService.new
|
51
|
+
|
52
|
+
::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS.each do |sev|
|
53
|
+
|
54
|
+
assert_false(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was logged")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_log_does_nothing_to_standard_streams
|
59
|
+
|
60
|
+
prev_stdout, prev_stderr = $stdout, $stderr
|
61
|
+
|
62
|
+
begin
|
63
|
+
|
64
|
+
$stdout = StringIO.new
|
65
|
+
$stderr = StringIO.new
|
66
|
+
|
67
|
+
svc = NullLogService.new
|
68
|
+
t = Time.now
|
69
|
+
|
70
|
+
(-1000..1000).each do |sev|
|
71
|
+
|
72
|
+
svc.log sev, t, 'some-prefix', 'some-message'
|
73
|
+
end
|
74
|
+
|
75
|
+
stdout_s = $stdout.string
|
76
|
+
stderr_s = $stderr.string
|
77
|
+
|
78
|
+
assert_empty stdout_s, "NullLogService has written to $stdout!"
|
79
|
+
assert_empty stderr_s, "NullLogService has written to $stderr!"
|
80
|
+
ensure
|
81
|
+
|
82
|
+
$stdout, $stderr = prev_stdout, prev_stderr
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# test/unit/services/tc_simple_console_log_service.rb
|
4
|
+
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), '../../..', 'lib')
|
6
|
+
|
7
|
+
require 'pantheios/services/simple_console_log_service'
|
8
|
+
|
9
|
+
require 'pantheios/application_layer/stock_severity_levels'
|
10
|
+
|
11
|
+
require 'xqsr3/extensions/test/unit'
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
|
15
|
+
require 'stringio'
|
16
|
+
|
17
|
+
class Test_SimpleConsoleLogservice < Test::Unit::TestCase
|
18
|
+
|
19
|
+
include ::Pantheios::Services
|
20
|
+
|
21
|
+
def test_SimpleConsoleLogService_type_exists
|
22
|
+
|
23
|
+
assert defined? SimpleConsoleLogService
|
24
|
+
end
|
25
|
+
|
26
|
+
if defined?(SimpleConsoleLogService)
|
27
|
+
|
28
|
+
def test_SimpleConsoleLogService_type_is_a_class
|
29
|
+
|
30
|
+
assert_kind_of(::Class, SimpleConsoleLogService)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_SimpleConsoleLogService_type_has_expected_instance_methods
|
34
|
+
|
35
|
+
assert_type_has_instance_methods SimpleConsoleLogService, [ :severity_logged?, :log ]
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_severity_logged_false_with_large_range_of_integers
|
39
|
+
|
40
|
+
svc = SimpleConsoleLogService.new
|
41
|
+
|
42
|
+
(-10000 .. 10000).each do |sev|
|
43
|
+
|
44
|
+
assert_true(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was not logged")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_severity_logged_false_with_stock_severity_levels
|
49
|
+
|
50
|
+
svc = SimpleConsoleLogService.new
|
51
|
+
|
52
|
+
::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS.each do |sev|
|
53
|
+
|
54
|
+
assert_true(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was not logged")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_log_does_nothing_to_standard_streams
|
59
|
+
|
60
|
+
prev_stdout, prev_stderr = $stdout, $stderr
|
61
|
+
|
62
|
+
begin
|
63
|
+
|
64
|
+
$stdout = StringIO.new
|
65
|
+
$stderr = StringIO.new
|
66
|
+
|
67
|
+
svc = SimpleConsoleLogService.new
|
68
|
+
t = Time.now
|
69
|
+
|
70
|
+
(-1000..1000).each do |sev|
|
71
|
+
|
72
|
+
svc.log sev, t, 'some-prefix', 'some-message'
|
73
|
+
end
|
74
|
+
|
75
|
+
stdout_s = $stdout.string
|
76
|
+
stderr_s = $stderr.string
|
77
|
+
|
78
|
+
assert_not_empty stdout_s, "NullLogService has not written to $stdout!"
|
79
|
+
assert_not_empty stderr_s, "NullLogService has not written to $stderr!"
|
80
|
+
ensure
|
81
|
+
|
82
|
+
$stdout, $stderr = prev_stdout, prev_stderr
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# executes all other tests
|
4
|
+
|
5
|
+
this_dir = File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
# all tc_*rb in current directory
|
8
|
+
Dir[File.join(this_dir, 'tc_*rb')].each { |file| require file }
|
9
|
+
|
10
|
+
# all ts_*rb in immediate sub-directories
|
11
|
+
Dir[File.join(this_dir, '*', 'ts_*rb')].each { |file| require file }
|
12
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pantheios-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.21.1
|
20
20
|
- - <
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '1.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.21.1
|
30
30
|
- - <
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '1.0'
|
@@ -44,7 +44,8 @@ files:
|
|
44
44
|
- lib/pantheios/application_layer/stock_severity_levels.rb
|
45
45
|
- lib/pantheios/core.rb
|
46
46
|
- lib/pantheios/globals.rb
|
47
|
-
- lib/pantheios/services/
|
47
|
+
- lib/pantheios/services/null_log_service.rb
|
48
|
+
- lib/pantheios/services/simple_console_log_service.rb
|
48
49
|
- lib/pantheios/util.rb
|
49
50
|
- lib/pantheios/util/process_util.rb
|
50
51
|
- lib/pantheios/util/thread_util.rb
|
@@ -53,6 +54,9 @@ files:
|
|
53
54
|
- test/unit/application_layer/tc_param_name_list.rb
|
54
55
|
- test/unit/application_layer/tc_stock_severity_levels.rb
|
55
56
|
- test/unit/application_layer/ts_all.rb
|
57
|
+
- test/unit/services/tc_null_log_service.rb
|
58
|
+
- test/unit/services/tc_simple_console_log_service.rb
|
59
|
+
- test/unit/services/ts_all.rb
|
56
60
|
- test/unit/ts_all.rb
|
57
61
|
- test/unit/util/tc_thread_util.rb
|
58
62
|
- test/unit/util/tc_version_util.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
|
2
|
-
module Pantheios
|
3
|
-
module Services
|
4
|
-
|
5
|
-
class SimpleConsoleService
|
6
|
-
|
7
|
-
def severity_logged? severity
|
8
|
-
|
9
|
-
true
|
10
|
-
end
|
11
|
-
|
12
|
-
def log sev, t, pref, msg
|
13
|
-
|
14
|
-
$stderr.puts "#{pref}#{msg}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end # module Services
|
19
|
-
end # module Pantheios
|
20
|
-
|