JoergWMittag-b001e 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rst +1 -1
- data/b001e.gemspec +1 -1
- data/lib/b001e.rb +12 -0
- data/lib/b001e/extensions/core/false_class_extensions.rb +23 -0
- data/lib/b001e/extensions/core/nil_class_extensions.rb +23 -0
- data/lib/b001e/extensions/core/object_extensions.rb +23 -0
- data/lib/b001e/extensions/core/true_class_extensions.rb +23 -0
- data/lib/b001e/falsiness.rb +38 -0
- data/lib/b001e/truthiness.rb +38 -0
- data/spec/b001e_suite.rb +12 -0
- data/spec/if_spec.rb +1 -1
- metadata +1 -1
data/README.rst
CHANGED
@@ -89,7 +89,7 @@ Usage
|
|
89
89
|
::
|
90
90
|
|
91
91
|
begin require 'rubygems'; rescue LoadError
|
92
|
-
else begin gem 'JoergWMittag-b001e', '~> 0.0.
|
92
|
+
else begin gem 'JoergWMittag-b001e', '~> 0.0.3'; rescue Gem::LoadError; end end
|
93
93
|
require 'b001e'
|
94
94
|
|
95
95
|
true.and { nil.or { 42 } }.if { puts "It's true!" }
|
data/b001e.gemspec
CHANGED
@@ -34,7 +34,7 @@ speclist = filelist.grep /^spec/
|
|
34
34
|
$spec = Gem::Specification.new do |s|
|
35
35
|
s.name = 'b001e'
|
36
36
|
s.summary = 'Message-sending based re-implementation of the Boolean operators.'
|
37
|
-
s.version = Gem::Version.new '0.0.
|
37
|
+
s.version = Gem::Version.new '0.0.3'
|
38
38
|
s.author = 'Jörg W Mittag'
|
39
39
|
s.email = 'JoergWMittag+B001e@GoogleMail.Com'
|
40
40
|
s.homepage = 'https://JoergWMittag.GitHub.Com/b001e/'
|
data/lib/b001e.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
2
|
+
|
3
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
4
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
require 'b001e/extensions/core/object_extensions'
|
10
|
+
require 'b001e/extensions/core/true_class_extensions'
|
11
|
+
require 'b001e/extensions/core/false_class_extensions'
|
12
|
+
require 'b001e/extensions/core/nil_class_extensions'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
2
|
+
|
3
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
4
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
require 'b001e/falsiness'
|
10
|
+
|
11
|
+
module B001e
|
12
|
+
module Extensions
|
13
|
+
module Core
|
14
|
+
module FalseClassExtensions
|
15
|
+
include B001e::Falsiness
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class FalseClass
|
22
|
+
include B001e::Extensions::Core::FalseClassExtensions
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
2
|
+
|
3
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
4
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
require 'b001e/falsiness'
|
10
|
+
|
11
|
+
module B001e
|
12
|
+
module Extensions
|
13
|
+
module Core
|
14
|
+
module NilClassExtensions
|
15
|
+
include B001e::Falsiness
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class NilClass
|
22
|
+
include B001e::Extensions::Core::NilClassExtensions
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
2
|
+
|
3
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
4
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
require 'b001e/truthiness'
|
10
|
+
|
11
|
+
module B001e
|
12
|
+
module Extensions
|
13
|
+
module Core
|
14
|
+
module ObjectExtensions
|
15
|
+
include B001e::Truthiness
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Object
|
22
|
+
include B001e::Extensions::Core::ObjectExtensions
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
2
|
+
|
3
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
4
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
require 'b001e/truthiness'
|
10
|
+
|
11
|
+
module B001e
|
12
|
+
module Extensions
|
13
|
+
module Core
|
14
|
+
module TrueClassExtensions
|
15
|
+
include B001e::Truthiness
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class TrueClass
|
22
|
+
include B001e::Extensions::Core::TrueClassExtensions
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
2
|
+
|
3
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
4
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
module B001e
|
10
|
+
module Falsiness
|
11
|
+
def if
|
12
|
+
end
|
13
|
+
|
14
|
+
def ifelse _ = nil, else_branch = ->() {}
|
15
|
+
else_branch.call
|
16
|
+
end
|
17
|
+
|
18
|
+
def unless
|
19
|
+
yield
|
20
|
+
end
|
21
|
+
|
22
|
+
def unlesselse unless_branch = ->() {}, _ = nil
|
23
|
+
ifelse _, unless_branch
|
24
|
+
end
|
25
|
+
|
26
|
+
def and
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def or
|
31
|
+
yield
|
32
|
+
end
|
33
|
+
|
34
|
+
def not
|
35
|
+
true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
2
|
+
|
3
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
4
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
module B001e
|
10
|
+
module Truthiness
|
11
|
+
def if
|
12
|
+
yield
|
13
|
+
end
|
14
|
+
|
15
|
+
def ifelse then_branch = ->() {}, _ = nil
|
16
|
+
then_branch.call
|
17
|
+
end
|
18
|
+
|
19
|
+
def unless
|
20
|
+
end
|
21
|
+
|
22
|
+
def unlesselse _ = nil, else_branch = ->() {}
|
23
|
+
ifelse else_branch, _
|
24
|
+
end
|
25
|
+
|
26
|
+
def and
|
27
|
+
yield
|
28
|
+
end
|
29
|
+
|
30
|
+
def or
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def not
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/b001e_suite.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby1.9
|
2
|
+
# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2
|
3
|
+
|
4
|
+
#Copyright (c) 2009 Jörg W Mittag <JoergWMittag+B001e@GoogleMail.Com>
|
5
|
+
#This code is licensed under the terms of the MIT License (see LICENSE.txt)
|
6
|
+
|
7
|
+
specdir = File.expand_path(File.dirname __FILE__).gsub(/(.*spec).*?/, '\1')
|
8
|
+
$LOAD_PATH.unshift specdir unless $LOAD_PATH.include? specdir
|
9
|
+
|
10
|
+
require 'spec_helper'
|
11
|
+
|
12
|
+
Dir[File.join specdir, '**', '*_spec.rb'].each { |spec| require spec }
|
data/spec/if_spec.rb
CHANGED