quality_extensions 1.1.0 → 1.1.1
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 → Readme.rdoc} +3 -3
- data/lib/quality_extensions/color/gradiate.rb +72 -0
- data/lib/quality_extensions/color/rgb.rb +80 -0
- data/lib/quality_extensions/dictable.rb +48 -0
- data/lib/quality_extensions/histogram.rb +48 -0
- data/lib/quality_extensions/inspect_with.rb +114 -0
- data/lib/quality_extensions/regexp/named_captures.rb +99 -0
- data/lib/quality_extensions/regexp/rfc822.rb +31 -0
- data/lib/quality_extensions/string/with_knowledge_of_color.rb +4 -2
- data/lib/quality_extensions.rb +1 -0
- metadata +104 -96
data/{Readme → Readme.rdoc}
RENAMED
@@ -1,14 +1,14 @@
|
|
1
1
|
= Quality Ruby Extensions
|
2
2
|
|
3
3
|
[<b>Home page</b>:] http://quality-ext.rubyforge.org/
|
4
|
-
[<b>Project site</b>:] http://rubyforge.org/projects/quality-ext/
|
4
|
+
[<b>Project site</b>:] http://github.com/TylerRick/quality_extensions/tree/master / http://rubyforge.org/projects/quality-ext/
|
5
5
|
[<b>Gem install</b>:] <tt>gem install quality_extensions</tt>
|
6
|
-
[<b>Author</b>:] Tyler Rick <
|
6
|
+
[<b>Author</b>:] Tyler Rick <github.com|tylerrick.com> and others
|
7
7
|
[<b>License</b>:] {Ruby License}[link:files/License.html]
|
8
8
|
|
9
9
|
== Introduction
|
10
10
|
|
11
|
-
QualityExtensions is a library of general-purpose, reusable methods/classes that are compatible with/built-upon Facets (2.4.
|
11
|
+
QualityExtensions is a library of general-purpose, reusable methods/classes that are compatible with/built-upon Facets (2.4.4) 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
12
|
|
13
13
|
It is similar in purpose and layout to {Ruby Facets}[http://facets.rubyforge.org/] but not intended _compete_ with Facets.
|
14
14
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# http://tfletcher.com/lib/gradiate.rb
|
2
|
+
require 'rgb'
|
3
|
+
|
4
|
+
class Numeric #:nodoc:
|
5
|
+
def diff(n)
|
6
|
+
return (self > n ? self - n : n - self)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Enumerable
|
11
|
+
|
12
|
+
# Sorts objects in the enumeration and applies a colour scale to them.
|
13
|
+
#
|
14
|
+
# Colour ranges must be in the form [x, y], where x and y are either fixnums
|
15
|
+
# (e.g. 255, 0xFF) or hexadecimal strings (e.g. 'FF').
|
16
|
+
#
|
17
|
+
# Ranges can be provided for each RGB colour e.g.
|
18
|
+
#
|
19
|
+
# gradiate(:red => red_range)
|
20
|
+
#
|
21
|
+
# ...and a default range (for all colours) can be set using :all e.g.
|
22
|
+
#
|
23
|
+
# gradiate(:all => default_range, :green => green_range)
|
24
|
+
#
|
25
|
+
# If no colour ranges are supplied then the _sorted_ enumeration will be returned.
|
26
|
+
#
|
27
|
+
# Objects contained in the enumeration are expected to have a colour (or color)
|
28
|
+
# attribute/method that returns a <tt>Colour::RGB</tt> object (or similar).
|
29
|
+
#
|
30
|
+
# By default, objects are sorted using <tt>:to_i</tt>. This can be overidden
|
31
|
+
# by setting <tt>options[:compare_using]</tt> to a different method symbol.
|
32
|
+
#
|
33
|
+
# By default, objects are ordered "smallest" first. To reverse this set
|
34
|
+
# <tt>options[:order]</tt> to either <tt>:desc</tt> or <tt>:reverse</tt>.
|
35
|
+
#
|
36
|
+
def gradiate(options={})
|
37
|
+
ranges = [:red, :green, :blue].map do |col|
|
38
|
+
if range = (options[col] || options[:all])
|
39
|
+
a, b = range.map { |x| x.respond_to?(:hex) ? x.hex : x.to_i }
|
40
|
+
a, b = b, a if a > b # smallest first
|
41
|
+
c = b.diff(a) / (self.size - 1)
|
42
|
+
next (a..b).every(c)
|
43
|
+
else [] end
|
44
|
+
end
|
45
|
+
objects = sort_by { |object| object.send(options[:compare_using] || :to_i) }
|
46
|
+
objects = objects.reverse if [:desc, :reverse].include?(options[:order])
|
47
|
+
objects.zip(*ranges).collect do |object, red, green, blue|
|
48
|
+
colour = object.respond_to?(:colour) ? object.colour : object.color
|
49
|
+
colour.red = red if red
|
50
|
+
colour.green = green if green
|
51
|
+
colour.blue = blue if blue
|
52
|
+
next object
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Yields every nth object (if invoked with a block),
|
57
|
+
# or returns an array of every nth object e.g.
|
58
|
+
#
|
59
|
+
# [1, 2, 3, 4, 5, 6].every(2) -> [1, 3, 5]
|
60
|
+
# [1, 2, 3, 4, 5, 6].every(2) { |i| ... } -> nil
|
61
|
+
#
|
62
|
+
def every(n)
|
63
|
+
result = [] unless block_given?
|
64
|
+
each_with_index do |object, i|
|
65
|
+
if i % n == 0
|
66
|
+
block_given?? yield(object) : result << object
|
67
|
+
end
|
68
|
+
end
|
69
|
+
return block_given?? nil : result
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# http://tfletcher.com/lib/rgb.rb
|
2
|
+
|
3
|
+
class Fixnum # :nodoc:
|
4
|
+
def to_rgb
|
5
|
+
a, b = divmod(65536)
|
6
|
+
return b.divmod(256).unshift(a)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class String # :nodoc:
|
11
|
+
def to_rgb
|
12
|
+
self.hex.to_rgb
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Symbol # :nodoc:
|
17
|
+
def to_rgb
|
18
|
+
self.to_s.to_rgb
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Colour # :nodoc:
|
23
|
+
#
|
24
|
+
# A lightweight implementation of rgb/hex colors, designed for web use.
|
25
|
+
#
|
26
|
+
# c = Colour::RGB.new(0xFFFFFF)
|
27
|
+
#
|
28
|
+
# c.to_s -> "ffffff"
|
29
|
+
#
|
30
|
+
# c.red = 196
|
31
|
+
# c.green = 0xDD
|
32
|
+
# c.blue = 'EE'
|
33
|
+
#
|
34
|
+
# c.to_s -> "c4ddee"
|
35
|
+
#
|
36
|
+
# Similar to (see also) {ColorTools}[http://rubyforge.org/projects/ruby-pdf].
|
37
|
+
#
|
38
|
+
class RGB
|
39
|
+
|
40
|
+
# :stopdoc:
|
41
|
+
[:red, :green, :blue].each do |col|
|
42
|
+
define_method(:"#{col}=") { |value| set!(col, value) }
|
43
|
+
end
|
44
|
+
# :startdoc:
|
45
|
+
|
46
|
+
attr_reader :red, :green, :blue
|
47
|
+
|
48
|
+
# The following are the same colour:
|
49
|
+
#
|
50
|
+
# RGB.new(0xFFFFFF)
|
51
|
+
# RGB.new(:FFFFFF)
|
52
|
+
# RGB.new("FFFFFF")
|
53
|
+
# RGB.new(255, "FF", 0xFF)
|
54
|
+
#
|
55
|
+
def initialize(*rgb)
|
56
|
+
(rgb.size == 1 ? rgb[0].to_rgb : rgb).zip([:red, :green, :blue]) do |(value, col)|
|
57
|
+
set!(col, value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns the hexadecimal string representation of the colour e.g.
|
62
|
+
#
|
63
|
+
# RGB.new(255, 255, 255).to_s -> "FFFFFF"
|
64
|
+
#
|
65
|
+
def to_s
|
66
|
+
"%02x%02x%02x" % [ red, green, blue ]
|
67
|
+
end
|
68
|
+
|
69
|
+
protected
|
70
|
+
|
71
|
+
def set!(colour, value)
|
72
|
+
value = value.hex if value.respond_to?(:hex)
|
73
|
+
unless (0..255) === value
|
74
|
+
raise ArgumentError, "#{value.inspect} not in range 0..255"
|
75
|
+
end
|
76
|
+
instance_variable_set(:"@#{colour}", value)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# http://tfletcher.com/lib/dictable.rb
|
2
|
+
|
3
|
+
# Provides dictionary/hash-like mixin for any enumerable object that yields
|
4
|
+
# key-value pairs and responds_to :update (the included Dict builds upon Array).
|
5
|
+
#
|
6
|
+
# For example:
|
7
|
+
#
|
8
|
+
# require 'dictable'
|
9
|
+
#
|
10
|
+
# a = Dict.new
|
11
|
+
#
|
12
|
+
# d[:one] = 1
|
13
|
+
# d[:two] = 2
|
14
|
+
#
|
15
|
+
# d[:one] -> 1
|
16
|
+
# d[:ten] -> nil
|
17
|
+
#
|
18
|
+
# d.keys -> [:one, :two]
|
19
|
+
# d.values -> [1, 2]
|
20
|
+
# d.to_hash -> {:two=>2, :one=>1}
|
21
|
+
#
|
22
|
+
#
|
23
|
+
module Dictable
|
24
|
+
def [](key)
|
25
|
+
each { |(k, v)| return v if k == key }
|
26
|
+
return nil
|
27
|
+
end
|
28
|
+
def []=(key, value)
|
29
|
+
update key, value
|
30
|
+
end
|
31
|
+
def keys
|
32
|
+
inject([]) { |keys, (k, v)| keys << k }
|
33
|
+
end
|
34
|
+
def values
|
35
|
+
inject([]) { |values, (k, v)| values << v }
|
36
|
+
end
|
37
|
+
def to_hash
|
38
|
+
inject({}) { |hash, (k, v)| hash.update({ k => v }) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Dict < Array
|
43
|
+
include Dictable
|
44
|
+
def update(key, value)
|
45
|
+
delete_if { |(k, v)| k == key }
|
46
|
+
push [ key, value ]
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Tyler Rick
|
3
|
+
# Copyright:: Copyright (c) 2008, Tyler Rick
|
4
|
+
# License:: Ruby license
|
5
|
+
# Submit to Facets?::
|
6
|
+
# Developer notes::
|
7
|
+
# Changes::
|
8
|
+
#++
|
9
|
+
|
10
|
+
# A histogram in this sense is an array of [value, frequency] pairs
|
11
|
+
class Histogram < Array
|
12
|
+
|
13
|
+
# Histogram.new([[1,1], [2,2], [3,5]).flatten
|
14
|
+
# => [1, 2,2, 3,3,3,3,3]
|
15
|
+
def flatten
|
16
|
+
array = []
|
17
|
+
each do |value, frequency|
|
18
|
+
array.concat [value]*frequency
|
19
|
+
end
|
20
|
+
array
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# _____ _
|
26
|
+
# |_ _|__ ___| |_
|
27
|
+
# | |/ _ \/ __| __|
|
28
|
+
# | | __/\__ \ |_
|
29
|
+
# |_|\___||___/\__|
|
30
|
+
#
|
31
|
+
=begin test
|
32
|
+
require 'test/unit'
|
33
|
+
|
34
|
+
class TheTest < Test::Unit::TestCase
|
35
|
+
def test_initialize
|
36
|
+
assert_equal [[1,1], [2,2], [3,5]],
|
37
|
+
Histogram.new([[1,1], [2,2], [3,5]])
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_flatten
|
41
|
+
assert_equal [1, 2,2, 3,3,3,3,3],
|
42
|
+
Histogram.new([[1,1], [2,2], [3,5]]).flatten
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
=end
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# http://tfletcher.com/lib/inspect_with.rb
|
2
|
+
module InspectWith
|
3
|
+
class Config
|
4
|
+
def with(*vars)
|
5
|
+
@variables_to_include = convert(vars)
|
6
|
+
end
|
7
|
+
|
8
|
+
def without(*vars)
|
9
|
+
@variables_to_ignore = convert(vars)
|
10
|
+
end
|
11
|
+
|
12
|
+
def unspecified?
|
13
|
+
variables_to_include.empty? && variables_to_ignore.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
def variables_to_include
|
17
|
+
@variables_to_include ||= []
|
18
|
+
end
|
19
|
+
|
20
|
+
def variables_to_ignore
|
21
|
+
@variables_to_ignore ||= []
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def convert(names)
|
27
|
+
names.map { |name| name.is_a?(Symbol) ? "@#{name}" : name }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Inspector
|
32
|
+
def initialize(config, object, default_inspect_string)
|
33
|
+
@config, @object, @default_inspect_string = config, object, default_inspect_string
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect
|
37
|
+
return @default_inspect_string if @config.unspecified?
|
38
|
+
|
39
|
+
return '%s %s>' % [ @default_inspect_string.split.first, vars.join(' ') ]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def vars
|
45
|
+
variable_names.map(&to_key_value { |name| [ name, @object.instance_variable_get(name) ] })
|
46
|
+
end
|
47
|
+
|
48
|
+
def variable_names
|
49
|
+
if @config.variables_to_include.empty?
|
50
|
+
@object.instance_variables - @config.variables_to_ignore
|
51
|
+
else
|
52
|
+
@config.variables_to_include
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_key_value(&block)
|
57
|
+
proc { |name| '%s=%p' % block.call(name) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
module ClassMethods
|
62
|
+
def inspect_with_config
|
63
|
+
@inspect_with_config ||= Config.new
|
64
|
+
end
|
65
|
+
|
66
|
+
def inspect_with(*vars)
|
67
|
+
inspect_with_config.with(*vars)
|
68
|
+
end
|
69
|
+
|
70
|
+
def inspect_without(*vars)
|
71
|
+
inspect_with_config.without(*vars)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def inspect
|
76
|
+
Inspector.new(self.class.inspect_with_config, self, super).inspect
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.included(klass)
|
80
|
+
klass.extend ClassMethods
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if __FILE__ == $0 then
|
85
|
+
require 'test/unit'
|
86
|
+
|
87
|
+
class HtmlElement
|
88
|
+
include InspectWith
|
89
|
+
|
90
|
+
inspect_with :name
|
91
|
+
|
92
|
+
def initialize(name, *children)
|
93
|
+
@name, @children = name, children
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class InspectWithTestCase < Test::Unit::TestCase
|
98
|
+
def setup
|
99
|
+
@div = HtmlElement.new(:div,
|
100
|
+
HtmlElement.new(:ul,
|
101
|
+
HtmlElement.new(:li, 'Hello'),
|
102
|
+
HtmlElement.new(:li, 'World')))
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_sanity
|
106
|
+
string = @div.inspect
|
107
|
+
|
108
|
+
assert_match /\#<HtmlElement:/, string
|
109
|
+
assert_match /@name=:div/, string
|
110
|
+
assert_no_match /@children/, string
|
111
|
+
assert_equal @div.object_id * 2, string[/(0x.+?) /, 1].hex
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# http://tfletcher.com/lib/named_captures.rb
|
2
|
+
require 'strscan'
|
3
|
+
|
4
|
+
class Module
|
5
|
+
# c.f. ActiveSupport
|
6
|
+
def alias_method_chain(target, feature)
|
7
|
+
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
8
|
+
yield(aliased_target, punctuation) if block_given?
|
9
|
+
alias_method "#{aliased_target}_without_#{feature}#{punctuation}", target
|
10
|
+
alias_method target, "#{aliased_target}_with_#{feature}#{punctuation}"
|
11
|
+
end unless method_defined?(:alias_method_chain)
|
12
|
+
end
|
13
|
+
|
14
|
+
class MatchData
|
15
|
+
attr_accessor :capture_names
|
16
|
+
|
17
|
+
def method_missing(capture_name, *args, &block)
|
18
|
+
if index = capture_names.index(capture_name)
|
19
|
+
return self[index + 1]
|
20
|
+
else
|
21
|
+
super capture_name, *args, &block
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Regexp
|
27
|
+
def match_with_named_captures(pattern)
|
28
|
+
matchdata = match_without_named_captures(pattern)
|
29
|
+
matchdata.capture_names = capture_names if matchdata.respond_to?(:capture_names=)
|
30
|
+
matchdata
|
31
|
+
end
|
32
|
+
|
33
|
+
alias_method_chain :match, :named_captures
|
34
|
+
|
35
|
+
def capture_names
|
36
|
+
@capture_names ||= extract_capture_names_from(source)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def extract_capture_names_from(pattern)
|
42
|
+
names, scanner, last_close = [], StringScanner.new(pattern), nil
|
43
|
+
|
44
|
+
while scanner.skip_until(/\(/)
|
45
|
+
next if scanner.pre_match =~ /\\$/
|
46
|
+
|
47
|
+
if scanner.scan(/\?\#(.+?)(?=\))/)
|
48
|
+
if scanner[1] =~ /^:(\w+)$/
|
49
|
+
names[last_close] = $1.to_sym
|
50
|
+
end
|
51
|
+
else
|
52
|
+
names << :capture
|
53
|
+
end
|
54
|
+
|
55
|
+
while scanner.skip_until(/[()]/)
|
56
|
+
if scanner.matched =~ /\)$/
|
57
|
+
(names.size - 1).downto(0) do |i|
|
58
|
+
if names[i] == :capture
|
59
|
+
names[last_close = i] = nil
|
60
|
+
break
|
61
|
+
end
|
62
|
+
end
|
63
|
+
else
|
64
|
+
scanner.unscan
|
65
|
+
break
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
return names
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
if __FILE__ == $0 then
|
75
|
+
require 'test/unit'
|
76
|
+
|
77
|
+
class NamedCapturesTest < Test::Unit::TestCase
|
78
|
+
def test_escaped_brackets_are_ignored
|
79
|
+
assert /\(\)\(\)/.capture_names.empty?
|
80
|
+
end
|
81
|
+
def test_normal_comments_are_ignored
|
82
|
+
assert /(?#a comment)/.capture_names.empty?
|
83
|
+
end
|
84
|
+
def test_unnamed_captures_are_nil
|
85
|
+
assert_equal Array.new(4), /()()()()/.capture_names
|
86
|
+
assert_equal Array.new(4), /(((())))/.capture_names
|
87
|
+
end
|
88
|
+
def test_named_captures
|
89
|
+
assert_equal [nil, :foo, nil], /()()(?#:foo)()/.capture_names
|
90
|
+
assert_equal [nil, :bar, nil], /((())(?#:bar))/.capture_names
|
91
|
+
end
|
92
|
+
def test_typical_usage
|
93
|
+
date = /(\d+)(?#:day)\/(\d+)(?#:month)\/(\d+)(?#:year)/.match('03/12/2006')
|
94
|
+
assert_equal 3, date.day.to_i
|
95
|
+
assert_equal 12, date.month.to_i
|
96
|
+
assert_equal 2006, date.year.to_i
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# http://tfletcher.com/lib/rfc822.rb
|
2
|
+
#
|
3
|
+
# RFC822 Email Address Regex
|
4
|
+
# --------------------------
|
5
|
+
#
|
6
|
+
# Originally written by Cal Henderson
|
7
|
+
# c.f. http://iamcal.com/publish/articles/php/parsing_email/
|
8
|
+
#
|
9
|
+
# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb.
|
10
|
+
#
|
11
|
+
# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License
|
12
|
+
# http://creativecommons.org/licenses/by-sa/2.5/
|
13
|
+
#
|
14
|
+
module RFC822
|
15
|
+
EmailAddress = begin
|
16
|
+
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
|
17
|
+
dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
|
18
|
+
atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
|
19
|
+
'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
|
20
|
+
quoted_pair = '\\x5c[\\x00-\\x7f]'
|
21
|
+
domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d"
|
22
|
+
quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22"
|
23
|
+
domain_ref = atom
|
24
|
+
sub_domain = "(?:#{domain_ref}|#{domain_literal})"
|
25
|
+
word = "(?:#{atom}|#{quoted_string})"
|
26
|
+
domain = "#{sub_domain}(?:\\x2e#{sub_domain})*"
|
27
|
+
local_part = "#{word}(?:\\x2e#{word})*"
|
28
|
+
addr_spec = "#{local_part}\\x40#{domain}"
|
29
|
+
pattern = /\A#{addr_spec}\z/
|
30
|
+
end
|
31
|
+
end
|
@@ -28,11 +28,13 @@ module WithKnowledgeOfColor
|
|
28
28
|
#ljust(width + nonprinting_characters_used_for_color.length, padstr)
|
29
29
|
# That didn't work when you wanted the padstr to have color (as in ' '.on_blue)
|
30
30
|
|
31
|
-
|
31
|
+
padding_width = [(width - length_without_color), 0].max
|
32
|
+
self + padstr*padding_width
|
32
33
|
end
|
33
34
|
|
34
35
|
def rjust_with_color(width, padstr=' ')
|
35
|
-
|
36
|
+
padding_width = [(width - length_without_color), 0].max
|
37
|
+
padstr*padding_width + self
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -0,0 +1 @@
|
|
1
|
+
true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quality_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rick and others
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-21 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,116 +20,124 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
-
- Readme
|
23
|
+
- Readme.rdoc
|
24
24
|
files:
|
25
|
-
- lib/quality_extensions/
|
26
|
-
- lib/quality_extensions/
|
27
|
-
- lib/quality_extensions/
|
28
|
-
- lib/quality_extensions/
|
29
|
-
- lib/quality_extensions/
|
30
|
-
- lib/quality_extensions/module/dirname.rb
|
31
|
-
- lib/quality_extensions/module/initializer.rb
|
32
|
-
- lib/quality_extensions/module/alias_method_chain.rb
|
33
|
-
- lib/quality_extensions/module/create.rb
|
34
|
-
- lib/quality_extensions/module/remove_const.rb
|
35
|
-
- lib/quality_extensions/module/basename.rb
|
36
|
-
- lib/quality_extensions/module/join.rb
|
37
|
-
- lib/quality_extensions/module/by_name.rb
|
38
|
-
- lib/quality_extensions/module/class_methods.rb
|
39
|
-
- lib/quality_extensions/module/bool_attr_accessor.rb
|
40
|
-
- lib/quality_extensions/module/split.rb
|
41
|
-
- lib/quality_extensions/module/module_methods.rb
|
42
|
-
- lib/quality_extensions/module/malias_method_chain.rb
|
43
|
-
- lib/quality_extensions/module/includable_once.rb
|
44
|
-
- lib/quality_extensions/module/alias_method.rb
|
45
|
-
- lib/quality_extensions/module/create_setter.rb
|
46
|
-
- lib/quality_extensions/module/ancestry_of_instance_method.rb
|
47
|
-
- lib/quality_extensions/object/if_else.rb
|
48
|
-
- lib/quality_extensions/object/send_if_not_nil.rb
|
49
|
-
- lib/quality_extensions/object/ignore_access.rb
|
50
|
-
- lib/quality_extensions/object/default.rb
|
51
|
-
- lib/quality_extensions/object/ancestry_of_method.rb
|
52
|
-
- lib/quality_extensions/object/singleton_send.rb
|
53
|
-
- lib/quality_extensions/object/mcall.rb
|
54
|
-
- lib/quality_extensions/object/send_if.rb
|
55
|
-
- lib/quality_extensions/object/methods.rb
|
56
|
-
- lib/quality_extensions/console/command.facets.1.8.54.rb
|
57
|
-
- lib/quality_extensions/console/command.facets.1.8.51.rb
|
58
|
-
- lib/quality_extensions/console/command.rb
|
59
|
-
- lib/quality_extensions/global_variable_set.rb
|
60
|
-
- lib/quality_extensions/dir/each_child.rb
|
61
|
-
- lib/quality_extensions/symbol/match.rb
|
62
|
-
- lib/quality_extensions/symbol/constantize.rb
|
63
|
-
- lib/quality_extensions/array/all.rb
|
64
|
-
- lib/quality_extensions/array/to_query_string.rb
|
65
|
-
- lib/quality_extensions/array/expand_ranges.rb
|
66
|
-
- lib/quality_extensions/array/group_by.rb
|
67
|
-
- lib/quality_extensions/array/shell_escape.rb
|
68
|
-
- lib/quality_extensions/array/sequence.rb
|
69
|
-
- lib/quality_extensions/array/average.rb
|
70
|
-
- lib/quality_extensions/array/to_a_recursive.rb
|
71
|
-
- lib/quality_extensions/array/classify.rb
|
72
|
-
- lib/quality_extensions/safe_nil.rb
|
73
|
-
- lib/quality_extensions/all.rb
|
74
|
-
- lib/quality_extensions/find/select.rb
|
75
|
-
- lib/quality_extensions/regexp/join.rb
|
76
|
-
- lib/quality_extensions/colored/toggleability.rb
|
77
|
-
- lib/quality_extensions/test/assert_user_error.rb
|
78
|
-
- lib/quality_extensions/test/all.rb
|
79
|
-
- lib/quality_extensions/test/assert_includes.rb
|
80
|
-
- lib/quality_extensions/test/assert_anything.rb
|
81
|
-
- lib/quality_extensions/test/difference_highlighting.rb
|
82
|
-
- lib/quality_extensions/test/assert_exception.rb
|
83
|
-
- lib/quality_extensions/test/assert_changed.rb
|
84
|
-
- lib/quality_extensions/enumerable/enum.rb
|
85
|
-
- lib/quality_extensions/enumerable/select_until.rb
|
86
|
-
- lib/quality_extensions/enumerable/map_with_index.rb
|
87
|
-
- lib/quality_extensions/enumerable/select_while.rb
|
88
|
-
- lib/quality_extensions/exception/inspect_with_backtrace.rb
|
89
|
-
- lib/quality_extensions/chainable_safe_nil.rb
|
90
|
-
- lib/quality_extensions/file_test/binary_file.rb
|
25
|
+
- lib/quality_extensions/collection_extensions_for_cgi.rb
|
26
|
+
- lib/quality_extensions/date/all.rb
|
27
|
+
- lib/quality_extensions/date/iso8601.rb
|
28
|
+
- lib/quality_extensions/date/month_ranges.rb
|
29
|
+
- lib/quality_extensions/date/deprecated.rb
|
91
30
|
- lib/quality_extensions/month.rb
|
92
|
-
- lib/quality_extensions/
|
93
|
-
- lib/quality_extensions/time/all.rb
|
94
|
-
- lib/quality_extensions/time/deprecated.rb
|
95
|
-
- lib/quality_extensions/kernel/trap_chain.rb
|
31
|
+
- lib/quality_extensions/kernel/example_printer.rb
|
96
32
|
- lib/quality_extensions/kernel/require_once.rb
|
97
33
|
- lib/quality_extensions/kernel/all.rb
|
98
|
-
- lib/quality_extensions/kernel/example_printer.rb
|
99
|
-
- lib/quality_extensions/kernel/filter_output.rb
|
100
|
-
- lib/quality_extensions/kernel/remove_const.rb
|
101
34
|
- lib/quality_extensions/kernel/require_all.rb
|
35
|
+
- lib/quality_extensions/kernel/trap_chain.rb
|
36
|
+
- lib/quality_extensions/kernel/die.rb
|
37
|
+
- lib/quality_extensions/kernel/capture_output.rb
|
38
|
+
- lib/quality_extensions/kernel/remove_const.rb
|
39
|
+
- lib/quality_extensions/kernel/backtrace.rb
|
102
40
|
- lib/quality_extensions/kernel/remove_module.rb
|
103
|
-
- lib/quality_extensions/kernel/
|
41
|
+
- lib/quality_extensions/kernel/filter_output.rb
|
104
42
|
- lib/quality_extensions/kernel/windows_platform.rb
|
105
|
-
- lib/quality_extensions/kernel/backtrace.rb
|
106
43
|
- lib/quality_extensions/kernel/simulate_input.rb
|
107
|
-
- lib/quality_extensions/kernel/
|
108
|
-
- lib/quality_extensions/
|
109
|
-
- lib/quality_extensions/
|
44
|
+
- lib/quality_extensions/kernel/require_local_all.rb
|
45
|
+
- lib/quality_extensions/exception/inspect_with_backtrace.rb
|
46
|
+
- lib/quality_extensions/dir/each_child.rb
|
47
|
+
- lib/quality_extensions/mutex/if_available.rb
|
48
|
+
- lib/quality_extensions/global_variable_set.rb
|
49
|
+
- lib/quality_extensions/hash/to_date.rb
|
110
50
|
- lib/quality_extensions/hash/all.rb
|
51
|
+
- lib/quality_extensions/hash/delete_unless.rb
|
111
52
|
- lib/quality_extensions/hash/to_query_string.rb
|
112
|
-
- lib/quality_extensions/hash/hash_select.rb
|
113
|
-
- lib/quality_extensions/hash/to_date.rb
|
114
53
|
- lib/quality_extensions/hash/assert_has_only_keys.rb
|
115
|
-
- lib/quality_extensions/
|
116
|
-
- lib/quality_extensions/
|
54
|
+
- lib/quality_extensions/hash/hash_select.rb
|
55
|
+
- lib/quality_extensions/symbol/match.rb
|
56
|
+
- lib/quality_extensions/symbol/constantize.rb
|
57
|
+
- lib/quality_extensions/console/command.facets.1.8.54.rb
|
58
|
+
- lib/quality_extensions/console/command.facets.1.8.51.rb
|
59
|
+
- lib/quality_extensions/console/command.rb
|
117
60
|
- lib/quality_extensions/string/to_underscored_label.rb
|
118
|
-
- lib/quality_extensions/string/
|
119
|
-
- lib/quality_extensions/string/digits_only.rb
|
61
|
+
- lib/quality_extensions/string/md5.rb
|
120
62
|
- lib/quality_extensions/string/all.rb
|
63
|
+
- lib/quality_extensions/string/constantize.rb
|
64
|
+
- lib/quality_extensions/string/with_knowledge_of_color.rb
|
121
65
|
- lib/quality_extensions/string/shell_escape.rb
|
122
66
|
- lib/quality_extensions/string/each_char_with_index.rb
|
123
|
-
- lib/quality_extensions/string/
|
124
|
-
- lib/quality_extensions/
|
125
|
-
- lib/quality_extensions/
|
126
|
-
- lib/quality_extensions/
|
127
|
-
- lib/quality_extensions/
|
128
|
-
- lib/quality_extensions/
|
129
|
-
- lib/quality_extensions/
|
67
|
+
- lib/quality_extensions/string/digits_only.rb
|
68
|
+
- lib/quality_extensions/file_test/binary_file.rb
|
69
|
+
- lib/quality_extensions/color/gradiate.rb
|
70
|
+
- lib/quality_extensions/color/rgb.rb
|
71
|
+
- lib/quality_extensions/enumerable/map_with_index.rb
|
72
|
+
- lib/quality_extensions/enumerable/select_until.rb
|
73
|
+
- lib/quality_extensions/enumerable/select_while.rb
|
74
|
+
- lib/quality_extensions/enumerable/enum.rb
|
75
|
+
- lib/quality_extensions/regexp/rfc822.rb
|
76
|
+
- lib/quality_extensions/regexp/named_captures.rb
|
77
|
+
- lib/quality_extensions/regexp/join.rb
|
78
|
+
- lib/quality_extensions/all.rb
|
79
|
+
- lib/quality_extensions/safe_nil.rb
|
80
|
+
- lib/quality_extensions/time/all.rb
|
81
|
+
- lib/quality_extensions/time/deprecated.rb
|
82
|
+
- lib/quality_extensions/test/assert_changed.rb
|
83
|
+
- lib/quality_extensions/test/assert_exception.rb
|
84
|
+
- lib/quality_extensions/test/assert_user_error.rb
|
85
|
+
- lib/quality_extensions/test/all.rb
|
86
|
+
- lib/quality_extensions/test/assert_includes.rb
|
87
|
+
- lib/quality_extensions/test/assert_anything.rb
|
88
|
+
- lib/quality_extensions/test/difference_highlighting.rb
|
89
|
+
- lib/quality_extensions/chainable_safe_nil.rb
|
90
|
+
- lib/quality_extensions/histogram.rb
|
130
91
|
- lib/quality_extensions/file/exact_match_regexp.rb
|
92
|
+
- lib/quality_extensions/object/send_if_not_nil.rb
|
93
|
+
- lib/quality_extensions/object/ancestry_of_method.rb
|
94
|
+
- lib/quality_extensions/object/methods.rb
|
95
|
+
- lib/quality_extensions/object/default.rb
|
96
|
+
- lib/quality_extensions/object/singleton_send.rb
|
97
|
+
- lib/quality_extensions/object/ignore_access.rb
|
98
|
+
- lib/quality_extensions/object/if_else.rb
|
99
|
+
- lib/quality_extensions/object/mcall.rb
|
100
|
+
- lib/quality_extensions/object/send_if.rb
|
101
|
+
- lib/quality_extensions/find/select.rb
|
102
|
+
- lib/quality_extensions/dictable.rb
|
103
|
+
- lib/quality_extensions/inspect_with.rb
|
104
|
+
- lib/quality_extensions/array/classify.rb
|
105
|
+
- lib/quality_extensions/array/average.rb
|
106
|
+
- lib/quality_extensions/array/group_by.rb
|
107
|
+
- lib/quality_extensions/array/all.rb
|
108
|
+
- lib/quality_extensions/array/to_a_recursive.rb
|
109
|
+
- lib/quality_extensions/array/shell_escape.rb
|
110
|
+
- lib/quality_extensions/array/to_query_string.rb
|
111
|
+
- lib/quality_extensions/array/expand_ranges.rb
|
112
|
+
- lib/quality_extensions/array/sequence.rb
|
113
|
+
- lib/quality_extensions/module/alias_method.rb
|
114
|
+
- lib/quality_extensions/module/includable_once.rb
|
115
|
+
- lib/quality_extensions/module/bool_attr_accessor.rb
|
116
|
+
- lib/quality_extensions/module/initializer.rb
|
117
|
+
- lib/quality_extensions/module/create.rb
|
118
|
+
- lib/quality_extensions/module/parents.rb
|
119
|
+
- lib/quality_extensions/module/module_methods.rb
|
120
|
+
- lib/quality_extensions/module/class_methods.rb
|
121
|
+
- lib/quality_extensions/module/malias_method_chain.rb
|
122
|
+
- lib/quality_extensions/module/basename.rb
|
123
|
+
- lib/quality_extensions/module/guard_method.rb
|
124
|
+
- lib/quality_extensions/module/dirname.rb
|
125
|
+
- lib/quality_extensions/module/by_name.rb
|
126
|
+
- lib/quality_extensions/module/join.rb
|
127
|
+
- lib/quality_extensions/module/split.rb
|
128
|
+
- lib/quality_extensions/module/alias_method_chain.rb
|
129
|
+
- lib/quality_extensions/module/attribute_accessors.rb
|
130
|
+
- lib/quality_extensions/module/ancestry_of_instance_method.rb
|
131
|
+
- lib/quality_extensions/module/remove_const.rb
|
132
|
+
- lib/quality_extensions/module/namespace.rb
|
133
|
+
- lib/quality_extensions/module/create_setter.rb
|
134
|
+
- lib/quality_extensions/nil_method_missing.rb
|
135
|
+
- lib/quality_extensions/colored/toggleability.rb
|
136
|
+
- lib/quality_extensions/float/truncate.rb
|
137
|
+
- lib/quality_extensions/template.rb
|
138
|
+
- lib/quality_extensions.rb
|
131
139
|
- test/all.rb
|
132
|
-
- Readme
|
140
|
+
- Readme.rdoc
|
133
141
|
has_rdoc: true
|
134
142
|
homepage: http://quality-ext.rubyforge.org/
|
135
143
|
post_install_message:
|
@@ -156,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
164
|
requirements: []
|
157
165
|
|
158
166
|
rubyforge_project: quality_extensions
|
159
|
-
rubygems_version: 1.
|
167
|
+
rubygems_version: 1.3.1
|
160
168
|
signing_key:
|
161
169
|
specification_version: 2
|
162
170
|
summary: A collection of reusable Ruby methods which are not (yet) in Facets.
|