fuby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/fuby.gemspec +21 -0
- data/lib/fuby.rb +1 -0
- data/lib/fuby/abbreviation.rb +20 -0
- data/lib/fuby/alias_method.rb +13 -0
- data/lib/fuby/all.rb +11 -0
- data/lib/fuby/and.rb +9 -0
- data/lib/fuby/any.rb +11 -0
- data/lib/fuby/attributes.rb +17 -0
- data/lib/fuby/bind.rb +21 -0
- data/lib/fuby/class_attributes.rb +39 -0
- data/lib/fuby/deep.rb +1 -0
- data/lib/fuby/deep_each.rb +14 -0
- data/lib/fuby/define_instance_method.rb +18 -0
- data/lib/fuby/define_missing_method.rb +36 -0
- data/lib/fuby/define_object_method.rb +18 -0
- data/lib/fuby/define_tok.rb +11 -0
- data/lib/fuby/descendants.rb +15 -0
- data/lib/fuby/dimension.rb +23 -0
- data/lib/fuby/drop.rb +20 -0
- data/lib/fuby/drop_until.rb +18 -0
- data/lib/fuby/drop_while.rb +15 -0
- data/lib/fuby/each.rb +2 -0
- data/lib/fuby/each_with_index_or_key.rb +19 -0
- data/lib/fuby/eql.rb +1 -0
- data/lib/fuby/eql_componentwise.rb +13 -0
- data/lib/fuby/equivalence.rb +13 -0
- data/lib/fuby/eval.rb +54 -0
- data/lib/fuby/extend.rb +13 -0
- data/lib/fuby/format.rb +9 -0
- data/lib/fuby/include.rb +13 -0
- data/lib/fuby/index_or_key.rb +19 -0
- data/lib/fuby/instance_attributes.rb +39 -0
- data/lib/fuby/intercept.rb +27 -0
- data/lib/fuby/invert.rb +16 -0
- data/lib/fuby/longest_common.rb +16 -0
- data/lib/fuby/matches.rb +11 -0
- data/lib/fuby/matches_componentwise.rb +11 -0
- data/lib/fuby/matches_part_of.rb +16 -0
- data/lib/fuby/matches_prefix_of.rb +11 -0
- data/lib/fuby/matches_suffix_of.rb +13 -0
- data/lib/fuby/member.rb +11 -0
- data/lib/fuby/merge.rb +20 -0
- data/lib/fuby/merge_css.rb +32 -0
- data/lib/fuby/method_added_as.rb +1 -0
- data/lib/fuby/method_added_as_binary_operator.rb +16 -0
- data/lib/fuby/method_added_as_filter.rb +19 -0
- data/lib/fuby/new.rb +16 -0
- data/lib/fuby/not.rb +25 -0
- data/lib/fuby/opposite.rb +29 -0
- data/lib/fuby/or.rb +9 -0
- data/lib/fuby/otherwise.rb +18 -0
- data/lib/fuby/part_of.rb +16 -0
- data/lib/fuby/plus.rb +10 -0
- data/lib/fuby/pop.rb +11 -0
- data/lib/fuby/pop_if.rb +15 -0
- data/lib/fuby/pop_options.rb +15 -0
- data/lib/fuby/pop_unless.rb +11 -0
- data/lib/fuby/pop_until.rb +11 -0
- data/lib/fuby/pop_while.rb +11 -0
- data/lib/fuby/prefix_of.rb +14 -0
- data/lib/fuby/prefixes.rb +11 -0
- data/lib/fuby/prepend.rb +11 -0
- data/lib/fuby/private.rb +11 -0
- data/lib/fuby/protected.rb +11 -0
- data/lib/fuby/public.rb +11 -0
- data/lib/fuby/push.rb +1 -0
- data/lib/fuby/push_options.rb +9 -0
- data/lib/fuby/random.rb +31 -0
- data/lib/fuby/self_and_descendants.rb +15 -0
- data/lib/fuby/shift.rb +11 -0
- data/lib/fuby/shift_if.rb +12 -0
- data/lib/fuby/shift_options.rb +11 -0
- data/lib/fuby/shift_unless.rb +12 -0
- data/lib/fuby/shift_until.rb +12 -0
- data/lib/fuby/shift_while.rb +16 -0
- data/lib/fuby/splat.rb +11 -0
- data/lib/fuby/strip.rb +24 -0
- data/lib/fuby/subclass.rb +22 -0
- data/lib/fuby/submodule.rb +22 -0
- data/lib/fuby/suffix_of.rb +19 -0
- data/lib/fuby/suffixes.rb +11 -0
- data/lib/fuby/take.rb +20 -0
- data/lib/fuby/take_until.rb +17 -0
- data/lib/fuby/take_while.rb +14 -0
- data/lib/fuby/tap.rb +28 -0
- data/lib/fuby/to.rb +1 -0
- data/lib/fuby/to_boolean.rb +32 -0
- data/lib/fuby/to_camel_case.rb +32 -0
- data/lib/fuby/to_case.rb +1 -0
- data/lib/fuby/to_components.rb +33 -0
- data/lib/fuby/to_dash_case.rb +28 -0
- data/lib/fuby/to_hash.rb +25 -0
- data/lib/fuby/to_pred.rb +7 -0
- data/lib/fuby/to_proc.rb +45 -0
- data/lib/fuby/to_regexp.rb +38 -0
- data/lib/fuby/to_snake_case.rb +28 -0
- data/lib/fuby/to_tok.rb +27 -0
- data/lib/fuby/tok.rb +2 -0
- data/lib/fuby/tok_arity.rb +18 -0
- data/lib/fuby/tok_direction.rb +16 -0
- data/lib/fuby/tok_parity.rb +11 -0
- data/lib/fuby/tok_side.rb +11 -0
- data/lib/fuby/try.rb +73 -0
- data/lib/fuby/try_each.rb +25 -0
- data/lib/fuby/try_eval.rb +19 -0
- data/lib/fuby/try_exec.rb +15 -0
- data/lib/fuby/unabbreviation.rb +17 -0
- data/lib/fuby/unshift.rb +1 -0
- data/lib/fuby/unshift_options.rb +11 -0
- data/lib/fuby/uuid.rb +28 -0
- data/test/fuby/abbreviation.rb +25 -0
- data/test/fuby/alias_method.rb +29 -0
- data/test/fuby/all.rb +15 -0
- data/test/fuby/and.rb +14 -0
- data/test/fuby/any.rb +15 -0
- data/test/fuby/attributes.rb +0 -0
- data/test/fuby/bind.rb +17 -0
- data/test/fuby/class_attributes.rb +0 -0
- data/test/fuby/deep.rb +0 -0
- data/test/fuby/deep_each.rb +0 -0
- data/test/fuby/define_missing_method.rb +33 -0
- data/test/fuby/define_tok.rb +0 -0
- data/test/fuby/descendants.rb +0 -0
- data/test/fuby/dimension.rb +0 -0
- data/test/fuby/drop.rb +28 -0
- data/test/fuby/drop_until.rb +26 -0
- data/test/fuby/drop_while.rb +26 -0
- data/test/fuby/each.rb +0 -0
- data/test/fuby/each_with_index_or_key.rb +22 -0
- data/test/fuby/eql.rb +0 -0
- data/test/fuby/eql_componentwise.rb +0 -0
- data/test/fuby/equivalence.rb +0 -0
- data/test/fuby/eval.rb +0 -0
- data/test/fuby/extend.rb +20 -0
- data/test/fuby/format.rb +0 -0
- data/test/fuby/include.rb +20 -0
- data/test/fuby/index_or_key.rb +0 -0
- data/test/fuby/instance_attributes.rb +0 -0
- data/test/fuby/intercept.rb +16 -0
- data/test/fuby/invert.rb +0 -0
- data/test/fuby/longest_common.rb +0 -0
- data/test/fuby/matches.rb +0 -0
- data/test/fuby/matches_componentwise.rb +0 -0
- data/test/fuby/matches_prefix_of.rb +0 -0
- data/test/fuby/matches_suffix_of.rb +0 -0
- data/test/fuby/member.rb +0 -0
- data/test/fuby/merge.rb +0 -0
- data/test/fuby/merge_css.rb +0 -0
- data/test/fuby/method_added_as.rb +0 -0
- data/test/fuby/method_added_as_binary_operator.rb +20 -0
- data/test/fuby/method_added_as_filter.rb +28 -0
- data/test/fuby/new.rb +3 -0
- data/test/fuby/not.rb +0 -0
- data/test/fuby/opposite.rb +0 -0
- data/test/fuby/or.rb +19 -0
- data/test/fuby/otherwise.rb +30 -0
- data/test/fuby/part_of.rb +0 -0
- data/test/fuby/plus.rb +0 -0
- data/test/fuby/pop.rb +0 -0
- data/test/fuby/pop_if.rb +31 -0
- data/test/fuby/pop_options.rb +31 -0
- data/test/fuby/pop_unless.rb +0 -0
- data/test/fuby/pop_until.rb +0 -0
- data/test/fuby/pop_while.rb +0 -0
- data/test/fuby/prefix_of.rb +0 -0
- data/test/fuby/prefixes.rb +13 -0
- data/test/fuby/prepend.rb +34 -0
- data/test/fuby/private.rb +0 -0
- data/test/fuby/protected.rb +0 -0
- data/test/fuby/public.rb +0 -0
- data/test/fuby/push.rb +0 -0
- data/test/fuby/push_options.rb +32 -0
- data/test/fuby/random.rb +0 -0
- data/test/fuby/self_and_descendants.rb +0 -0
- data/test/fuby/shift.rb +0 -0
- data/test/fuby/shift_if.rb +0 -0
- data/test/fuby/shift_options.rb +0 -0
- data/test/fuby/shift_unless.rb +0 -0
- data/test/fuby/shift_until.rb +0 -0
- data/test/fuby/shift_while.rb +0 -0
- data/test/fuby/splat.rb +0 -0
- data/test/fuby/strip.rb +0 -0
- data/test/fuby/submodule.rb +15 -0
- data/test/fuby/suffix_of.rb +0 -0
- data/test/fuby/suffixes.rb +13 -0
- data/test/fuby/take.rb +0 -0
- data/test/fuby/take_until.rb +0 -0
- data/test/fuby/take_while.rb +0 -0
- data/test/fuby/tap.rb +58 -0
- data/test/fuby/to_boolean.rb +31 -0
- data/test/fuby/to_camel_case.rb +15 -0
- data/test/fuby/to_components.rb +0 -0
- data/test/fuby/to_dash_case.rb +15 -0
- data/test/fuby/to_hash.rb +23 -0
- data/test/fuby/to_pred.rb +25 -0
- data/test/fuby/to_proc.rb +56 -0
- data/test/fuby/to_regexp.rb +38 -0
- data/test/fuby/to_snake_case.rb +15 -0
- data/test/fuby/to_tok.rb +0 -0
- data/test/fuby/tok.rb +0 -0
- data/test/fuby/tok_arity.rb +0 -0
- data/test/fuby/tok_direction.rb +0 -0
- data/test/fuby/tok_parity.rb +0 -0
- data/test/fuby/tok_side.rb +0 -0
- data/test/fuby/try.rb +52 -0
- data/test/fuby/try_each.rb +30 -0
- data/test/fuby/try_eval.rb +34 -0
- data/test/fuby/try_exec.rb +0 -0
- data/test/fuby/unabbreviation.rb +25 -0
- data/test/fuby/unshift.rb +0 -0
- data/test/fuby/unshift_options.rb +0 -0
- data/test/fuby/uuid.rb +31 -0
- data/test/fuby/version.rb +0 -0
- metadata +369 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fuby
|
2
|
+
refine ::Regexp do
|
3
|
+
|
4
|
+
def to_regexp
|
5
|
+
dup
|
6
|
+
end
|
7
|
+
|
8
|
+
alias_method :to_re, :to_regexp
|
9
|
+
|
10
|
+
end
|
11
|
+
refine ::Array do
|
12
|
+
|
13
|
+
def to_regexp
|
14
|
+
::Regexp.new map { |term| term.to_regexp.source }.join '|'
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method :to_re, :to_regexp
|
18
|
+
|
19
|
+
end
|
20
|
+
refine ::String do
|
21
|
+
|
22
|
+
def to_regexp
|
23
|
+
::Regexp.new "(_|\\b|[^A-z])#{ ::Regexp.escape self }(_|\\b|[^A-z])"
|
24
|
+
end
|
25
|
+
|
26
|
+
alias_method :to_re, :to_regexp
|
27
|
+
|
28
|
+
end
|
29
|
+
refine ::Symbol do
|
30
|
+
|
31
|
+
def to_regexp
|
32
|
+
to_s.to_re
|
33
|
+
end
|
34
|
+
|
35
|
+
alias_method :to_re, :to_regexp
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'to_components'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
refine ::String do
|
7
|
+
|
8
|
+
def to_snake_case
|
9
|
+
to_components.join('_').downcase
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_SNAKE_CASE
|
13
|
+
to_components.join('_').upcase
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
refine ::Symbol do
|
18
|
+
|
19
|
+
def to_snake_case
|
20
|
+
@to_snake_case ||= to_s.to_snake_case.to_sym
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_SNAKE_CASE
|
24
|
+
@to_SNAKE_CASE ||= to_s.to_SNAKE_CASE.to_sym
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/fuby/to_tok.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
module Fuby
|
3
|
+
module ::Enumerable # can't refine Module
|
4
|
+
|
5
|
+
def to_tok
|
6
|
+
::Proc.new &method(:[])
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
refine ::Hash do
|
11
|
+
|
12
|
+
def to_tok
|
13
|
+
invert.to_proc
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
refine ::Regexp do
|
18
|
+
|
19
|
+
def to_tok
|
20
|
+
proc do |str|
|
21
|
+
match = str.match self
|
22
|
+
match.names[ match.captures.index &:just? ].to_sym
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/fuby/tok.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fuby
|
2
|
+
refine ::Proc do
|
3
|
+
|
4
|
+
def tok_arity
|
5
|
+
arity.tok_arity
|
6
|
+
end
|
7
|
+
|
8
|
+
end
|
9
|
+
refine ::Integer do
|
10
|
+
|
11
|
+
TOK_ARITY = [ :nullary, :unary, :binary, :ternary, :quaternary ].freeze
|
12
|
+
|
13
|
+
def tok_arity
|
14
|
+
TOK_ARITY[ self ]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'define_tok'
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::String do
|
5
|
+
|
6
|
+
define_tok :tok_direction, up: /^u/i,
|
7
|
+
down: /^d/i,
|
8
|
+
left: /^l/i,
|
9
|
+
right: /^r/i,
|
10
|
+
ascending: /^ascending/i,
|
11
|
+
asc: /^asc/i,
|
12
|
+
descending: /^descending/i,
|
13
|
+
desc: /^desc/i
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/fuby/try.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
module Fuby
|
2
|
+
refine ::Object do
|
3
|
+
|
4
|
+
def try *sig, &blk
|
5
|
+
if sig.empty?
|
6
|
+
if block_given?
|
7
|
+
result = yield Try::Many.new self
|
8
|
+
return result.__unwrap__ if Try::Base === result
|
9
|
+
return result
|
10
|
+
end
|
11
|
+
return Try::Once.new self
|
12
|
+
else
|
13
|
+
return send *sig, &blk if respond_to? sig.first
|
14
|
+
return nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def try? *sig, &blk
|
19
|
+
if sig.empty?
|
20
|
+
if block_given?
|
21
|
+
result = yield Try::Many.new self, self
|
22
|
+
return result.__unwrap__ if Try::Base === result
|
23
|
+
return result
|
24
|
+
end
|
25
|
+
return Try::Once.new self, self
|
26
|
+
else
|
27
|
+
return send *sig, &blk if respond_to? sig.first
|
28
|
+
return self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
module Try
|
34
|
+
|
35
|
+
class Base < BasicObject
|
36
|
+
|
37
|
+
def initialize object, maybe = nil
|
38
|
+
@object = object
|
39
|
+
@maybe = maybe
|
40
|
+
@class = (class << self; self end).superclass
|
41
|
+
end
|
42
|
+
|
43
|
+
def method_missing key, *sig, &blk
|
44
|
+
return __wrap__ @object.send key, *sig, &blk if @object.respond_to? key
|
45
|
+
return __wrap__ nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def __unwrap__
|
49
|
+
@object.nil? ? @maybe : @object
|
50
|
+
end
|
51
|
+
|
52
|
+
def __wrap__ result
|
53
|
+
@class.new result, @maybe
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
class Once < Base
|
59
|
+
|
60
|
+
def __wrap__ result
|
61
|
+
super.__unwrap__
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
class Many < Base
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
73
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'try'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
refine ::Object do
|
7
|
+
|
8
|
+
def try_each *sig, &blk
|
9
|
+
return Try::Each.new self if sig.empty? && !blk
|
10
|
+
return each { |arg| arg.try *sig, &blk }
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
module Try
|
15
|
+
|
16
|
+
class Each < Base
|
17
|
+
|
18
|
+
def method_missing *sig, &blk
|
19
|
+
@object.each { |arg| arg.try *sig, &blk }
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'fuby/try'
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::Object do
|
5
|
+
|
6
|
+
def try_eval &blk
|
7
|
+
result = (Try::Many.new self).instance_eval &blk
|
8
|
+
return result.__unwrap__ if Try::Base === result
|
9
|
+
return result
|
10
|
+
end
|
11
|
+
|
12
|
+
def try_eval? &blk
|
13
|
+
result = (Try::Many.new self, self).instance_eval &blk
|
14
|
+
return result.__unwrap__ if Try::Base === result
|
15
|
+
return result
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fuby/abbreviation'
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::Symbol do
|
5
|
+
|
6
|
+
attr_reader :unabbreviation
|
7
|
+
alias_method :unabbr, :unabbreviation
|
8
|
+
|
9
|
+
def unabbreviation= sym
|
10
|
+
raise ArgumentError, "`unabbreviation` of a Symbol must be a Symbol, found #{ sym.class }: #{ sym }" unless Symbol === sym
|
11
|
+
raise ArgumentError, "`unabbreviation` of :#{ self } already :#{ unabbreviation }, found #{ sym }" unless @unabbreviation.nil? || @unabbreviation == sym
|
12
|
+
return if @unabbreviation == sym
|
13
|
+
@unabbreviation = sym and sym.abbreviation = self
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/fuby/unshift.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/lib/fuby/uuid.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'format'
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
refine ::String.singleton_class do
|
7
|
+
|
8
|
+
def uuid
|
9
|
+
::SecureRandom.uuid.gsub '-', '_'
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
refine ::Symbol.singleton_class do
|
14
|
+
|
15
|
+
def uuid
|
16
|
+
::String.uuid.to_sym
|
17
|
+
end
|
18
|
+
|
19
|
+
def __uuid
|
20
|
+
:"__%s" % ::String.uuid
|
21
|
+
end
|
22
|
+
|
23
|
+
def __uuid__
|
24
|
+
:"__%s__" % ::String.uuid
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fuby/abbreviation'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Symbol do
|
6
|
+
describe "abbreviation" do
|
7
|
+
it "gets the abbreviation for the receiver" do
|
8
|
+
|
9
|
+
:ascending.abbreviation = :asc
|
10
|
+
:ascending.abbreviation.must_equal :asc
|
11
|
+
|
12
|
+
:desc.unabbreviation = :descending
|
13
|
+
:descending.abbreviation.must_equal :desc
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
describe "abbreviation=" do
|
18
|
+
it "results in an error if the abbreviation is set twice" do
|
19
|
+
|
20
|
+
:ascending.abbreviation = :asc
|
21
|
+
-> { :ascending.abbreviation = :a }.must_raise ArgumentError
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'fuby/alias_method'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Module do
|
6
|
+
describe "alias_method! existing_method_name" do
|
7
|
+
it "creates and returns a new symbol that aliases the existing_method_name" do
|
8
|
+
|
9
|
+
class A
|
10
|
+
|
11
|
+
def foo
|
12
|
+
5
|
13
|
+
end
|
14
|
+
|
15
|
+
eval %{
|
16
|
+
|
17
|
+
def foo
|
18
|
+
#{ alias_method! :foo } * 10
|
19
|
+
end
|
20
|
+
|
21
|
+
}
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
A.new.foo.must_equal 50
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/test/fuby/all.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fuby/all'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Enumerable do
|
6
|
+
describe "all?" do
|
7
|
+
it "the behaviour of `all?` is modified in order to allow object (as well as Proc) arguments" do
|
8
|
+
|
9
|
+
[1, 2, 3].all?.must_be_instance_of Method
|
10
|
+
[1, 2, 3].all?.call(String).must_equal false
|
11
|
+
[1, 2, 3].all?(Integer).must_equal true
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|