backports 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/VERSION.yml +2 -2
- data/backports.gemspec +2 -2
- data/lib/backports/1.9.1/enumerator.rb +22 -1
- data/lib/backports/tools.rb +0 -16
- metadata +5 -5
data/CHANGELOG.rdoc
CHANGED
data/VERSION.yml
CHANGED
data/backports.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{backports}
|
8
|
-
s.version = "2.
|
8
|
+
s.version = "2.3.0"
|
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{2011-
|
12
|
+
s.date = %q{2011-06-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}
|
@@ -4,9 +4,30 @@ Enumerator = Enumerable::Enumerator unless Object.const_defined? :Enumerator # S
|
|
4
4
|
class Enumerator
|
5
5
|
# new with block, standard in Ruby 1.9
|
6
6
|
unless (self.new{} rescue false)
|
7
|
+
# A simple class which allows the construction of Enumerator from a block
|
8
|
+
class Yielder
|
9
|
+
def initialize(&block)
|
10
|
+
@main_block = block
|
11
|
+
end
|
12
|
+
|
13
|
+
def each(&block)
|
14
|
+
@final_block = block
|
15
|
+
@main_block.call(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
def yield(*arg)
|
19
|
+
@final_block.yield(*arg)
|
20
|
+
end
|
21
|
+
|
22
|
+
def <<(*arg)
|
23
|
+
@final_block.yield(*arg)
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
7
28
|
def initialize_with_optional_block(*arg, &block)
|
8
29
|
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(
|
30
|
+
initialize_without_optional_block(Yielder.new(&block))
|
10
31
|
end
|
11
32
|
Backports.alias_method_chain self, :initialize, :optional_block
|
12
33
|
end
|
data/lib/backports/tools.rb
CHANGED
@@ -182,20 +182,4 @@ module Backports
|
|
182
182
|
to.instance_variable_set :@is_lambda, is_lambda
|
183
183
|
to
|
184
184
|
end
|
185
|
-
|
186
|
-
# A simple class which allows the construction of Enumerator from a block
|
187
|
-
class Yielder
|
188
|
-
def initialize(&block)
|
189
|
-
@main_block = block
|
190
|
-
end
|
191
|
-
|
192
|
-
def each(&block)
|
193
|
-
@final_block = block
|
194
|
-
@main_block.call(self)
|
195
|
-
end
|
196
|
-
|
197
|
-
def yield(*arg)
|
198
|
-
@final_block.yield(*arg)
|
199
|
-
end
|
200
|
-
end
|
201
185
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 2.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Marc-Andr\xC3\xA9 Lafortune"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-23 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|