transparent_nil 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/License.txt +1 -1
- data/README.txt +19 -3
- data/Rakefile.rb +10 -10
- data/lib/transparent_nil/nil.rb +1 -12
- data/lib/transparent_nil.rb +2 -2
- data/test/test_nil.rb +2 -2
- metadata +17 -1
data/License.txt
CHANGED
data/README.txt
CHANGED
@@ -3,9 +3,25 @@
|
|
3
3
|
|
4
4
|
http://bklippstein.github.com/transparent_nil/
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
nil values can be quite annoying. Although it is a nice error indicator but you're source code
|
7
|
+
gets ugly with too many conditional statements that handle the nil case.
|
8
|
+
|
9
|
+
TransparentNil defines some methods for +nil+ so nil values behave like any other object. Most of them return just nil, but some are different:
|
10
|
+
nil.empty?
|
11
|
+
> true
|
12
|
+
|
13
|
+
nil << [element]
|
14
|
+
> [element]
|
15
|
+
|
16
|
+
nil.size
|
17
|
+
> 0
|
18
|
+
|
19
|
+
nil.split(//)
|
20
|
+
> []
|
21
|
+
|
22
|
+
Think +nil+ als "nothing". You can ask for nil if you need to, but you don't have to do it so often.
|
23
|
+
|
24
|
+
The Kyanite gem extends the usage of nil.
|
9
25
|
|
10
26
|
|
11
27
|
|
data/Rakefile.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'kyanite/smart_load_path'
|
4
4
|
smart_load_path
|
5
|
-
|
6
|
-
require '
|
7
|
-
|
8
|
-
|
5
|
+
|
6
|
+
require 'drumherum'
|
7
|
+
Drumherum.project_name = File.dirname(__FILE__).split("/")[-1].strip # Name des Projekt-Stammverzeichnisses
|
8
|
+
Drumherum.github_username = 'bklippstein'
|
9
9
|
require 'rdoc/task'
|
10
|
-
require '
|
10
|
+
require 'drumherum/rake'
|
11
11
|
|
12
12
|
require 'transparent_nil'
|
13
13
|
|
@@ -18,16 +18,16 @@ require 'transparent_nil'
|
|
18
18
|
#
|
19
19
|
# http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe
|
20
20
|
#
|
21
|
-
$hoe = Hoe.spec
|
21
|
+
$hoe = Hoe.spec Drumherum.project_name do
|
22
22
|
|
23
23
|
# self.rubyforge_name = 'yourgemx' # if different than 'yourgem'
|
24
24
|
|
25
25
|
developer('Bjoern Klippstein', 'klippstein@klippstein.com')
|
26
|
-
summary = '
|
27
|
-
|
26
|
+
summary = 'Nil values can be quite annoying. TransparentNil defines some methods for +nil+ so nil values behave like any other object.'
|
27
|
+
extra_dev_deps << ['drumherum', '>= 0.1.0']
|
28
28
|
|
29
29
|
remote_rdoc_dir = '' # Release to root only one project
|
30
|
-
urls = [["http://#{
|
30
|
+
urls = [["http://#{Drumherum.github_username}.github.com/#{Drumherum.project_name}/"]]
|
31
31
|
|
32
32
|
|
33
33
|
end
|
@@ -51,7 +51,7 @@ remove_task 'docs'
|
|
51
51
|
desc "generate RDoc documentation"
|
52
52
|
Rake::RDocTask.new(:docs) do |rd|
|
53
53
|
|
54
|
-
rd.title = "#{
|
54
|
+
rd.title = "#{Drumherum.project_class.to_s} #{Drumherum.project_version}"
|
55
55
|
|
56
56
|
rd.rdoc_dir = 'doc'
|
57
57
|
rd.rdoc_files.include('lib/**/*.rb')
|
data/lib/transparent_nil/nil.rb
CHANGED
@@ -1,18 +1,7 @@
|
|
1
1
|
# ruby encoding: utf-8
|
2
2
|
# ü
|
3
3
|
|
4
|
-
|
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
|
-
#
|
4
|
+
|
16
5
|
module TransparentNil
|
17
6
|
|
18
7
|
# Rückgabe: Array mit dem einen Element
|
data/lib/transparent_nil.rb
CHANGED
data/test/test_nil.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transparent_nil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.10'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: drumherum
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.1.0
|
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: 0.1.0
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: hoe
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|