fuby 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/fuby.gemspec +1 -1
  5. data/lib/fuby/alias_method.rb +26 -2
  6. data/lib/fuby/alias_singleton_method.rb +20 -0
  7. data/lib/fuby/ancestors.rb +12 -0
  8. data/lib/fuby/cardinality.rb +27 -0
  9. data/lib/fuby/curry_eval.rb +19 -0
  10. data/lib/fuby/deep_const_get.rb +13 -0
  11. data/lib/fuby/deep_each.rb +21 -6
  12. data/lib/fuby/define.rb +1 -0
  13. data/lib/fuby/define_missing_method.rb +13 -23
  14. data/lib/fuby/define_tok.rb +2 -0
  15. data/lib/fuby/descendants.rb +3 -4
  16. data/lib/fuby/eastern_name.rb +11 -0
  17. data/lib/fuby/enumerables.rb +7 -0
  18. data/lib/fuby/eql_componentwise.rb +7 -4
  19. data/lib/fuby/equivalence.rb +7 -4
  20. data/lib/fuby/eval.rb +1 -51
  21. data/lib/fuby/extend.rb +15 -4
  22. data/lib/fuby/first.rb +9 -0
  23. data/lib/fuby/hash_eval.rb +32 -0
  24. data/lib/fuby/include.rb +14 -3
  25. data/lib/fuby/invert.rb +10 -7
  26. data/lib/fuby/last.rb +9 -0
  27. data/lib/fuby/longest_common.rb +1 -15
  28. data/lib/fuby/longest_common_prefix.rb +11 -0
  29. data/lib/fuby/longest_common_suffix.rb +11 -0
  30. data/lib/fuby/matches.rb +12 -4
  31. data/lib/fuby/matches_componentwise.rb +11 -4
  32. data/lib/fuby/matches_part_of.rb +9 -5
  33. data/lib/fuby/matches_prefix_of.rb +6 -1
  34. data/lib/fuby/matches_suffix_of.rb +3 -0
  35. data/lib/fuby/method_added_as_binary_operator.rb +3 -1
  36. data/lib/fuby/method_added_as_filter.rb +1 -1
  37. data/lib/fuby/names.rb +9 -0
  38. data/lib/fuby/outer_module.rb +18 -0
  39. data/lib/fuby/part_of.rb +4 -0
  40. data/lib/fuby/pop.rb +3 -2
  41. data/lib/fuby/prefix_of.rb +5 -4
  42. data/lib/fuby/prepend.rb +12 -3
  43. data/lib/fuby/reject.rb +19 -0
  44. data/lib/fuby/select.rb +19 -0
  45. data/lib/fuby/self_and_descendants.rb +1 -3
  46. data/lib/fuby/send.rb +24 -0
  47. data/lib/fuby/shift.rb +3 -2
  48. data/lib/fuby/singleton_method_defined.rb +9 -0
  49. data/lib/fuby/subclass.rb +2 -2
  50. data/lib/fuby/submodule.rb +2 -2
  51. data/lib/fuby/suffix_of.rb +2 -6
  52. data/lib/fuby/take_until.rb +5 -0
  53. data/lib/fuby/take_while.rb +8 -0
  54. data/lib/fuby/to_camel_case.rb +1 -1
  55. data/lib/fuby/to_dot_case.rb +26 -0
  56. data/lib/fuby/to_hash.rb +8 -14
  57. data/lib/fuby/to_slash_case.rb +26 -0
  58. data/lib/fuby/tok.rb +0 -1
  59. data/lib/fuby/try_each.rb +1 -0
  60. data/lib/fuby/try_eval.rb +1 -0
  61. data/lib/fuby/unshift_options.rb +1 -0
  62. data/lib/fuby/western_name.rb +11 -0
  63. data/test/fuby/alias_method.rb +2 -2
  64. data/test/fuby/ancestors.rb +41 -0
  65. data/test/fuby/cardinality.rb +34 -0
  66. data/test/fuby/curry_eval.rb +3 -0
  67. data/test/fuby/deep.rb +1 -0
  68. data/test/fuby/deep_each.rb +22 -0
  69. data/test/fuby/define.rb +1 -0
  70. data/test/fuby/define_tok.rb +3 -0
  71. data/test/fuby/descendants.rb +56 -0
  72. data/test/fuby/drop_until.rb +18 -18
  73. data/test/fuby/drop_while.rb +18 -18
  74. data/test/fuby/each.rb +1 -0
  75. data/test/fuby/eql.rb +1 -0
  76. data/test/fuby/eql_componentwise.rb +4 -0
  77. data/test/fuby/equivalence.rb +14 -0
  78. data/test/fuby/eval.rb +1 -0
  79. data/test/fuby/extend.rb +1 -1
  80. data/test/fuby/format.rb +3 -0
  81. data/test/fuby/hash_eval.rb +3 -0
  82. data/test/fuby/include.rb +1 -1
  83. data/test/fuby/index_or_key.rb +3 -0
  84. data/test/fuby/invert.rb +22 -0
  85. data/test/fuby/longest_common.rb +1 -0
  86. data/test/fuby/longest_common_prefix.rb +3 -0
  87. data/test/fuby/longest_common_suffix.rb +3 -0
  88. data/test/fuby/matches.rb +5 -0
  89. data/test/fuby/matches_part_of.rb +3 -0
  90. data/test/fuby/matches_prefix_of.rb +3 -0
  91. data/test/fuby/matches_suffix_of.rb +3 -0
  92. data/test/fuby/new.rb +19 -0
  93. data/test/fuby/part_of.rb +5 -0
  94. data/test/fuby/prefix_of.rb +5 -0
  95. data/test/fuby/prepend.rb +1 -1
  96. data/test/fuby/private.rb +3 -0
  97. data/test/fuby/protected.rb +3 -0
  98. data/test/fuby/public.rb +3 -0
  99. data/test/fuby/push.rb +1 -0
  100. data/test/fuby/random.rb +3 -0
  101. data/test/fuby/self_and_descendants.rb +3 -0
  102. data/test/fuby/shift.rb +5 -0
  103. data/test/fuby/shift_if.rb +3 -0
  104. data/test/fuby/shift_options.rb +3 -0
  105. data/test/fuby/shift_unless.rb +3 -0
  106. data/test/fuby/shift_until.rb +3 -0
  107. data/test/fuby/shift_while.rb +3 -0
  108. data/test/fuby/splat.rb +3 -0
  109. data/test/fuby/strip.rb +3 -0
  110. data/test/fuby/suffix_of.rb +5 -0
  111. data/test/fuby/take.rb +5 -0
  112. data/test/fuby/take_until.rb +3 -0
  113. data/test/fuby/take_while.rb +3 -0
  114. data/test/fuby/to_components.rb +3 -0
  115. data/test/fuby/to_dot_case.rb +15 -0
  116. data/test/fuby/to_slash_case.rb +15 -0
  117. data/test/fuby/to_tok.rb +3 -0
  118. data/test/fuby/tok.rb +1 -0
  119. data/test/fuby/tok_arity.rb +3 -0
  120. data/test/fuby/tok_direction.rb +3 -0
  121. data/test/fuby/tok_parity.rb +3 -0
  122. data/test/fuby/tok_side.rb +3 -0
  123. data/test/fuby/try.rb +52 -52
  124. data/test/fuby/try_each.rb +1 -1
  125. data/test/fuby/try_eval.rb +2 -2
  126. data/test/fuby/unshift.rb +3 -0
  127. data/test/fuby/unshift_options.rb +3 -0
  128. metadata +50 -24
  129. data/lib/fuby/attributes.rb +0 -15
  130. data/lib/fuby/class_attributes.rb +0 -37
  131. data/lib/fuby/dimension.rb +0 -23
  132. data/lib/fuby/instance_attributes.rb +0 -37
  133. data/lib/fuby/try_exec.rb +0 -16
  134. data/test/fuby/attributes.rb +0 -0
  135. data/test/fuby/class_attributes.rb +0 -0
  136. data/test/fuby/dimension.rb +0 -0
  137. data/test/fuby/instance_attributes.rb +0 -0
  138. data/test/fuby/try_exec.rb +0 -0
@@ -0,0 +1 @@
1
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1 @@
1
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1,4 @@
1
+ require 'fuby/eql_componentwise'
2
+
3
+ using Fuby
4
+
@@ -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
@@ -0,0 +1 @@
1
+ Dir.glob "*_#{ __FILE__.chomp ".rb" }.rb", &method(:require)
@@ -7,7 +7,7 @@ describe Module do
7
7
  it "creates and extends a module based on the given &block" do
8
8
 
9
9
  o = Object.new
10
- o.extend! do
10
+ o.send.extend do
11
11
 
12
12
  def foo
13
13
  end
@@ -0,0 +1,3 @@
1
+ require 'fuby/format'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/hash_eval'
2
+
3
+ using Fuby
@@ -7,7 +7,7 @@ describe Module do
7
7
  it "creates and includes a module based on the given &block" do
8
8
 
9
9
  c = Class.new
10
- c.include! do
10
+ c.send.include do
11
11
 
12
12
  def foo
13
13
  end
@@ -0,0 +1,3 @@
1
+ require 'fuby/index_or_key'
2
+
3
+ using Fuby
@@ -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
@@ -0,0 +1 @@
1
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1,3 @@
1
+ require 'fuby/longest_common_prefix'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/longest_common_suffix'
2
+
3
+ using Fuby
@@ -0,0 +1,5 @@
1
+ require 'fuby/matches'
2
+
3
+ using Fuby
4
+
5
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1,3 @@
1
+ require 'fuby/matches_part_of'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/matches_prefix_of'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/matches_suffix_of'
2
+
3
+ using Fuby
@@ -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
@@ -0,0 +1,5 @@
1
+ require 'fuby/part_of'
2
+
3
+ using Fuby
4
+
5
+ Dir.glob "*_#{ __FILE__.chomp ".rb" }.rb", &method(:require)
@@ -0,0 +1,5 @@
1
+ require 'fuby/prefix_of'
2
+
3
+ using Fuby
4
+
5
+ Dir.glob "*_#{ __FILE__.chomp ".rb" }.rb", &method(:require)
@@ -19,7 +19,7 @@ describe Module do
19
19
  end
20
20
 
21
21
  end
22
- klass.prepend! do
22
+ klass.send.prepend do
23
23
 
24
24
  def foo
25
25
  '3rd' + super
@@ -0,0 +1,3 @@
1
+ require 'fuby/private'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/protected'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/public'
2
+
3
+ using Fuby
@@ -0,0 +1 @@
1
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1,3 @@
1
+ require 'fuby/random'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/self_and_descendants'
2
+
3
+ using Fuby
@@ -0,0 +1,5 @@
1
+ require 'fuby/shift'
2
+
3
+ using Fuby
4
+
5
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1,3 @@
1
+ require 'fuby/shift_if'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/shift_options'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/shift_unless'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/shift_until'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/shift_while'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/splat'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/strip'
2
+
3
+ using Fuby
@@ -0,0 +1,5 @@
1
+ require 'fuby/suffix_of'
2
+
3
+ using Fuby
4
+
5
+ Dir.glob "*_suffix_of.rb", &method(:require)
@@ -0,0 +1,5 @@
1
+ require 'fuby/take'
2
+
3
+ using Fuby
4
+
5
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1,3 @@
1
+ require 'fuby/take_until'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/take_while'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/to_components'
2
+
3
+ using Fuby
@@ -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
@@ -0,0 +1,3 @@
1
+ require 'fuby/to_tok'
2
+
3
+ using Fuby
@@ -0,0 +1 @@
1
+ Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
@@ -0,0 +1,3 @@
1
+ require 'fuby/tok_arity'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/tok_direction'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/tok_parity'
2
+
3
+ using Fuby
@@ -0,0 +1,3 @@
1
+ require 'fuby/tok_side'
2
+
3
+ using Fuby
@@ -1,52 +1,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 nil 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
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
@@ -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 try proxy" do
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