nullz 0.1.0 → 0.5.0
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/.travis.yml +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +11 -5
- data/lib/.DS_Store +0 -0
- data/lib/null_object.rb +43 -58
- data/lib/nullz/version.rb +3 -0
- data/nullz.gemspec +4 -4
- data/pkg/nullz-0.1.0.gem +0 -0
- metadata +7 -7
- data/lib/null_object/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b733432ecb5440b4e01a67cc4d883b32ac5233cfc398ee9d834f4a5f4ece2ef4
|
4
|
+
data.tar.gz: 308b61f2e9ce2b7643a56c153789b8ad311de16c2b23efb1dc6bb478c8753f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76b123a92bb1e636cf7595af2fd1d8a5701f75cbc00c4e46735bc0565c4c689ccd77f49e16ef8ac95a108628fe949575762a13f0e1a9c880127b23a6e47fada2
|
7
|
+
data.tar.gz: aaec8fe9e0231b14e07981ed816ca56c509f9978ea8adc5149168d0ae51c6a4e72affa60d296dbbae77e929688abfda07954a4a7d392ccc240c7a826429f2788
|
data/.travis.yml
CHANGED
@@ -1 +1,9 @@
|
|
1
1
|
language: ruby
|
2
|
+
deploy:
|
3
|
+
provider: rubygems
|
4
|
+
api_key:
|
5
|
+
secure: NljDAIxl+Gku+d894m758sm6PFuaaL7GUmmbR87h5GAhgMJJYXEIeRinlFm5LNow09n9ssBu4iSAf28Xg0lNKLGAyLLpS9y3wVQBOd11j+Dp6/M6VCb+Ramb1aLc47RSh8cynWMJQeVGKNv2apP88hITbC+0qAKklY45176s/2xZKSnKq5RStQ76OE0iNTjxtDgZPSALrNmu/C/a6ajIymtIFo+rhTTLl8ZfX+jjTIButl3o+IulRpsiPwPBH/R6eWSoZ69PXc62ZlHK/X9KLTOkYddra0TjjqC+379kYHZNdAWnPL+VQaTJj73Njg9rkxVx+b3QRTSn7je7qyDxwjambSixs7CoM5Sgh69iaMD6Qii1ef7uKvIYj9T9IPi04UaiB8QVH4aukI/BhHbTlkY5IwGr6Mkzoyg257iUoHVOefGmt3sd6/NerM0XRooauZcuNkYutVbwqOkSFumt11XBM+e0Yipsx89w8/lHVpl4f1/d3sXa5aZaqe2nXDtAtsdKu+YWckHQ1HRF8JWTF6IUrWpMlOg9AM+gZKGPQ+B+EZ2WsL6wbGLbMUMyTGW3gOmvmJJ2ebA1AGteYHRSMEuZF5ifU+Q69MpyVq6VTCs9Tj4q2r+KZJrA3XnIRETzPzpNF+D2BwdvefPREg11IOungXGBcF8l1jSe5ytxec8=
|
6
|
+
gem: nullz
|
7
|
+
on:
|
8
|
+
tags: true
|
9
|
+
repo: rootedbox/nullz
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
# Nullz a
|
1
|
+
# Nullz a Null Object pattern gem.
|
2
|
+
Nullz is a null object pattern gem to safely wrap nils in a do nothing null objects.
|
3
|
+
|
4
|
+
[](https://travis-ci.org/rootedbox/nullz)
|
5
|
+
[](https://codeclimate.com/github/rootedbox/nullz)
|
6
|
+
|
7
|
+
## Usage
|
2
8
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/untitled`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
9
|
|
5
|
-
|
10
|
+
|
11
|
+
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
@@ -22,7 +28,7 @@ Or install it yourself as:
|
|
22
28
|
|
23
29
|
## Usage
|
24
30
|
|
25
|
-
|
31
|
+
|
26
32
|
|
27
33
|
## Development
|
28
34
|
|
@@ -40,4 +46,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
46
|
|
41
47
|
## Code of Conduct
|
42
48
|
|
43
|
-
Everyone interacting in the
|
49
|
+
Everyone interacting in the Nullz project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/untitled/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/.DS_Store
CHANGED
Binary file
|
data/lib/null_object.rb
CHANGED
@@ -1,4 +1,23 @@
|
|
1
|
-
require '
|
1
|
+
require 'nullz/version'
|
2
|
+
|
3
|
+
ON_NULL_OBJECT_CREATED = Proc.new { }
|
4
|
+
USE_NULL_OBJECT = false
|
5
|
+
|
6
|
+
def _(obj)
|
7
|
+
obj || NullObject.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def __(obj, on_null_object_created_proc = ON_NULL_OBJECT_CREATED)
|
11
|
+
return obj if obj
|
12
|
+
|
13
|
+
on_null_object_created_proc.call
|
14
|
+
|
15
|
+
NullObject.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def safe(obj, on_null_object_created_proc = ON_NULL_OBJECT_CREATED)
|
19
|
+
USE_NULL_OBJECT ? __(obj, on_null_object_created_proc) : obj
|
20
|
+
end
|
2
21
|
|
3
22
|
class NullObject
|
4
23
|
def method_missing(method, *_args, &_block)
|
@@ -7,48 +26,30 @@ class NullObject
|
|
7
26
|
end
|
8
27
|
|
9
28
|
def to_s
|
10
|
-
to_str
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_str
|
14
29
|
''
|
15
30
|
end
|
16
31
|
|
17
|
-
|
18
|
-
NullObject.new
|
19
|
-
end
|
32
|
+
alias_method :to_str, :to_s
|
20
33
|
|
21
34
|
def coerce(value)
|
22
35
|
[NullObject.new, value]
|
23
36
|
end
|
24
37
|
|
25
|
-
def
|
26
|
-
NullObject.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def -(_value)
|
30
|
-
NullObject.new
|
31
|
-
end
|
32
|
-
|
33
|
-
def *(_value)
|
34
|
-
NullObject.new
|
35
|
-
end
|
36
|
-
|
37
|
-
def /(_value)
|
38
|
-
NullObject.new
|
39
|
-
end
|
40
|
-
|
41
|
-
def [](_value)
|
42
|
-
NullObject.new
|
43
|
-
end
|
44
|
-
|
45
|
-
def <<(_value)
|
38
|
+
def return_null_object(_value)
|
46
39
|
NullObject.new
|
47
40
|
end
|
48
41
|
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
alias_method :+, :return_null_object
|
43
|
+
alias_method :-, :return_null_object
|
44
|
+
alias_method :*, :return_null_object
|
45
|
+
alias_method :/, :return_null_object
|
46
|
+
alias_method :|, :return_null_object
|
47
|
+
alias_method :^, :return_null_object
|
48
|
+
alias_method :~, :return_null_object
|
49
|
+
alias_method :&, :return_null_object
|
50
|
+
alias_method :[], :return_null_object
|
51
|
+
alias_method :<<, :return_null_object
|
52
|
+
alias_method :>>, :return_null_object
|
52
53
|
|
53
54
|
def ==(value)
|
54
55
|
value.nil?
|
@@ -58,40 +59,22 @@ class NullObject
|
|
58
59
|
!value.nil?
|
59
60
|
end
|
60
61
|
|
61
|
-
def
|
62
|
-
|
62
|
+
def to_int
|
63
|
+
0
|
63
64
|
end
|
64
65
|
|
65
|
-
def
|
66
|
+
def to_bool
|
66
67
|
false
|
67
68
|
end
|
68
69
|
|
69
|
-
|
70
|
-
NullObject.new
|
71
|
-
end
|
72
|
-
|
73
|
-
def ^(_value)
|
74
|
-
NullObject.new
|
75
|
-
end
|
76
|
-
|
77
|
-
def ~(_value)
|
78
|
-
NullObject.new
|
79
|
-
end
|
80
|
-
|
81
|
-
def &(_value)
|
82
|
-
NullObject.new
|
83
|
-
end
|
84
|
-
|
85
|
-
def to_int
|
86
|
-
0
|
87
|
-
end
|
70
|
+
alias_method :to_b, :to_bool
|
88
71
|
|
89
|
-
def
|
90
|
-
false
|
72
|
+
def >(_value)
|
73
|
+
return false
|
91
74
|
end
|
92
75
|
|
93
|
-
def
|
94
|
-
false
|
76
|
+
def <(_value)
|
77
|
+
return false
|
95
78
|
end
|
96
79
|
|
97
80
|
def empty?
|
@@ -106,3 +89,5 @@ class NullObject
|
|
106
89
|
true
|
107
90
|
end
|
108
91
|
end
|
92
|
+
|
93
|
+
|
data/nullz.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'nullz/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'nullz'
|
8
|
-
spec.version =
|
8
|
+
spec.version = Nullz::VERSION
|
9
9
|
spec.authors = ['Jason Jacobs']
|
10
10
|
spec.email = ['nerfnerd@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = '
|
13
|
-
spec.description = '
|
12
|
+
spec.summary = 'Null Object'
|
13
|
+
spec.description = 'Null Object Implementation'
|
14
14
|
spec.homepage = 'https://github.com/rootedbox/nullz'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
data/pkg/nullz-0.1.0.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nullz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Jacobs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description:
|
55
|
+
description: Null Object Implementation
|
56
56
|
email:
|
57
57
|
- nerfnerd@gmail.com
|
58
58
|
executables: []
|
@@ -71,8 +71,9 @@ files:
|
|
71
71
|
- bin/setup
|
72
72
|
- lib/.DS_Store
|
73
73
|
- lib/null_object.rb
|
74
|
-
- lib/
|
74
|
+
- lib/nullz/version.rb
|
75
75
|
- nullz.gemspec
|
76
|
+
- pkg/nullz-0.1.0.gem
|
76
77
|
homepage: https://github.com/rootedbox/nullz
|
77
78
|
licenses:
|
78
79
|
- MIT
|
@@ -93,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
94
|
- !ruby/object:Gem::Version
|
94
95
|
version: '0'
|
95
96
|
requirements: []
|
96
|
-
|
97
|
-
rubygems_version: 2.7.6
|
97
|
+
rubygems_version: 3.0.2
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
|
-
summary:
|
100
|
+
summary: Null Object
|
101
101
|
test_files: []
|
data/lib/null_object/version.rb
DELETED