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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b32c422c938ac0a08d7dfde0c4cad4d1a7982d96
|
4
|
+
data.tar.gz: 68ae7e8b2d24571257f928fe885e1bbaea415423
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7191422d20c2ead219d23b550491fc9d160b13173e51d69444c875e95b16b441bccc76fc5bfda05956595bc2412a2971eb50a836ea0295421fb683e0c21ef653
|
7
|
+
data.tar.gz: 15c992b9a874306832c8819ba5489ca12c51d4387cb8e7e5bd79a92720b8106f61d7bca8ae405f31d96b260af1e8bb73b35430b128b3e9e8bbfd88592bb9a038
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p247
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alex Goldsmith
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Fuby
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fuby'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fuby
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/fuby.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
path_to = proc do |name| File.expand_path "../#{ name }", __FILE__ end
|
4
|
+
|
5
|
+
version = File.read(path_to.('VERSION')).strip
|
6
|
+
|
7
|
+
$:.push path_to.('lib')
|
8
|
+
|
9
|
+
Gem::Specification.new do |gem|
|
10
|
+
gem.name = "fuby"
|
11
|
+
gem.version = version
|
12
|
+
gem.license = "MIT"
|
13
|
+
gem.authors = ["Alex Goldsmith"]
|
14
|
+
gem.email = ["alex.k.goldsmith@gmail.com"]
|
15
|
+
gem.summary = "Lightweight extensions to the Ruby standard library"
|
16
|
+
gem.description = "Lightweight extensions to the Ruby standard library provided by the refinements mechanism."
|
17
|
+
gem.homepage = "http://github.com/tosyx/fuby"
|
18
|
+
|
19
|
+
gem.files = `git ls-files`.split($/)
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
end
|
data/lib/fuby.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Dir.glob "#{ File.dirname __FILE__ }/fuby/*.rb", &method(:require)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fuby/unabbreviation'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
refine ::Symbol do
|
7
|
+
|
8
|
+
attr_reader :abbreviation
|
9
|
+
alias_method :abbr, :abbreviation
|
10
|
+
|
11
|
+
def abbreviation= sym
|
12
|
+
raise ArgumentError, "`abbreviation` of a Symbol must be a Symbol, found #{ sym.class }: #{ sym }" unless Symbol === sym
|
13
|
+
raise ArgumentError, "`abbreviation` of :#{ self } already :#{ abbreviation }, found #{ sym }" unless @abbreviation.nil? || @abbreviation == sym
|
14
|
+
return if @abbreviation == sym
|
15
|
+
@abbreviation = sym
|
16
|
+
sym.instance_variable_set :@unabbreviation, self
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/fuby/all.rb
ADDED
data/lib/fuby/and.rb
ADDED
data/lib/fuby/any.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
class Attributes < SimpleDelegator
|
7
|
+
|
8
|
+
def [] key
|
9
|
+
__getobj__.send :"#{ __name__ }_get", key
|
10
|
+
end
|
11
|
+
|
12
|
+
def []= key, val
|
13
|
+
__getobj__.send :"#{ __name__ }_set", key, val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/fuby/bind.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'uuid'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
refine ::Proc do
|
7
|
+
|
8
|
+
def bind receiver # pinched from facets#lib/core/facets/proc/bind.rb
|
9
|
+
block = self
|
10
|
+
anonymous_name = Symbol.__uuid__
|
11
|
+
|
12
|
+
receiver.singleton_class.class_eval do
|
13
|
+
define_method anonymous_name, &block
|
14
|
+
anonymous_method = instance_method anonymous_name
|
15
|
+
remove_method anonymous_name
|
16
|
+
anonymous_method
|
17
|
+
end.bind receiver
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'attributes'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
refine ::Module do
|
7
|
+
|
8
|
+
def class_attribute_set key, val
|
9
|
+
(singleton_class.respond_to? :"#{ key }=") ? (singleton_class.send :"#{ key }=", val) : (class_variable_set "@@{ key }", val)
|
10
|
+
end
|
11
|
+
|
12
|
+
def class_attribute_get key
|
13
|
+
(respond_to? key) ? (send key) : (class_variable_get :"@@#{ key }")
|
14
|
+
end
|
15
|
+
|
16
|
+
def class_attributes_set opt
|
17
|
+
opt.each { |key, val| class_attribute_set key, val }
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def class_attributes_get *keys
|
22
|
+
keys.map &(method :class_attribute_get)
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method :class_attributes_at, :class_attributes_get
|
26
|
+
|
27
|
+
def class_attributes
|
28
|
+
ClassAttributes.new self
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
class ClassAttributes < Attributes
|
33
|
+
|
34
|
+
def __name__
|
35
|
+
:class_attributes
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/fuby/deep.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
using Fuby
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::Module do
|
5
|
+
|
6
|
+
def define_instance_method *sig, &blk
|
7
|
+
self.define_method *sig, &blk
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
refine ::Object do
|
12
|
+
|
13
|
+
def define_instance_method *sig, &blk
|
14
|
+
self.define_singleton_method *sig, &blk
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'uuid'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
module Fuby
|
6
|
+
refine ::Module do
|
7
|
+
protected
|
8
|
+
|
9
|
+
def define_missing_method missing_reg, &missing_blk
|
10
|
+
mod = self
|
11
|
+
|
12
|
+
send :define_method, missing_method = Symbol.__uuid__, &missing_blk
|
13
|
+
|
14
|
+
alias_method was_method_missing = Symbol.__uuid__, :method_missing
|
15
|
+
|
16
|
+
define_method :method_missing do |key, *sig, &blk|
|
17
|
+
return send was_method_missing, key, *sig, &blk unless matched_sig = missing_reg.match(key)
|
18
|
+
|
19
|
+
matched_sig = matched_sig.to_a.drop 1
|
20
|
+
|
21
|
+
mod.send :define_method, key do |*sig, &blk|
|
22
|
+
send missing_method, *(matched_sig + sig), &blk
|
23
|
+
end
|
24
|
+
|
25
|
+
send key, *sig, &blk
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method was_respond_to = Symbol.__uuid__, :respond_to?
|
29
|
+
|
30
|
+
define_method :respond_to? do |key|
|
31
|
+
missing_reg === key or send was_respond_to, key
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
using Fuby
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::Module do
|
5
|
+
|
6
|
+
def define_object_method *sig, &blk
|
7
|
+
self.define_singleton_method *sig, &blk
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
refine ::Object do
|
12
|
+
|
13
|
+
def define_object_method *sig, &blk
|
14
|
+
self.class.define_method *sig, &blk
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
using Fuby
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::Module do
|
5
|
+
|
6
|
+
def descendants type = ::Module
|
7
|
+
# ObjectSpace.each_object(type).select { |mod| mod < self } FIXME
|
8
|
+
ObjectSpace.each_object(type).select { |mod| mod.ancestors.include? self }
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir.glob "descendants_*.rb", &method(:require)
|
15
|
+
Dir.glob "*_descendants.rb", &method(:require)
|
data/lib/fuby/drop.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
using Fuby
|
2
|
+
|
3
|
+
module Fuby
|
4
|
+
refine ::Array do
|
5
|
+
|
6
|
+
def drop i = 1
|
7
|
+
return [] if empty?
|
8
|
+
return super if i >= 0
|
9
|
+
return super i % length
|
10
|
+
end
|
11
|
+
|
12
|
+
def drop! i = 1
|
13
|
+
shift i
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Dir.glob "#{ __FILE__.chomp ".rb" }_*.rb", &method(:require)
|