ruby-nuggets 0.9.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +20 -324
- data/COPYING +0 -663
- data/ChangeLog +0 -7
- data/README +0 -62
- data/Rakefile +0 -47
- data/lib/nuggets.rb +0 -73
- data/lib/nuggets/all.rb +0 -36
- data/lib/nuggets/all_mixins.rb +0 -34
- data/lib/nuggets/ansicolor2css.rb +0 -125
- data/lib/nuggets/argv/option.rb +0 -3
- data/lib/nuggets/argv/option_mixin.rb +0 -85
- data/lib/nuggets/array/boost.rb +0 -5
- data/lib/nuggets/array/boost_mixin.rb +0 -78
- data/lib/nuggets/array/combination.rb +0 -63
- data/lib/nuggets/array/correlation.rb +0 -5
- data/lib/nuggets/array/correlation_mixin.rb +0 -64
- data/lib/nuggets/array/flatten_once.rb +0 -57
- data/lib/nuggets/array/flush.rb +0 -5
- data/lib/nuggets/array/flush_mixin.rb +0 -47
- data/lib/nuggets/array/format.rb +0 -66
- data/lib/nuggets/array/hashify.rb +0 -5
- data/lib/nuggets/array/hashify_mixin.rb +0 -48
- data/lib/nuggets/array/histogram.rb +0 -5
- data/lib/nuggets/array/histogram_mixin.rb +0 -170
- data/lib/nuggets/array/in_order.rb +0 -51
- data/lib/nuggets/array/limit.rb +0 -5
- data/lib/nuggets/array/limit_mixin.rb +0 -57
- data/lib/nuggets/array/mean.rb +0 -5
- data/lib/nuggets/array/mean_mixin.rb +0 -203
- data/lib/nuggets/array/median.rb +0 -5
- data/lib/nuggets/array/median_mixin.rb +0 -74
- data/lib/nuggets/array/mode.rb +0 -5
- data/lib/nuggets/array/mode_mixin.rb +0 -70
- data/lib/nuggets/array/monotone.rb +0 -84
- data/lib/nuggets/array/only.rb +0 -42
- data/lib/nuggets/array/rand.rb +0 -45
- data/lib/nuggets/array/regression.rb +0 -5
- data/lib/nuggets/array/regression_mixin.rb +0 -150
- data/lib/nuggets/array/runiq.rb +0 -5
- data/lib/nuggets/array/runiq_mixin.rb +0 -53
- data/lib/nuggets/array/shuffle.rb +0 -133
- data/lib/nuggets/array/standard_deviation.rb +0 -5
- data/lib/nuggets/array/standard_deviation_mixin.rb +0 -51
- data/lib/nuggets/array/to_hash.rb +0 -65
- data/lib/nuggets/array/variance.rb +0 -5
- data/lib/nuggets/array/variance_mixin.rb +0 -82
- data/lib/nuggets/cli.rb +0 -8
- data/lib/nuggets/content_type.rb +0 -98
- data/lib/nuggets/dotted_decimal.rb +0 -60
- data/lib/nuggets/enumerable/agrep.rb +0 -80
- data/lib/nuggets/enumerable/all_any_extended.rb +0 -67
- data/lib/nuggets/enumerable/minmax.rb +0 -103
- data/lib/nuggets/env/set.rb +0 -3
- data/lib/nuggets/env/set_mixin.rb +0 -68
- data/lib/nuggets/env/user_encoding.rb +0 -3
- data/lib/nuggets/env/user_encoding_mixin.rb +0 -55
- data/lib/nuggets/env/user_home.rb +0 -3
- data/lib/nuggets/env/user_home_mixin.rb +0 -57
- data/lib/nuggets/file/ext.rb +0 -5
- data/lib/nuggets/file/ext_mixin.rb +0 -88
- data/lib/nuggets/file/replace.rb +0 -5
- data/lib/nuggets/file/replace_mixin.rb +0 -56
- data/lib/nuggets/file/sub.rb +0 -5
- data/lib/nuggets/file/sub_mixin.rb +0 -96
- data/lib/nuggets/file/which.rb +0 -5
- data/lib/nuggets/file/which_mixin.rb +0 -73
- data/lib/nuggets/hash/at.rb +0 -69
- data/lib/nuggets/hash/deep_fetch.rb +0 -5
- data/lib/nuggets/hash/deep_fetch_mixin.rb +0 -75
- data/lib/nuggets/hash/deep_merge.rb +0 -5
- data/lib/nuggets/hash/deep_merge_mixin.rb +0 -54
- data/lib/nuggets/hash/idmap.rb +0 -5
- data/lib/nuggets/hash/idmap_mixin.rb +0 -42
- data/lib/nuggets/hash/in_order.rb +0 -44
- data/lib/nuggets/hash/insert.rb +0 -54
- data/lib/nuggets/hash/nest.rb +0 -5
- data/lib/nuggets/hash/nest_mixin.rb +0 -79
- data/lib/nuggets/hash/only.rb +0 -53
- data/lib/nuggets/hash/seen.rb +0 -5
- data/lib/nuggets/hash/seen_mixin.rb +0 -59
- data/lib/nuggets/hash/unroll.rb +0 -5
- data/lib/nuggets/hash/unroll_mixin.rb +0 -89
- data/lib/nuggets/hash/zip.rb +0 -5
- data/lib/nuggets/hash/zip_mixin.rb +0 -160
- data/lib/nuggets/i18n.rb +0 -156
- data/lib/nuggets/integer/factorial.rb +0 -57
- data/lib/nuggets/integer/length.rb +0 -5
- data/lib/nuggets/integer/length_mixin.rb +0 -50
- data/lib/nuggets/integer/map.rb +0 -5
- data/lib/nuggets/integer/map_mixin.rb +0 -43
- data/lib/nuggets/integer/to_binary_s.rb +0 -39
- data/lib/nuggets/io/agrep.rb +0 -44
- data/lib/nuggets/io/interact.rb +0 -5
- data/lib/nuggets/io/interact_mixin.rb +0 -160
- data/lib/nuggets/io/modes.rb +0 -122
- data/lib/nuggets/io/null.rb +0 -5
- data/lib/nuggets/io/null_mixin.rb +0 -41
- data/lib/nuggets/io/redirect.rb +0 -5
- data/lib/nuggets/io/redirect_mixin.rb +0 -51
- data/lib/nuggets/lazy_attr.rb +0 -45
- data/lib/nuggets/log_parser.rb +0 -71
- data/lib/nuggets/log_parser/apache.rb +0 -102
- data/lib/nuggets/log_parser/rails.rb +0 -220
- data/lib/nuggets/lsi.rb +0 -8
- data/lib/nuggets/midos.rb +0 -8
- data/lib/nuggets/mysql.rb +0 -8
- data/lib/nuggets/net/success.rb +0 -60
- data/lib/nuggets/numeric/between.rb +0 -2
- data/lib/nuggets/numeric/duration.rb +0 -101
- data/lib/nuggets/numeric/limit.rb +0 -63
- data/lib/nuggets/numeric/signum.rb +0 -53
- data/lib/nuggets/numeric/to_multiple.rb +0 -62
- data/lib/nuggets/object/blank.rb +0 -20
- data/lib/nuggets/object/blank_mixin.rb +0 -100
- data/lib/nuggets/object/boolean.rb +0 -5
- data/lib/nuggets/object/boolean_mixin.rb +0 -62
- data/lib/nuggets/object/eigenclass.rb +0 -2
- data/lib/nuggets/object/ghost_class.rb +0 -2
- data/lib/nuggets/object/metaclass.rb +0 -2
- data/lib/nuggets/object/msend.rb +0 -5
- data/lib/nuggets/object/msend_mixin.rb +0 -44
- data/lib/nuggets/object/silence.rb +0 -5
- data/lib/nuggets/object/silence_mixin.rb +0 -45
- data/lib/nuggets/object/singleton_class.rb +0 -5
- data/lib/nuggets/object/singleton_class_mixin.rb +0 -96
- data/lib/nuggets/object/uniclass.rb +0 -2
- data/lib/nuggets/object/virtual_class.rb +0 -2
- data/lib/nuggets/pluggable.rb +0 -92
- data/lib/nuggets/proc/bind.rb +0 -5
- data/lib/nuggets/proc/bind_mixin.rb +0 -52
- data/lib/nuggets/range/quantile.rb +0 -5
- data/lib/nuggets/range/quantile_mixin.rb +0 -43
- data/lib/nuggets/rdf/compression.rb +0 -6
- data/lib/nuggets/rdf/prefix.rb +0 -6
- data/lib/nuggets/rdf/turtle.rb +0 -8
- data/lib/nuggets/rdf/turtle/reader.rb +0 -6
- data/lib/nuggets/rdf/uri.rb +0 -6
- data/lib/nuggets/ruby.rb +0 -236
- data/lib/nuggets/statistics.rb +0 -12
- data/lib/nuggets/statistics_mixins.rb +0 -12
- data/lib/nuggets/string/camelscore.rb +0 -5
- data/lib/nuggets/string/camelscore_mixin.rb +0 -117
- data/lib/nuggets/string/capitalize_first.rb +0 -47
- data/lib/nuggets/string/case.rb +0 -82
- data/lib/nuggets/string/evaluate.rb +0 -5
- data/lib/nuggets/string/evaluate_mixin.rb +0 -48
- data/lib/nuggets/string/msub.rb +0 -85
- data/lib/nuggets/string/nsub.rb +0 -66
- data/lib/nuggets/string/sub_with_md.rb +0 -112
- data/lib/nuggets/string/wc.rb +0 -5
- data/lib/nuggets/string/wc_mixin.rb +0 -96
- data/lib/nuggets/string/word_wrap.rb +0 -77
- data/lib/nuggets/string/xor.rb +0 -5
- data/lib/nuggets/string/xor_mixin.rb +0 -60
- data/lib/nuggets/tempfile/open.rb +0 -58
- data/lib/nuggets/uri/content_type.rb +0 -5
- data/lib/nuggets/uri/content_type_mixin.rb +0 -48
- data/lib/nuggets/uri/exist.rb +0 -5
- data/lib/nuggets/uri/exist_mixin.rb +0 -57
- data/lib/nuggets/uri/redirect.rb +0 -5
- data/lib/nuggets/uri/redirect_mixin.rb +0 -102
- data/lib/nuggets/util/ansicolor2css.rb +0 -4
- data/lib/nuggets/util/cli.rb +0 -4
- data/lib/nuggets/util/content_type.rb +0 -4
- data/lib/nuggets/util/dotted_decimal.rb +0 -3
- data/lib/nuggets/util/i18n.rb +0 -4
- data/lib/nuggets/util/lazy_attr.rb +0 -4
- data/lib/nuggets/util/log_parser.rb +0 -4
- data/lib/nuggets/util/log_parser/apache.rb +0 -4
- data/lib/nuggets/util/log_parser/rails.rb +0 -4
- data/lib/nuggets/util/midos.rb +0 -4
- data/lib/nuggets/util/mysql.rb +0 -4
- data/lib/nuggets/util/pluggable.rb +0 -4
- data/lib/nuggets/util/ruby.rb +0 -4
- data/lib/nuggets/version.rb +0 -27
- data/spec/nuggets/array/boost_spec.rb +0 -50
- data/spec/nuggets/array/combination_spec.rb +0 -25
- data/spec/nuggets/array/correlation_spec.rb +0 -81
- data/spec/nuggets/array/flatten_once_spec.rb +0 -16
- data/spec/nuggets/array/flush_spec.rb +0 -43
- data/spec/nuggets/array/format_spec.rb +0 -52
- data/spec/nuggets/array/hashify_spec.rb +0 -41
- data/spec/nuggets/array/histogram_spec.rb +0 -87
- data/spec/nuggets/array/in_order_spec.rb +0 -13
- data/spec/nuggets/array/limit_spec.rb +0 -62
- data/spec/nuggets/array/mean_spec.rb +0 -203
- data/spec/nuggets/array/median_spec.rb +0 -77
- data/spec/nuggets/array/mode_spec.rb +0 -57
- data/spec/nuggets/array/monotone_spec.rb +0 -30
- data/spec/nuggets/array/only_spec.rb +0 -26
- data/spec/nuggets/array/regression_spec.rb +0 -54
- data/spec/nuggets/array/runiq_spec.rb +0 -25
- data/spec/nuggets/array/standard_deviation_spec.rb +0 -33
- data/spec/nuggets/array/to_hash_spec.rb +0 -28
- data/spec/nuggets/array/variance_spec.rb +0 -106
- data/spec/nuggets/dotted_decimal_spec.rb +0 -27
- data/spec/nuggets/enumerable/all_any_extended_spec.rb +0 -31
- data/spec/nuggets/enumerable/minmax_spec.rb +0 -21
- data/spec/nuggets/env/set_spec.rb +0 -29
- data/spec/nuggets/env/user_encoding_spec.rb +0 -38
- data/spec/nuggets/env/user_home_spec.rb +0 -42
- data/spec/nuggets/file/ext_spec.rb +0 -38
- data/spec/nuggets/file/replace_spec.rb +0 -95
- data/spec/nuggets/file/sub_spec.rb +0 -149
- data/spec/nuggets/file/which_spec.rb +0 -22
- data/spec/nuggets/hash/at_spec.rb +0 -19
- data/spec/nuggets/hash/deep_fetch_spec.rb +0 -159
- data/spec/nuggets/hash/deep_merge_spec.rb +0 -78
- data/spec/nuggets/hash/in_order_spec.rb +0 -12
- data/spec/nuggets/hash/insert_spec.rb +0 -13
- data/spec/nuggets/hash/nest_spec.rb +0 -102
- data/spec/nuggets/hash/only_spec.rb +0 -29
- data/spec/nuggets/hash/seen_spec.rb +0 -36
- data/spec/nuggets/hash/unroll_spec.rb +0 -68
- data/spec/nuggets/i18n_spec.rb +0 -13
- data/spec/nuggets/integer/factorial_spec.rb +0 -10
- data/spec/nuggets/integer/length_spec.rb +0 -18
- data/spec/nuggets/integer/map_spec.rb +0 -19
- data/spec/nuggets/integer/to_binary_s_spec.rb +0 -19
- data/spec/nuggets/numeric/duration_spec.rb +0 -25
- data/spec/nuggets/numeric/limit_spec.rb +0 -16
- data/spec/nuggets/numeric/signum_spec.rb +0 -16
- data/spec/nuggets/numeric/to_multiple_spec.rb +0 -16
- data/spec/nuggets/object/blank_spec.rb +0 -34
- data/spec/nuggets/object/boolean_spec.rb +0 -23
- data/spec/nuggets/object/msend_spec.rb +0 -25
- data/spec/nuggets/object/silence_spec.rb +0 -36
- data/spec/nuggets/object/singleton_class_spec.rb +0 -51
- data/spec/nuggets/proc/bind_spec.rb +0 -28
- data/spec/nuggets/range/quantile_spec.rb +0 -33
- data/spec/nuggets/string/camelscore_spec.rb +0 -114
- data/spec/nuggets/string/capitalize_first_spec.rb +0 -13
- data/spec/nuggets/string/case_spec.rb +0 -31
- data/spec/nuggets/string/evaluate_spec.rb +0 -24
- data/spec/nuggets/string/msub_spec.rb +0 -20
- data/spec/nuggets/string/nsub_spec.rb +0 -13
- data/spec/nuggets/string/sub_with_md_spec.rb +0 -25
- data/spec/nuggets/string/wc_spec.rb +0 -73
- data/spec/nuggets/string/word_wrap_spec.rb +0 -81
- data/spec/nuggets/string/xor_spec.rb +0 -57
- data/spec/nuggets/uri/content_type_spec.rb +0 -42
- data/spec/nuggets/uri/exist_spec.rb +0 -49
- data/spec/spec_helper.rb +0 -36
data/ChangeLog
DELETED
data/README
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
= ruby-nuggets - Some extensions to the Ruby programming language
|
2
|
-
|
3
|
-
== VERSION
|
4
|
-
|
5
|
-
This documentation refers to ruby-nuggets version 0.9.9
|
6
|
-
|
7
|
-
|
8
|
-
== DESCRIPTION
|
9
|
-
|
10
|
-
ruby-nuggets provides a collection of extensions to Ruby core classes. In
|
11
|
-
its effort, it's similar to projects like Facets[http://facets.rubyforge.org]
|
12
|
-
and Extensions[http://extensions.rubyforge.org] (or even
|
13
|
-
Labrador[http://rubyforge.org/projects/labrador/]), though not as ambitious ;-)
|
14
|
-
This is simply where I put stuff that I need on a more or less regular basis
|
15
|
-
or that struck me as interesting while surfing the web, reading books, or
|
16
|
-
following discussions on ruby-talk.
|
17
|
-
|
18
|
-
There are several ways to get at the nuggets you're interested in:
|
19
|
-
|
20
|
-
# The usual way: Just require() what you need
|
21
|
-
require 'nuggets/object/singleton_class'
|
22
|
-
|
23
|
-
# The more fancy way ;-) (see the documentation of Nuggets() for more examples)
|
24
|
-
require 'nuggets'
|
25
|
-
Nuggets(:object => 'singleton_class', :string => %w[nsub sub_with_md])
|
26
|
-
|
27
|
-
# Finally, get everything there is...
|
28
|
-
require 'nuggets/all'
|
29
|
-
|
30
|
-
Please be aware that some of the things herein might not work as expected or
|
31
|
-
cause other libraries to misbehave. Use at your own risk!
|
32
|
-
|
33
|
-
|
34
|
-
== LINKS
|
35
|
-
|
36
|
-
Documentation:: https://blackwinter.github.io/ruby-nuggets/
|
37
|
-
Source code:: https://github.com/blackwinter/ruby-nuggets
|
38
|
-
RubyGem:: https://rubygems.org/gems/ruby-nuggets
|
39
|
-
Travis CI:: https://travis-ci.org/blackwinter/ruby-nuggets
|
40
|
-
|
41
|
-
|
42
|
-
== AUTHORS
|
43
|
-
|
44
|
-
* Jens Wille <mailto:jens.wille@gmail.com>
|
45
|
-
|
46
|
-
|
47
|
-
== LICENSE AND COPYRIGHT
|
48
|
-
|
49
|
-
Copyright (C) 2007-2014 Jens Wille
|
50
|
-
|
51
|
-
ruby-nuggets is free software: you can redistribute it and/or modify it under
|
52
|
-
the terms of the GNU Affero General Public License as published by the Free
|
53
|
-
Software Foundation, either version 3 of the License, or (at your option)
|
54
|
-
any later version.
|
55
|
-
|
56
|
-
ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT
|
57
|
-
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
58
|
-
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
59
|
-
details.
|
60
|
-
|
61
|
-
You should have received a copy of the GNU Affero General Public License along
|
62
|
-
with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>.
|
data/Rakefile
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require File.expand_path(%q{../lib/nuggets/version}, __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'hen'
|
5
|
-
|
6
|
-
Hen.lay! {{
|
7
|
-
:gem => {
|
8
|
-
:name => %q{ruby-nuggets},
|
9
|
-
:version => Nuggets::VERSION,
|
10
|
-
:summary => %q{Some extensions to the Ruby programming language.},
|
11
|
-
:author => %q{Jens Wille},
|
12
|
-
:email => %q{jens.wille@gmail.com},
|
13
|
-
:license => %q{AGPL-3.0},
|
14
|
-
:homepage => :blackwinter,
|
15
|
-
:dependencies => %w[],
|
16
|
-
|
17
|
-
:development_dependencies => [
|
18
|
-
#'amatch', # enumerable/agrep
|
19
|
-
'mime-types', # content_type
|
20
|
-
'open4', # ruby
|
21
|
-
#'ruby-filemagic' # content_type
|
22
|
-
]
|
23
|
-
}
|
24
|
-
}}
|
25
|
-
rescue LoadError => err
|
26
|
-
warn "Please install the `hen' gem first. (#{err})"
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "Run all specs in isolation"
|
30
|
-
task 'spec:isolated' do
|
31
|
-
ARGV.delete('spec:isolated')
|
32
|
-
ARGV.unshift('spec')
|
33
|
-
|
34
|
-
Dir['spec/*/**/*_spec.rb'].each { |spec|
|
35
|
-
ENV['SPEC'] = spec
|
36
|
-
system($0, *ARGV)
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
if RUBY_PLATFORM == 'java'
|
41
|
-
task :spec => :enable_objspace
|
42
|
-
|
43
|
-
task :enable_objspace do
|
44
|
-
k, v = 'JRUBY_OPTS', '-X+O'
|
45
|
-
ENV[k] ? ENV[k] += " #{v}" : ENV[k] = v
|
46
|
-
end
|
47
|
-
end
|
data/lib/nuggets.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
###############################################################################
|
3
|
-
# #
|
4
|
-
# ruby-nuggets - some extensions to the Ruby programming language. #
|
5
|
-
# #
|
6
|
-
# Copyright (C) 2007-2011 Jens Wille #
|
7
|
-
# #
|
8
|
-
# Authors: #
|
9
|
-
# Jens Wille <jens.wille@gmail.com> #
|
10
|
-
# #
|
11
|
-
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
12
|
-
# under the terms of the GNU Affero General Public License as published by #
|
13
|
-
# the Free Software Foundation; either version 3 of the License, or (at your #
|
14
|
-
# option) any later version. #
|
15
|
-
# #
|
16
|
-
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
17
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License #
|
19
|
-
# for more details. #
|
20
|
-
# #
|
21
|
-
# You should have received a copy of the GNU Affero General Public License #
|
22
|
-
# along with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
23
|
-
# #
|
24
|
-
###############################################################################
|
25
|
-
#++
|
26
|
-
|
27
|
-
# Load selected +nuggets+.
|
28
|
-
#
|
29
|
-
# Examples:
|
30
|
-
# # All String nuggets
|
31
|
-
# Nuggets(:string)
|
32
|
-
# Nuggets(String)
|
33
|
-
#
|
34
|
-
# # Only 'msub' and 'word_wrap' String nuggets
|
35
|
-
# Nuggets(:string => %w[msub word_wrap])
|
36
|
-
#
|
37
|
-
# # Selected String nuggets and all Numeric nuggets
|
38
|
-
# Nuggets(:numeric, :string => %w[msub word_wrap])
|
39
|
-
#
|
40
|
-
# # ...you see the pattern ;-)
|
41
|
-
def Nuggets(*nuggets)
|
42
|
-
loaded_nuggets = []
|
43
|
-
|
44
|
-
load_nuggets = lambda { |base, *nuggets|
|
45
|
-
nuggets_by_hierarchy = nuggets.last.is_a?(::Hash) ? nuggets.pop : {}
|
46
|
-
|
47
|
-
nuggets.each { |nugget|
|
48
|
-
begin
|
49
|
-
require path = ::File.join(base.to_s, nugget.to_s.downcase)
|
50
|
-
loaded_nuggets << path
|
51
|
-
rescue ::LoadError
|
52
|
-
# if it's a directory, load anything in it
|
53
|
-
$LOAD_PATH.each { |dir|
|
54
|
-
if ::File.directory?(dir_path = ::File.join(dir, path))
|
55
|
-
load_nuggets[path, *::Dir[::File.join(dir_path, '*')].map { |file|
|
56
|
-
::File.basename(file, '.rb') unless file =~ /_mixin\.rb\z/
|
57
|
-
}.compact]
|
58
|
-
break
|
59
|
-
end
|
60
|
-
} and raise # otherwise, re-raise
|
61
|
-
end
|
62
|
-
}
|
63
|
-
|
64
|
-
nuggets_by_hierarchy.each { |hierarchy, nuggets|
|
65
|
-
nuggets = [nuggets] if nuggets.is_a?(::Hash)
|
66
|
-
load_nuggets[::File.join(base.to_s, hierarchy.to_s.downcase), *nuggets]
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
load_nuggets['nuggets', *nuggets]
|
71
|
-
|
72
|
-
loaded_nuggets
|
73
|
-
end
|
data/lib/nuggets/all.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
###############################################################################
|
3
|
-
# #
|
4
|
-
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
-
# language. #
|
6
|
-
# #
|
7
|
-
# Copyright (C) 2007-2011 Jens Wille #
|
8
|
-
# #
|
9
|
-
# Authors: #
|
10
|
-
# Jens Wille <jens.wille@gmail.com> #
|
11
|
-
# #
|
12
|
-
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
-
# under the terms of the GNU Affero General Public License as published by #
|
14
|
-
# the Free Software Foundation; either version 3 of the License, or (at your #
|
15
|
-
# option) any later version. #
|
16
|
-
# #
|
17
|
-
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License #
|
20
|
-
# for more details. #
|
21
|
-
# #
|
22
|
-
# You should have received a copy of the GNU Affero General Public License #
|
23
|
-
# along with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
-
# #
|
25
|
-
###############################################################################
|
26
|
-
#++
|
27
|
-
|
28
|
-
base = ::File.dirname(__FILE__)
|
29
|
-
base_re = ::Regexp.escape(base)
|
30
|
-
|
31
|
-
::Dir[::File.join(base, %w[* ** *.rb])].sort.each { |path|
|
32
|
-
next if path.include?('/util/') || path.end_with?('_mixin.rb')
|
33
|
-
|
34
|
-
ext_re = ::Regexp.escape(::File.extname(path))
|
35
|
-
require path.sub(/#{base_re}(.*)#{ext_re}/, 'nuggets\1')
|
36
|
-
}
|
data/lib/nuggets/all_mixins.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
###############################################################################
|
3
|
-
# #
|
4
|
-
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
-
# language. #
|
6
|
-
# #
|
7
|
-
# Copyright (C) 2007-2011 Jens Wille #
|
8
|
-
# #
|
9
|
-
# Authors: #
|
10
|
-
# Jens Wille <jens.wille@gmail.com> #
|
11
|
-
# #
|
12
|
-
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
-
# under the terms of the GNU Affero General Public License as published by #
|
14
|
-
# the Free Software Foundation; either version 3 of the License, or (at your #
|
15
|
-
# option) any later version. #
|
16
|
-
# #
|
17
|
-
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License #
|
20
|
-
# for more details. #
|
21
|
-
# #
|
22
|
-
# You should have received a copy of the GNU Affero General Public License #
|
23
|
-
# along with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
-
# #
|
25
|
-
###############################################################################
|
26
|
-
#++
|
27
|
-
|
28
|
-
base = ::File.dirname(__FILE__)
|
29
|
-
base_re = ::Regexp.escape(base)
|
30
|
-
|
31
|
-
::Dir[::File.join(base, %w[* ** *_mixin.rb])].sort.each { |path|
|
32
|
-
ext_re = ::Regexp.escape(::File.extname(path))
|
33
|
-
require path.sub(/#{base_re}(.*)#{ext_re}/, 'nuggets\1')
|
34
|
-
}
|
@@ -1,125 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
###############################################################################
|
3
|
-
# #
|
4
|
-
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
-
# language. #
|
6
|
-
# #
|
7
|
-
# Copyright (C) 2007-2011 Jens Wille #
|
8
|
-
# #
|
9
|
-
# Authors: #
|
10
|
-
# Jens Wille <jens.wille@gmail.com> #
|
11
|
-
# #
|
12
|
-
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
-
# under the terms of the GNU Affero General Public License as published by #
|
14
|
-
# the Free Software Foundation; either version 3 of the License, or (at your #
|
15
|
-
# option) any later version. #
|
16
|
-
# #
|
17
|
-
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License #
|
20
|
-
# for more details. #
|
21
|
-
# #
|
22
|
-
# You should have received a copy of the GNU Affero General Public License #
|
23
|
-
# along with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
-
# #
|
25
|
-
###############################################################################
|
26
|
-
#++
|
27
|
-
|
28
|
-
module Nuggets
|
29
|
-
module ANSIColor2CSS
|
30
|
-
|
31
|
-
extend self
|
32
|
-
|
33
|
-
ATTRIBUTES = {
|
34
|
-
'0' => nil, # clear
|
35
|
-
'1' => 'font-weight: bold', # bold
|
36
|
-
'2' => '', # dark
|
37
|
-
'3' => 'font-style: italic', # italic -- not widely implemented
|
38
|
-
'4' => 'text-decoration: underline', # underline
|
39
|
-
'5' => 'text-decoration: blink', # blink
|
40
|
-
'6' => 'text-decoration: blink', # rapid blink -- not widely implemented
|
41
|
-
'7' => '', # reverse
|
42
|
-
'8' => 'opacity: 0', # concealed
|
43
|
-
'9' => 'text-decoration: line-through', # strikethrough -- not widely implemented
|
44
|
-
'22' => 'font-weight: normal', # bold off
|
45
|
-
'23' => 'font-style: normal', # italic off
|
46
|
-
'24' => 'text-decoration: none', # underline off
|
47
|
-
'25' => 'text-decoration: none', # blink off
|
48
|
-
'27' => '', # reverse off
|
49
|
-
'28' => 'opacity: 1', # concealed off
|
50
|
-
'29' => 'text-decoration: none', # strikethrough off
|
51
|
-
'30' => 'color: black', # black
|
52
|
-
'31' => 'color: maroon', # red
|
53
|
-
'32' => 'color: green', # green
|
54
|
-
'33' => 'color: olive', # yellow
|
55
|
-
'34' => 'color: navy', # blue
|
56
|
-
'35' => 'color: purple', # magenta
|
57
|
-
'36' => 'color: teal', # cyan
|
58
|
-
'37' => 'color: silver', # white
|
59
|
-
'39' => 'color: silver', # default (white)
|
60
|
-
'40' => 'background-color: black', # on black
|
61
|
-
'41' => 'background-color: maroon', # on red
|
62
|
-
'42' => 'background-color: green', # on green
|
63
|
-
'43' => 'background-color: olive', # on yellow
|
64
|
-
'44' => 'background-color: navy', # on blue
|
65
|
-
'45' => 'background-color: purple', # on magenta
|
66
|
-
'46' => 'background-color: teal', # on cyan
|
67
|
-
'47' => 'background-color: silver', # on white
|
68
|
-
'49' => 'background-color: black', # on default (black)
|
69
|
-
'90' => 'color: gray', # bright black
|
70
|
-
'91' => 'color: red', # bright red
|
71
|
-
'92' => 'color: lime', # bright green
|
72
|
-
'93' => 'color: yellow', # bright yellow
|
73
|
-
'94' => 'color: blue', # bright blue
|
74
|
-
'95' => 'color: fuchsia', # bright magenta
|
75
|
-
'96' => 'color: cyan', # bright cyan
|
76
|
-
'97' => 'color: white', # bright white
|
77
|
-
'100' => 'background-color: gray', # on bright black
|
78
|
-
'101' => 'background-color: red', # on bright red
|
79
|
-
'102' => 'background-color: lime', # on bright green
|
80
|
-
'103' => 'background-color: yellow', # on bright yellow
|
81
|
-
'104' => 'background-color: blue', # on bright blue
|
82
|
-
'105' => 'background-color: fuchsia', # on bright magenta
|
83
|
-
'106' => 'background-color: cyan', # on bright cyan
|
84
|
-
'107' => 'background-color: white' # on bright white
|
85
|
-
}
|
86
|
-
|
87
|
-
ATTRIBUTES_RE = ::Regexp.union(*ATTRIBUTES.keys)
|
88
|
-
|
89
|
-
DELIMITER = ';'
|
90
|
-
|
91
|
-
COLOR_RE = %r{
|
92
|
-
\e \[ ( #{ATTRIBUTES_RE} (?: #{DELIMITER} #{ATTRIBUTES_RE} )* ) m
|
93
|
-
}x
|
94
|
-
|
95
|
-
STYLE = '<span style="%s">'
|
96
|
-
CLEAR = '</span>'
|
97
|
-
|
98
|
-
def convert(string)
|
99
|
-
string.gsub(COLOR_RE) { format($1.split(DELIMITER).uniq) }
|
100
|
-
end
|
101
|
-
|
102
|
-
def format(attributes)
|
103
|
-
"#{clear(attributes)}#{style(attributes) if attributes.any?}"
|
104
|
-
end
|
105
|
-
|
106
|
-
def clear(attributes)
|
107
|
-
CLEAR if attributes.delete('0')
|
108
|
-
end
|
109
|
-
|
110
|
-
def style(attributes)
|
111
|
-
STYLE % ATTRIBUTES.values_at(*attributes).join('; ')
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
class String
|
118
|
-
|
119
|
-
def ansicolor2css
|
120
|
-
::Nuggets::ANSIColor2CSS.convert(self)
|
121
|
-
end
|
122
|
-
|
123
|
-
alias_method :ansicolour2css, :ansicolor2css
|
124
|
-
|
125
|
-
end
|
data/lib/nuggets/argv/option.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
###############################################################################
|
3
|
-
# #
|
4
|
-
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
-
# language. #
|
6
|
-
# #
|
7
|
-
# Copyright (C) 2007-2013 Jens Wille #
|
8
|
-
# #
|
9
|
-
# Authors: #
|
10
|
-
# Jens Wille <jens.wille@gmail.com> #
|
11
|
-
# #
|
12
|
-
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
-
# under the terms of the GNU Affero General Public License as published by #
|
14
|
-
# the Free Software Foundation; either version 3 of the License, or (at your #
|
15
|
-
# option) any later version. #
|
16
|
-
# #
|
17
|
-
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License #
|
20
|
-
# for more details. #
|
21
|
-
# #
|
22
|
-
# You should have received a copy of the GNU Affero General Public License #
|
23
|
-
# along with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
-
# #
|
25
|
-
###############################################################################
|
26
|
-
#++
|
27
|
-
|
28
|
-
module Nuggets
|
29
|
-
module Argv
|
30
|
-
module OptionMixin
|
31
|
-
|
32
|
-
# call-seq:
|
33
|
-
# ARGV.switch(short[, long]) -> true | false
|
34
|
-
#
|
35
|
-
# Whether ARGV includes the switch +short+ (or +long+).
|
36
|
-
def switch(*args)
|
37
|
-
!!(__key(*args) { |key| include?(key) })
|
38
|
-
end
|
39
|
-
|
40
|
-
# call-seq:
|
41
|
-
# ARGV.option(short[, long]) -> aString
|
42
|
-
# ARGV.option(short[, long]) { |value| ... } -> anObject
|
43
|
-
#
|
44
|
-
# Returns the value associated with the option +short+ (or +long+) if present
|
45
|
-
# in ARGV. Yields that value to the block if given and returns its result.
|
46
|
-
def option(*args, &block)
|
47
|
-
__opt(block, *args) { |index| at(index + 1) }
|
48
|
-
end
|
49
|
-
|
50
|
-
# call-seq:
|
51
|
-
# ARGV.switch!(short[, long]) -> true | false
|
52
|
-
#
|
53
|
-
# Whether ARGV includes the switch +short+ (or +long+). Removes the matching
|
54
|
-
# switch from ARGV.
|
55
|
-
def switch!(*args)
|
56
|
-
!!(__key(*args) { |key| delete(key) })
|
57
|
-
end
|
58
|
-
|
59
|
-
# call-seq:
|
60
|
-
# ARGV.option!(short[, long]) -> aString
|
61
|
-
# ARGV.option!(short[, long]) { |value| ... } -> anObject
|
62
|
-
#
|
63
|
-
# Returns the value associated with the option +short+ (or +long+) if present
|
64
|
-
# in ARGV and removes both from ARGV. Yields that value to the block if given
|
65
|
-
# and returns its result.
|
66
|
-
def option!(*args, &block)
|
67
|
-
__opt(block, *args) { |index| delete_at(index); delete_at(index) }
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def __key(short, long = nil) # :yield: key
|
73
|
-
long && yield("--#{long}") || yield("-#{short}")
|
74
|
-
end
|
75
|
-
|
76
|
-
def __opt(block, *args)
|
77
|
-
index = __key(*args) { |key| index(key) } or return
|
78
|
-
|
79
|
-
value = yield(index)
|
80
|
-
block ? block[value] : value
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|