backports 1.12.1 → 1.12.2

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.
@@ -1,5 +1,5 @@
1
1
  ---
2
- :major: 1
3
2
  :minor: 12
3
+ :patch: 2
4
4
  :build:
5
- :patch: 1
5
+ :major: 1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{backports}
8
- s.version = "1.12.1"
8
+ s.version = "1.12.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marc-Andr\303\251 Lafortune"]
12
- s.date = %q{2009-12-17}
12
+ s.date = %q{2009-12-23}
13
13
  s.description = %q{ 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.
14
14
  }
15
15
  s.email = %q{github@marc-andre.ca}
@@ -1,19 +1,21 @@
1
1
  class Hash
2
2
  # New Ruby 1.8.7+ constructor -- not documented, see redmine # 1385
3
3
  # <tt>Hash[[[:foo, :bar],[:hello, "world"]]] ==> {:foo => :bar, :hello => "world"}</tt>
4
- class << self
5
- alias_method :original_constructor, :[]
6
- def [](*args)
7
- return original_constructor(*args) unless args.length == 1 && args.first.is_a?(Array)
8
- {}.tap do |h|
4
+ unless (Hash[[[:test, :test]]] rescue false)
5
+ class << self
6
+ alias_method :constructor_without_key_value_pair_form, :[]
7
+ def [](*args)
8
+ return constructor_without_key_value_pair_form(*args) unless args.length == 1 && args.first.is_a?(Array)
9
+ h = {}
9
10
  args.first.each do |arr|
10
11
  next unless arr.respond_to? :to_ary
11
12
  arr = arr.to_ary
12
13
  next unless (1..2).include? arr.size
13
14
  h[arr.at(0)] = arr.at(1)
14
15
  end
16
+ h
15
17
  end
16
- end unless (Hash[[[:test, :test]]] rescue false)
18
+ end
17
19
  end
18
20
 
19
21
  Backports.make_block_optional self, :delete_if, :each, :each_key, :each_pair, :each_value, :reject, :reject!, :select, :test_on => {:hello => "world!"}
@@ -27,9 +27,9 @@ unless Method.method_defined? :name
27
27
  module Kernel
28
28
  def method_with_additional_info(name)
29
29
  method_without_additional_info(name).tap do |bound|
30
- bound.name = name.to_sym
30
+ bound.name = name.to_s
31
31
  bound.receiver = self
32
- bound.owner = self.class.ancestors.find{|mod| mod.instance_methods(false).include? name.to_s}
32
+ bound.owner = self.class.ancestors.find{|mod| mod.instance_methods(false).include? bound.name}
33
33
  end
34
34
  end
35
35
  Backports.alias_method_chain self, :method, :additional_info
@@ -38,8 +38,8 @@ unless Method.method_defined? :name
38
38
  class Module
39
39
  def instance_method_with_additional_info(name)
40
40
  instance_method_without_additional_info(name).tap do |unbound|
41
- unbound.name = name.to_sym
42
- unbound.owner = ancestors.find{|mod| mod.instance_methods(false).include? name.to_s}
41
+ unbound.name = name.to_s
42
+ unbound.owner = ancestors.find{|mod| mod.instance_methods(false).include? unbound.name}
43
43
  end
44
44
  end
45
45
  Backports.alias_method_chain self, :instance_method, :additional_info
@@ -10,7 +10,7 @@ class ArrayTest < Test::Unit::TestCase
10
10
 
11
11
  context "#name" do
12
12
  should "conform to doc" do
13
- assert_equal :upcase, @bound.name
13
+ assert_equal "upcase", @bound.name
14
14
  end
15
15
  end
16
16
 
@@ -33,7 +33,7 @@ class ArrayTest < Test::Unit::TestCase
33
33
 
34
34
  context "#name" do
35
35
  should "conform to doc" do
36
- assert_equal :upcase, @unbound.name
36
+ assert_equal "upcase", @unbound.name
37
37
  end
38
38
  end
39
39
 
@@ -51,7 +51,7 @@ class ArrayTest < Test::Unit::TestCase
51
51
 
52
52
  context "#name" do
53
53
  should "conform to doc" do
54
- assert_equal :upcase, @bound_again.name
54
+ assert_equal "upcase", @bound_again.name
55
55
  end
56
56
  end
57
57
 
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.12.1
4
+ version: 1.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Marc-Andr\xC3\xA9 Lafortune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-17 00:00:00 -05:00
12
+ date: 2009-12-23 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15