backports 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,15 @@
1
1
  = Packable --- History
2
2
 
3
+ == Version 2.2.0 - May 13th, 2011
4
+
5
+ * Ruby 1.8.8 was officially cancelled; code was moved to Ruby 1.9.1 and README updated.
6
+
7
+ * <tt>"".ord</tt> now raises an error.
8
+
9
+ == Version 2.1.0 - April 16th, 2011
10
+
11
+ * Proc#curry, #lambda (thanks Konstantine Haase)
12
+
3
13
  == Version 2.0.0 - December 5th, 2010
4
14
 
5
15
  Change of major version because of two small changes that are not quite compatible and because the minor version was getting quite high!
@@ -10,7 +10,7 @@ The goal of 'backports' is to make it easier to write ruby code that runs across
10
10
 
11
11
  require 'backports'
12
12
 
13
- This will bring Ruby 1.8.6 or 1.8.7 up to date with the upcoming Ruby 1.8.8, as well as include many features of Ruby 1.9.1 and Ruby 1.9.2!
13
+ This will bring in all the features of 1.8.7 (for Ruby 1.8.6) and many features of Ruby 1.9.1 (for Ruby 1.8.x) and Ruby 1.9.2 (for all earlier versions)!
14
14
 
15
15
  +Note+: Although I am a Ruby committer, this gem is a personal project and is not endorsed by ruby-core.
16
16
 
@@ -25,7 +25,7 @@ Let's be a bit more precise about the breaking code business. It is of course en
25
25
 
26
26
  A real incompatibility is, for example, <tt>Module::instance_methods</tt> which returns strings in 1.8 and symbols in 1.9. No change can be made without the risk of breaking existing code. Such incompatibilities are left unchanged.
27
27
 
28
- All features of 1.8.7 & 1.8.8 are backported (well, almost all, see the exception list bellow), and many of 1.9 are also.
28
+ All features of 1.8.7 are backported (well, almost all, see the exception list bellow), and many of 1.9 are also.
29
29
 
30
30
  Some generic and self-contained features of active-support are also included. By simple I mean that String#camelcase is there, but #pluralize isn't.
31
31
 
@@ -40,7 +40,7 @@ To use:
40
40
  require 'rubygems'
41
41
  require 'backports' # or a subset, see next section
42
42
 
43
- Compatible with Ruby 1.8.6, 1.8.7, 1.9.1, JRuby and Rubinius, as well as the upcoming Ruby 1.8.8 and 1.9.2
43
+ Compatible with Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2, JRuby and Rubinius.
44
44
 
45
45
  = Complete List of backports
46
46
 
@@ -57,24 +57,33 @@ To include _only_ these backports, <tt>require "backports/1.8.7"</tt>
57
57
 
58
58
  == Ruby 1.8.8
59
59
 
60
- Complete Ruby 1.8.8 backporting (core language). In case you are wondering: no, it's not out yet :-). Refer to the official list of changes[http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8/NEWS].
61
-
62
- Only exception:
63
- * Enumerator#rewind (incompatible change, so won't be implemented)
64
-
65
- To include _only_ these backports and those preceding, <tt>require "backports/1.8.8"</tt>.
60
+ Ruby 1.8.8 has been officially cancelled. As of version 2.2, <tt>require "backports/1.8.8"</tt> does nothing.
66
61
 
67
62
  == Ruby 1.9.1
68
63
 
69
64
  Additionally, the following Ruby 1.9 features have been backported:
65
+ * Array
66
+ * +try_convert+
67
+
68
+ * Enumerable
69
+ * +each_with_object+
70
+
71
+ * Enumerator
72
+ * +new+ (with block)
70
73
 
71
74
  * File
72
75
  * +binread+
73
76
  * +to_path+
74
- * All class methods accepting filenames will accept files or anything with a #to_path method.
77
+ * All class methods accepting filenames will accept files or anything with a <tt>#to_path</tt> method.
78
+
79
+ * Hash
80
+ * +try_convert+
81
+ * <tt>default_proc=</tt>
75
82
 
76
83
  * IO
77
84
  * +bin_read+
85
+ * +try_convert+
86
+ * +ungetbyte+
78
87
 
79
88
  * Kernel
80
89
  * +require_relative+
@@ -92,12 +101,22 @@ Additionally, the following Ruby 1.9 features have been backported:
92
101
  * +yield+
93
102
  * +lambda?+
94
103
  * +curry+
104
+ * <tt>===</tt>
105
+
106
+ * Range
107
+ * <tt>cover?</tt>
108
+
109
+ * Regexp
110
+ * +try_convert+
95
111
 
96
112
  * String
97
113
  * <tt>ascii_only?</tt>
98
114
  * +chr+
99
115
  * +clear+
100
116
  * +codepoints+, +each_codepoint+
117
+ * +get_byte+, +set_byte+
118
+ * +ord+
119
+ * +try_convert+
101
120
 
102
121
  +Enumerator+ can be accessed directly (instead of <tt>Enumerable::Enumerator</tt>)
103
122
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 0
3
2
  :build:
4
3
  :major: 2
5
- :minor: 1
4
+ :minor: 2
5
+ :patch: 0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{backports}
8
- s.version = "2.1.0"
8
+ s.version = "2.2.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-04-16}
12
+ s.date = %q{2011-05-13}
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}
@@ -54,25 +54,22 @@ Gem::Specification.new do |s|
54
54
  "lib/backports/1.8.7/struct.rb",
55
55
  "lib/backports/1.8.7/symbol.rb",
56
56
  "lib/backports/1.8.8.rb",
57
- "lib/backports/1.8.8/array.rb",
58
- "lib/backports/1.8.8/enumerable.rb",
59
- "lib/backports/1.8.8/enumerator.rb",
60
- "lib/backports/1.8.8/env.rb",
61
- "lib/backports/1.8.8/hash.rb",
62
- "lib/backports/1.8.8/io.rb",
63
- "lib/backports/1.8.8/proc.rb",
64
- "lib/backports/1.8.8/range.rb",
65
- "lib/backports/1.8.8/regexp.rb",
66
- "lib/backports/1.8.8/string.rb",
67
57
  "lib/backports/1.8.rb",
68
58
  "lib/backports/1.9.1.rb",
59
+ "lib/backports/1.9.1/array.rb",
69
60
  "lib/backports/1.9.1/dir.rb",
61
+ "lib/backports/1.9.1/enumerable.rb",
62
+ "lib/backports/1.9.1/enumerator.rb",
63
+ "lib/backports/1.9.1/env.rb",
70
64
  "lib/backports/1.9.1/file.rb",
65
+ "lib/backports/1.9.1/hash.rb",
71
66
  "lib/backports/1.9.1/integer.rb",
72
67
  "lib/backports/1.9.1/io.rb",
73
68
  "lib/backports/1.9.1/kernel.rb",
74
69
  "lib/backports/1.9.1/math.rb",
75
70
  "lib/backports/1.9.1/proc.rb",
71
+ "lib/backports/1.9.1/range.rb",
72
+ "lib/backports/1.9.1/regexp.rb",
76
73
  "lib/backports/1.9.1/string.rb",
77
74
  "lib/backports/1.9.1/symbol.rb",
78
75
  "lib/backports/1.9.2.rb",
@@ -121,7 +118,7 @@ Gem::Specification.new do |s|
121
118
  s.rdoc_options = ["--charset=UTF-8", "--title", "Backports library", "--main", "README.rdoc", "--line-numbers", "--inline-source"]
122
119
  s.require_paths = ["lib"]
123
120
  s.rubyforge_project = %q{backports}
124
- s.rubygems_version = %q{1.6.0}
121
+ s.rubygems_version = %q{1.3.7}
125
122
  s.summary = %q{Backports of Ruby 1.8.7+ for older ruby.}
126
123
  s.test_files = [
127
124
  "test/array_test.rb",
@@ -144,6 +141,7 @@ Gem::Specification.new do |s|
144
141
  ]
145
142
 
146
143
  if s.respond_to? :specification_version then
144
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
147
145
  s.specification_version = 3
148
146
 
149
147
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
File without changes
File without changes
File without changes
@@ -6,5 +6,12 @@ class IO
6
6
  f.read(*arg)
7
7
  end
8
8
  end unless method_defined? :binread
9
+
10
+ def try_convert(obj)
11
+ return nil unless obj.respond_to?(:to_io)
12
+ Backports.coerce_to(obj, IO, :to_io)
13
+ end unless method_defined? :try_convert
9
14
  end
15
+
16
+ Backports.alias_method self, :ungetbyte, :ungetc
10
17
  end
@@ -49,4 +49,6 @@ class Proc
49
49
  end
50
50
  end
51
51
  end unless method_defined? :curry
52
+
53
+ alias_method :===, :call unless Proc.new{true} === 42
52
54
  end
File without changes
File without changes
@@ -1,5 +1,13 @@
1
1
  class String
2
2
 
3
+ class << self
4
+ # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
5
+ def try_convert(x)
6
+ return nil unless x.respond_do(:to_str)
7
+ x.to_str
8
+ end unless method_defined? :try_convert
9
+ end
10
+
3
11
  # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
4
12
  def ascii_only?
5
13
  !(self =~ /[^\x00-\x7f]/)
@@ -17,9 +25,26 @@ class String
17
25
  end unless method_defined? :clear
18
26
 
19
27
  # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
20
- public :codepoints # Definition in 1.8.8/string.rb
28
+ def codepoints
29
+ return to_enum(:codepoints) unless block_given?
30
+ each_char do |s|
31
+ utf8 = s.each_byte.to_a
32
+ utf8[0] &= 0xff >> utf8.size # clear high bits (1 to 4, depending of number of bytes used)
33
+ yield utf8.inject{|result, b| (result << 6) + (b & 0x3f) }
34
+ end
35
+ end unless method_defined? :codepoints
21
36
 
22
37
  # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
23
38
  Backports.alias_method self, :each_codepoint, :codepoints
24
39
 
25
- end
40
+ # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
41
+ def ord
42
+ codepoints.first or raise ArgumentError, "empty string"
43
+ end unless method_defined? :ord
44
+
45
+ # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
46
+ Backports.alias_method self, :getbyte, :[]
47
+
48
+ # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
49
+ Backports.alias_method self, :setbyte, :[]=
50
+ 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: 11
5
- prerelease:
4
+ hash: 7
5
+ prerelease: false
6
6
  segments:
7
7
  - 2
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 2.1.0
10
+ version: 2.2.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-04-16 00:00:00 -04:00
18
+ date: 2011-05-13 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -65,25 +65,22 @@ files:
65
65
  - lib/backports/1.8.7/struct.rb
66
66
  - lib/backports/1.8.7/symbol.rb
67
67
  - lib/backports/1.8.8.rb
68
- - lib/backports/1.8.8/array.rb
69
- - lib/backports/1.8.8/enumerable.rb
70
- - lib/backports/1.8.8/enumerator.rb
71
- - lib/backports/1.8.8/env.rb
72
- - lib/backports/1.8.8/hash.rb
73
- - lib/backports/1.8.8/io.rb
74
- - lib/backports/1.8.8/proc.rb
75
- - lib/backports/1.8.8/range.rb
76
- - lib/backports/1.8.8/regexp.rb
77
- - lib/backports/1.8.8/string.rb
78
68
  - lib/backports/1.8.rb
79
69
  - lib/backports/1.9.1.rb
70
+ - lib/backports/1.9.1/array.rb
80
71
  - lib/backports/1.9.1/dir.rb
72
+ - lib/backports/1.9.1/enumerable.rb
73
+ - lib/backports/1.9.1/enumerator.rb
74
+ - lib/backports/1.9.1/env.rb
81
75
  - lib/backports/1.9.1/file.rb
76
+ - lib/backports/1.9.1/hash.rb
82
77
  - lib/backports/1.9.1/integer.rb
83
78
  - lib/backports/1.9.1/io.rb
84
79
  - lib/backports/1.9.1/kernel.rb
85
80
  - lib/backports/1.9.1/math.rb
86
81
  - lib/backports/1.9.1/proc.rb
82
+ - lib/backports/1.9.1/range.rb
83
+ - lib/backports/1.9.1/regexp.rb
87
84
  - lib/backports/1.9.1/string.rb
88
85
  - lib/backports/1.9.1/symbol.rb
89
86
  - lib/backports/1.9.2.rb
@@ -163,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
160
  requirements: []
164
161
 
165
162
  rubyforge_project: backports
166
- rubygems_version: 1.6.0
163
+ rubygems_version: 1.3.7
167
164
  signing_key:
168
165
  specification_version: 3
169
166
  summary: Backports of Ruby 1.8.7+ for older ruby.
@@ -1,11 +0,0 @@
1
- class IO
2
- # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/IO.html]
3
- class << self
4
- def try_convert(obj)
5
- return nil unless obj.respond_to?(:to_io)
6
- Backports.coerce_to(obj, IO, :to_io)
7
- end unless method_defined? :try_convert
8
- end
9
-
10
- Backports.alias_method self, :ungetbyte, :ungetc
11
- end
@@ -1,3 +0,0 @@
1
- class Proc
2
- alias_method :===, :call unless Proc.new{true} === 42
3
- end
@@ -1,33 +0,0 @@
1
- class String
2
- class << self
3
- # Standard in Ruby 1.8.8. 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.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
11
- Backports.alias_method self, :getbyte, :[]
12
-
13
- # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
14
- Backports.alias_method self, :setbyte, :[]=
15
-
16
- # Let's define this here, we can use it for ord:
17
- unless method_defined? :codepoints
18
- def codepoints
19
- return to_enum(:codepoints) unless block_given?
20
- each_char do |s|
21
- utf8 = s.each_byte.to_a
22
- utf8[0] &= 0xff >> utf8.size # clear high bits (1 to 4, depending of number of bytes used)
23
- yield utf8.inject{|result, b| (result << 6) + (b & 0x3f) }
24
- end
25
- end
26
- private :codepoints # Will be made available in 1.9.1/string.rb, if included
27
- end
28
-
29
- # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
30
- def ord
31
- codepoints.first
32
- end unless method_defined? :ord
33
- end