cayuga 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dd3c6bc284e88b29c92830f3c61bbc8daf0c0fb8ea3c897ec944dfb4bd00d37
|
4
|
+
data.tar.gz: 48025310872a2af12849560ad82ab0610e7109001039192d8dfa33356d096f15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5971b7e037f68c0254bdab4abe8729039dc7ddb59c326ef879af231528361df3e9de9b2590b5ed5716eaa8011e6fa3613119613145c88583c7e21e58f1a2e5d4
|
7
|
+
data.tar.gz: c282550d6ccc7d9759be9a7db75ff23680632a1a15da2ff0fd04b2804543289d04307a084a1976e8f2b2a2ea71ad2679e2521c372227f37514055093d8e08560
|
@@ -2,14 +2,11 @@
|
|
2
2
|
# Copyright (c) 2018 Patrick Thomas. All rights reserved.
|
3
3
|
#
|
4
4
|
require 'cayuga'
|
5
|
-
require 'cayuga/object/factory_helper_shared'
|
6
5
|
|
7
6
|
module Cayuga
|
8
7
|
module Object
|
9
8
|
# noinspection RubyModuleAsSuperclassInspection
|
10
9
|
class Constants < Singleton
|
11
|
-
include FactoryHelperShared
|
12
|
-
|
13
10
|
def constant(constant)
|
14
11
|
constants[constant.symbolize]
|
15
12
|
end
|
@@ -32,9 +29,9 @@ module Cayuga
|
|
32
29
|
|
33
30
|
def initialize(factory, configuration)
|
34
31
|
super
|
35
|
-
@constants =
|
36
|
-
@directories =
|
37
|
-
@files =
|
32
|
+
@constants = configuration[:constants]
|
33
|
+
@directories = configuration[:directories]
|
34
|
+
@files = configuration[:files]
|
38
35
|
end
|
39
36
|
|
40
37
|
end
|
@@ -5,7 +5,6 @@ require 'json'
|
|
5
5
|
require 'ice_nine'
|
6
6
|
require 'ice_nine/core_ext/object'
|
7
7
|
require 'cayuga'
|
8
|
-
require 'cayuga/object/factory_helper_shared'
|
9
8
|
require 'cayuga/object/factory_helper'
|
10
9
|
|
11
10
|
module Cayuga
|
@@ -13,10 +12,9 @@ module Cayuga
|
|
13
12
|
# Cayuga Object Factory
|
14
13
|
class Factory
|
15
14
|
include Tools::Loggable
|
16
|
-
include FactoryHelperShared
|
17
15
|
include FactoryHelper
|
18
16
|
|
19
|
-
attr_reader :configuration_name
|
17
|
+
attr_reader :configuration_name
|
20
18
|
|
21
19
|
def logger
|
22
20
|
@logger ||= self[Cayuga::Object::Logger]
|
@@ -84,16 +82,16 @@ module Cayuga
|
|
84
82
|
|
85
83
|
private
|
86
84
|
|
87
|
-
attr_reader :configuration, :types, :instances
|
85
|
+
attr_reader :configuration, :types, :instances
|
88
86
|
|
89
87
|
def initialize(config)
|
90
88
|
@configuration =
|
91
89
|
JSON.parse(File.read(config), symbolize_names: true).deep_freeze
|
92
|
-
@configuration_name =
|
90
|
+
@configuration_name = :configuration_name
|
93
91
|
setup_types
|
94
92
|
@instances = {}
|
95
|
-
|
96
|
-
|
93
|
+
setup_primary_configurations
|
94
|
+
log_missing_keys unless missing_keys.empty?
|
97
95
|
end
|
98
96
|
|
99
97
|
end
|
@@ -8,12 +8,57 @@ module Cayuga
|
|
8
8
|
module Object
|
9
9
|
# Cayuga Object Factory Helper
|
10
10
|
module FactoryHelper
|
11
|
+
attr_reader :_constants, :_directories, :_files
|
12
|
+
attr_reader :_logs_annotation_marker, :_logs_directory
|
13
|
+
|
11
14
|
private
|
12
15
|
|
16
|
+
attr_reader :missing_keys
|
17
|
+
|
13
18
|
OBJECTS = {
|
14
19
|
singletons: %w[Cayuga::Object::Logger Cayuga::Object::Constants]
|
15
20
|
}.deep_freeze
|
16
21
|
|
22
|
+
def log_missing_keys
|
23
|
+
logger
|
24
|
+
missing_keys.each do |key|
|
25
|
+
log.warn('missing key', key: key, configuration: configuration_name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_primary_configurations
|
30
|
+
@missing_keys = Set.new
|
31
|
+
@configuration_name = setup_constant(
|
32
|
+
configuration, :configuration_name, 'Missing Name'
|
33
|
+
)
|
34
|
+
setup_primary_keys
|
35
|
+
setup_log_configuration
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup_primary_keys
|
39
|
+
@_constants = setup_constant(configuration, :constants, {}).deep_freeze
|
40
|
+
@_directories =
|
41
|
+
setup_constant(configuration, :directories, {}).deep_freeze
|
42
|
+
@_files = setup_constant(configuration, :files, {}).deep_freeze
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_log_configuration
|
46
|
+
@_logs_annotation_marker = setup_constant(
|
47
|
+
_constants, :log_annotation_marker, '-missing-marker'
|
48
|
+
).freeze
|
49
|
+
@_logs_directory = setup_constant(_directories, :logs, 'logs').freeze
|
50
|
+
end
|
51
|
+
|
52
|
+
def setup_constant(source, key, default)
|
53
|
+
case source.key?(key)
|
54
|
+
when true
|
55
|
+
source[key]
|
56
|
+
else
|
57
|
+
@missing_keys.add(key)
|
58
|
+
default
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
17
62
|
def setup_types
|
18
63
|
@types = {}
|
19
64
|
register_classes(configuration[:object_classes], :object)
|
data/lib/cayuga/object/logger.rb
CHANGED
@@ -12,7 +12,7 @@ module Cayuga
|
|
12
12
|
|
13
13
|
def generic_log_file(name)
|
14
14
|
filename = name.stringify.filenamify('.log')
|
15
|
-
"#{factory.
|
15
|
+
"#{factory._logs_directory}/#{filename}"
|
16
16
|
end
|
17
17
|
|
18
18
|
def log_names
|
@@ -46,10 +46,10 @@ module Cayuga
|
|
46
46
|
unless log_log?(name)
|
47
47
|
remove_any_orphan_appender(name)
|
48
48
|
make_appender(name, filename, stream, filter, level)
|
49
|
+
logger.info('log created', name: name, annotation: fetch_annotation)
|
50
|
+
logger.debug('logs', log_names: log_names)
|
51
|
+
logger.debug('logs', count: SemanticLogger.appenders.count)
|
49
52
|
end
|
50
|
-
logger.info('log created', name: name)
|
51
|
-
logger.debug('logs', log_names: log_names)
|
52
|
-
logger.debug('logs', count: SemanticLogger.appenders.count)
|
53
53
|
log_filename(name)
|
54
54
|
end
|
55
55
|
|
@@ -69,8 +69,7 @@ module Cayuga
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def fetch_annotation
|
72
|
-
|
73
|
-
value.nil? ? '' : value
|
72
|
+
factory._logs_annotation_marker
|
74
73
|
end
|
75
74
|
|
76
75
|
def create_logs
|
@@ -87,7 +86,7 @@ module Cayuga
|
|
87
86
|
def make_appender(name, filename, stream, filter, level)
|
88
87
|
if stream.nil?
|
89
88
|
if filename.nil?
|
90
|
-
filename = factory.
|
89
|
+
filename = factory._logs_directory + '/' + name.classify.log_file
|
91
90
|
end
|
92
91
|
log = SemanticLogger.add_appender(file_name: filename, filter: filter)
|
93
92
|
else
|
@@ -102,7 +101,11 @@ module Cayuga
|
|
102
101
|
def remove_any_orphan_appender(name)
|
103
102
|
return if log_log?(name)
|
104
103
|
return unless log_appender_exists?(name)
|
105
|
-
logger.warn(
|
104
|
+
logger.warn(
|
105
|
+
'log without registration',
|
106
|
+
name: name,
|
107
|
+
configuration: configuration_name
|
108
|
+
)
|
106
109
|
logger.debug('log without registration', log: log_names)
|
107
110
|
SemanticLogger.remove_appender(log_appender(name))
|
108
111
|
end
|
data/lib/cayuga/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cayuga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- patrick
|
@@ -129,7 +129,6 @@ files:
|
|
129
129
|
- lib/cayuga/object/constants.rb
|
130
130
|
- lib/cayuga/object/factory.rb
|
131
131
|
- lib/cayuga/object/factory_helper.rb
|
132
|
-
- lib/cayuga/object/factory_helper_shared.rb
|
133
132
|
- lib/cayuga/object/logger.rb
|
134
133
|
- lib/cayuga/object/named_object.rb
|
135
134
|
- lib/cayuga/object/object.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2018 Patrick Thomas. All rights reserved.
|
3
|
-
#
|
4
|
-
require 'ice_nine'
|
5
|
-
require 'ice_nine/core_ext/object'
|
6
|
-
|
7
|
-
module Cayuga
|
8
|
-
module Object
|
9
|
-
# Cayuga Object Factory Helper Shared
|
10
|
-
module FactoryHelperShared
|
11
|
-
private
|
12
|
-
|
13
|
-
def primary_configuration(key, type: Hash)
|
14
|
-
if configuration.key? key
|
15
|
-
configuration[key]
|
16
|
-
else
|
17
|
-
log.warn('missing key in configuration', key: key, type: type.name )
|
18
|
-
type.new
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|