skn_utils 3.1.4 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/README.md +40 -22
- data/bin/benchmark.rb +0 -1
- data/bin/console +0 -3
- data/lib/skn_hash.rb +6 -0
- data/lib/skn_utils/nested_result.rb +17 -17
- data/lib/skn_utils/skn_configuration.rb +6 -2
- data/lib/skn_utils/version.rb +3 -2
- data/lib/skn_utils.rb +7 -1
- data/skn_utils.gemspec +6 -6
- data/spec/spec_helper.rb +0 -8
- metadata +25 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecb548ae02a698328f3c04c7b9e7dbfd115804cb
|
4
|
+
data.tar.gz: eec07b8981a3778c0146e529cf635a402b7ca3d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2297dc9806e0155a8cdf6e89051c699b4f41c871f89cb69cc6f07faf0159b230edfebfff452cb58684909e57e6fc6eb5cff9330b8a844a66a2548ccbd1f1e76
|
7
|
+
data.tar.gz: a8c18cc46ac4f2b6c770d2aad74c0505612aff180d37a235641a8587345a1ee3882411ba51dee464221c035954a13ec02156358b4ca9f901f6bb1cbfdb0b296d
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -16,16 +16,14 @@ Ruby Gem containing a Ruby PORO (Plain Old Ruby Object) that can be instantiated
|
|
16
16
|
|
17
17
|
|
18
18
|
## New Features
|
19
|
-
07/2017 V3.1.
|
19
|
+
07/2017 V3.1.5
|
20
20
|
Added SknSettings class for use as a replacement to the popular, but obsolete, Config.gem
|
21
21
|
SknSettings.load_configuration_basename!(config_file_name-only) or 'Rails.env.to_s' value, will load all the yml files in this order:
|
22
22
|
./config/settings.yml
|
23
|
-
./config/settings/<
|
24
|
-
./config/settings/<
|
25
|
-
and deep_merge the results. Ya might have to add this gem statement to your Rails Application GemFile.
|
26
|
-
gem 'deep_merge', '~> 1.1', :require => 'deep_merge/rails_compat'
|
23
|
+
./config/settings/<config_name>.yml
|
24
|
+
./config/settings/<config_name>.local.yml
|
27
25
|
I also restored SknUtils:ResultBean and SknUtils::PageControls to the classes contained in this gem. They are simple wrappers
|
28
|
-
inheriting the NestedResult class.
|
26
|
+
inheriting the NestedResult class. Also added SknHash class as a wrapper without the SknUtils namespace required or exposed
|
29
27
|
|
30
28
|
03/2017 V3.0.0
|
31
29
|
Added SknUtils::NestedResult to replace, or be an alternate, to ResultBean, GenericBean, PageControls, ValueBean, and AttributeHelper.
|
@@ -54,33 +52,47 @@ Ruby Gem containing a Ruby PORO (Plain Old Ruby Object) that can be instantiated
|
|
54
52
|
None required other than initialization hash
|
55
53
|
|
56
54
|
|
57
|
-
## Public Methods
|
55
|
+
## Public Methods: SknSettings ONLY
|
56
|
+
SknSettings is global constant containing an initialized Object of SknUtils::SknConfiguration using defaults
|
57
|
+
To change the 'development'.yml default please use the following method early or in the case of Rails in 'application.rb
|
58
|
+
#load_config_basename!(config_name) -- Where config_name is the name of yml files stored in the `./config/settings` directory
|
59
|
+
#config_path!(path) -- Where path format is './<dirs>/', default is: './config/'
|
60
|
+
and contains a settings.yml file and a 'path/settings/' directory
|
61
|
+
|
62
|
+
Paths ./config and ./config/settings must exist.
|
63
|
+
File ./config/settings.yml must exist and contain a valid YAML file structure.
|
64
|
+
./config/settings.yml -- Required base
|
65
|
+
./config/settings/<config_name>.yml -- Optional base.deep_merge!()
|
66
|
+
./config/settings/<config_name>.local.yml -- Optional base.deep_merge!()
|
67
|
+
|
68
|
+
|
69
|
+
## Public Methods: SknUtils::NestedResult, SknHash & SknSettings
|
58
70
|
Each concrete Class supports the following utility methods:
|
59
71
|
#to_hash -- returns a hash of current key/value pairs, including nested
|
60
72
|
#to_json -- returns a json string of current key/value pairs, including nested
|
61
73
|
#hash_from(:base_key) -- exports the internal hash starting with this base level key
|
62
74
|
#obj.obj2.hash_from(:base) -- exports the internal hash starting from this nested base level key
|
75
|
+
|
63
76
|
#[] -- returns value of attr, when #[<attr_name_symbol>]
|
64
77
|
#[]=(attr, value) -- assigns value to existing attr, or creates a new key/value pair
|
65
|
-
#<attr>? -- detects true/false presence? of attr, and non-blank existance of attr's value; when #address?
|
66
78
|
#<attr> -- returns value of named attribute
|
67
79
|
#<attr> = (value) -- assigns value to existing attr, or creates a new key/value pair
|
68
|
-
-- Where <attr> is a key value from the initial hash, or a key that was/will be dynamically added
|
80
|
+
-- Where <attr> is a key value from the initial hash, or a key that was/will be dynamically added
|
69
81
|
|
82
|
+
#keys -- returns array of symbol #keys from current nested level
|
83
|
+
#== -- alias to #===
|
84
|
+
#=== -- returns true/false from camparison of the two objects
|
85
|
+
#eql? -- returns true/false from camparison of the two objects
|
86
|
+
#<attr>? -- detects true/false presence? of attr, and non-blank existance of attr's value; when #address?
|
70
87
|
|
71
88
|
|
72
89
|
## Public Components
|
73
|
-
SknUtils::NestedResult
|
74
|
-
|
75
|
-
|
76
|
-
*** <= V 2.0.6 Depreciated, HAS been removed ***
|
90
|
+
SknUtils::NestedResult # >= V 3.0.0 Primary Key/Value Container with Dot/Hash notiation support.
|
91
|
+
SknSettings # Application Configuration class, Key/Value Container with Dot/Hash notiation support.
|
77
92
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
SknUtils::GenericBean # => Serializable and follows hash values only.
|
82
|
-
SknUtils::ValueBean # => Serializable and DOES NOT follows hash values.
|
83
|
-
or Include SknUtils::AttributeHelpers # => Adds getter/setters, and hash notation access to instance vars of any object.
|
93
|
+
SknHash # Wrapper for name only, WITHOUT SknUtils namespace, inherits from SknUtils::NestedResult
|
94
|
+
SknUtils::ResultBean # Wrapper for name only, inherits from SknUtils::NestedResult
|
95
|
+
SknUtils::PageControls # Wrapper for name only, inherits from SknUtils::NestedResult
|
84
96
|
|
85
97
|
|
86
98
|
## Basic features include:
|
@@ -192,7 +204,7 @@ gem 'skn_utils'
|
|
192
204
|
|
193
205
|
|
194
206
|
And then execute:
|
195
|
-
$ bundle
|
207
|
+
$ bundle install
|
196
208
|
|
197
209
|
|
198
210
|
Or install it yourself as:
|
@@ -219,14 +231,20 @@ $ cd skn_utils
|
|
219
231
|
$ bin/console
|
220
232
|
|
221
233
|
[1] pry(main)> rb = SknUtils::NestedResult.new({sample: [{one: "one", two: "two"},{one: 1, two: 2}] })
|
222
|
-
[2] pry(main)> pg =
|
234
|
+
[2] pry(main)> pg = SknHash.new({sample: [{three: 3, four: 4},{five: 'five', two: 'two'}] })
|
223
235
|
[3] pry(main)> pg.sample.first.three
|
224
236
|
[4] pry(main)> rb.sample.first.one
|
225
237
|
[5] pry(main)> rb.sample.first[:one]
|
226
238
|
[6] pry(main)> rb.hash_from(:sample)
|
227
239
|
[7] pry(main)> rb.sample?
|
228
240
|
[8] pry(main)> rb.sample[0].one?
|
229
|
-
|
241
|
+
...
|
242
|
+
[10] pry(main)> cfg = SknSettings
|
243
|
+
[11] pry(main)> cfg.config_path!('./spec/factories/')
|
244
|
+
[12] pry(main)> cfg.load_config_basename!('test')
|
245
|
+
[13] pry(main)> cfg.keys
|
246
|
+
[14] pry(main)> cfg.Packaging.keys
|
247
|
+
|
230
248
|
[n] pry(main)> exit
|
231
249
|
* Done
|
232
250
|
```
|
data/bin/benchmark.rb
CHANGED
data/bin/console
CHANGED
data/lib/skn_hash.rb
ADDED
@@ -173,6 +173,23 @@ module SknUtils
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
+
# returns hash from any root key starting point: object.root_key
|
177
|
+
# - protected to reasonably ensure key is a symbol
|
178
|
+
def hash_from(sym)
|
179
|
+
starting_sym = key_as_sym(sym)
|
180
|
+
bundle = ((starting_sym == container) ? container : { starting_sym => container[starting_sym] })
|
181
|
+
bundle.keys.each_with_object({}) do |attr,collector|
|
182
|
+
value = bundle[attr]
|
183
|
+
case value
|
184
|
+
when NestedResult
|
185
|
+
value = value.to_hash
|
186
|
+
when Array
|
187
|
+
value = value.map {|ele| array_to_hash(ele) }
|
188
|
+
end
|
189
|
+
collector[attr] = value # new copy
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
176
193
|
protected
|
177
194
|
|
178
195
|
def reset_from_empty!(params={})
|
@@ -214,23 +231,6 @@ module SknUtils
|
|
214
231
|
@container ||= {}
|
215
232
|
end
|
216
233
|
|
217
|
-
# returns hash from any root key starting point: object.root_key
|
218
|
-
# - protected to reasonably ensure key is a symbol
|
219
|
-
def hash_from(sym)
|
220
|
-
starting_sym = key_as_sym(sym)
|
221
|
-
bundle = ((starting_sym == container) ? container : { starting_sym => container[starting_sym] })
|
222
|
-
bundle.keys.each_with_object({}) do |attr,collector|
|
223
|
-
value = bundle[attr]
|
224
|
-
case value
|
225
|
-
when NestedResult
|
226
|
-
value = value.to_hash
|
227
|
-
when Array
|
228
|
-
value = value.map {|ele| array_to_hash(ele) }
|
229
|
-
end
|
230
|
-
collector[attr] = value # new copy
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
234
|
# Feature: enables dot.notation and creates matching getter/setters
|
235
235
|
def enable_dot_notation(sym)
|
236
236
|
name = key_as_sym(sym)
|
@@ -17,6 +17,10 @@ module SknUtils
|
|
17
17
|
self
|
18
18
|
end
|
19
19
|
|
20
|
+
def config_path!(fpath)
|
21
|
+
@base_path = fpath if File.exist?("#{fpath}settings.yml")
|
22
|
+
end
|
23
|
+
|
20
24
|
private
|
21
25
|
|
22
26
|
def load_config(conf)
|
@@ -26,11 +30,11 @@ module SknUtils
|
|
26
30
|
|
27
31
|
yname = "#{@base_path}settings/#{conf}.yml"
|
28
32
|
f_env = load_yml_with_erb(yname) if File.exist?(yname)
|
29
|
-
f_base = f_base.
|
33
|
+
f_base = f_base.deep_merge!(f_env) unless (f_env.nil? || f_env.empty?)
|
30
34
|
|
31
35
|
yname = "#{@base_path}settings/#{conf}.local.yml"
|
32
36
|
f_local = load_yml_with_erb(yname) if File.exist?(yname)
|
33
|
-
f_base = f_base.
|
37
|
+
f_base = f_base.deep_merge!(f_local) unless (f_local.nil? || f_local.empty?)
|
34
38
|
|
35
39
|
f_base
|
36
40
|
end
|
data/lib/skn_utils/version.rb
CHANGED
data/lib/skn_utils.rb
CHANGED
@@ -7,7 +7,13 @@ require 'skn_utils/notifier_base'
|
|
7
7
|
require 'skn_utils/skn_configuration'
|
8
8
|
require 'skn_utils/exploring/commander'
|
9
9
|
require 'skn_utils/exploring/action_service'
|
10
|
-
require '
|
10
|
+
require 'psych'
|
11
|
+
require 'json'
|
12
|
+
require 'erb'
|
13
|
+
unless defined?(Rails)
|
14
|
+
require 'deep_merge'
|
15
|
+
end
|
16
|
+
require 'skn_hash'
|
11
17
|
require 'skn_settings'
|
12
18
|
|
13
19
|
module SknUtils
|
data/skn_utils.gemspec
CHANGED
@@ -19,16 +19,16 @@ with easy access to its contents, and on-demand transformation back to the hash
|
|
19
19
|
Review the RSpec tests, and or review the README for more details.
|
20
20
|
EOF
|
21
21
|
spec.post_install_message = <<-EOF
|
22
|
-
This version
|
23
|
-
SknUtils::NestedResult class replaces those original classes and their function.
|
22
|
+
This version includes modified versions of SknUtils::ResultBean, SknUtils::PageControls classes, which inherit from
|
23
|
+
SknUtils::NestedResult class. SknUtils::NestedResult replaces those original classes and consolidates their function.
|
24
24
|
|
25
|
-
Please update your existing code
|
25
|
+
Please update your existing code in consideration of the above change, or use the prior version 2.0.6.
|
26
26
|
|
27
27
|
ATTENTION: ****************************************************************
|
28
|
-
This version
|
28
|
+
This version may require the following be added to your Rails Application 'Gemfile',
|
29
29
|
if you are using the SknSettings configuration class.
|
30
30
|
|
31
|
-
gem 'deep_merge', '~> 1.1'
|
31
|
+
gem 'deep_merge', '~> 1.1'
|
32
32
|
|
33
33
|
************************************************************************
|
34
34
|
EOF
|
@@ -40,7 +40,7 @@ EOF
|
|
40
40
|
spec.test_files = spec.files.grep(%r{^(spec)/})
|
41
41
|
spec.require_paths = ['lib']
|
42
42
|
|
43
|
-
|
43
|
+
spec.add_runtime_dependency 'deep_merge', '~> 1.1'
|
44
44
|
|
45
45
|
spec.add_development_dependency "bundler", ">= 0"
|
46
46
|
spec.add_development_dependency "rake", ">= 0"
|
data/spec/spec_helper.rb
CHANGED
@@ -11,11 +11,6 @@ SimpleCov.start do
|
|
11
11
|
add_filter '/spec/'
|
12
12
|
end
|
13
13
|
|
14
|
-
require 'psych'
|
15
|
-
require 'json'
|
16
|
-
require 'erb'
|
17
|
-
require 'deep_merge/rails_compat'
|
18
|
-
|
19
14
|
require 'skn_utils'
|
20
15
|
require 'skn_utils/exploring/commander'
|
21
16
|
require 'skn_utils/exploring/action_service'
|
@@ -23,9 +18,6 @@ require 'skn_utils/exploring/configuration'
|
|
23
18
|
|
24
19
|
require 'rspec'
|
25
20
|
|
26
|
-
# Shared Examples and Support Routines
|
27
|
-
Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
|
28
|
-
|
29
21
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
30
22
|
RSpec.configure do |config|
|
31
23
|
Kernel.srand config.seed
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skn_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Scott Jr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: deep_merge
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +128,7 @@ files:
|
|
114
128
|
- Rakefile
|
115
129
|
- bin/benchmark.rb
|
116
130
|
- bin/console
|
131
|
+
- lib/skn_hash.rb
|
117
132
|
- lib/skn_settings.rb
|
118
133
|
- lib/skn_utils.rb
|
119
134
|
- lib/skn_utils/exploring/action_service.rb
|
@@ -142,13 +157,14 @@ homepage: https://github.com/skoona/skn_utils
|
|
142
157
|
licenses:
|
143
158
|
- MIT
|
144
159
|
metadata: {}
|
145
|
-
post_install_message: "This version
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
\
|
151
|
-
'
|
160
|
+
post_install_message: "This version includes modified versions of SknUtils::ResultBean,
|
161
|
+
SknUtils::PageControls classes, which inherit from \nSknUtils::NestedResult class.
|
162
|
+
\ SknUtils::NestedResult replaces those original classes and consolidates their
|
163
|
+
function. \n\nPlease update your existing code in consideration of the above change,
|
164
|
+
or use the prior version 2.0.6.\n\nATTENTION: ****************************************************************
|
165
|
+
\n This version may require the following be added to your Rails Application
|
166
|
+
'Gemfile',\n if you are using the SknSettings configuration class.\n\n gem
|
167
|
+
'deep_merge', '~> 1.1'\n\n ************************************************************************\n"
|
152
168
|
rdoc_options: []
|
153
169
|
require_paths:
|
154
170
|
- lib
|