fuby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/fuby.gemspec +1 -1
- data/lib/fuby/alias_method.rb +26 -2
- data/lib/fuby/alias_singleton_method.rb +20 -0
- data/lib/fuby/ancestors.rb +12 -0
- data/lib/fuby/cardinality.rb +27 -0
- data/lib/fuby/curry_eval.rb +19 -0
- data/lib/fuby/deep_const_get.rb +13 -0
- data/lib/fuby/deep_each.rb +21 -6
- data/lib/fuby/define.rb +1 -0
- data/lib/fuby/define_missing_method.rb +13 -23
- data/lib/fuby/define_tok.rb +2 -0
- data/lib/fuby/descendants.rb +3 -4
- data/lib/fuby/eastern_name.rb +11 -0
- data/lib/fuby/enumerables.rb +7 -0
- data/lib/fuby/eql_componentwise.rb +7 -4
- data/lib/fuby/equivalence.rb +7 -4
- data/lib/fuby/eval.rb +1 -51
- data/lib/fuby/extend.rb +15 -4
- data/lib/fuby/first.rb +9 -0
- data/lib/fuby/hash_eval.rb +32 -0
- data/lib/fuby/include.rb +14 -3
- data/lib/fuby/invert.rb +10 -7
- data/lib/fuby/last.rb +9 -0
- data/lib/fuby/longest_common.rb +1 -15
- data/lib/fuby/longest_common_prefix.rb +11 -0
- data/lib/fuby/longest_common_suffix.rb +11 -0
- data/lib/fuby/matches.rb +12 -4
- data/lib/fuby/matches_componentwise.rb +11 -4
- data/lib/fuby/matches_part_of.rb +9 -5
- data/lib/fuby/matches_prefix_of.rb +6 -1
- data/lib/fuby/matches_suffix_of.rb +3 -0
- data/lib/fuby/method_added_as_binary_operator.rb +3 -1
- data/lib/fuby/method_added_as_filter.rb +1 -1
- data/lib/fuby/names.rb +9 -0
- data/lib/fuby/outer_module.rb +18 -0
- data/lib/fuby/part_of.rb +4 -0
- data/lib/fuby/pop.rb +3 -2
- data/lib/fuby/prefix_of.rb +5 -4
- data/lib/fuby/prepend.rb +12 -3
- data/lib/fuby/reject.rb +19 -0
- data/lib/fuby/select.rb +19 -0
- data/lib/fuby/self_and_descendants.rb +1 -3
- data/lib/fuby/send.rb +24 -0
- data/lib/fuby/shift.rb +3 -2
- data/lib/fuby/singleton_method_defined.rb +9 -0
- data/lib/fuby/subclass.rb +2 -2
- data/lib/fuby/submodule.rb +2 -2
- data/lib/fuby/suffix_of.rb +2 -6
- data/lib/fuby/take_until.rb +5 -0
- data/lib/fuby/take_while.rb +8 -0
- data/lib/fuby/to_camel_case.rb +1 -1
- data/lib/fuby/to_dot_case.rb +26 -0
- data/lib/fuby/to_hash.rb +8 -14
- data/lib/fuby/to_slash_case.rb +26 -0
- data/lib/fuby/tok.rb +0 -1
- data/lib/fuby/try_each.rb +1 -0
- data/lib/fuby/try_eval.rb +1 -0
- data/lib/fuby/unshift_options.rb +1 -0
- data/lib/fuby/western_name.rb +11 -0
- data/test/fuby/alias_method.rb +2 -2
- data/test/fuby/ancestors.rb +41 -0
- data/test/fuby/cardinality.rb +34 -0
- data/test/fuby/curry_eval.rb +3 -0
- data/test/fuby/deep.rb +1 -0
- data/test/fuby/deep_each.rb +22 -0
- data/test/fuby/define.rb +1 -0
- data/test/fuby/define_tok.rb +3 -0
- data/test/fuby/descendants.rb +56 -0
- data/test/fuby/drop_until.rb +18 -18
- data/test/fuby/drop_while.rb +18 -18
- data/test/fuby/each.rb +1 -0
- data/test/fuby/eql.rb +1 -0
- data/test/fuby/eql_componentwise.rb +4 -0
- data/test/fuby/equivalence.rb +14 -0
- data/test/fuby/eval.rb +1 -0
- data/test/fuby/extend.rb +1 -1
- data/test/fuby/format.rb +3 -0
- data/test/fuby/hash_eval.rb +3 -0
- data/test/fuby/include.rb +1 -1
- data/test/fuby/index_or_key.rb +3 -0
- data/test/fuby/invert.rb +22 -0
- data/test/fuby/longest_common.rb +1 -0
- data/test/fuby/longest_common_prefix.rb +3 -0
- data/test/fuby/longest_common_suffix.rb +3 -0
- data/test/fuby/matches.rb +5 -0
- data/test/fuby/matches_part_of.rb +3 -0
- data/test/fuby/matches_prefix_of.rb +3 -0
- data/test/fuby/matches_suffix_of.rb +3 -0
- data/test/fuby/new.rb +19 -0
- data/test/fuby/part_of.rb +5 -0
- data/test/fuby/prefix_of.rb +5 -0
- data/test/fuby/prepend.rb +1 -1
- data/test/fuby/private.rb +3 -0
- data/test/fuby/protected.rb +3 -0
- data/test/fuby/public.rb +3 -0
- data/test/fuby/push.rb +1 -0
- data/test/fuby/random.rb +3 -0
- data/test/fuby/self_and_descendants.rb +3 -0
- data/test/fuby/shift.rb +5 -0
- data/test/fuby/shift_if.rb +3 -0
- data/test/fuby/shift_options.rb +3 -0
- data/test/fuby/shift_unless.rb +3 -0
- data/test/fuby/shift_until.rb +3 -0
- data/test/fuby/shift_while.rb +3 -0
- data/test/fuby/splat.rb +3 -0
- data/test/fuby/strip.rb +3 -0
- data/test/fuby/suffix_of.rb +5 -0
- data/test/fuby/take.rb +5 -0
- data/test/fuby/take_until.rb +3 -0
- data/test/fuby/take_while.rb +3 -0
- data/test/fuby/to_components.rb +3 -0
- data/test/fuby/to_dot_case.rb +15 -0
- data/test/fuby/to_slash_case.rb +15 -0
- data/test/fuby/to_tok.rb +3 -0
- data/test/fuby/tok.rb +1 -0
- data/test/fuby/tok_arity.rb +3 -0
- data/test/fuby/tok_direction.rb +3 -0
- data/test/fuby/tok_parity.rb +3 -0
- data/test/fuby/tok_side.rb +3 -0
- data/test/fuby/try.rb +52 -52
- data/test/fuby/try_each.rb +1 -1
- data/test/fuby/try_eval.rb +2 -2
- data/test/fuby/unshift.rb +3 -0
- data/test/fuby/unshift_options.rb +3 -0
- metadata +50 -24
- data/lib/fuby/attributes.rb +0 -15
- data/lib/fuby/class_attributes.rb +0 -37
- data/lib/fuby/dimension.rb +0 -23
- data/lib/fuby/instance_attributes.rb +0 -37
- data/lib/fuby/try_exec.rb +0 -16
- data/test/fuby/attributes.rb +0 -0
- data/test/fuby/class_attributes.rb +0 -0
- data/test/fuby/dimension.rb +0 -0
- data/test/fuby/instance_attributes.rb +0 -0
- data/test/fuby/try_exec.rb +0 -0
data/test/fuby/each.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/test/fuby/eql.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/test/fuby/equivalence.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'fuby/equivalence'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Enumerable do
|
6
|
+
describe "equivalence?" do
|
7
|
+
it "returns `true` if all elements in `self` are `eql?`, `false` otherwise" do
|
8
|
+
|
9
|
+
[1, 1, 1].equivalence?.must_equal true
|
10
|
+
[1, 2, 3].equivalence?.must_equal false
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/fuby/eval.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "*_#{ __FILE__.chomp ".rb" }.rb", &method(:require)
|
data/test/fuby/extend.rb
CHANGED
data/test/fuby/format.rb
CHANGED
data/test/fuby/include.rb
CHANGED
data/test/fuby/index_or_key.rb
CHANGED
data/test/fuby/invert.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'fuby/invert'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Hash do
|
6
|
+
describe "invert" do
|
7
|
+
it "returns a Hash with its keys from self's values and values from self's keys" do
|
8
|
+
|
9
|
+
{ a:1, b:2 }.invert.must_equal 1 => :a, 2 => :b
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
describe Array do
|
15
|
+
describe "invert" do
|
16
|
+
it "returns a Hash with its keys from self's values and values from self's keys" do
|
17
|
+
|
18
|
+
[:a, :b].invert.must_equal a: 0, b: 1
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/fuby/longest_common.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/test/fuby/matches.rb
CHANGED
data/test/fuby/new.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
1
|
require 'fuby/new'
|
2
2
|
|
3
3
|
using Fuby
|
4
|
+
|
5
|
+
describe Float do
|
6
|
+
describe "new" do
|
7
|
+
it "returns 0.0" do
|
8
|
+
|
9
|
+
Float.new.must_equal 0.0
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
describe Integer do
|
15
|
+
describe "new" do
|
16
|
+
it "returns 0.0" do
|
17
|
+
|
18
|
+
Integer.new.must_equal 0
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/fuby/part_of.rb
CHANGED
data/test/fuby/prefix_of.rb
CHANGED
data/test/fuby/prepend.rb
CHANGED
data/test/fuby/private.rb
CHANGED
data/test/fuby/protected.rb
CHANGED
data/test/fuby/public.rb
CHANGED
data/test/fuby/push.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/test/fuby/random.rb
CHANGED
data/test/fuby/shift.rb
CHANGED
data/test/fuby/shift_if.rb
CHANGED
data/test/fuby/shift_options.rb
CHANGED
data/test/fuby/shift_unless.rb
CHANGED
data/test/fuby/shift_until.rb
CHANGED
data/test/fuby/shift_while.rb
CHANGED
data/test/fuby/splat.rb
CHANGED
data/test/fuby/strip.rb
CHANGED
data/test/fuby/suffix_of.rb
CHANGED
data/test/fuby/take.rb
CHANGED
data/test/fuby/take_until.rb
CHANGED
data/test/fuby/take_while.rb
CHANGED
data/test/fuby/to_components.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fuby/to_dot_case'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe String do
|
6
|
+
describe "to_dot_case" do
|
7
|
+
it "converts self to a dot.case string" do
|
8
|
+
|
9
|
+
"html5The5thElement".to_dot_case.must_equal "html5.the.5th.element"
|
10
|
+
"HTML5TH".to_dot_case.must_equal "html.5th"
|
11
|
+
"HTML5th".to_dot_case.must_equal "html.5th"
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fuby/to_slash_case'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe String do
|
6
|
+
describe "to_slash_case" do
|
7
|
+
it "converts self to a slash/case string" do
|
8
|
+
|
9
|
+
"html5The5thElement".to_slash_case.must_equal "html5/the/5th/element"
|
10
|
+
"HTML5TH".to_slash_case.must_equal "html/5th"
|
11
|
+
"HTML5th".to_slash_case.must_equal "html/5th"
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/test/fuby/to_tok.rb
CHANGED
data/test/fuby/tok.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/test/fuby/tok_arity.rb
CHANGED
data/test/fuby/tok_direction.rb
CHANGED
data/test/fuby/tok_parity.rb
CHANGED
data/test/fuby/tok_side.rb
CHANGED
data/test/fuby/try.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
1
|
+
require 'fuby/try'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Object do
|
6
|
+
describe :try do
|
7
|
+
describe [] do
|
8
|
+
it "returns a proxy of self that either responds with the original method, or nil if method_missing" do
|
9
|
+
|
10
|
+
obj = Object.new
|
11
|
+
obj.try.this_method_does_not_exist.must_be_nil
|
12
|
+
obj.try.class.must_equal Object
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
describe [Proc] do
|
17
|
+
it "calls the block_given with self, chaining each method as a try, returning the result" do
|
18
|
+
|
19
|
+
arr = [1, 2, 3]
|
20
|
+
arr.try { |arr| arr }.must_be_same_as arr
|
21
|
+
arr.try { |arr| arr.length }.must_equal 3
|
22
|
+
arr.try { |arr| arr.length.this_method_does_not_exist 5, 6, 7 }.must_be_nil
|
23
|
+
arr.try { |arr| arr.this_method_does_not_exist.and_neither_does_this }.must_be_nil
|
24
|
+
arr.try { |arr| 5 }.must_equal 5
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe :try? do
|
30
|
+
describe [] do
|
31
|
+
it "returns a proxy of self that either responds with the original method, or `self` if method_missing" do
|
32
|
+
|
33
|
+
obj = Object.new
|
34
|
+
obj.try?.this_method_does_not_exist.must_be_same_as obj
|
35
|
+
obj.try?.class.must_equal Object
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
describe [Proc] do
|
40
|
+
it "calls the block_given with self, chaining each method as a try, returning the result or the original object (if the result is nil)" do
|
41
|
+
|
42
|
+
arr = [1, 2, 3]
|
43
|
+
arr.try? { |arr| arr }.must_be_same_as arr
|
44
|
+
arr.try? { |arr| arr.length }.must_equal 3
|
45
|
+
arr.try? { |arr| arr.length.this_method_does_not_exist 5, 6, 7 }.must_be_same_as arr
|
46
|
+
arr.try? { |arr| arr.this_method_does_not_exist.and_neither_does_this }.must_be_same_as arr
|
47
|
+
arr.try? { |arr| 5 }.must_equal 5
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/test/fuby/try_each.rb
CHANGED
@@ -18,7 +18,7 @@ describe Object do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
describe [Proc] do
|
21
|
-
it "tries calling the block_given with each element wrapped in a
|
21
|
+
it "tries calling the block_given with each element wrapped in a send proxy" do
|
22
22
|
|
23
23
|
[Array, Object, Enumerable].try_each do |mod|
|
24
24
|
mod.non_existant_method.must_be_nil
|