transparent_nil 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ == 0.1.0 2012-10-15
3
+ * Initial public release
4
+
5
+
6
+
7
+
data/License.txt ADDED
@@ -0,0 +1,39 @@
1
+
2
+ == License For Kyanite
3
+ Creative Commons Attribution-Share Alike 3.0 Germany
4
+
5
+ (cc-by-sa) http://creativecommons.org/licenses/by-sa/3.0/de/deed.en
6
+
7
+ AUTOR: Björn Klippstein
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
13
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
15
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+
17
+
18
+ == License For ActiveSupport Methods
19
+
20
+ Copyright (c) 2005 David Heinemeier Hansson
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining
23
+ a copy of this software and associated documentation files (the
24
+ "Software"), to deal in the Software without restriction, including
25
+ without limitation the rights to use, copy, modify, merge, publish,
26
+ distribute, sublicense, and/or sell copies of the Software, and to
27
+ permit persons to whom the Software is furnished to do so, subject to
28
+ the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be
31
+ included in all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
37
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
38
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
39
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,11 @@
1
+ console.rb
2
+ History.txt
3
+ init.rb
4
+ License.txt
5
+ Manifest.txt
6
+ Rakefile.rb
7
+ README.txt
8
+ lib/transparent_nil.rb
9
+ lib/transparent_nil/nil.rb
10
+ test/_start_all.rb
11
+ test/test_nil.rb
data/README.txt ADDED
@@ -0,0 +1,39 @@
1
+
2
+ = *Transparent Nil*
3
+
4
+ http://bklippstein.github.com/transparent-nil/
5
+
6
+
7
+ == Features
8
+ * Transparent nil Handling, see NilClass
9
+
10
+
11
+
12
+ == Usage
13
+ require 'transparent_nil'
14
+
15
+
16
+ == License
17
+ cc-by-sa
18
+
19
+ Creative Commons Attribution-Share Alike 3.0 Germany
20
+
21
+ http://creativecommons.org/licenses/by-sa/3.0/de/deed.en
22
+
23
+
24
+ == Homepage
25
+ http://bklippstein.github.com/transparent-nil/
26
+
27
+
28
+ == Author
29
+ Björn Klippstein
30
+
31
+
32
+ == Disclaimer
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
37
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
38
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
39
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile.rb ADDED
@@ -0,0 +1,95 @@
1
+ # ruby encoding: utf-8
2
+
3
+ require 'kyanite/smart_load_path'
4
+ smart_load_path
5
+ require 'kyanite/hoe'
6
+ require 'kyanite/string'
7
+ Kyanite.projectname = File.dirname(__FILE__).split("/")[-1].strip # Name des Projekt-Stammverzeichnisses
8
+ Kyanite.github_username = 'bklippstein'
9
+ require 'rdoc/task'
10
+ require 'kyanite/rake'
11
+
12
+ require 'transparent_nil'
13
+
14
+
15
+
16
+ # ----------------------------------------------------------------------------------------------
17
+ # Hoe
18
+ #
19
+ # http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe
20
+ #
21
+ $hoe = Hoe.spec Kyanite.projectname do
22
+
23
+ # self.rubyforge_name = 'yourgemx' # if different than 'yourgem'
24
+
25
+ developer('Bjoern Klippstein', 'klippstein@klippstein.com')
26
+ summary = 'Transparent Nil'
27
+ extra_deps << ['kyanite', '>= 0.5.17']
28
+
29
+ remote_rdoc_dir = '' # Release to root only one project
30
+ urls = [["http://#{Kyanite.github_username}.github.com/#{Kyanite.projectname}/"]]
31
+
32
+
33
+ end
34
+
35
+ # require 'pp'
36
+ # pp $hoe
37
+
38
+
39
+
40
+
41
+
42
+ # ----------------------------------------------------------------------------------------------
43
+ # Documentation
44
+ #
45
+ # http://rubeh.tumblr.com/post/27622544/rake-rdoctask-with-all-of-the-options-stubbed-out
46
+ # http://www.java2s.com/Code/Ruby/Language-Basics/RDocoptionsareusedlikethisrdocoptionsnames.htm
47
+ #
48
+
49
+ remove_task 'docs'
50
+
51
+ desc "generate RDoc documentation"
52
+ Rake::RDocTask.new(:docs) do |rd|
53
+
54
+ rd.title = "#{Kyanite.projectname.capitalize} #{Kyanite.projectname.to_class.const_get('VERSION')}"
55
+
56
+ rd.rdoc_dir = 'doc'
57
+ rd.rdoc_files.include('lib/**/*.rb')
58
+ # rd.rdoc_files.include('test/**/test_*.rb')
59
+ rd.rdoc_files.include('README.txt', 'License.txt', 'History.txt' )
60
+
61
+ rd.options += [
62
+ '--tab-width', '4',
63
+ '--main', 'README.txt',
64
+ '--show-hash', # A name of the form #name in a comment is a possible hyperlink to an instance method name. When displayed, the # is removed unless this option is specified.
65
+ '--line-numbers',
66
+ '--all',
67
+ '--charset=utf8'
68
+ ]
69
+
70
+ end
71
+
72
+
73
+ # ----------------------------------------------------------------------------------------------
74
+ # Local Tasks
75
+ #
76
+
77
+ remove_task 'ridocs'
78
+ remove_task 'rdoc'
79
+ remove_task 'audit'
80
+ remove_task 'dcov'
81
+ remove_task 'debug_email'
82
+ remove_task 'debug_gem'
83
+ remove_task 'deploy'
84
+ remove_task 'deps:email'
85
+ remove_task 'install_gem'
86
+ remove_task 'multi'
87
+ remove_task 'newb'
88
+ #Dir['tasks/**/*.rake'].each { |t| load t }
89
+
90
+
91
+
92
+
93
+
94
+
95
+
data/console.rb ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+ libs = " -r irb/completion"
5
+ libs << " -r #{File.dirname(__FILE__) + '/init.rb'}"
6
+
7
+ puts "Welcome to Transparent Nil gem"
8
+
9
+ exec "#{irb} #{libs} --simple-prompt --noreadline"
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+
2
+ require File.join(File.dirname(__FILE__), 'lib', 'transparent_nil.rb' )
@@ -0,0 +1,88 @@
1
+ # ruby encoding: utf-8
2
+ # ü
3
+
4
+ puts 'required nil.rb'
5
+
6
+
7
+ # == Transparent Nil
8
+ # Nil nervt oft. Zwar ist es ein schöner Fehlerindikator
9
+ # (meist läuft irgendwas schief wenn man es unerwartet mit nil zu tun hat)
10
+ # aber man verunstaltet seinen Quellcode schnell mit Fallunterscheidungen, die den nil-Fall behandeln.
11
+ #
12
+ # In Kyanite werden daher zahlreiche Methoden für nil definiert.
13
+ # Nil verhält sich damit wie alle anderen Objekte auch.
14
+ # Man kann immer noch nach Nil fragen, wenn man es möchte, aber man muss es nicht mehr tun!
15
+ #
16
+ class NilClass
17
+
18
+ # Rückgabe: Array mit dem einen Element
19
+ def <<(element); [element]; end
20
+
21
+ # Rückgabe: true
22
+ def empty?; true; end
23
+
24
+ # Rückgabe: 0
25
+ def length; 0; end
26
+
27
+ # Rückgabe: 0
28
+ def size; 0; end
29
+
30
+ # Rückgabe: 0
31
+ def count(*a); 0; end
32
+
33
+ # Rückgabe: leeres Array
34
+ def split(*a); []; end
35
+
36
+ # Rückgabe: false
37
+ def =~(other); false; end
38
+
39
+ # Rückgabe: false
40
+ # redundante Definition!
41
+ def include?(*a); false; end
42
+
43
+
44
+ def -(other); nil; end
45
+ def +(other); nil; end
46
+ def <(*a); nil; end
47
+ def <=>(*a); nil; end
48
+ def >(*a); nil; end
49
+ def abs; nil; end
50
+ def chop; nil; end
51
+ def clear; nil; end
52
+ def code; nil; end
53
+ def collect(&block); nil; end
54
+ def compact; nil; end
55
+ def downcase; nil; end
56
+ def dup; nil; end
57
+ def each(*a); nil; end
58
+ def grep(*a); nil; end
59
+ def gsub!(*a); nil; end
60
+ def gsub(*a); nil; end
61
+ def join; nil; end
62
+ def keys; nil; end
63
+ def pop(*a); nil; end
64
+ def push(*a); nil; end
65
+ #def split(*a); nil; end
66
+ def strip!(*a); nil; end
67
+ def strip(*a); nil; end
68
+ def sub(*a); nil; end
69
+ def to_i; nil; end
70
+ def to_integer; nil; end
71
+ def to_nil; nil; end
72
+ def to_sym; nil; end
73
+ def uniq!; nil; end
74
+ def uniq; nil; end
75
+ def [](*a); nil; end
76
+ def []=(*a); nil; end
77
+
78
+
79
+ end
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
@@ -0,0 +1,19 @@
1
+ # ruby encoding: utf-8
2
+ # ü
3
+ if $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
4
+ #puts 'Path schon aktuell'
5
+ else
6
+ $:.unshift(File.dirname(__FILE__))
7
+ end
8
+
9
+ puts 'required transparent_nil.rb'
10
+
11
+ module TransparentNil #:nodoc
12
+
13
+ VERSION = '0.1.0'
14
+
15
+ end
16
+
17
+ require 'transparent_nil/nil'
18
+
19
+
@@ -0,0 +1,19 @@
1
+ # ruby encoding: utf-8
2
+ #!/usr/bin/env ruby
3
+ #
4
+ # Führt alle Tests aus
5
+ #
6
+
7
+ if $0 == __FILE__
8
+ require 'kyanite/smart_load_path.rb'
9
+ smart_load_path
10
+ end
11
+
12
+
13
+ # Test-Verzeichnis der Applikation
14
+ test_verzeichnis = File.expand_path(File.dirname(__FILE__) )
15
+
16
+ Dir["#{test_verzeichnis}/test_*.rb"].sort.each { |t| require t }
17
+
18
+
19
+
data/test/test_nil.rb ADDED
@@ -0,0 +1,48 @@
1
+ # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'kyanite/smart_load_path.rb'
5
+ smart_load_path
6
+ end
7
+
8
+ require 'kyanite/unit_test'
9
+ require 'kyanite/general/nil'
10
+
11
+ # Tests for NilClass
12
+ class TestTransparentNil < UnitTest
13
+
14
+ def test_nil_patches
15
+ assert nil.empty?
16
+
17
+ assert ! nil.include?('g')
18
+ assert ! nil.include?(nil)
19
+
20
+ assert_nil nil.to_nil
21
+ assert_equal 0, nil.size
22
+ assert_equal 0, nil.length
23
+
24
+ assert_equal nil, nil + 42
25
+ assert_equal nil, nil + '42'
26
+ assert_equal '', nil.to_s
27
+
28
+ assert_nil nil[1]
29
+ assert_nil nil[1,2]
30
+ assert_nil nil[1][2]
31
+ assert_nil nil[1][2,3][4]
32
+ assert_nil nil[nil]
33
+ assert_nil nil[nil,nil]
34
+ assert_nil nil[nil][nil]
35
+
36
+ assert_equal 42, nil[1] = 42
37
+ assert_equal 42, nil[1,2] = 42
38
+ assert_equal 42, nil[1][2] = 42
39
+ assert_equal 42, nil[1][2,3][4] = 42
40
+ assert_equal 42, nil[nil] = 42
41
+ assert_equal 42, nil[nil,nil] = 42
42
+ assert_equal 42, nil[nil][nil] = 42
43
+
44
+ end # test_nil_patches
45
+
46
+
47
+
48
+ end # class
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: transparent_nil
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bjoern Klippstein
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: kyanite
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.5.17
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.5.17
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.10'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.10'
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '3.1'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ description: ''
63
+ email:
64
+ - klippstein@klippstein.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files:
68
+ - History.txt
69
+ - License.txt
70
+ - Manifest.txt
71
+ - README.txt
72
+ files:
73
+ - console.rb
74
+ - History.txt
75
+ - init.rb
76
+ - License.txt
77
+ - Manifest.txt
78
+ - Rakefile.rb
79
+ - README.txt
80
+ - lib/transparent_nil.rb
81
+ - lib/transparent_nil/nil.rb
82
+ - test/_start_all.rb
83
+ - test/test_nil.rb
84
+ - .gemtest
85
+ homepage: http://bklippstein.github.com/transparent-nil/
86
+ licenses: []
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --main
90
+ - README.txt
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project: transparent_nil
107
+ rubygems_version: 1.8.24
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: ''
111
+ test_files:
112
+ - test/test_nil.rb