backports 1.7.1 → 1.8.0
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/CHANGELOG.rdoc +7 -0
- data/README.rdoc +31 -36
- data/Rakefile +4 -27
- data/VERSION.yml +2 -2
- data/backports.gemspec +52 -32
- data/lib/backports.rb +4 -15
- data/lib/backports/1.8.7.rb +4 -0
- data/lib/backports/{argf.rb → 1.8.7/argf.rb} +8 -8
- data/lib/backports/{array.rb → 1.8.7/array.rb} +26 -43
- data/lib/backports/{binding.rb → 1.8.7/binding.rb} +0 -0
- data/lib/backports/1.8.7/dir.rb +7 -0
- data/lib/backports/{enumerable.rb → 1.8.7/enumerable.rb} +22 -38
- data/lib/backports/1.8.7/enumerator.rb +19 -0
- data/lib/backports/1.8.7/env.rb +3 -0
- data/lib/backports/1.8.7/fixnum.rb +11 -0
- data/lib/backports/1.8.7/float.rb +4 -0
- data/lib/backports/{gc.rb → 1.8.7/gc.rb} +0 -0
- data/lib/backports/1.8.7/hash.rb +23 -0
- data/lib/backports/1.8.7/integer.rb +23 -0
- data/lib/backports/{io.rb → 1.8.7/io.rb} +8 -7
- data/lib/backports/1.8.7/kernel.rb +39 -0
- data/lib/backports/{method.rb → 1.8.7/method.rb} +8 -8
- data/lib/backports/1.8.7/module.rb +7 -0
- data/lib/backports/1.8.7/numeric.rb +3 -0
- data/lib/backports/1.8.7/object_space.rb +5 -0
- data/lib/backports/{proc.rb → 1.8.7/proc.rb} +0 -0
- data/lib/backports/{process.rb → 1.8.7/process.rb} +0 -0
- data/lib/backports/1.8.7/range.rb +4 -0
- data/lib/backports/{regexp.rb → 1.8.7/regexp.rb} +2 -1
- data/lib/backports/1.8.7/string.rb +90 -0
- data/lib/backports/1.8.7/struct.rb +3 -0
- data/lib/backports/1.8.7/symbol.rb +6 -0
- data/lib/backports/1.9.rb +5 -0
- data/lib/backports/1.9/array.rb +12 -0
- data/lib/backports/1.9/enumerable.rb +8 -0
- data/lib/backports/1.9/enumerator.rb +15 -0
- data/lib/backports/1.9/hash.rb +15 -0
- data/lib/backports/1.9/integer.rb +3 -0
- data/lib/backports/1.9/kernel.rb +11 -0
- data/lib/backports/1.9/string.rb +39 -0
- data/lib/backports/{symbol.rb → 1.9/symbol.rb} +1 -6
- data/lib/backports/rails.rb +4 -0
- data/lib/backports/rails/array.rb +6 -0
- data/lib/backports/rails/enumerable.rb +12 -0
- data/lib/backports/rails/hash.rb +31 -0
- data/lib/backports/rails/kernel.rb +12 -0
- data/lib/backports/rails/module.rb +6 -0
- data/lib/backports/rails/string.rb +42 -0
- data/lib/backports/tools.rb +117 -0
- data/test/enumerator_test.rb +3 -3
- data/test/test_helper.rb +1 -3
- metadata +50 -31
- data/lib/backports/core_ext.rb +0 -61
- data/lib/backports/dir.rb +0 -7
- data/lib/backports/enumerator.rb +0 -43
- data/lib/backports/env.rb +0 -3
- data/lib/backports/fixnum.rb +0 -11
- data/lib/backports/float.rb +0 -4
- data/lib/backports/hash.rb +0 -64
- data/lib/backports/integer.rb +0 -25
- data/lib/backports/kernel.rb +0 -55
- data/lib/backports/module.rb +0 -30
- data/lib/backports/numeric.rb +0 -3
- data/lib/backports/object_space.rb +0 -5
- data/lib/backports/range.rb +0 -4
- data/lib/backports/string.rb +0 -167
- data/lib/backports/struct.rb +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class Array
|
|
2
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Array.html]
|
|
3
|
+
class << self
|
|
4
|
+
# Try to convert obj into an array, using to_ary method.
|
|
5
|
+
# Returns converted array or nil if obj cannot be converted
|
|
6
|
+
# for any reason. This method is to check if an argument is an array.
|
|
7
|
+
def try_convert(obj)
|
|
8
|
+
return nil unless obj.respond_to?(:to_ary)
|
|
9
|
+
Backports.coerce_to(obj, Array, :to_ary)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module Enumerable
|
|
2
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
|
|
3
|
+
def each_with_object(memo, &block)
|
|
4
|
+
return to_enum(:each_with_object, memo) unless block_given?
|
|
5
|
+
each {|obj| block.call(obj, memo)}
|
|
6
|
+
memo
|
|
7
|
+
end unless method_defined? :each_with_object
|
|
8
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Must be defined outside of Kernel for jruby, see http://jira.codehaus.org/browse/JRUBY-3609
|
|
2
|
+
Enumerator = Enumerable::Enumerator unless Kernel.const_defined? :Enumerator # Standard in ruby 1.9
|
|
3
|
+
|
|
4
|
+
class Enumerator
|
|
5
|
+
# new with block, standard in Ruby 1.9
|
|
6
|
+
unless (self.new{} rescue false)
|
|
7
|
+
def initialize_with_optional_block(*arg, &block)
|
|
8
|
+
return initialize_without_optional_block(*arg, &nil) unless arg.empty? # Ruby 1.9 apparently ignores the block if any argument is present
|
|
9
|
+
initialize_without_optional_block(Backports::Yielder.new(&block))
|
|
10
|
+
end
|
|
11
|
+
Backports.alias_method_chain self, :initialize, :optional_block
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
alias_method :with_object, :each_with_object unless method_defined? :with_object
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
# New Ruby 1.8.7+ constructor -- not documented, see redmine # 1385
|
|
3
|
+
# <tt>Hash[[[:foo, :bar],[:hello, "world"]]] ==> {:foo => :bar, :hello => "world"}</tt>
|
|
4
|
+
class << self
|
|
5
|
+
def try_convert(x)
|
|
6
|
+
return nil unless x.respond_to? :to_hash
|
|
7
|
+
x.to_hash
|
|
8
|
+
end unless method_defined? :to_hash
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html]
|
|
12
|
+
def default_proc=(proc)
|
|
13
|
+
replace(Hash.new(&Backports.coerce_to(proc, Proc, :to_proc)).merge!(self))
|
|
14
|
+
end unless method_defined? :default_proc=
|
|
15
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
alias_method :__callee__, :__method__ unless (__callee__ || true rescue false)
|
|
3
|
+
|
|
4
|
+
def require_relative(relative_feature)
|
|
5
|
+
file = caller.first.split(/:\d/,2).first
|
|
6
|
+
if /\A\((.*)\)/ =~ file # eval, etc.
|
|
7
|
+
raise LoadError, "require_relative is called in #{$1}"
|
|
8
|
+
end
|
|
9
|
+
require File.expand_path(relative_feature, File.dirname(file))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
class String
|
|
2
|
+
class << self
|
|
3
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
|
4
|
+
def try_convert(x)
|
|
5
|
+
return nil unless x.respond_do(:to_str)
|
|
6
|
+
x.to_str
|
|
7
|
+
end unless method_defined? :try_convert
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
|
11
|
+
def ascii_only?
|
|
12
|
+
!(self =~ /[^\x00-\x7f]/)
|
|
13
|
+
end unless method_defined? :ascii_only?
|
|
14
|
+
|
|
15
|
+
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
|
16
|
+
def clear
|
|
17
|
+
self[0,length] = ""
|
|
18
|
+
self
|
|
19
|
+
end unless method_defined? :clear
|
|
20
|
+
|
|
21
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
|
22
|
+
def codepoints
|
|
23
|
+
return to_enum(:codepoints) unless block_given?
|
|
24
|
+
each_char.each do |s|
|
|
25
|
+
utf8 = s.each_byte.to_a
|
|
26
|
+
utf8[0] &= 0xff >> utf8.size # clear high bits (1 to 4, depending of number of bytes used)
|
|
27
|
+
yield utf8.inject{|result, b| (result << 6) + (b & 0x3f) }
|
|
28
|
+
end
|
|
29
|
+
end unless method_defined? :codepoints
|
|
30
|
+
|
|
31
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
|
32
|
+
alias_method :each_codepoint, :codepoints unless method_defined? :each_codepoint
|
|
33
|
+
|
|
34
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
|
35
|
+
def getbyte(i)
|
|
36
|
+
self[i]
|
|
37
|
+
end unless method_defined? :getbyte
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
class Symbol
|
|
2
|
-
# Standard in ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Symbol.html]
|
|
3
|
-
def to_proc
|
|
4
|
-
Proc.new { |*args| args.shift.__send__(self, *args) }
|
|
5
|
-
end unless :to_proc.respond_to?(:to_proc)
|
|
6
|
-
|
|
7
2
|
# Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Symbol.html]
|
|
8
3
|
[ [%w(capitalize downcase next succ swapcase upcase), {:after => ".to_sym"}],
|
|
9
4
|
[%w(=~ [] empty? length match size), {}]
|
|
@@ -34,4 +29,4 @@ class Symbol
|
|
|
34
29
|
alias_method :==, :dont_override_equal_please
|
|
35
30
|
end
|
|
36
31
|
|
|
37
|
-
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Enumerable
|
|
2
|
+
# Standard in rails... See official documentation[http://api.rubyonrails.org/classes/Enumerable.html]
|
|
3
|
+
# Modified from rails 2.3 to not rely on size
|
|
4
|
+
def sum(identity = 0, &block)
|
|
5
|
+
if block_given?
|
|
6
|
+
map(&block).sum(identity)
|
|
7
|
+
else
|
|
8
|
+
inject { |sum, element| sum + element } || identity
|
|
9
|
+
end
|
|
10
|
+
end unless method_defined? :sum
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
|
|
3
|
+
def reverse_merge(other_hash)
|
|
4
|
+
other_hash.merge(self)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
|
|
8
|
+
def reverse_merge!(other_hash)
|
|
9
|
+
replace(reverse_merge(other_hash))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
|
|
13
|
+
def symbolize_keys
|
|
14
|
+
Hash[map{|key,value| [(key.to_sym rescue key) || key, value] }]
|
|
15
|
+
end unless method_defined? :symbolize_keys
|
|
16
|
+
|
|
17
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
|
|
18
|
+
def symbolize_keys!
|
|
19
|
+
self.replace(self.symbolize_keys)
|
|
20
|
+
end unless method_defined? :symbolize_keys!
|
|
21
|
+
|
|
22
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
|
|
23
|
+
def stringify_keys
|
|
24
|
+
Hash[map{|key,value| [key.to_s, value] }]
|
|
25
|
+
end unless method_defined? :stringify_keys
|
|
26
|
+
|
|
27
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
|
|
28
|
+
def stringify_keys!
|
|
29
|
+
self.replace(self.stringify_keys)
|
|
30
|
+
end unless method_defined? :stringify_keys!
|
|
31
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/Object.html]
|
|
3
|
+
def try(method_id, *args, &block)
|
|
4
|
+
send(method_id, *args, &block) unless self.nil?
|
|
5
|
+
end unless method_defined? :try
|
|
6
|
+
|
|
7
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/Object.html]
|
|
8
|
+
def returning(obj)
|
|
9
|
+
yield obj
|
|
10
|
+
obj
|
|
11
|
+
end unless method_defined? :returning
|
|
12
|
+
end
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
class Module
|
|
2
|
+
# Standard in rails... See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Module.html]
|
|
3
|
+
def alias_method_chain(target, feature)
|
|
4
|
+
Backports.alias_method_chain(self, target, feature)
|
|
5
|
+
end unless method_defined? :alias_method_chain
|
|
6
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class String
|
|
2
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
|
3
|
+
def camelize(first_letter = :upper)
|
|
4
|
+
if first_letter == :upper
|
|
5
|
+
gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
|
6
|
+
else
|
|
7
|
+
first.downcase + camelize[1..-1]
|
|
8
|
+
end
|
|
9
|
+
end unless method_defined? :camelize
|
|
10
|
+
|
|
11
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
|
12
|
+
def constantize
|
|
13
|
+
names = split('::')
|
|
14
|
+
names.shift if names.empty? || names.first.empty?
|
|
15
|
+
|
|
16
|
+
constant = Object
|
|
17
|
+
names.each do |name|
|
|
18
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
|
19
|
+
end
|
|
20
|
+
constant
|
|
21
|
+
end unless method_defined? :constantize
|
|
22
|
+
|
|
23
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
|
24
|
+
def dasherize
|
|
25
|
+
gsub(/_/, '-')
|
|
26
|
+
end unless method_defined? :dasherize
|
|
27
|
+
|
|
28
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
|
29
|
+
def demodulize
|
|
30
|
+
gsub(/^.*::/, '')
|
|
31
|
+
end unless method_defined? :demodulize
|
|
32
|
+
|
|
33
|
+
# Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
|
34
|
+
def underscore
|
|
35
|
+
gsub(/::/, '/').
|
|
36
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
37
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
38
|
+
tr("-", "_").
|
|
39
|
+
downcase
|
|
40
|
+
end unless method_defined? :underscore
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Methods used internally by the backports.
|
|
2
|
+
|
|
3
|
+
module Backports
|
|
4
|
+
# Adapted from Pragmatic's "Programming Ruby" (since their version was buggy...)
|
|
5
|
+
def self.require_relative(relative_feature)
|
|
6
|
+
file = caller.first.split(/:\d/,2).first
|
|
7
|
+
if /\A\((.*)\)/ =~ file # eval, etc.
|
|
8
|
+
raise LoadError, "require_relative is called in #{$1}"
|
|
9
|
+
end
|
|
10
|
+
require File.expand_path(relative_feature, File.dirname(file))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Metaprogramming utility to make block optional.
|
|
14
|
+
# Tests first if block is already optional when given options
|
|
15
|
+
def self.make_block_optional mod,*methods
|
|
16
|
+
options = methods.last.is_a?(Hash) ? methods.pop : {}
|
|
17
|
+
methods.each do |selector|
|
|
18
|
+
unless mod.method_defined? selector
|
|
19
|
+
warn "#{mod}##{selector} is not defined, so block can't be made optional"
|
|
20
|
+
next
|
|
21
|
+
end
|
|
22
|
+
unless options.empty?
|
|
23
|
+
test_on = options[:test_on] || self.new
|
|
24
|
+
next if (test_on.send(selector, *options.fetch(:arg, [])) rescue false)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
arity = mod.instance_method(selector).arity
|
|
28
|
+
last_arg = []
|
|
29
|
+
if arity < 0
|
|
30
|
+
last_arg = ["*rest"]
|
|
31
|
+
arity = -1-arity
|
|
32
|
+
end
|
|
33
|
+
arg_sequence = ((0...arity).map{|i| "arg_#{i}"} + last_arg + ["&block"]).join(", ")
|
|
34
|
+
|
|
35
|
+
alias_method_chain(mod, selector, :optional_block) do |aliased_target, punctuation|
|
|
36
|
+
mod.module_eval <<-end_eval
|
|
37
|
+
def #{aliased_target}_with_optional_block#{punctuation}(#{arg_sequence})
|
|
38
|
+
return to_enum(:#{aliased_target}_without_optional_block#{punctuation}, #{arg_sequence}) unless block_given?
|
|
39
|
+
#{aliased_target}_without_optional_block#{punctuation}(#{arg_sequence})
|
|
40
|
+
end
|
|
41
|
+
end_eval
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Modified to avoid polluting Module if so desired
|
|
47
|
+
# (from Rails)
|
|
48
|
+
def self.alias_method_chain(mod, target, feature)
|
|
49
|
+
mod.class_eval do
|
|
50
|
+
# Strip out punctuation on predicates or bang methods since
|
|
51
|
+
# e.g. target?_without_feature is not a valid method name.
|
|
52
|
+
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
|
53
|
+
yield(aliased_target, punctuation) if block_given?
|
|
54
|
+
|
|
55
|
+
with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
|
|
56
|
+
|
|
57
|
+
alias_method without_method, target
|
|
58
|
+
alias_method target, with_method
|
|
59
|
+
|
|
60
|
+
case
|
|
61
|
+
when public_method_defined?(without_method)
|
|
62
|
+
public target
|
|
63
|
+
when protected_method_defined?(without_method)
|
|
64
|
+
protected target
|
|
65
|
+
when private_method_defined?(without_method)
|
|
66
|
+
private target
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Helper method to coerce a value into a specific class.
|
|
72
|
+
# Raises a TypeError if the coercion fails or the returned value
|
|
73
|
+
# is not of the right class.
|
|
74
|
+
# (from Rubinius)
|
|
75
|
+
def self.coerce_to(obj, cls, meth)
|
|
76
|
+
return obj if obj.kind_of?(cls)
|
|
77
|
+
|
|
78
|
+
begin
|
|
79
|
+
ret = obj.__send__(meth)
|
|
80
|
+
rescue Exception => e
|
|
81
|
+
raise TypeError, "Coercion error: #{obj.inspect}.#{meth} => #{cls} failed:\n" \
|
|
82
|
+
"(#{e.message})"
|
|
83
|
+
end
|
|
84
|
+
raise TypeError, "Coercion error: obj.#{meth} did NOT return a #{cls} (was #{ret.class})" unless ret.kind_of? cls
|
|
85
|
+
ret
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Checks for a failed comparison (in which case it throws an ArgumentError)
|
|
89
|
+
# Additionally, it maps any negative value to -1 and any positive value to +1
|
|
90
|
+
# (from Rubinius)
|
|
91
|
+
def self.coerce_to_comparison(a, b, cmp = (a <=> b))
|
|
92
|
+
raise ArgumentError, "comparison of #{a} with #{b} failed" if cmp.nil?
|
|
93
|
+
return 1 if cmp > 0
|
|
94
|
+
return -1 if cmp < 0
|
|
95
|
+
0
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Used internally to make it easy to deal with optional arguments
|
|
99
|
+
# (from Rubinius)
|
|
100
|
+
Undefined = Object.new
|
|
101
|
+
|
|
102
|
+
# A simple class which allows the construction of Enumerator from a block
|
|
103
|
+
class Yielder
|
|
104
|
+
def initialize(&block)
|
|
105
|
+
@main_block = block
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def each(&block)
|
|
109
|
+
@final_block = block
|
|
110
|
+
@main_block.call(self)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def yield(*arg)
|
|
114
|
+
@final_block.yield(*arg)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
data/test/enumerator_test.rb
CHANGED
|
@@ -16,12 +16,12 @@ class EnumeratorTest < Test::Unit::TestCase
|
|
|
16
16
|
context "#new" do
|
|
17
17
|
should "should accept block" do
|
|
18
18
|
enum = Enumerator.new do |yielder|
|
|
19
|
-
yielder.yield "This
|
|
20
|
-
yielder.yield
|
|
19
|
+
yielder.yield "This syntax is"
|
|
20
|
+
yielder.yield "cool!"
|
|
21
21
|
end
|
|
22
22
|
assert enum.is_a?(Enumerator)
|
|
23
23
|
2.times do
|
|
24
|
-
assert_equal ["This
|
|
24
|
+
assert_equal ["This syntax is", "cool!"], enum.to_a
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -2,9 +2,7 @@ require 'rubygems'
|
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
require 'shoulda'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
7
|
-
require 'backports'
|
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/backports")
|
|
8
6
|
|
|
9
7
|
# class Test::Unit::TestCase
|
|
10
8
|
# end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: backports
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- "Marc-Andr\xC3\xA9 Lafortune"
|
|
@@ -9,11 +9,11 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-08-
|
|
12
|
+
date: 2009-08-31 00:00:00 -04:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
16
|
-
description: Essential backports that enable some of the really nice features of ruby 1.8.7, ruby 1.9 and rails from ruby 1.8.6 and earlier
|
|
16
|
+
description: " Essential backports that enable some of the really nice features of ruby 1.8.7, ruby 1.9 and rails from ruby 1.8.6 and earlier.\n"
|
|
17
17
|
email: github@marc-andre.ca
|
|
18
18
|
executables: []
|
|
19
19
|
|
|
@@ -32,32 +32,49 @@ files:
|
|
|
32
32
|
- VERSION.yml
|
|
33
33
|
- backports.gemspec
|
|
34
34
|
- lib/backports.rb
|
|
35
|
-
- lib/backports/
|
|
36
|
-
- lib/backports/
|
|
37
|
-
- lib/backports/
|
|
38
|
-
- lib/backports/
|
|
39
|
-
- lib/backports/dir.rb
|
|
40
|
-
- lib/backports/enumerable.rb
|
|
41
|
-
- lib/backports/enumerator.rb
|
|
42
|
-
- lib/backports/env.rb
|
|
43
|
-
- lib/backports/fixnum.rb
|
|
44
|
-
- lib/backports/float.rb
|
|
45
|
-
- lib/backports/gc.rb
|
|
46
|
-
- lib/backports/hash.rb
|
|
47
|
-
- lib/backports/integer.rb
|
|
48
|
-
- lib/backports/io.rb
|
|
49
|
-
- lib/backports/kernel.rb
|
|
50
|
-
- lib/backports/method.rb
|
|
51
|
-
- lib/backports/module.rb
|
|
52
|
-
- lib/backports/numeric.rb
|
|
53
|
-
- lib/backports/object_space.rb
|
|
54
|
-
- lib/backports/proc.rb
|
|
55
|
-
- lib/backports/process.rb
|
|
56
|
-
- lib/backports/range.rb
|
|
57
|
-
- lib/backports/regexp.rb
|
|
58
|
-
- lib/backports/string.rb
|
|
59
|
-
- lib/backports/struct.rb
|
|
60
|
-
- lib/backports/symbol.rb
|
|
35
|
+
- lib/backports/1.8.7.rb
|
|
36
|
+
- lib/backports/1.8.7/argf.rb
|
|
37
|
+
- lib/backports/1.8.7/array.rb
|
|
38
|
+
- lib/backports/1.8.7/binding.rb
|
|
39
|
+
- lib/backports/1.8.7/dir.rb
|
|
40
|
+
- lib/backports/1.8.7/enumerable.rb
|
|
41
|
+
- lib/backports/1.8.7/enumerator.rb
|
|
42
|
+
- lib/backports/1.8.7/env.rb
|
|
43
|
+
- lib/backports/1.8.7/fixnum.rb
|
|
44
|
+
- lib/backports/1.8.7/float.rb
|
|
45
|
+
- lib/backports/1.8.7/gc.rb
|
|
46
|
+
- lib/backports/1.8.7/hash.rb
|
|
47
|
+
- lib/backports/1.8.7/integer.rb
|
|
48
|
+
- lib/backports/1.8.7/io.rb
|
|
49
|
+
- lib/backports/1.8.7/kernel.rb
|
|
50
|
+
- lib/backports/1.8.7/method.rb
|
|
51
|
+
- lib/backports/1.8.7/module.rb
|
|
52
|
+
- lib/backports/1.8.7/numeric.rb
|
|
53
|
+
- lib/backports/1.8.7/object_space.rb
|
|
54
|
+
- lib/backports/1.8.7/proc.rb
|
|
55
|
+
- lib/backports/1.8.7/process.rb
|
|
56
|
+
- lib/backports/1.8.7/range.rb
|
|
57
|
+
- lib/backports/1.8.7/regexp.rb
|
|
58
|
+
- lib/backports/1.8.7/string.rb
|
|
59
|
+
- lib/backports/1.8.7/struct.rb
|
|
60
|
+
- lib/backports/1.8.7/symbol.rb
|
|
61
|
+
- lib/backports/1.9.rb
|
|
62
|
+
- lib/backports/1.9/array.rb
|
|
63
|
+
- lib/backports/1.9/enumerable.rb
|
|
64
|
+
- lib/backports/1.9/enumerator.rb
|
|
65
|
+
- lib/backports/1.9/hash.rb
|
|
66
|
+
- lib/backports/1.9/integer.rb
|
|
67
|
+
- lib/backports/1.9/kernel.rb
|
|
68
|
+
- lib/backports/1.9/string.rb
|
|
69
|
+
- lib/backports/1.9/symbol.rb
|
|
70
|
+
- lib/backports/rails.rb
|
|
71
|
+
- lib/backports/rails/array.rb
|
|
72
|
+
- lib/backports/rails/enumerable.rb
|
|
73
|
+
- lib/backports/rails/hash.rb
|
|
74
|
+
- lib/backports/rails/kernel.rb
|
|
75
|
+
- lib/backports/rails/module.rb
|
|
76
|
+
- lib/backports/rails/string.rb
|
|
77
|
+
- lib/backports/tools.rb
|
|
61
78
|
- test/array_test.rb
|
|
62
79
|
- test/binding_test.rb
|
|
63
80
|
- test/enumerable_test.rb
|
|
@@ -73,6 +90,8 @@ files:
|
|
|
73
90
|
- test/test_helper.rb
|
|
74
91
|
has_rdoc: true
|
|
75
92
|
homepage: http://github.com/marcandre/backports
|
|
93
|
+
licenses: []
|
|
94
|
+
|
|
76
95
|
post_install_message:
|
|
77
96
|
rdoc_options:
|
|
78
97
|
- --charset=UTF-8
|
|
@@ -99,9 +118,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
99
118
|
requirements: []
|
|
100
119
|
|
|
101
120
|
rubyforge_project: backports
|
|
102
|
-
rubygems_version: 1.3.
|
|
121
|
+
rubygems_version: 1.3.5
|
|
103
122
|
signing_key:
|
|
104
|
-
specification_version:
|
|
123
|
+
specification_version: 3
|
|
105
124
|
summary: Backports or ruby 1.8.7+ & rails for older ruby.
|
|
106
125
|
test_files:
|
|
107
126
|
- test/array_test.rb
|