evt-settings 0.2.0.7 → 0.2.1.0

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: cbd1c157ee40d1d754e92efe35c44cb386c46735fba85eefb16102e9fa4fc762
4
- data.tar.gz: 40c04f93097f6a82b51295247ff4c4cdf28608bc21906074783ae40e774db29f
3
+ metadata.gz: a01cdd21b4055fede7d1d452e5e70f0ee9bbb655ee4dfd553aa1af3c9d5c0a3b
4
+ data.tar.gz: 70efd12bdffea6a5cab2779028bcb3d1b5f012a3335d28a9c7805d0b1a329810
5
5
  SHA512:
6
- metadata.gz: 28a4315141ee178c571f43da87be2d4418848dda5377558d072369f171c2c4a7aad783d7eb94fb550c550af4febe03fb0c0612eb66bdb31b1dc8319d48b32c1c
7
- data.tar.gz: 9f06b8d0f67d7decad752e620b37c30c4bf82c7deb10894577e5e0c23261fbf3819ff6491532fab01d5f86ea49fc834745b990a504e8365cd0eba278c0577880
6
+ metadata.gz: ae05442873131efafa881a3f79fdf4052cef5bd288328b3fb378c9c0720ad8868e981a46e8687192066409504e72fa505149d4255a2ed9fbcc56dc902ed61224
7
+ data.tar.gz: cf6db56d40d866ccc635b95acfbc87a17d19ba82781a1efba66bc2b97698f36cf1058d9e9af48a838ef68759ad4cbb4b169c614eb25d493607479c85c09abfc1
@@ -4,7 +4,7 @@ class Settings
4
4
 
5
5
  macro_module = Settings::Setting::Macro
6
6
 
7
- return if target_class.is_a? macro_module
7
+ return if target_class.is_a?(macro_module)
8
8
 
9
9
  target_class.extend(macro_module)
10
10
  end
@@ -0,0 +1,29 @@
1
+ class Settings
2
+ module Controls
3
+ module DataSource
4
+ module Hash
5
+ def self.example
6
+ ::Settings::DataSource::Hash.build(data)
7
+ end
8
+
9
+ def self.data
10
+ {
11
+ some_setting: 'some value'
12
+ }
13
+ end
14
+ end
15
+
16
+ module Implementer
17
+ def self.example
18
+ Example.build
19
+ end
20
+
21
+ class Example < Settings
22
+ def self.data_source
23
+ DataSource::Hash.data
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,74 @@
1
+ class Settings
2
+ module Controls
3
+ module Settings
4
+ module SettingAttribute
5
+ def self.example
6
+ ::Settings.new(data)
7
+ end
8
+
9
+ def self.data
10
+ {
11
+ "some_setting" => "some value"
12
+ }
13
+ end
14
+ end
15
+
16
+ module SettingAttributes
17
+ def self.example
18
+ ::Settings.new(data)
19
+ end
20
+
21
+ def self.data
22
+ {
23
+ "some_setting" => "some value",
24
+ "some_other_setting" => "some other value",
25
+ "yet_another_setting" => "yet another value"
26
+ }
27
+ end
28
+ end
29
+
30
+ module AccessorAttribute
31
+ def self.example
32
+ ::Settings.new(data)
33
+ end
34
+
35
+ def self.data
36
+ {
37
+ "some_accessor_attribute" => "some accessor value"
38
+ }
39
+ end
40
+ end
41
+
42
+ module Namespace
43
+ def self.example
44
+ ::Settings.new(data)
45
+ end
46
+
47
+ def self.data
48
+ {
49
+ "some_namespace" => {
50
+ "some_setting" => "some value"
51
+ }
52
+ }
53
+ end
54
+
55
+ module Override
56
+ def self.example
57
+ s = ::Settings.build(Namespace.data)
58
+ s.override(data)
59
+ s
60
+ end
61
+
62
+ def self.data
63
+ {
64
+ "some_namespace" => {
65
+ "some_setting" => "some overridden value",
66
+ "some_other_setting" => "some other value"
67
+ }
68
+ }
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,17 @@
1
+ class Settings
2
+ module Controls
3
+ module Subject
4
+ class Example
5
+ setting :some_setting
6
+ setting :some_other_setting
7
+ setting :yet_another_setting
8
+ attr_reader :some_reader_attribute
9
+ attr_accessor :some_accessor_attribute
10
+ end
11
+
12
+ def self.example
13
+ Example.new
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ require 'settings/controls/subject'
2
+ require 'settings/controls/data_source'
3
+ require 'settings/controls/settings'
@@ -40,7 +40,7 @@ class Settings
40
40
  def digest(receiver, attribute, strict)
41
41
  content = []
42
42
  content << "Attribute: #{attribute}" if attribute
43
- content << "Receiver: #{receiver}"
43
+ content << "Receiver: #{receiver.class.name}"
44
44
  strict = "<not set>" if strict.nil?
45
45
  content << "Strict: #{strict}"
46
46
  content.join ', '
@@ -59,14 +59,14 @@ class Settings
59
59
  if strict
60
60
  setting = setting?(receiver, attribute)
61
61
  unless setting
62
- logger.warn { "Can't set \"#{attribute}\". It isn't a setting of #{receiver}." }
62
+ logger.warn { "Can't set \"#{attribute}\". It isn't a setting of #{receiver.class.name}." }
63
63
  return false
64
64
  end
65
65
  end
66
66
 
67
67
  assignable = assignable? receiver, attribute
68
68
  unless assignable
69
- logger.warn { "Can't set \"#{attribute}\". It isn't assignable to #{receiver}." }
69
+ logger.warn { "Can't set \"#{attribute}\". It isn't assignable to #{receiver.class.name}." }
70
70
  return false
71
71
  end
72
72
 
@@ -86,7 +86,7 @@ class Settings
86
86
  if strict
87
87
  setting = setting? receiver, attribute
88
88
  unless setting
89
- msg = "Can't set \"#{attribute}\". It isn't a setting of #{receiver}."
89
+ msg = "Can't set \"#{attribute}\". It isn't a setting of #{receiver.class.name}."
90
90
  logger.error { msg }
91
91
  raise msg
92
92
  end
@@ -94,7 +94,7 @@ class Settings
94
94
 
95
95
  assignable = assignable? receiver, attribute
96
96
  unless assignable
97
- msg = "Can't set \"#{attribute}\". It isn't assignable to #{receiver}."
97
+ msg = "Can't set \"#{attribute}\". It isn't assignable to #{receiver.class.name}."
98
98
  logger.error { msg }
99
99
  raise msg
100
100
  end
@@ -56,7 +56,7 @@ class Settings
56
56
  end
57
57
 
58
58
  def set(receiver, *namespace, attribute: nil, strict: true)
59
- logger.trace { "Setting #{receiver} (#{digest(namespace, attribute, strict)})" }
59
+ logger.trace { "Setting #{receiver.class.name} (#{digest(namespace, attribute, strict)})" }
60
60
  unless attribute.nil?
61
61
  value = set_attribute(receiver, attribute, namespace, strict)
62
62
  else
@@ -66,9 +66,9 @@ class Settings
66
66
  end
67
67
 
68
68
  def set_attribute(receiver, attribute, namespace, strict)
69
- logger.trace { "Setting #{receiver} attribute (#{digest(namespace, attribute, strict)})" }
69
+ logger.trace { "Setting #{receiver.class.name} attribute (#{digest(namespace, attribute, strict)})" }
70
70
 
71
- attribute = attribute.to_s if attribute.is_a? Symbol
71
+ attribute = attribute.to_s if attribute.is_a?(Symbol)
72
72
 
73
73
  attribute_namespace = namespace.dup
74
74
  attribute_namespace << attribute
@@ -83,16 +83,13 @@ class Settings
83
83
 
84
84
  Settings::Setting::Assignment::Attribute.assign(receiver, attribute.to_sym, value, strict)
85
85
 
86
- log_value = value
87
- log_value = log_value.to_h if log_value.respond_to? :to_h
88
-
89
- logger.debug { "Set #{receiver} #{attribute} to #{log_value}" }
86
+ logger.debug { "Set #{receiver.class.name} #{attribute} to #{value.inspect}" }
90
87
 
91
88
  value
92
89
  end
93
90
 
94
91
  def set_object(receiver, namespace, strict)
95
- logger.trace { "Setting #{receiver} object (#{digest(namespace, nil, strict)})" }
92
+ logger.trace { "Setting #{receiver.class.name} object (#{digest(namespace, nil, strict)})" }
96
93
 
97
94
  data = get(namespace)
98
95
 
@@ -106,7 +103,7 @@ class Settings
106
103
  Settings::Setting::Assignment::Object.assign(receiver, attribute.to_sym, value, strict)
107
104
  end
108
105
 
109
- logger.debug { "Set #{receiver} object (#{digest(namespace, nil, strict)})" }
106
+ logger.debug { "Set #{receiver.class.name} object (#{digest(namespace, nil, strict)})" }
110
107
 
111
108
  receiver
112
109
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.7
4
+ version: 0.2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-30 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-log
@@ -74,6 +74,10 @@ extra_rdoc_files: []
74
74
  files:
75
75
  - lib/settings.rb
76
76
  - lib/settings/activate.rb
77
+ - lib/settings/controls.rb
78
+ - lib/settings/controls/data_source.rb
79
+ - lib/settings/controls/settings.rb
80
+ - lib/settings/controls/subject.rb
77
81
  - lib/settings/data_source/build.rb
78
82
  - lib/settings/data_source/data_source.rb
79
83
  - lib/settings/data_source/file.rb