null_and_void 1.5.0 → 1.6.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE.txt +19 -0
- data/lib/null_and_void/convertible.rb +4 -2
- data/lib/null_and_void/inflections.rb +4 -2
- data/lib/null_and_void/model_support.rb +2 -0
- data/lib/null_and_void/nullified.rb +5 -5
- data/lib/null_and_void/persistable.rb +12 -0
- data/lib/null_and_void/version.rb +1 -1
- metadata +31 -6
- metadata.gz.sig +0 -0
- data/LICENSE +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd57b6116b87debb496856ec08bfb61534b32736
|
4
|
+
data.tar.gz: ac78347d4f9623371d3793180bd38ca427244cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce07d944a7a2349de21ba76166f0815d4ed0cdca8b0ae107b8add0016a4c791b4f1f78433f587513cdcf367356c079ef1e4b63b370c61078af5306c0eb97cd98
|
7
|
+
data.tar.gz: 0fa946f52e6d6975cc2df4fccce0d1f1d4c94b02bfcae5be5f28d9d9eda14e8f8a381a0cc253c621932feaad156cd4df4cf9f844fc1bc51888f7447207c98464
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010-2016 The Kompanee, Ltd
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -10,7 +10,7 @@ module NullAndVoid
|
|
10
10
|
Complex(0)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
alias to_int to_i
|
14
14
|
|
15
15
|
def to_f
|
16
16
|
0.0
|
@@ -28,7 +28,7 @@ module NullAndVoid
|
|
28
28
|
[]
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
alias to_ary to_a
|
32
32
|
|
33
33
|
def to_hash
|
34
34
|
{}
|
@@ -50,6 +50,7 @@ module NullAndVoid
|
|
50
50
|
''
|
51
51
|
end
|
52
52
|
|
53
|
+
# rubocop:disable Style/ExtraSpacing
|
53
54
|
def to_model
|
54
55
|
base_path = NullAndVoid::Inflections.demodulize(self.class.name)
|
55
56
|
module_path = NullAndVoid::Inflections.deconstantize(self.class.name)
|
@@ -58,5 +59,6 @@ module NullAndVoid
|
|
58
59
|
|
59
60
|
NullAndVoid::Inflections.constantize(source_model_path).new
|
60
61
|
end
|
62
|
+
# rubocop:enable Style/ExtraSpacing
|
61
63
|
end
|
62
64
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# rubocop:disable Lint/AssignmentInCondition, Metrics/CyclomaticComplexity
|
2
2
|
# rubocop:disable Metrics/LineLength, Metrics/PerceivedComplexity, Style/EachWithObject
|
3
|
+
# rubocop:disable Style/ExtraSpacing
|
3
4
|
module NullAndVoid
|
4
5
|
module Inflections
|
5
6
|
def self.demodulize(path)
|
@@ -24,7 +25,7 @@ module Inflections
|
|
24
25
|
# Remove the first blank element in case of '::ClassName' notation.
|
25
26
|
names.shift if names.size > 1 && names.first.empty?
|
26
27
|
|
27
|
-
names.
|
28
|
+
names.inject(Object) do |constant, name|
|
28
29
|
if constant == Object
|
29
30
|
constant.const_get(name)
|
30
31
|
else
|
@@ -34,7 +35,7 @@ module Inflections
|
|
34
35
|
|
35
36
|
# Go down the ancestors to check it it's owned
|
36
37
|
# directly before we reach Object or the end of ancestors.
|
37
|
-
constant = constant.ancestors.
|
38
|
+
constant = constant.ancestors.inject do |const, ancestor|
|
38
39
|
break const if ancestor == Object
|
39
40
|
break ancestor if ancestor.const_defined?(name, false)
|
40
41
|
const
|
@@ -49,3 +50,4 @@ end
|
|
49
50
|
end
|
50
51
|
# rubocop:enable Lint/AssignmentInCondition, Metrics/CyclomaticComplexity
|
51
52
|
# rubocop:enable Metrics/LineLength, Metrics/PerceivedComplexity, Style/EachWithObject
|
53
|
+
# rubocop:enable Style/ExtraSpacing
|
@@ -4,6 +4,7 @@ require 'null_and_void/null_object'
|
|
4
4
|
module NullAndVoid
|
5
5
|
module ModelSupport
|
6
6
|
module ClassMethods
|
7
|
+
# rubocop:disable Style/ExtraSpacing
|
7
8
|
def as_null_object
|
8
9
|
base_path = NullAndVoid::Inflections.demodulize(name)
|
9
10
|
module_path = NullAndVoid::Inflections.deconstantize(name)
|
@@ -14,6 +15,7 @@ module NullAndVoid
|
|
14
15
|
rescue NameError
|
15
16
|
NullAndVoid::NullObject.instance
|
16
17
|
end
|
18
|
+
# rubocop:enable Style/ExtraSpacing
|
17
19
|
end
|
18
20
|
|
19
21
|
def as_null_object
|
@@ -7,11 +7,11 @@ require 'null_and_void/introspectable'
|
|
7
7
|
module NullAndVoid
|
8
8
|
module Nullified
|
9
9
|
def self.included(base)
|
10
|
-
base.
|
11
|
-
base.
|
12
|
-
base.
|
13
|
-
base.
|
14
|
-
base.
|
10
|
+
base.__send__(:include, Singleton)
|
11
|
+
base.__send__(:include, ::NullAndVoid::Stubbable)
|
12
|
+
base.__send__(:include, ::NullAndVoid::Convertible)
|
13
|
+
base.__send__(:include, ::NullAndVoid::Falsifiable)
|
14
|
+
base.__send__(:include, ::NullAndVoid::Introspectable)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
module NullAndVoid
|
2
2
|
module Persistable
|
3
|
+
module ClassMethods
|
4
|
+
def find(_id)
|
5
|
+
instance
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
def id
|
10
|
+
return 1 if caller[1].include?('/globalid')
|
11
|
+
|
4
12
|
nil
|
5
13
|
end
|
6
14
|
|
@@ -35,5 +43,9 @@ module NullAndVoid
|
|
35
43
|
def valid?
|
36
44
|
true
|
37
45
|
end
|
46
|
+
|
47
|
+
def self.included(base)
|
48
|
+
base.extend(ClassMethods)
|
49
|
+
end
|
38
50
|
end
|
39
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: null_and_void
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDrjCCApagAwIBAgIBATANBgkqhkiG9w0BAQUFADBOMRowGAYDVQQDDBFhY2Nv
|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eo8onII
|
29
|
+
lsVsWdMCLZS21M0uCQmcV+OQMNxL8jV3c0D3x9Srr9yO4oamW3seIdb+b9RfhmV2
|
30
|
+
ryr+NH8U/4xgzdJ4hWV4qk93nwigp4lwJ4u93XJ7Cdyw7itvaEPnn8HpCfzsiLcw
|
31
|
+
QwSfDGz6+zsImi5N3UT71+mk7YcviQSgvMRl3VkAv8MZ6wcJ5SQRpf9w0OeFH6Ln
|
32
|
+
nNbCoHiYeXX/lz/M6AIbxDIZZTwxcyvF7bdrQ2fbH5MsfQ==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2016-05-12 00:00:00.000000000 Z
|
12
35
|
dependencies:
|
13
36
|
- !ruby/object:Gem::Dependency
|
14
37
|
name: rspec
|
@@ -44,7 +67,7 @@ executables: []
|
|
44
67
|
extensions: []
|
45
68
|
extra_rdoc_files: []
|
46
69
|
files:
|
47
|
-
- LICENSE
|
70
|
+
- LICENSE.txt
|
48
71
|
- README.md
|
49
72
|
- Rakefile
|
50
73
|
- lib/null_and_void.rb
|
@@ -69,7 +92,8 @@ files:
|
|
69
92
|
- spec/nullified_spec.rb
|
70
93
|
- spec/stubbable_spec.rb
|
71
94
|
homepage: https://github.com/jfelchner/null_and_void
|
72
|
-
licenses:
|
95
|
+
licenses:
|
96
|
+
- MIT
|
73
97
|
metadata: {}
|
74
98
|
post_install_message:
|
75
99
|
rdoc_options: []
|
@@ -87,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
111
|
version: '0'
|
88
112
|
requirements: []
|
89
113
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.4.
|
114
|
+
rubygems_version: 2.4.5.1
|
91
115
|
signing_key:
|
92
116
|
specification_version: 4
|
93
117
|
summary: Easy Null Objects
|
@@ -101,3 +125,4 @@ test_files:
|
|
101
125
|
- spec/null_object_spec.rb
|
102
126
|
- spec/nullified_spec.rb
|
103
127
|
- spec/stubbable_spec.rb
|
128
|
+
has_rdoc:
|
metadata.gz.sig
ADDED
Binary file
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 Jeff Felchner
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|