skn_utils 2.0.4 → 2.0.5
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 +4 -4
- data/README.md +2 -1
- data/lib/skn_utils/exploring/configuration.rb +53 -0
- data/lib/skn_utils/version.rb +1 -1
- data/spec/lib/skn_utils/{action_service_spec.rb → exploring/action_service_spec.rb} +0 -0
- data/spec/lib/skn_utils/{commander_spec.rb → exploring/commander_spec.rb} +0 -0
- data/spec/lib/skn_utils/exploring/configuration_spec.rb +52 -0
- data/spec/spec_helper.rb +2 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1dc55e64c570ca63ce385bbedae8052d9166603
|
4
|
+
data.tar.gz: a8e49bd524bbfebbb11ccb0cc1b6a21f3a0af8cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75aa0eace6c9d4ac13f674b67a50724e37c7b18439f7cfa42aeeb6bfa676ac13d1136302e9833e986d5ebefaf833490746003e35ca8b965b4b80c5ce6a59d35d
|
7
|
+
data.tar.gz: 7009021f7d9aea4afd4a1c530ad0a5bfa1f6dd95d9501db230c21d0f53fd57c0c5158affde4f5a2dc4ca93b9fdb6d96c84a1c24f4cded6f58155bec34507e6ef
|
data/README.md
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
##
|
2
|
+
# File: <gem-root>/lib/skn_utils/exploring/configuration.rb
|
3
|
+
#
|
4
|
+
# Engines and Gem sometimes need a configuration object, this is an example
|
5
|
+
# Options class, consider OpenStruct2 or ActiveSupport::OrderedOptions as alternatives
|
6
|
+
|
7
|
+
module SknUtils
|
8
|
+
module Exploring
|
9
|
+
module Configuration
|
10
|
+
|
11
|
+
module_function
|
12
|
+
|
13
|
+
def option_defaults
|
14
|
+
@@option_defaults ||= {one: 1, two: 2, three: 3}
|
15
|
+
end
|
16
|
+
def option_defaults=(parms)
|
17
|
+
@@option_defaults = parms
|
18
|
+
end
|
19
|
+
|
20
|
+
def reset!
|
21
|
+
@@configuration = Options.new(option_defaults)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def config
|
26
|
+
configure
|
27
|
+
end
|
28
|
+
|
29
|
+
def configure # Initialize with both the configuration keys and default values
|
30
|
+
@@configuration || reset!
|
31
|
+
yield(@@configuration) if block_given?
|
32
|
+
@@configuration
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
class Options
|
38
|
+
def initialize(parms={})
|
39
|
+
parms.each_pair do |k,v|
|
40
|
+
self.singleton_class.send(:attr_accessor, k)
|
41
|
+
instance_variable_set("@#{k}",v)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
# require your Gem or Engine here
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# In config/initializers/gem_config.rb
|
53
|
+
# SknUtils::Exploring::Configuration.class_variable_set(:option_defaults, {one: 1, two: 2, three: 3})
|
data/lib/skn_utils/version.rb
CHANGED
File without changes
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
##
|
2
|
+
# spec/lib/skn_utils/exploring/configuration_spec.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
describe "Gem Configuration Example." do
|
6
|
+
|
7
|
+
let!(:subject) { SknUtils::Exploring::Configuration }
|
8
|
+
|
9
|
+
|
10
|
+
context "Initializers Feature. " do
|
11
|
+
before(:each) do
|
12
|
+
subject.reset!
|
13
|
+
end
|
14
|
+
|
15
|
+
it "#configure can be called without a block." do
|
16
|
+
expect( subject.configure ).to be_a(SknUtils::Exploring::Configuration::Options)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "#configure can be called with a block." do
|
20
|
+
expect( subject.configure() {|c| c.one = 'One'} ).to be_a(SknUtils::Exploring::Configuration::Options)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "#reset! allows new defaults to be applied." do
|
24
|
+
subject.option_defaults = {four: 4, five: 5, six: 6}
|
25
|
+
subject.reset!
|
26
|
+
expect( subject.config.five ).to eq(5)
|
27
|
+
subject.option_defaults = nil # remove prior defaults
|
28
|
+
subject.reset!
|
29
|
+
expect( subject.config.one ).to eq(1)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
context "Runtime Features. " do
|
35
|
+
before(:each) do
|
36
|
+
subject.reset!
|
37
|
+
end
|
38
|
+
|
39
|
+
it "#config returns the selected value." do
|
40
|
+
subject.config.one = 1
|
41
|
+
expect( subject.config.one ).to eq(1)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "#config overrides the selected value." do
|
45
|
+
subject.config.three = 12
|
46
|
+
expect( subject.config.three ).to eq(12)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,7 @@ ENV['RAILS_ENV'] ||= 'test'
|
|
3
3
|
require 'skn_utils'
|
4
4
|
require 'skn_utils/exploring/commander'
|
5
5
|
require 'skn_utils/exploring/action_service'
|
6
|
+
require 'skn_utils/exploring/configuration'
|
6
7
|
|
7
8
|
require 'rspec'
|
8
9
|
require 'yaml'
|
@@ -21,7 +22,7 @@ RSpec.configure do |config|
|
|
21
22
|
config.filter_run :focus
|
22
23
|
config.run_all_when_everything_filtered = true
|
23
24
|
|
24
|
-
config.disable_monkey_patching! # -- breaks rspec runtime
|
25
|
+
# config.disable_monkey_patching! # -- breaks rspec runtime
|
25
26
|
config.warnings = true
|
26
27
|
|
27
28
|
if config.files_to_run.one?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skn_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
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: 2016-09-
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/skn_utils/attribute_helpers.rb
|
95
95
|
- lib/skn_utils/exploring/action_service.rb
|
96
96
|
- lib/skn_utils/exploring/commander.rb
|
97
|
+
- lib/skn_utils/exploring/configuration.rb
|
97
98
|
- lib/skn_utils/generic_bean.rb
|
98
99
|
- lib/skn_utils/nested_result_base.rb
|
99
100
|
- lib/skn_utils/page_controls.rb
|
@@ -101,8 +102,9 @@ files:
|
|
101
102
|
- lib/skn_utils/value_bean.rb
|
102
103
|
- lib/skn_utils/version.rb
|
103
104
|
- skn_utils.gemspec
|
104
|
-
- spec/lib/skn_utils/action_service_spec.rb
|
105
|
-
- spec/lib/skn_utils/commander_spec.rb
|
105
|
+
- spec/lib/skn_utils/exploring/action_service_spec.rb
|
106
|
+
- spec/lib/skn_utils/exploring/commander_spec.rb
|
107
|
+
- spec/lib/skn_utils/exploring/configuration_spec.rb
|
106
108
|
- spec/lib/skn_utils/generic_bean_spec.rb
|
107
109
|
- spec/lib/skn_utils/page_controls_spec.rb
|
108
110
|
- spec/lib/skn_utils/result_bean_spec.rb
|
@@ -139,8 +141,9 @@ summary: Ruby convenience utilities, the first being a ResultBean. ResultBean
|
|
139
141
|
via dot or hash notation, and is serializable (<obj>.to_hash) using standard Hash
|
140
142
|
serialization methods.
|
141
143
|
test_files:
|
142
|
-
- spec/lib/skn_utils/action_service_spec.rb
|
143
|
-
- spec/lib/skn_utils/commander_spec.rb
|
144
|
+
- spec/lib/skn_utils/exploring/action_service_spec.rb
|
145
|
+
- spec/lib/skn_utils/exploring/commander_spec.rb
|
146
|
+
- spec/lib/skn_utils/exploring/configuration_spec.rb
|
144
147
|
- spec/lib/skn_utils/generic_bean_spec.rb
|
145
148
|
- spec/lib/skn_utils/page_controls_spec.rb
|
146
149
|
- spec/lib/skn_utils/result_bean_spec.rb
|