quality_extensions 1.0.0 → 1.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.
- data/Readme +11 -2
- data/lib/quality_extensions/array/classify.rb +1 -1
- data/lib/quality_extensions/array/expand_ranges.rb +1 -1
- data/lib/quality_extensions/array/group_by.rb +1 -1
- data/lib/quality_extensions/array/shell_escape.rb +6 -8
- data/lib/quality_extensions/colored/toggleability.rb +1 -1
- data/lib/quality_extensions/console/command.rb +1 -1
- data/lib/quality_extensions/date/iso8601.rb +1 -1
- data/lib/quality_extensions/enumerable/map_with_index.rb +55 -0
- data/lib/quality_extensions/exception/inspect_with_backtrace.rb +1 -1
- data/lib/quality_extensions/hash/assert_has_only_keys.rb +1 -1
- data/lib/quality_extensions/hash/to_query_string.rb +1 -1
- data/lib/quality_extensions/kernel/capture_output.rb +1 -1
- data/lib/quality_extensions/kernel/die.rb +2 -2
- data/lib/quality_extensions/kernel/example_printer.rb +1 -1
- data/lib/quality_extensions/kernel/remove_const.rb +1 -1
- data/lib/quality_extensions/kernel/remove_module.rb +1 -1
- data/lib/quality_extensions/kernel/require_all.rb +3 -3
- data/lib/quality_extensions/kernel/require_once.rb +1 -1
- data/lib/quality_extensions/kernel/simulate_input.rb +1 -1
- data/lib/quality_extensions/kernel/trap_chain.rb +1 -1
- data/lib/quality_extensions/module/alias_method_chain.rb +1 -1
- data/lib/quality_extensions/module/basename.rb +1 -1
- data/lib/quality_extensions/module/bool_attr_accessor.rb +1 -1
- data/lib/quality_extensions/module/class_methods.rb +1 -1
- data/lib/quality_extensions/module/create.rb +2 -2
- data/lib/quality_extensions/module/guard_method.rb +1 -3
- data/lib/quality_extensions/module/initializer.rb +72 -0
- data/lib/quality_extensions/module/join.rb +1 -1
- data/lib/quality_extensions/module/malias_method_chain.rb +1 -1
- data/lib/quality_extensions/module/namespace.rb +1 -2
- data/lib/quality_extensions/module/parents.rb +1 -1
- data/lib/quality_extensions/module/remove_const.rb +2 -2
- data/lib/quality_extensions/module/split.rb +1 -1
- data/lib/quality_extensions/nil_method_missing.rb +1 -1
- data/lib/quality_extensions/object/ancestry_of_method.rb +1 -1
- data/lib/quality_extensions/object/if_else.rb +1 -1
- data/lib/quality_extensions/object/ignore_access.rb +1 -1
- data/lib/quality_extensions/object/mcall.rb +1 -1
- data/lib/quality_extensions/object/methods.rb +1 -1
- data/lib/quality_extensions/object/send_if.rb +1 -1
- data/lib/quality_extensions/object/singleton_send.rb +1 -1
- data/lib/quality_extensions/safe_nil.rb +1 -1
- data/lib/quality_extensions/string/each_char_with_index.rb +1 -1
- data/lib/quality_extensions/string/shell_escape.rb +10 -3
- data/lib/quality_extensions/string/with_knowledge_of_color.rb +1 -1
- data/lib/quality_extensions/symbol/constantize.rb +1 -1
- data/lib/quality_extensions/symbol/match.rb +1 -1
- data/lib/quality_extensions/template.rb +1 -1
- data/lib/quality_extensions/test/difference_highlighting.rb +1 -1
- metadata +4 -2
data/Readme
CHANGED
@@ -3,11 +3,14 @@
|
|
3
3
|
[<b>Home page</b>:] http://quality-ext.rubyforge.org/
|
4
4
|
[<b>Project site</b>:] http://rubyforge.org/projects/quality-ext/
|
5
5
|
[<b>Gem install</b>:] <tt>gem install quality_extensions</tt>
|
6
|
+
[<b>Author</b>:] Tyler Rick <rubyforge.org|tylerrick.com> and others
|
6
7
|
[<b>License</b>:] {Ruby License}[link:files/License.html]
|
7
8
|
|
8
9
|
== Introduction
|
9
10
|
|
10
|
-
|
11
|
+
QualityExtensions is a library of general-purpose, reusable methods/classes that are compatible with/built-upon Facets (2.4.1) but not (yet) included in Facets... including FileTest.binary_file?, Enumerable#enum, String#digits_only, send_if_not_nil, send_if_true, send_unless, Kernel#capture_output, Kernel#backtrace, Symbol#=~, Hash#hash_select, Hash#delete_unless, Array#expand_ranges, assert_changed, assert_contains, and many more.
|
12
|
+
|
13
|
+
It is similar in purpose and layout to {Ruby Facets}[http://facets.rubyforge.org/] but not intended _compete_ with Facets.
|
11
14
|
|
12
15
|
Developers are encouraged to first check if the method or class they are looking for already exists in one of the fine existing open-source projects (like {Facets}[http://facets.rubyforge.org/] or {Extensions}[http://extensions.rubyforge.org/rdoc/index.html] or {stdlib}[http://www.ruby-doc.org/stdlib/]).
|
13
16
|
|
@@ -17,9 +20,15 @@ Like Facets, this library contains:
|
|
17
20
|
* methods that add functionality to existing Ruby classes (String, Array, etc.)
|
18
21
|
* as well as new classes that aren't in core Ruby
|
19
22
|
|
23
|
+
== Featured methods
|
24
|
+
|
25
|
+
* <tt>Regexp#+</tt>, <tt>Regexp#join</tt>
|
26
|
+
* <tt>guard_method</tt>/<tt>mguard_method</tt>
|
27
|
+
* ...
|
28
|
+
|
20
29
|
== Installation
|
21
30
|
|
22
|
-
gem install quality_extensions
|
31
|
+
gem install quality_extensions -y
|
23
32
|
|
24
33
|
== Usage
|
25
34
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# column from the array, which can be nice, since the classification key in the hash makes it somewhat redundant.
|
11
11
|
#++
|
12
12
|
|
13
|
-
$LOAD_PATH
|
13
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
14
14
|
require 'rubygems'
|
15
15
|
gem 'facets'
|
16
16
|
require 'facets/to_hash'
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# *not* in "table" form (whose elements are *not* all arrays of equal size and might not even be *arrays*).
|
11
11
|
#++
|
12
12
|
|
13
|
-
$LOAD_PATH
|
13
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
14
14
|
require 'rubygems'
|
15
15
|
gem 'facets'
|
16
16
|
require 'facets/array/delete'
|
@@ -5,16 +5,16 @@
|
|
5
5
|
# Submit to Facets?:: Yes.
|
6
6
|
#++
|
7
7
|
|
8
|
-
$LOAD_PATH
|
8
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
9
9
|
require 'rubygems'
|
10
10
|
require 'facets/ruby' # to_proc
|
11
11
|
require 'facets/kernel/load'
|
12
12
|
require_local '../string/shell_escape.rb'
|
13
13
|
|
14
|
+
require 'pp'
|
14
15
|
class Array
|
15
16
|
def shell_escape
|
16
|
-
|
17
|
-
Escape.shell_command(self)
|
17
|
+
self.map(&:shell_escape).map(&:to_s)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -29,13 +29,11 @@ require 'test/unit'
|
|
29
29
|
|
30
30
|
class TheTest < Test::Unit::TestCase
|
31
31
|
def test_1
|
32
|
-
assert_equal 'a', ['a'].shell_escape
|
32
|
+
assert_equal ['a'], ['a'].shell_escape
|
33
33
|
end
|
34
34
|
def test_2
|
35
|
-
|
36
|
-
|
37
|
-
assert_equal "arg1 'multiple words for single argument'",
|
38
|
-
['arg1', 'multiple words for single argument'].shell_escape.to_s
|
35
|
+
assert_equal ["arg1", "'multiple words for single argument'"],
|
36
|
+
['arg1', 'multiple words for single argument'].shell_escape
|
39
37
|
end
|
40
38
|
end
|
41
39
|
=end
|
@@ -29,7 +29,7 @@
|
|
29
29
|
# Copyright:: Copyright (c) 2005-2007
|
30
30
|
# License:: Ruby License
|
31
31
|
|
32
|
-
$LOAD_PATH
|
32
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
33
33
|
require 'shellwords'
|
34
34
|
require 'rubygems'
|
35
35
|
require 'facets/style' #modulize
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: vinterbleg <http://snippets.dzone.com/posts/show/5119>, Tyler Rick
|
3
|
+
# Copyright:: Copyright (c) Its authors.
|
4
|
+
# License:: Ruby License
|
5
|
+
# Submit to Facets?:: Yes. facets/enumerable/collect.rb only has non-in-place version (map_with_index).
|
6
|
+
# Developer notes::
|
7
|
+
# Changes::
|
8
|
+
#++
|
9
|
+
|
10
|
+
module Enumerable
|
11
|
+
def map_with_index!
|
12
|
+
each_with_index do |e, i|
|
13
|
+
self[i] = yield(e, i)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def map_with_index(&block)
|
18
|
+
dup.map_with_index!(&block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# _____ _
|
24
|
+
# |_ _|__ ___| |_
|
25
|
+
# | |/ _ \/ __| __|
|
26
|
+
# | | __/\__ \ |_
|
27
|
+
# |_|\___||___/\__|
|
28
|
+
#
|
29
|
+
=begin test
|
30
|
+
require 'test/unit'
|
31
|
+
|
32
|
+
class NonInPlaceTest < Test::Unit::TestCase
|
33
|
+
def test_1
|
34
|
+
array = ['a', 'b']
|
35
|
+
after = array.map_with_index do |e, i|
|
36
|
+
e.upcase + array[i+1].to_s
|
37
|
+
end
|
38
|
+
assert_equal ['Ab', 'B'], after
|
39
|
+
assert_equal ['a', 'b'], array
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class InPlaceTest < Test::Unit::TestCase
|
44
|
+
def test_1
|
45
|
+
array = ['a', 'b']
|
46
|
+
after = array.map_with_index! do |e, i|
|
47
|
+
e.upcase + array[i+1].to_s
|
48
|
+
end
|
49
|
+
assert_equal ['Ab', 'B'], after
|
50
|
+
assert_equal after, array
|
51
|
+
end
|
52
|
+
end
|
53
|
+
=end
|
54
|
+
|
55
|
+
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# stream.reopen(old_stream)
|
18
18
|
# end
|
19
19
|
|
20
|
-
$LOAD_PATH
|
20
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
21
21
|
require 'stringio'
|
22
22
|
require 'rubygems'
|
23
23
|
require 'facets/dictionary'
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Deprecated. Because I discovered Kernel::abort !
|
7
7
|
#++
|
8
8
|
|
9
|
-
$LOAD_PATH
|
9
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
10
|
module Kernel
|
11
11
|
def die(message, exit_code = 1)
|
12
12
|
$stderr.puts message
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
# |_|\___||___/\__|
|
22
22
|
#
|
23
23
|
=begin test
|
24
|
-
$LOAD_PATH
|
24
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
25
25
|
require 'test/unit'
|
26
26
|
require 'rubygems'
|
27
27
|
require 'quality_extensions/kernel/capture_output'
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# * Add class method for ExamplePrinter to set a template for use by xmp? So if you don't like the default ("=> #{result}"), you can specify your own...
|
12
12
|
#++
|
13
13
|
|
14
|
-
$LOAD_PATH
|
14
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
15
15
|
require 'rubygems'
|
16
16
|
#require 'facets/binding/self/of_caller'
|
17
17
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Developer notes::
|
7
7
|
#++
|
8
8
|
|
9
|
-
$LOAD_PATH
|
9
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
10
|
require 'rubygems'
|
11
11
|
require 'quality_extensions/object/ignore_access'
|
12
12
|
require 'quality_extensions/module/split'
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# * Deprecated by quality_extensions/module/remove.rb
|
8
8
|
#++
|
9
9
|
|
10
|
-
$LOAD_PATH
|
10
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
11
11
|
require 'rubygems'
|
12
12
|
require 'quality_extensions/object/ignore_access'
|
13
13
|
require 'quality_extensions/module/split'
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Submit to Facets?:: Yes
|
6
6
|
#++
|
7
7
|
|
8
|
-
$LOAD_PATH
|
8
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
9
9
|
require 'rubygems'
|
10
10
|
require 'facets/filelist'
|
11
11
|
|
@@ -50,7 +50,7 @@ module Kernel
|
|
50
50
|
# <tt>require</tt>s all Ruby files in +dir+ (relative to <tt>File.dirname(__FILE__)</tt>) or any of its subdirectories.
|
51
51
|
#
|
52
52
|
# This is just a shortcut for this:
|
53
|
-
# require_all File.join(File.dirname(__FILE__), dir)
|
53
|
+
# require_all File.expand_path(File.join(File.dirname(__FILE__), dir))
|
54
54
|
#
|
55
55
|
# All of the +options+ available for +require_all+ are still available here.
|
56
56
|
#
|
@@ -58,7 +58,7 @@ module Kernel
|
|
58
58
|
raise ArgumentError.new("dir must be a String") unless dir.is_a?(String)
|
59
59
|
local_dir = File.dirname( caller[0] )
|
60
60
|
require_all(
|
61
|
-
File.join(local_dir, dir),
|
61
|
+
File.expand_path(File.join(local_dir, dir)),
|
62
62
|
options
|
63
63
|
)
|
64
64
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Submit to Facets?:: Yes!
|
6
6
|
#++
|
7
7
|
|
8
|
-
$LOAD_PATH
|
8
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
9
9
|
|
10
10
|
module Kernel
|
11
11
|
# Calling <tt>Kernel#trap()</tt> by itself will _replace_ any previously registered handler code.
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# Changes::
|
8
8
|
#++
|
9
9
|
|
10
|
-
$LOAD_PATH
|
10
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
11
11
|
require 'rubygems'
|
12
12
|
require 'facets/module/basename'
|
13
13
|
require 'quality_extensions/module/namespace'
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# * Changed it so that if you call a!(false) it would actually set @a to false rather than leaving it unchanged. (I assume that was a bug.)
|
13
13
|
#++
|
14
14
|
|
15
|
-
$LOAD_PATH
|
15
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
16
16
|
|
17
17
|
# bool_attr_accessor
|
18
18
|
|
@@ -23,10 +23,10 @@
|
|
23
23
|
# * Added __FILE__, __LINE__ to class_eval so that error messages would be more helpful.
|
24
24
|
#++
|
25
25
|
|
26
|
-
$LOAD_PATH
|
26
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
27
27
|
require 'rubygems'
|
28
28
|
require 'quality_extensions/hash/assert_has_only_keys'
|
29
|
-
require 'facets/hash/
|
29
|
+
require 'facets/hash/merge'
|
30
30
|
require 'facets/kernel/constant'
|
31
31
|
require 'facets/ruby' # to_proc
|
32
32
|
require 'quality_extensions/module/split'
|
@@ -11,11 +11,9 @@
|
|
11
11
|
# possible to make it thread-safe?
|
12
12
|
#++
|
13
13
|
|
14
|
-
$LOAD_PATH
|
14
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
15
15
|
require 'rubygems'
|
16
|
-
puts '1'
|
17
16
|
require 'quality_extensions/module/attribute_accessors'
|
18
|
-
puts '2'
|
19
17
|
require 'facets/kernel/load'
|
20
18
|
require_local 'bool_attr_accessor'
|
21
19
|
#require 'quality_extensions/module/bool_attr_accessor'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Trans?
|
3
|
+
# Copyright:: Copyright (c) Trans?
|
4
|
+
# License:: Ruby License
|
5
|
+
# Submit to Facets?:: No. Copied from facets-1.8.54/lib/facets/core/hash/assert_has_only_keys.rb. No longer exists in 2.4.1.
|
6
|
+
# Developer notes::
|
7
|
+
#++
|
8
|
+
|
9
|
+
class Module
|
10
|
+
|
11
|
+
# Automatically create an initializer assigning the given
|
12
|
+
# arguments.
|
13
|
+
#
|
14
|
+
# class MyClass
|
15
|
+
# initializer(:a, "b", :c)
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# _is equivalent to_
|
19
|
+
#
|
20
|
+
# class MyClass
|
21
|
+
# def initialize(a, b, c)
|
22
|
+
# @a,@b,@c = a,b,c
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# Downside: Initializers defined like this can't take blocks.
|
27
|
+
# This can be fixed when Ruby 1.9 is out.
|
28
|
+
#
|
29
|
+
# The initializer will not raise an Exception when the user
|
30
|
+
# does not supply a value for each instance variable. In that
|
31
|
+
# case it will just set the instance variable to nil. You can
|
32
|
+
# assign default values or raise an Exception in the block.
|
33
|
+
#
|
34
|
+
def initializer(*attributes, &block)
|
35
|
+
define_method(:initialize) do |*args|
|
36
|
+
attributes.zip(args) do |sym, value|
|
37
|
+
instance_variable_set("@#{sym}", value)
|
38
|
+
end
|
39
|
+
|
40
|
+
instance_eval(&block) if block
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
# _____ _
|
49
|
+
# |_ _|__ ___| |_
|
50
|
+
# | |/ _ \/ __| __|
|
51
|
+
# | | __/\__ \ |_
|
52
|
+
# |_|\___||___/\__|
|
53
|
+
#
|
54
|
+
=begin test
|
55
|
+
|
56
|
+
require 'test/unit'
|
57
|
+
|
58
|
+
class TCModule < Test::Unit::TestCase
|
59
|
+
|
60
|
+
def test_attr_initializer
|
61
|
+
cc = Class.new
|
62
|
+
cc.class_eval {
|
63
|
+
initializer :ai
|
64
|
+
attr_reader :ai
|
65
|
+
}
|
66
|
+
c = cc.new(10)
|
67
|
+
assert_equal( 10, c.ai )
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
=end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# Changes::
|
8
8
|
#++
|
9
9
|
|
10
|
-
$LOAD_PATH
|
10
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
11
11
|
require 'rubygems'
|
12
12
|
require 'facets/ruby' # to_proc
|
13
13
|
require 'quality_extensions/symbol/constantize'
|
@@ -8,8 +8,7 @@
|
|
8
8
|
# * 0.0.52: Renamed namespace to namespace_module to avoid conflicting with Facets' Module#namespace and Rake's namespace
|
9
9
|
#++
|
10
10
|
|
11
|
-
$LOAD_PATH
|
12
|
-
require 'rubygems'
|
11
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
13
12
|
require 'quality_extensions/symbol/constantize'
|
14
13
|
require 'quality_extensions/module/split'
|
15
14
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
# * Copied from ActiveSupport.
|
10
10
|
#++
|
11
11
|
|
12
|
-
$LOAD_PATH
|
12
|
+
$LOAD_PATH << File.expand_path(File.expand_path(File.join(File.dirname(__FILE__), '..', '..')))
|
13
13
|
require 'rubygems'
|
14
14
|
require 'facets/kernel/constant'
|
15
15
|
|
@@ -6,11 +6,11 @@
|
|
6
6
|
# Developer notes::
|
7
7
|
#++
|
8
8
|
|
9
|
-
$LOAD_PATH
|
9
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
10
|
require 'rubygems'
|
11
11
|
require 'quality_extensions/object/ignore_access'
|
12
12
|
require 'quality_extensions/module/split'
|
13
|
-
require '
|
13
|
+
require 'quality_extensions/module/by_name'
|
14
14
|
require 'facets/module/modspace'
|
15
15
|
|
16
16
|
module Kernel
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# Developer notes::
|
9
9
|
#++
|
10
10
|
|
11
|
-
$LOAD_PATH
|
11
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
12
12
|
|
13
13
|
class NilClass
|
14
14
|
# This allows you to call undefined methods on nil without an exception being raised.
|
@@ -9,7 +9,7 @@
|
|
9
9
|
# * Rename to origin_of_method (or source_of_method)?? Since strictly speaking it may return a method that is not from any *ancestors* but is from the Class class.
|
10
10
|
#++
|
11
11
|
|
12
|
-
$LOAD_PATH
|
12
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
13
13
|
require 'rubygems'
|
14
14
|
require 'quality_extensions/module/class_methods'
|
15
15
|
require 'quality_extensions/module/ancestry_of_instance_method'
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# * promiscuous (like rdoc's --promiscuous -- different semantics though)
|
18
18
|
#++
|
19
19
|
|
20
|
-
$LOAD_PATH
|
20
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
21
21
|
require 'rubygems'
|
22
22
|
require 'facets/functor'
|
23
23
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Developer notes::
|
7
7
|
#++
|
8
8
|
|
9
|
-
$LOAD_PATH
|
9
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
10
|
|
11
11
|
class Object
|
12
12
|
# Calls the method implementation from the module of your choice (+moduule+) on the object of your choice (+self+).
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Developer notes::
|
7
7
|
#++
|
8
8
|
|
9
|
-
$LOAD_PATH
|
9
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
10
|
require 'rubygems'
|
11
11
|
require 'facets/module/alias'
|
12
12
|
require 'facets/ruby' # to_proc
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# * Or just leave it how it is because all the alternatives are too long...
|
14
14
|
#++
|
15
15
|
|
16
|
-
$LOAD_PATH
|
16
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
17
17
|
require 'rubygems'
|
18
18
|
gem 'facets'
|
19
19
|
require 'facets/kernel/with' # returning
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Submit to Facets?:: Yes
|
6
6
|
#++
|
7
7
|
|
8
|
-
$LOAD_PATH
|
8
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
9
9
|
require 'rubygems'
|
10
10
|
require 'escape' # http://www.a-k-r.org/escape/
|
11
11
|
require 'facets/ruby' unless Symbol.method_defined?(:to_proc)
|
@@ -27,19 +27,26 @@ end
|
|
27
27
|
require 'test/unit'
|
28
28
|
|
29
29
|
class TheTest < Test::Unit::TestCase
|
30
|
+
# Use `echo` command to test integrity all the way to a command and back out the other side.
|
30
31
|
def assert_that_echo_gives_back_what_we_put_in(input)
|
31
32
|
input = %q{!&'"`$0 |()<>}
|
32
33
|
output = `echo -n #{input.shell_escape}`
|
33
34
|
assert_equal input, output
|
34
35
|
end
|
35
|
-
def
|
36
|
+
def test_using_echo_1
|
36
37
|
assert_that_echo_gives_back_what_we_put_in(
|
37
38
|
%q{!&'"`$0 |()<>} )
|
38
39
|
end
|
39
|
-
def
|
40
|
+
def test_using_echo_2
|
40
41
|
assert_that_echo_gives_back_what_we_put_in(
|
41
42
|
%q{'an arg that's got "quotes"} )
|
42
43
|
end
|
44
|
+
|
45
|
+
# Escape has changed its behavior in newer versions. It wants to return it as type Escape::ShellEscaped.
|
46
|
+
def test_type
|
47
|
+
assert_equal Escape::ShellEscaped, 'a'.shell_escape.class
|
48
|
+
assert_equal 'a', 'a'.shell_escape.to_s
|
49
|
+
end
|
43
50
|
end
|
44
51
|
=end
|
45
52
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# This file adds a bit of color to your failed string comparisons (assert_equal).
|
9
9
|
# Differences will be highlighted for you in color so that you can instantly find them.
|
10
10
|
|
11
|
-
$LOAD_PATH
|
11
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
12
12
|
require 'rubygems'
|
13
13
|
gem 'colored'
|
14
14
|
require 'colored'
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: quality_extensions
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2008-06-
|
6
|
+
version: 1.0.3
|
7
|
+
date: 2008-06-20 00:00:00 -07:00
|
8
8
|
summary: A collection of reusable Ruby methods which are not (yet) in Facets.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/quality_extensions/module/namespace.rb
|
35
35
|
- lib/quality_extensions/module/guard_method.rb
|
36
36
|
- lib/quality_extensions/module/dirname.rb
|
37
|
+
- lib/quality_extensions/module/initializer.rb
|
37
38
|
- lib/quality_extensions/module/alias_method_chain.rb
|
38
39
|
- lib/quality_extensions/module/create.rb
|
39
40
|
- lib/quality_extensions/module/remove_const.rb
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- lib/quality_extensions/test/assert_changed.rb
|
89
90
|
- lib/quality_extensions/enumerable/enum.rb
|
90
91
|
- lib/quality_extensions/enumerable/select_until.rb
|
92
|
+
- lib/quality_extensions/enumerable/map_with_index.rb
|
91
93
|
- lib/quality_extensions/enumerable/select_while.rb
|
92
94
|
- lib/quality_extensions/exception/inspect_with_backtrace.rb
|
93
95
|
- lib/quality_extensions/chainable_safe_nil.rb
|