transparent_nil 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
data/License.rdoc CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- == License For TransparentNil
2
+ == License
3
3
  Creative Commons Attribution-Share Alike 3.0 Germany
4
4
 
5
5
  (cc-by-sa) http://creativecommons.org/licenses/by-sa/3.0/de/deed.en
@@ -14,26 +14,3 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14
14
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
15
15
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
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 CHANGED
@@ -9,5 +9,7 @@ README.rdoc
9
9
  version.rb
10
10
  lib/transparent_nil.rb
11
11
  lib/transparent_nil/nil.rb
12
+ lib/transparent_nil/numeric.rb
13
+ lib/transparent_nil/object.rb
12
14
  test/_start_all.rb
13
15
  test/test_nil.rb
data/README.rdoc CHANGED
@@ -40,7 +40,7 @@ The Kyanite gem extends the usage of nil.
40
40
 
41
41
  == More Info
42
42
  * *Documentation*: {http://bklippstein.github.com/transparent_nil/frames.html github.com/transparent_nil}
43
- * *Source* *code*: {https://github.com/bklippstein/transparent_nil github.com/bklippstein/transparent_nil}
43
+ * *Source* *code*: {https://github.com/bklippstein/transparent_nil github.com/bklippstein}
44
44
  * *License*: {http://creativecommons.org/licenses/by-sa/3.0/de/deed.en cc-by-sa Creative Commons Attribution-Share Alike 3.0 Germany}
45
45
  * *Autor*: {mailto:klippstein@klippstein.com Björn Klippstein}
46
46
 
data/Rakefile.rb CHANGED
@@ -24,7 +24,7 @@ $hoe = Hoe.spec Drumherum.project_name do |p|
24
24
 
25
25
  p.developer('Bjoern Klippstein', 'klippstein@klippstein.com')
26
26
  p.remote_rdoc_dir = '' # Release to root only one project
27
- p.urls = [Drumherum.url_docs, Drumherum.url_source]
27
+ p.urls = [Drumherum.url_docs, 'https://github.com/bklippstein']
28
28
 
29
29
 
30
30
  end
@@ -3,5 +3,6 @@
3
3
 
4
4
  puts 'Using TransparentNil'
5
5
  require 'transparent_nil/nil'
6
+ require 'transparent_nil/numeric'
6
7
 
7
8
 
@@ -6,29 +6,36 @@ module TransparentNil
6
6
 
7
7
  # @group Return something
8
8
 
9
+ # Returns one element array
9
10
  # @return [Array] one element array
10
11
  def <<(element); [element]; end
11
12
 
12
- # @return [true]
13
+ # +true+
14
+ # @return [Boolean]
13
15
  def empty?; true; end
14
16
 
15
- # @return [false]
17
+ # +false+
18
+ # @return [Boolean]
16
19
  def =~(other); false; end
17
20
 
18
- # @return [false]
19
- # redundante Definition!
21
+ # +false+. Redundante Definition!
22
+ # @return [Boolean]
20
23
  def include?(*a); false; end
21
24
 
22
- # @return [0]
25
+ # +0+.
26
+ # @return [Integer]
23
27
  def length; 0; end
24
28
 
25
- # @return [0]
29
+ # +0+.
30
+ # @return [Integer]
26
31
  def size; 0; end
27
32
 
28
- # @return [0]
33
+ # +0+.
34
+ # @return [Integer]
29
35
  def count(*a); 0; end
30
36
 
31
- # @return [Array] empty Array
37
+ # Empty Array.
38
+ # @return [Array]
32
39
  def split(*a); []; end
33
40
 
34
41
 
@@ -61,12 +68,14 @@ module TransparentNil
61
68
  def to_i; nil; end
62
69
  def to_integer; nil; end
63
70
  def to_nil; nil; end
71
+ def to_nil_if(*a); nil; end
72
+ def to_nil_unless(*a); nil; end
64
73
  def to_sym; nil; end
65
74
  def uniq!; nil; end
66
75
  def uniq; nil; end
67
76
  def [](*a); nil; end
68
77
  def []=(*a); nil; end
69
-
78
+ def substract(other); nil; end
70
79
 
71
80
  end
72
81
 
@@ -0,0 +1,33 @@
1
+ # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
8
+
9
+
10
+
11
+ # @!macro numeric
12
+ class Numeric
13
+
14
+ # Returns nil if 0.
15
+ # @return [Numeric, NilClass]
16
+ def to_nil(*args)
17
+ return nil if self == 0
18
+ self
19
+ end
20
+
21
+
22
+ # Nil-safe substraction.
23
+ # Returns nil if 0.
24
+ # @return [Numeric, NilClass]
25
+ def substract(other)
26
+ return nil if other.nil?
27
+ self - other
28
+ end
29
+
30
+
31
+
32
+ end # class
33
+
@@ -0,0 +1,38 @@
1
+ # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
8
+
9
+
10
+
11
+ class Object
12
+
13
+ # Returns +nil+ if the condition is true. Otherwise +self+.
14
+ # @param condition [Symbol]
15
+ # @return [nil, self]
16
+ #
17
+ def to_nil_if(condition = :empty)
18
+ return nil if self.respond(condition.to_s + '?')
19
+ return self
20
+ end
21
+
22
+
23
+
24
+ # (see #to_nil_if)
25
+ def to_nil_unless(condition = :empty)
26
+ return nil unless self.respond(condition.to_s + '?')
27
+ return self
28
+ end
29
+
30
+
31
+ end
32
+
33
+
34
+
35
+
36
+
37
+
38
+
data/test/_start_all.rb CHANGED
@@ -3,16 +3,8 @@
3
3
  # Führt alle Tests aus
4
4
  #
5
5
 
6
- if $0 == __FILE__
7
- require 'drumherum'
8
- smart_init
9
- end
10
-
11
-
12
- # Test-Verzeichnis der Applikation
13
- test_verzeichnis = File.join(Drumherum::directory_main, 'test')
14
-
15
- Dir["#{test_verzeichnis}/test_*.rb"].sort.each { |t| require t }
6
+ test_verzeichnis = File.expand_path(File.dirname(__FILE__) )
7
+ Dir["#{File.join(test_verzeichnis)}/test_*.rb"].sort.each { |t| require t }
16
8
 
17
9
 
18
10
 
data/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  module TransparentNil
3
3
 
4
- VERSION = '0.1.19'
4
+ VERSION = '0.1.20'
5
5
 
6
6
  end
7
7
 
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.19
4
+ version: 0.1.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-26 00:00:00.000000000 Z
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -98,6 +98,8 @@ files:
98
98
  - version.rb
99
99
  - lib/transparent_nil.rb
100
100
  - lib/transparent_nil/nil.rb
101
+ - lib/transparent_nil/numeric.rb
102
+ - lib/transparent_nil/object.rb
101
103
  - test/_start_all.rb
102
104
  - test/test_nil.rb
103
105
  - .gemtest