NilBeGone 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 48227e928066bb6128aad3d1ef56070a28b7b7ca
4
+ data.tar.gz: e82703de50fcc4e65db74ded73ac2954102b00e0
5
+ SHA512:
6
+ metadata.gz: 700270652c646553cde20ffbccf278c539c4825ca0cda31efa9648f0d1fa674c41c667a1ead509a9aaf14f0282b13112c7fa1f856f7274c2a30487db98c2d046
7
+ data.tar.gz: e294538413bc58a249d97b083f9aa12b282b3b0b958405cdc8616b97e119207f324165ee4b64dd3ef330efa277efe82fcb724c6d4bcdc757486eaf12b5dcf649
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in NilBeGone.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matt Cassidy
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.
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'NilBeGone/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'NilBeGone'
8
+ spec.version = NilBeGone::VERSION
9
+ spec.authors = ['Matt Cassidy']
10
+ spec.email = ['mc11235@gmail.com']
11
+ spec.summary = %q{Nil is a pain so stop it}
12
+ spec.description = %q{Allow nil to be temporarily changed to nil_value in the context of the call stack}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler'
22
+ spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'rake'
24
+
25
+ spec.add_dependency 'binding_of_caller'
26
+ end
@@ -0,0 +1,34 @@
1
+ # NilBeGone
2
+
3
+ Nil got you down, showing up at the wrong time and in the wrong place? Use NilBeGone and change that nil to something else.
4
+
5
+ Probably shouldn't be used in production.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'NilBeGone'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install NilBeGone
20
+
21
+ ## Usage
22
+
23
+ nil_value = 5
24
+ other_value = nil
25
+ other_value + 10 == 15
26
+
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/[my-github-username]/NilBeGone/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create a new Pull Request
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ # Get your spec rake tasks working in RSpec 2.0
4
+
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ require 'NilBeGone/version'
2
+ require 'binding_of_caller'
3
+
4
+ class NilClass
5
+ def method_missing(method, *args, &block)
6
+ missing_value = nil
7
+ n = 2
8
+ loop do
9
+ begin
10
+ missing_value = binding.of_caller(n).eval('nil_value rescue nil')
11
+ return missing_value.send(method, *args, &block) unless missing_value.nil?
12
+ n += 1
13
+ rescue
14
+ break
15
+ end
16
+ end
17
+ super
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module NilBeGone
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,56 @@
1
+ unless Object.const_defined? :NilBeGone
2
+ $:.unshift File.expand_path '../../lib', __FILE__
3
+ require 'NilBeGone'
4
+ require 'NilBeGone/version'
5
+ end
6
+
7
+ describe NilBeGone do
8
+ describe 'magic' do
9
+ it 'should look up nil_value in binding for LHS' do
10
+ nil_value = 2
11
+ (nil + 2).should eql(4)
12
+ end
13
+
14
+
15
+ xit 'should look up nil_value in binding for RHS' do
16
+ nil_value = 3
17
+ result = 2 + nil
18
+ result.should eql(5)
19
+ end
20
+
21
+ it 'should pass along the message to the nil_value' do
22
+ nil_value = 'hello'
23
+ (nil.split('')).should eql(%w(h e l l o))
24
+ end
25
+
26
+ it 'should work if variable isnt the nil literal on the LHS' do
27
+ nil_value = 'hello'
28
+ other_value = nil
29
+ (other_value + ' world').should eql('hello world')
30
+ end
31
+
32
+ xit 'should work if variable isnt the nil literal on the RHS' do
33
+ nil_value = ' world'
34
+ other_value = nil
35
+ ('hello' + other_value).should eql('hello world')
36
+ end
37
+
38
+ it 'should look up multiple bindings for nil_value' do
39
+ klass = Class.new do
40
+ def a
41
+ nil_value = 'hello'
42
+ b
43
+ end
44
+
45
+ def b
46
+ c
47
+ end
48
+
49
+ def c
50
+ nil + ' world'
51
+ end
52
+ end
53
+ klass.new.a.should eql('hello world')
54
+ end
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: NilBeGone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Cassidy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: binding_of_caller
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Allow nil to be temporarily changed to nil_value in the context of the
70
+ call stack
71
+ email:
72
+ - mc11235@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - NilBeGone.gemspec
81
+ - README.md
82
+ - Rakefile
83
+ - lib/NilBeGone.rb
84
+ - lib/NilBeGone/version.rb
85
+ - spec/nil_be_gone_spec.rb
86
+ homepage: ''
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.4.4
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Nil is a pain so stop it
110
+ test_files:
111
+ - spec/nil_be_gone_spec.rb
112
+ has_rdoc: