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/lib/fuby/include.rb
CHANGED
@@ -1,11 +1,22 @@
|
|
1
|
+
require_relative 'send'
|
2
|
+
|
1
3
|
module Fuby
|
2
4
|
refine ::Module do
|
3
5
|
|
4
|
-
def include
|
5
|
-
include *includes unless includes.empty?
|
6
|
-
include ::Module.new(&body) if block_given?
|
6
|
+
def include *includes, &body
|
7
|
+
self.send :include, *includes unless includes.empty?
|
8
|
+
self.send :include, ::Module.new(&body) if block_given?
|
7
9
|
self
|
8
10
|
end
|
9
11
|
|
10
12
|
end
|
13
|
+
class Send
|
14
|
+
|
15
|
+
def include *includes, &body
|
16
|
+
@self.send :include, *includes unless includes.empty?
|
17
|
+
@self.send :include, ::Module.new(&body) if block_given?
|
18
|
+
@self
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
11
22
|
end
|
data/lib/fuby/invert.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '
|
1
|
+
require_relative 'enumerables'
|
2
|
+
require_relative 'to_hash'
|
3
|
+
|
4
|
+
using Fuby
|
3
5
|
|
4
6
|
module Fuby
|
7
|
+
Enumerables.each do |enumerable|
|
8
|
+
next if Hash >= enumerable
|
9
|
+
refine enumerable do
|
5
10
|
|
6
|
-
|
11
|
+
def invert
|
12
|
+
to_hash.invert
|
13
|
+
end
|
7
14
|
|
8
|
-
def invert
|
9
|
-
::Hash[ each_with_index_or_key.to_a ]
|
10
15
|
end
|
11
|
-
|
12
16
|
end
|
13
|
-
|
14
17
|
end
|
data/lib/fuby/last.rb
ADDED
data/lib/fuby/longest_common.rb
CHANGED
@@ -1,15 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Fuby
|
4
|
-
module ::Enumerable # can't refine Module
|
5
|
-
|
6
|
-
def longest_common_prefix *those
|
7
|
-
zip(*those).take_while(:equivalence?).map(:first)
|
8
|
-
end
|
9
|
-
|
10
|
-
def longest_common_suffix *those
|
11
|
-
zip(*those).map(&:reverse).take_while(:equivalence?).map(:first).map(&:reverse)
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/lib/fuby/matches.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
+
require_relative 'method_added_as_binary_operator'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
1
5
|
module Fuby
|
2
|
-
|
6
|
+
Enumerables.each do |enumerable|
|
7
|
+
refine enumerable do
|
3
8
|
|
4
|
-
|
5
|
-
|
6
|
-
|
9
|
+
def matches? that
|
10
|
+
count == that.count and matches_componentwise? that
|
11
|
+
end
|
7
12
|
|
13
|
+
method_added_as_binary_operator :matches?
|
14
|
+
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
10
18
|
|
@@ -1,11 +1,18 @@
|
|
1
|
+
require_relative 'method_added_as_binary_operator'
|
1
2
|
require_relative 'each_with_index_or_key'
|
2
3
|
|
4
|
+
using Fuby
|
5
|
+
|
3
6
|
module Fuby
|
4
|
-
|
7
|
+
Enumerables.each do |enumerable|
|
8
|
+
refine enumerable do
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
def matches_componentwise? that
|
11
|
+
each_with_index_or_key.all? { |e, k| e === that[k] }
|
12
|
+
end
|
9
13
|
|
14
|
+
method_added_as_binary_operator :matches_componentwise?
|
15
|
+
|
16
|
+
end
|
10
17
|
end
|
11
18
|
end
|
data/lib/fuby/matches_part_of.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
require_relative 'method_added_as_binary_operator'
|
2
2
|
require_relative 'matches_componentwise'
|
3
3
|
|
4
|
+
using Fuby
|
5
|
+
|
4
6
|
module Fuby
|
5
|
-
|
7
|
+
Enumerables.each do |enumerable|
|
8
|
+
refine enumerable do
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
def matches_part_of? that
|
11
|
+
count <= that.count and matches_componentwise? that
|
12
|
+
end
|
10
13
|
|
11
|
-
|
14
|
+
method_added_as_binary_operator :matches_part_of?
|
12
15
|
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
@@ -1,9 +1,14 @@
|
|
1
|
+
require_relative 'method_added_as_binary_operator'
|
1
2
|
require_relative 'matches_part_of'
|
2
3
|
|
4
|
+
using Fuby
|
5
|
+
|
3
6
|
module Fuby
|
4
7
|
refine ::Array do
|
5
8
|
|
6
|
-
|
9
|
+
def matches_prefix_of? *sig, &blk
|
10
|
+
matches_part_of? *sig, &blk
|
11
|
+
end
|
7
12
|
|
8
13
|
method_added_as_binary_operator :matches_prefix_of?
|
9
14
|
|
data/lib/fuby/names.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'deep_const_get'
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::Module do
|
5
|
+
|
6
|
+
def outer_module
|
7
|
+
@outer_module ||= /::[^:]+\Z/ === self ? Kernel.deep_const_get($`) : Kernel
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
refine ::Kernel.singleton_class do
|
12
|
+
|
13
|
+
def outer_module
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/fuby/part_of.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative 'method_added_as_binary_operator'
|
2
2
|
require_relative 'eql_componentwise'
|
3
3
|
|
4
|
+
using Fuby
|
5
|
+
|
4
6
|
module Fuby
|
5
7
|
module ::Enumerable # can't refine Module
|
6
8
|
|
@@ -12,3 +14,5 @@ module Fuby
|
|
12
14
|
|
13
15
|
end
|
14
16
|
end
|
17
|
+
|
18
|
+
Dir.glob "*_#{ __FILE__.chomp ".rb" }.rb", &method(:require)
|
data/lib/fuby/pop.rb
CHANGED
data/lib/fuby/prefix_of.rb
CHANGED
@@ -3,12 +3,13 @@ require_relative 'part_of'
|
|
3
3
|
module Fuby
|
4
4
|
refine ::Array do
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
def prefix_of? *sig, &blk
|
7
|
+
part_of? *sig, &blk
|
8
|
+
end
|
8
9
|
|
9
|
-
method_added_as_binary_operator :prefix_of
|
10
|
+
method_added_as_binary_operator :prefix_of?
|
10
11
|
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
|
-
Dir.glob "*
|
15
|
+
Dir.glob "*_#{ __FILE__.chomp ".rb" }.rb", &method(:require)
|
data/lib/fuby/prepend.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
module Fuby
|
2
2
|
refine ::Module do
|
3
3
|
|
4
|
-
def prepend
|
5
|
-
prepend *includes unless includes.empty?
|
6
|
-
prepend ::Module.new(&body) if block_given?
|
4
|
+
def prepend *includes, &body
|
5
|
+
self.send :prepend, *includes unless includes.empty?
|
6
|
+
self.send :prepend, ::Module.new(&body) if block_given?
|
7
7
|
self
|
8
8
|
end
|
9
9
|
|
10
10
|
end
|
11
|
+
class Send
|
12
|
+
|
13
|
+
def prepend *includes, &body
|
14
|
+
@self.send :prepend, *includes unless includes.empty?
|
15
|
+
@self.send :prepend, ::Module.new(&body) if block_given?
|
16
|
+
@self
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
11
20
|
end
|
data/lib/fuby/reject.rb
ADDED
data/lib/fuby/select.rb
ADDED
data/lib/fuby/send.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fuby
|
2
|
+
refine ::Object do
|
3
|
+
|
4
|
+
def send *sig, &blk
|
5
|
+
return super unless sig.empty?
|
6
|
+
return yield Send.new self if block_given?
|
7
|
+
return Send.new self
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
class Send
|
12
|
+
|
13
|
+
def initialize receiver
|
14
|
+
@self = receiver
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing key, *sig, &blk
|
18
|
+
@self.send key, *sig, &blk
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
data/lib/fuby/shift.rb
CHANGED
data/lib/fuby/subclass.rb
CHANGED