cayuga 0.0.16 → 0.0.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d50fe8ce3348011a524be668a3409de19f144d9ed54150c3d6e0991c143f95a
4
- data.tar.gz: 29057f914e65f8b68d02e4ad76ac89a1a5dd5077426bae2e291ea393e1939824
3
+ metadata.gz: 28806f913a01ae797e4751924b71bbdead9a425575051711c430c8327e75b1cb
4
+ data.tar.gz: ece3a5e21f131ee8f490bb3ac42b22afdd94741a5574a7b42371314e34a305bd
5
5
  SHA512:
6
- metadata.gz: 0d3d861a7da42d38e39ea709a74ecd66369d3a0091dbbbb0482b9feedba7142882138b6787c15693975adc45e263122c3261181fccce57e0a45f5cf7278c44a4
7
- data.tar.gz: e74fd9bda2736773e5640e0963716387e8d22ed8a4fdb774763622189c9f4226ab633ed7cb923a578775ddc3e14ad76f3d3f5ff000e27e367084c83919847c2e
6
+ metadata.gz: dd7623054ed934575f1455a6430c793c6ee82eea54890730a87a38316cea06b1a0f0549e7fc8cc96a4cb57900bea157eb8bca048cc6849767004c460ddc9f4e5
7
+ data.tar.gz: '01792132b0cbf8eb613a35c8d0b5d0d05dac6ab10453c39e615b2396a30ca01cc37cf02b5fdd426939efa74fe9620bf2b673e8382cf57c19771a832aa20367c5'
@@ -2,11 +2,14 @@
2
2
  # Copyright (c) 2018 Patrick Thomas. All rights reserved.
3
3
  #
4
4
  require 'cayuga'
5
+ require 'cayuga/object/factory_helper_shared'
5
6
 
6
7
  module Cayuga
7
8
  module Object
8
9
  # noinspection RubyModuleAsSuperclassInspection
9
10
  class Constants < Singleton
11
+ include FactoryHelperShared
12
+
10
13
  def constant(constant)
11
14
  constants[constant.symbolize]
12
15
  end
@@ -21,10 +24,6 @@ module Cayuga
21
24
  files[constant.symbolize]
22
25
  end
23
26
 
24
- def repository(constant)
25
- repositories[constant.symbolize]
26
- end
27
-
28
27
  private_class_method :new
29
28
 
30
29
  private
@@ -33,10 +32,9 @@ module Cayuga
33
32
 
34
33
  def initialize(factory, configuration)
35
34
  super
36
- @constants = configuration[:constants]
37
- @directories = configuration[:directories]
38
- @files = configuration[:files]
39
- @repositories = configuration[:repositories]
35
+ @constants = primary_configuration(:constants)
36
+ @directories = primary_configuration(:directories)
37
+ @files = primary_configuration(:files)
40
38
  end
41
39
 
42
40
  end
@@ -5,14 +5,16 @@ require 'json'
5
5
  require 'ice_nine'
6
6
  require 'ice_nine/core_ext/object'
7
7
  require 'cayuga'
8
- require_relative 'factory_helper.rb'
8
+ require 'cayuga/object/factory_helper_shared'
9
+ require 'cayuga/object/factory_helper'
9
10
 
10
11
  module Cayuga
11
12
  module Object
12
13
  # Cayuga Object Factory
13
14
  class Factory
14
- include Cayuga::Object::FactoryHelper
15
15
  include Tools::Loggable
16
+ include FactoryHelperShared
17
+ include FactoryHelper
16
18
 
17
19
  attr_reader :configuration_name, :logs_directory
18
20
 
@@ -82,16 +84,16 @@ module Cayuga
82
84
 
83
85
  private
84
86
 
85
- attr_reader :configuration, :types, :instances
87
+ attr_reader :configuration, :types, :instances, :directories
86
88
 
87
89
  def initialize(config)
88
90
  @configuration =
89
91
  JSON.parse(File.read(config), symbolize_names: true).deep_freeze
90
- @configuration_name = configuration[:configuration_name]
91
- @logs_directory = configuration[:directories][:logs]
92
+ @configuration_name = primary_configuration(:configuration_name, type: String)
92
93
  setup_types
93
94
  @instances = {}
94
- @directories = configuration[:directories].freeze
95
+ @directories = primary_configuration(:directories).freeze
96
+ @logs_directory = directories[:logs]
95
97
  end
96
98
 
97
99
  end
@@ -0,0 +1,24 @@
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
@@ -1,3 +1,3 @@
1
1
  module Cayuga
2
- VERSION = '0.0.16'.freeze
2
+ VERSION = '0.0.17'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cayuga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - patrick
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-01 00:00:00.000000000 Z
11
+ date: 2018-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facets
@@ -129,6 +129,7 @@ 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
132
133
  - lib/cayuga/object/logger.rb
133
134
  - lib/cayuga/object/named_object.rb
134
135
  - lib/cayuga/object/object.rb