skn_utils 2.0.5 → 2.0.6

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: b1dc55e64c570ca63ce385bbedae8052d9166603
4
- data.tar.gz: a8e49bd524bbfebbb11ccb0cc1b6a21f3a0af8cd
3
+ metadata.gz: cefc06c3edeecb51df5198df7b9e66f7bd6436d9
4
+ data.tar.gz: cfcb3e42124bfc01175839f88ac54f97ce352b55
5
5
  SHA512:
6
- metadata.gz: 75aa0eace6c9d4ac13f674b67a50724e37c7b18439f7cfa42aeeb6bfa676ac13d1136302e9833e986d5ebefaf833490746003e35ca8b965b4b80c5ce6a59d35d
7
- data.tar.gz: 7009021f7d9aea4afd4a1c530ad0a5bfa1f6dd95d9501db230c21d0f53fd57c0c5158affde4f5a2dc4ca93b9fdb6d96c84a1c24f4cded6f58155bec34507e6ef
6
+ metadata.gz: 1668823c468aacec8b9dd450c0f7c3188370a48553b60285aa0aa7a66f50c2c6a29b54601b4ca75ec1f83cab30194d2ea927701f49e344ffdefbb2191b935946
7
+ data.tar.gz: 523243ed0ceedf0fa67cace2ba399a075918eaefcb21689089a9031929f51c3d9ca94aff6a5e6a8c847131ecf8de478a5ce3364eb07436b9477fe368c4d25531
data/README.md CHANGED
@@ -25,14 +25,14 @@ into the input params key ':enable_serialization' set to true. It defaults to f
25
25
  ### New Features
26
26
  --------------------------------
27
27
 
28
+ 10/2016 V2.0.6
29
+ Added an SknUtils::NullObject and SknUtils::nullable?(value) extracted from [Avdi Grimm's Confident Code](https://gist.github.com/jschoolcraft/979827)
30
+ The NullObject class has great all around utility, check out it's specs!
31
+
28
32
  08/2016 V2.0.3
29
33
  Added an exploritory ActionService class and RSpec test, triggered by reading [Kamil Lelonek](https://blog.lelonek.me/what-service-objects-are-not-7abef8aa2f99#.p64vudxq4)
30
34
  I don't support his approach, but the CreateTask class caught my attention as a Rubyist.
31
35
 
32
- 02/2015 V2.0.2
33
- Added Jim Gay's Direction module, from his [Eastward Video](http://confreaks.tv/videos/rubyconf2014-eastward-ho-a-clear-path-through-ruby-with-oo)
34
- which allows to use :command instead of :Forwardable to implement a portion of the 'Eastward' methodology.
35
-
36
36
  12/2015 V2.0
37
37
  All references to ActiveRecord or Rails has been removed to allow use in non-Rails environments
38
38
  as a result serialization is done with standard Ruby Hash serialization methods; by first transforming
data/lib/skn_utils.rb CHANGED
@@ -5,9 +5,10 @@ require 'skn_utils/generic_bean'
5
5
  require 'skn_utils/page_controls'
6
6
  require 'skn_utils/result_bean'
7
7
  require 'skn_utils/value_bean'
8
+ require 'skn_utils/null_object'
8
9
  require 'skn_utils/exploring/commander'
9
10
  require 'skn_utils/exploring/action_service'
10
11
 
11
12
  module SknUtils
12
-
13
+
13
14
  end
@@ -0,0 +1,29 @@
1
+ #
2
+ # lib/skn_utils/null_object.rb
3
+ #
4
+ module SknUtils
5
+
6
+ # From: https://github.com/avdi/cowsay
7
+ class NullObject
8
+ def initialize
9
+ @origin = caller.first
10
+ end
11
+
12
+ def __null_origin__
13
+ @origin
14
+ end
15
+
16
+ def method_missing(*args, &block)
17
+ self
18
+ end
19
+
20
+ def nil?
21
+ true
22
+ end
23
+ end
24
+
25
+ def self.nullable?(value)
26
+ value.nil? ? NullObject.new : value
27
+ end
28
+
29
+ end
@@ -3,7 +3,7 @@ module SknUtils
3
3
  class Version
4
4
  MAJOR = 2
5
5
  MINOR = 0
6
- PATCH = 5
6
+ PATCH = 6
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, PATCH].join('.')
@@ -0,0 +1,30 @@
1
+ ##
2
+ # spec/lib/skn_utils/null_object_spec.rb
3
+ #
4
+
5
+ RSpec.describe SknUtils::NullObject, "NullObject with Helpers " do
6
+
7
+ context "Null Object Operations" do
8
+ it "consumes any method called on it" do
9
+ expect(subject.any_method).to be_a(subject.class)
10
+ end
11
+
12
+ it "consumes the whole chain of methods called on it" do
13
+ expect(subject.any_method.chaining_methods).to be_a(subject.class)
14
+ end
15
+ end
16
+
17
+ context "Alternate #try() named #nullable?() " do
18
+ it "#nullable?(value) returns null object if value is nil" do
19
+ expect(SknUtils::nullable?(nil)).to be_a(subject.class)
20
+ end
21
+
22
+ it "#nullable?(value) consumes the whole chain of methods called on it if value is nil" do
23
+ expect(SknUtils::nullable?(nil).any_method.chaining_methods).to be_a(subject.class)
24
+ end
25
+ it "#nullable?(value) returns the value if valid" do
26
+ expect(SknUtils::nullable?({value: true})[:value]).to be true
27
+ end
28
+ end
29
+
30
+ end
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.5
4
+ version: 2.0.6
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-16 00:00:00.000000000 Z
11
+ date: 2016-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,6 +97,7 @@ files:
97
97
  - lib/skn_utils/exploring/configuration.rb
98
98
  - lib/skn_utils/generic_bean.rb
99
99
  - lib/skn_utils/nested_result_base.rb
100
+ - lib/skn_utils/null_object.rb
100
101
  - lib/skn_utils/page_controls.rb
101
102
  - lib/skn_utils/result_bean.rb
102
103
  - lib/skn_utils/value_bean.rb
@@ -106,6 +107,7 @@ files:
106
107
  - spec/lib/skn_utils/exploring/commander_spec.rb
107
108
  - spec/lib/skn_utils/exploring/configuration_spec.rb
108
109
  - spec/lib/skn_utils/generic_bean_spec.rb
110
+ - spec/lib/skn_utils/null_object_spec.rb
109
111
  - spec/lib/skn_utils/page_controls_spec.rb
110
112
  - spec/lib/skn_utils/result_bean_spec.rb
111
113
  - spec/lib/skn_utils/value_bean_spec.rb
@@ -145,6 +147,7 @@ test_files:
145
147
  - spec/lib/skn_utils/exploring/commander_spec.rb
146
148
  - spec/lib/skn_utils/exploring/configuration_spec.rb
147
149
  - spec/lib/skn_utils/generic_bean_spec.rb
150
+ - spec/lib/skn_utils/null_object_spec.rb
148
151
  - spec/lib/skn_utils/page_controls_spec.rb
149
152
  - spec/lib/skn_utils/result_bean_spec.rb
150
153
  - spec/lib/skn_utils/value_bean_spec.rb