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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb76906e8c9a9acc4a24c4f3d901a82a4a75551e
4
- data.tar.gz: 5c837b3b0237136a0d26f9819360c5223b49f0e6
3
+ metadata.gz: b1dc55e64c570ca63ce385bbedae8052d9166603
4
+ data.tar.gz: a8e49bd524bbfebbb11ccb0cc1b6a21f3a0af8cd
5
5
  SHA512:
6
- metadata.gz: 17ae5f8c61d19c3aed3e5b4915c68b341a2ac4f45da80b8a2841bafc620a88af72c245b45271782d3d748abce12406e712a53d7004b800c87bb75f82ed88c5b7
7
- data.tar.gz: 3baa78fcdb3f07c458a5b9b5b378d971ec68a7b9828489e1971386a14dafce68929eef868c16ed790a80919d26e574a1fd4551b0ee2fb46a125b722d2a784b4e
6
+ metadata.gz: 75aa0eace6c9d4ac13f674b67a50724e37c7b18439f7cfa42aeeb6bfa676ac13d1136302e9833e986d5ebefaf833490746003e35ca8b965b4b80c5ce6a59d35d
7
+ data.tar.gz: 7009021f7d9aea4afd4a1c530ad0a5bfa1f6dd95d9501db230c21d0f53fd57c0c5158affde4f5a2dc4ca93b9fdb6d96c84a1c24f4cded6f58155bec34507e6ef
data/README.md CHANGED
@@ -272,4 +272,5 @@ $ bundle exec pry
272
272
 
273
273
  ## License
274
274
 
275
- MIT. See `LICENSE`.
275
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
276
+
@@ -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})
@@ -3,7 +3,7 @@ module SknUtils
3
3
  class Version
4
4
  MAJOR = 2
5
5
  MINOR = 0
6
- PATCH = 4
6
+ PATCH = 5
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, PATCH].join('.')
@@ -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
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-10 00:00:00.000000000 Z
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