backports 1.13.1 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -1
- data/VERSION.yml +1 -1
- data/backports.gemspec +2 -2
- data/lib/backports/1.8.7/argf.rb +2 -2
- data/lib/backports/1.8.7/enumerable.rb +1 -1
- data/lib/backports/1.8.7/float.rb +1 -1
- data/lib/backports/1.8.7/hash.rb +1 -1
- data/lib/backports/1.8.7/io.rb +2 -2
- data/lib/backports/1.8.7/module.rb +1 -1
- data/lib/backports/1.8.7/proc.rb +1 -1
- data/lib/backports/1.8.7/string.rb +4 -4
- data/lib/backports/1.8.8/enumerator.rb +1 -1
- data/lib/backports/1.8.8/env.rb +1 -1
- data/lib/backports/1.8.8/io.rb +1 -1
- data/lib/backports/1.8.8/range.rb +1 -1
- data/lib/backports/1.8.8/string.rb +2 -2
- data/lib/backports/1.9.1/dir.rb +1 -1
- data/lib/backports/1.9.1/file.rb +1 -1
- data/lib/backports/1.9.1/integer.rb +1 -1
- data/lib/backports/1.9.1/string.rb +1 -1
- data/lib/backports/1.9.2/enumerable.rb +1 -1
- data/lib/backports/tools.rb +8 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
= Backports Library
|
2
2
|
|
3
|
-
Can't remember if you can use Array#sample?
|
3
|
+
* Can't remember if you can use Array#sample?
|
4
|
+
* One of your client is stuck with Ruby 1.8.6 but you want to use a gem using some features of 1.8.7?
|
5
|
+
* Yearning to use some of the new cool features in 1.9, (even the upcoming 1.9.2)?
|
6
|
+
|
7
|
+
This gem is for you!
|
4
8
|
|
5
9
|
The goal of 'backports' is to make it easier to write ruby code that runs across different versions of Ruby. All you need to bring any version of Ruby up to today's standards:
|
6
10
|
|
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 = "1.13.
|
8
|
+
s.version = "1.13.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{2010-01-
|
12
|
+
s.date = %q{2010-01-25}
|
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}
|
data/lib/backports/1.8.7/argf.rb
CHANGED
@@ -45,10 +45,10 @@ class << ARGF
|
|
45
45
|
end unless method_defined? :each_char
|
46
46
|
|
47
47
|
# No official documentation...
|
48
|
-
alias_method :getbyte, :getc
|
48
|
+
Backports.alias_method self, :getbyte, :getc
|
49
49
|
|
50
50
|
# No official documentation...
|
51
|
-
alias_method :readbyte, :readchar
|
51
|
+
Backports.alias_method self, :readbyte, :readchar
|
52
52
|
|
53
53
|
# No official documentation...
|
54
54
|
def lines(*args)
|
@@ -186,7 +186,7 @@ module Enumerable
|
|
186
186
|
found_one
|
187
187
|
end unless method_defined? :one?
|
188
188
|
|
189
|
-
alias_method :reduce, :inject
|
189
|
+
Backports.alias_method self, :reduce, :inject
|
190
190
|
|
191
191
|
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
|
192
192
|
def reverse_each(&block)
|
data/lib/backports/1.8.7/hash.rb
CHANGED
@@ -39,5 +39,5 @@ class Hash
|
|
39
39
|
Backports.make_block_optional self, :delete_if, :each, :each_key, :each_pair, :each_value, :reject, :reject!, :select, :test_on => {:hello => "world!"}
|
40
40
|
|
41
41
|
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html]
|
42
|
-
alias_method :key, :index
|
42
|
+
Backports.alias_method self, :key, :index
|
43
43
|
end
|
data/lib/backports/1.8.7/io.rb
CHANGED
@@ -44,8 +44,8 @@ class IO
|
|
44
44
|
self
|
45
45
|
end unless method_defined? :each_char
|
46
46
|
|
47
|
-
alias_method :getbyte, :getc
|
48
|
-
alias_method :readbyte, :readchar
|
47
|
+
Backports.alias_method self, :getbyte, :getc
|
48
|
+
Backports.alias_method self, :readbyte, :readchar
|
49
49
|
|
50
50
|
# Standard in ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/IO.html]
|
51
51
|
def lines(*args)
|
data/lib/backports/1.8.7/proc.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class String
|
2
2
|
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
3
|
-
alias_method :bytesize, :length
|
3
|
+
Backports.alias_method self, :bytesize, :length
|
4
4
|
|
5
5
|
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
6
6
|
def chr
|
@@ -10,7 +10,7 @@ class String
|
|
10
10
|
Backports.make_block_optional self, :each_byte, :each_line, :test_on => "abc"
|
11
11
|
|
12
12
|
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
13
|
-
alias_method :bytes, :each_byte
|
13
|
+
Backports.alias_method self, :bytes, :each_byte
|
14
14
|
|
15
15
|
Backports.make_block_optional self, :each, :test_on => "abc" if "is there still an each?".respond_to? :each
|
16
16
|
|
@@ -25,10 +25,10 @@ class String
|
|
25
25
|
scan(/./, &block)
|
26
26
|
end
|
27
27
|
|
28
|
-
alias_method :chars, :each_char
|
28
|
+
Backports.alias_method self, :chars, :each_char
|
29
29
|
end
|
30
30
|
|
31
|
-
alias_method :lines, :each_line
|
31
|
+
Backports.alias_method self, :lines, :each_line
|
32
32
|
|
33
33
|
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
34
34
|
def end_with?(*suffixes)
|
data/lib/backports/1.8.8/env.rb
CHANGED
data/lib/backports/1.8.8/io.rb
CHANGED
@@ -8,10 +8,10 @@ class String
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
11
|
-
alias_method :getbyte, :[]
|
11
|
+
Backports.alias_method self, :getbyte, :[]
|
12
12
|
|
13
13
|
# Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
14
|
-
alias_method :setbyte, :[]=
|
14
|
+
Backports.alias_method self, :setbyte, :[]=
|
15
15
|
|
16
16
|
# Let's define this here, we can use it for ord:
|
17
17
|
unless method_defined? :codepoints
|
data/lib/backports/1.9.1/dir.rb
CHANGED
data/lib/backports/1.9.1/file.rb
CHANGED
@@ -3,7 +3,7 @@ class File
|
|
3
3
|
stat.size
|
4
4
|
end unless method_defined? :size
|
5
5
|
|
6
|
-
alias_method :to_path, :path
|
6
|
+
Backports.alias_method self, :to_path, :path
|
7
7
|
|
8
8
|
class << self
|
9
9
|
if RUBY_VERSION < '1.9' # can't see any other reasonable way to test than this
|
@@ -15,6 +15,6 @@ class String
|
|
15
15
|
public :codepoints # Definition in 1.8.8/string.rb
|
16
16
|
|
17
17
|
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
|
18
|
-
alias_method :each_codepoint, :codepoints
|
18
|
+
Backports.alias_method self, :each_codepoint, :codepoints
|
19
19
|
|
20
20
|
end
|
@@ -39,5 +39,5 @@ module Enumerable
|
|
39
39
|
return to_enum(:flat_map) unless block_given?
|
40
40
|
map(&block).flatten(1)
|
41
41
|
end unless method_defined? :flat_map
|
42
|
-
alias_method :collect_concat, :flat_map
|
42
|
+
Backports.alias_method self, :collect_concat, :flat_map
|
43
43
|
end
|
data/lib/backports/tools.rb
CHANGED
@@ -159,6 +159,14 @@ module Backports
|
|
159
159
|
# (from Rubinius)
|
160
160
|
Undefined = Object.new
|
161
161
|
|
162
|
+
# Used internally.
|
163
|
+
# Safe alias_method that will only alias if the source exists and destination doesn't
|
164
|
+
def self.alias_method(mod, new_name, old_name)
|
165
|
+
mod.class_eval do
|
166
|
+
alias_method new_name, old_name if method_defined?(old_name) and not method_defined?(new_name)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
162
170
|
# A simple class which allows the construction of Enumerator from a block
|
163
171
|
class Yielder
|
164
172
|
def initialize(&block)
|
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.13.
|
4
|
+
version: 1.13.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: 2010-01-
|
12
|
+
date: 2010-01-25 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|