null_and_void 1.3.0 → 1.3.1

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: 58b39812153fc58e40a5fc785eeecbb11f5b6505
4
- data.tar.gz: 392b568d86fe7b7a3271c7c440346147dccf52b0
3
+ metadata.gz: 0654e5f58b7aff4685fe3987c117b6d4534e9dfb
4
+ data.tar.gz: d41982e1fdbecf212796ede8842f2826a59ba8ae
5
5
  SHA512:
6
- metadata.gz: aacd733afcbf39f5f7dcec15ca0b10d2731633a7e580135f5bde4e0dceea42f7018bc2092ee4d61eaa2f1db0081d280c2df7132c10acc2a5db53583570b52e32
7
- data.tar.gz: 88be210ed359bdfbde81eea48ff5e70be1d077ac0859194b440860c0ad7ed533f9449d107dea7c284f95b2505255d306810ccac66d3ab3bf34d4634d8df7d1e4
6
+ metadata.gz: c113841029277cb3c5edb8e3dea85618173d3e29ac86fa791263beebdbbdf0f52e4209868444b342cb0fc72e07af681c3da0fc304121188f63309f787df83d8e
7
+ data.tar.gz: b86c5b629f33e49577e193afba301f9e1cd2847acc207629a9a8d214ddabadbfbfed27ea794c6b0c96a2f77221b0f961800fba1833f7215d312471429afd848a
data/LICENSE ADDED
@@ -0,0 +1,22 @@
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.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Null And Void
2
2
  ================================
3
3
 
4
+ [![Build Status](https://secure.travis-ci.org/jfelchner/null_and_void.png?branch=master)](http://travis-ci.org/jfelchner/null_and_void) [![Code Climate](https://codeclimate.com/github/jfelchner/null_and_void.png)](https://codeclimate.com/github/jfelchner/null_and_void) [![Code Climate](https://codeclimate.com/github/jfelchner/null_and_void/coverage.png)](https://codeclimate.com/github/jfelchner/null_and_void)
5
+
4
6
  **Create Null Objects with Ease**
5
7
 
6
8
  <img src="https://dl.dropbox.com/s/3vro4yd2vsa5xga/bad-luck-brian-null-object.jpg" align="right" />
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -10,13 +10,13 @@ module NullAndVoid
10
10
  Complex(0)
11
11
  end
12
12
 
13
- alias :to_int :to_i
13
+ alias_method :to_int, :to_i
14
14
 
15
15
  def to_f
16
16
  0.0
17
17
  end
18
18
 
19
- def rationalize(*args)
19
+ def rationalize(*_args)
20
20
  Rational(0)
21
21
  end
22
22
 
@@ -25,13 +25,13 @@ module NullAndVoid
25
25
  end
26
26
 
27
27
  def to_a
28
- Array.new
28
+ []
29
29
  end
30
30
 
31
- alias :to_ary :to_a
31
+ alias_method :to_ary, :to_a
32
32
 
33
33
  def to_hash
34
- Hash.new
34
+ {}
35
35
  end
36
36
 
37
37
  def to_html
@@ -1,9 +1,11 @@
1
+ # rubocop:disable Lint/AssignmentInCondition, Metrics/CyclomaticComplexity
2
+ # rubocop:disable Metrics/LineLength, Metrics/PerceivedComplexity, Style/EachWithObject
1
3
  module NullAndVoid
2
4
  module Inflections
3
5
  def self.demodulize(path)
4
6
  path = path.to_s
5
7
  if i = path.rindex('::')
6
- path[(i+2)..-1]
8
+ path[(i + 2)..-1]
7
9
  else
8
10
  path
9
11
  end
@@ -22,7 +24,7 @@ module Inflections
22
24
  # Remove the first blank element in case of '::ClassName' notation.
23
25
  names.shift if names.size > 1 && names.first.empty?
24
26
 
25
- names.inject(Object) do |constant, name|
27
+ names.reduce(Object) do |constant, name|
26
28
  if constant == Object
27
29
  constant.const_get(name)
28
30
  else
@@ -32,7 +34,7 @@ module Inflections
32
34
 
33
35
  # Go down the ancestors to check it it's owned
34
36
  # directly before we reach Object or the end of ancestors.
35
- constant = constant.ancestors.inject do |const, ancestor|
37
+ constant = constant.ancestors.reduce do |const, ancestor|
36
38
  break const if ancestor == Object
37
39
  break ancestor if ancestor.const_defined?(name, false)
38
40
  const
@@ -45,3 +47,5 @@ module Inflections
45
47
  end
46
48
  end
47
49
  end
50
+ # rubocop:enable Lint/AssignmentInCondition, Metrics/CyclomaticComplexity
51
+ # rubocop:enable Metrics/LineLength, Metrics/PerceivedComplexity, Style/EachWithObject
@@ -5,8 +5,8 @@ module NullAndVoid
5
5
  module ModelSupport
6
6
  module ClassMethods
7
7
  def as_null_object
8
- base_path = NullAndVoid::Inflections.demodulize(self.name)
9
- module_path = NullAndVoid::Inflections.deconstantize(self.name)
8
+ base_path = NullAndVoid::Inflections.demodulize(name)
9
+ module_path = NullAndVoid::Inflections.deconstantize(name)
10
10
  null_object_base = "Null#{base_path}"
11
11
  source_model_path = "#{module_path}::#{null_object_base}"
12
12
 
@@ -1,6 +1,6 @@
1
1
  module NullAndVoid
2
2
  module Stubbable
3
- def method_missing(*args, &block)
3
+ def method_missing(*_args, &_block)
4
4
  self
5
5
  end
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module NullAndVoid
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -18,58 +18,60 @@ describe NullAndVoid::Convertible do
18
18
  let(:null_object) { FooBar::NullObject.new }
19
19
 
20
20
  it 'is zero when the attempt is made to convert it to an Integer' do
21
- null_object.to_i.should be_an Integer
22
- null_object.to_i.should be_zero
21
+ expect(null_object.to_i).to be_an Integer
22
+ expect(null_object.to_i).to be_zero
23
23
 
24
- null_object.to_int.should be_an Integer
25
- null_object.to_int.should be_zero
24
+ expect(null_object.to_int).to be_an Integer
25
+ expect(null_object.to_int).to be_zero
26
26
  end
27
27
 
28
28
  it 'is zero when the attempt is made to convert it to a Complex number' do
29
- null_object.to_c.should be_a Complex
30
- null_object.to_c.should be_zero
29
+ expect(null_object.to_c).to be_a Complex
30
+ expect(null_object.to_c).to be_zero
31
31
  end
32
32
 
33
33
  it 'is zero when the attempt is made to convert it to a Float' do
34
- null_object.to_f.should be_a Float
35
- null_object.to_f.should be_zero
34
+ expect(null_object.to_f).to be_a Float
35
+ expect(null_object.to_f).to be_zero
36
36
  end
37
37
 
38
38
  it 'is zero when the attempt is made to convert it to a Rational' do
39
- null_object.to_r.should be_a Rational
40
- null_object.to_r.should be_zero
39
+ expect(null_object.to_r).to be_a Rational
40
+ expect(null_object.to_r).to be_zero
41
41
 
42
- null_object.rationalize.should be_a Rational
43
- null_object.rationalize.should be_zero
42
+ expect(null_object.rationalize).to be_a Rational
43
+ expect(null_object.rationalize).to be_zero
44
44
  end
45
45
 
46
46
  it 'is an empty Array when the attempt is made to convert it to an Array' do
47
- null_object.to_a.should eql []
48
- null_object.to_ary.should eql []
47
+ expect(null_object.to_a).to eql []
48
+ expect(null_object.to_ary).to eql []
49
49
  end
50
50
 
51
51
  it 'is an empty Hash when the attempt is made to convert it to an Hash' do
52
- null_object.to_hash.should eql Hash.new
52
+ expect(null_object.to_hash).to eql({})
53
53
  end
54
54
 
55
55
  it 'is an empty String when the attempt is made to convert it to HTML' do
56
- null_object.to_html.should eql ''
56
+ expect(null_object.to_html).to eql ''
57
57
  end
58
58
 
59
59
  it 'is an empty String when the attempt is made to convert it to JSON' do
60
- null_object.to_json.should eql 'null'
60
+ expect(null_object.to_json).to eql 'null'
61
61
  end
62
62
 
63
63
  it 'is an empty String when the attempt is made to convert it to XML' do
64
- null_object.to_xml.should eql ''
64
+ expect(null_object.to_xml).to eql ''
65
65
  end
66
66
 
67
67
  it 'is an empty String when the attempt is made to convert it to a String' do
68
- null_object.to_s.should eql ''
68
+ expect(null_object.to_s).to eql ''
69
69
  end
70
70
 
71
- it 'is the class the Null Object is based on when the attempt is made to convert it to a value object' do
72
- null_object.to_model.should be_a FooBar::Object
71
+ it 'is the class the Null Object is based on when the attempt is made to convert ' \
72
+ 'it to a value object' do
73
+
74
+ expect(null_object.to_model).to be_a FooBar::Object
73
75
  end
74
76
 
75
77
  it 'raises an error if the model the Null Object is based on does not exist' do
@@ -8,19 +8,21 @@ end
8
8
  describe NullAndVoid::Falsifiable do
9
9
  let(:null_object) { NullObject.new }
10
10
 
11
+ # rubocop:disable Style/DoubleNegation
11
12
  it 'can be double inverted to be false' do
12
- (!!null_object).should be_false
13
+ expect(!!null_object).to eql false
13
14
  end
15
+ # rubocop:enable Style/DoubleNegation
14
16
 
15
17
  it 'is blank' do
16
- null_object.should be_blank
18
+ expect(null_object).to be_blank
17
19
  end
18
20
 
19
21
  it 'is nil' do
20
- null_object.should be_nil
22
+ expect(null_object).to be_nil
21
23
  end
22
24
 
23
25
  it 'is not present' do
24
- null_object.should_not be_present
26
+ expect(null_object).not_to be_present
25
27
  end
26
28
  end
@@ -9,10 +9,10 @@ describe NullAndVoid::Introspectable do
9
9
  let(:null_object) { MyNullObject.new }
10
10
 
11
11
  it 'knows it is a null object' do
12
- null_object.should be_null_object
12
+ expect(null_object).to be_null_object
13
13
  end
14
14
 
15
15
  it 'can inspect itself' do
16
- null_object.inspect.should match /\A#<MyNullObject:0x[a-f0-9]{12}>\z/
16
+ expect(null_object.inspect).to match(/\A#<MyNullObject:0x[a-f0-9]{4,12}>\z/)
17
17
  end
18
18
  end
@@ -8,13 +8,13 @@ end
8
8
  describe NullAndVoid::Maybe do
9
9
  context 'when it is passed a nil' do
10
10
  it 'is a null object' do
11
- MyObject.new.maybe(nil).should be_a NullAndVoid::NullObject
11
+ expect(MyObject.new.maybe(nil)).to be_a NullAndVoid::NullObject
12
12
  end
13
13
  end
14
14
 
15
15
  context 'when it is passed something other than nil' do
16
16
  it 'is the non-nil object' do
17
- MyObject.new.maybe(1).should eql 1
17
+ expect(MyObject.new.maybe(1)).to eql 1
18
18
  end
19
19
  end
20
20
  end
@@ -19,14 +19,16 @@ describe NullAndVoid::ModelSupport do
19
19
  let(:model) { FooBar::MyNullableModel.new }
20
20
 
21
21
  it 'can convert a model into its Null Object if it exists' do
22
- model.as_null_object.should be_a FooBar::NullMyNullableModel
22
+ expect(model.as_null_object).to be_a FooBar::NullMyNullableModel
23
23
  end
24
24
 
25
25
  it "can convert the model's class into its Null Object if it exists" do
26
- model.class.as_null_object.should be_a FooBar::NullMyNullableModel
26
+ expect(model.class.as_null_object).to be_a FooBar::NullMyNullableModel
27
27
  end
28
28
 
29
- it 'can convert a model into a generic Null Object a model-specific Null Object does not exist' do
30
- NonNullableModel.as_null_object.should be_a NullAndVoid::NullObject
29
+ it 'can convert a model into a generic Null Object a model-specific Null Object ' \
30
+ 'does not exist' do
31
+
32
+ expect(NonNullableModel.as_null_object).to be_a NullAndVoid::NullObject
31
33
  end
32
34
  end
@@ -3,6 +3,6 @@ require 'null_and_void'
3
3
 
4
4
  describe NullAndVoid do
5
5
  it 'can perform "maybies"' do
6
- NullAndVoid.maybe(nil).should be_a NullAndVoid::NullObject
6
+ expect(NullAndVoid.maybe(nil)).to be_a NullAndVoid::NullObject
7
7
  end
8
8
  end
@@ -9,14 +9,14 @@ describe NullAndVoid::NullObject do
9
9
  end
10
10
 
11
11
  it 'is stubbable' do
12
- null_object.should be_a NullAndVoid::Stubbable
12
+ expect(null_object).to be_a NullAndVoid::Stubbable
13
13
  end
14
14
 
15
15
  it 'is convertible' do
16
- null_object.should be_a NullAndVoid::Convertible
16
+ expect(null_object).to be_a NullAndVoid::Convertible
17
17
  end
18
18
 
19
19
  it 'is falsifiable' do
20
- null_object.should be_a NullAndVoid::Falsifiable
20
+ expect(null_object).to be_a NullAndVoid::Falsifiable
21
21
  end
22
22
  end
@@ -22,18 +22,20 @@ describe NullAndVoid::Nullified do
22
22
  end
23
23
 
24
24
  it 'handles undefined methods' do
25
- null_object.foobar.should eql NullWidget.instance
25
+ expect(null_object.foobar).to eql NullWidget.instance
26
26
  end
27
27
 
28
28
  it 'handles conversions' do
29
- null_object.to_a.should eql []
29
+ expect(null_object.to_a).to eql []
30
30
  end
31
31
 
32
+ # rubocop:disable Style/DoubleNegation
32
33
  it 'is falsifiable' do
33
- (!!null_object).should be_false
34
+ expect(!!null_object).to eql false
34
35
  end
36
+ # rubocop:enable Style/DoubleNegation
35
37
 
36
38
  it 'can implement its own methods' do
37
- null_object.my_null_object_method.should eql 'i am null'
39
+ expect(null_object.my_null_object_method).to eql 'i am null'
38
40
  end
39
41
  end
@@ -9,6 +9,6 @@ describe NullAndVoid::Stubbable do
9
9
  let(:null_object) { NullObject.new }
10
10
 
11
11
  it 'returns itself for all unknown method calls' do
12
- null_object.foobar.should eql null_object
12
+ expect(null_object.foobar).to eql null_object
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: null_and_void
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,35 +16,35 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.12'
19
+ version: '3.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.12'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspectacular
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.11'
33
+ version: 0.21.6
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.11'
40
+ version: 0.21.6
41
41
  description: Makes generating Null Objects easy.
42
42
  email: accounts+git@thekompanee.com
43
43
  executables: []
44
44
  extensions: []
45
- extra_rdoc_files:
46
- - README.md
45
+ extra_rdoc_files: []
47
46
  files:
47
+ - LICENSE
48
48
  - README.md
49
49
  - Rakefile
50
50
  - lib/null_and_void.rb
@@ -71,8 +71,7 @@ homepage: https://github.com/jfelchner/null_and_void
71
71
  licenses: []
72
72
  metadata: {}
73
73
  post_install_message:
74
- rdoc_options:
75
- - "--charset = UTF-8"
74
+ rdoc_options: []
76
75
  require_paths:
77
76
  - lib
78
77
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -86,8 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
85
  - !ruby/object:Gem::Version
87
86
  version: '0'
88
87
  requirements: []
89
- rubyforge_project: null_and_void
90
- rubygems_version: 2.2.0
88
+ rubyforge_project:
89
+ rubygems_version: 2.4.6
91
90
  signing_key:
92
91
  specification_version: 4
93
92
  summary: Easy Null Objects
@@ -101,4 +100,3 @@ test_files:
101
100
  - spec/null_object_spec.rb
102
101
  - spec/nullified_spec.rb
103
102
  - spec/stubbable_spec.rb
104
- has_rdoc: