backports 1.13.3 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,24 @@
1
1
  = Packable --- History
2
2
 
3
+ == Version 1.14.0 - March 3rd, 2010
4
+
5
+ * Added some features of 1.9.2:
6
+
7
+ * Array#rotate, rotate!
8
+ * Array#keep_if, select!
9
+ * Array#sort_by!
10
+ * Enumerable#join
11
+ * Enumerable#slice_before
12
+ * Float::INFINITY, NAN
13
+ * MatchData#==
14
+
15
+ == Version 1.13.0 - January 20th, 2010
16
+
17
+ * Missing for 1.8.7 were
18
+ * Array#permutation
19
+ * Hash#hash (was only inherited)
20
+ * Hash#eql? (was only inherited)
21
+
3
22
  == Version 1.12.0 - December 4th, 2009
4
23
 
5
24
  * Finer grain includes (see README)
@@ -62,7 +62,7 @@ Complete Ruby 1.8.8 backporting (core language). In case you are wondering: no,
62
62
  Only exception:
63
63
  * Enumerator#rewind (incompatible change, so won't be implemented)
64
64
 
65
- To include _only_ these backports and those preceeding, <tt>require "backports/1.8.8"</tt>.
65
+ To include _only_ these backports and those preceding, <tt>require "backports/1.8.8"</tt>.
66
66
 
67
67
  == Ruby 1.9.1
68
68
 
@@ -106,14 +106,23 @@ but since it is only an imitation, it must be required explicitly:
106
106
 
107
107
  Finally, some Ruby 1.9.2 features have been backported. As this version has not been feature frozen yet, changes are still possible.
108
108
 
109
+ * Array
110
+ * <tt>rotate, rotate!</tt>
111
+ * <tt>keep_if, select!</tt>
112
+ * <tt>sort_by!</tt>
113
+
109
114
  * Enumerable
110
- * +flat_map+, +collect_concat+
111
115
  * +chunk+
116
+ * +flat_map+, +collect_concat+
117
+ * +join+
118
+ * +slice_before+
119
+
120
+ * Float::INFINITY, NAN
112
121
 
113
122
  * Object
114
123
  * <tt>respond_to_missing?</tt>
115
124
 
116
- To include all Ruby backports but not those of Rails, <tt>require "backports/1.9.2"</tt>.
125
+ To include all Ruby backports but not those of Rails, <tt>require "backports/1.9.2"</tt> (or "backports/1.9")
117
126
 
118
127
  == Rails
119
128
 
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 13
4
- :patch: 3
3
+ :minor: 14
4
+ :patch: 0
5
5
  :build:
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{backports}
8
- s.version = "1.13.3"
8
+ s.version = "1.14.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{2010-02-26}
12
+ s.date = %q{2010-03-04}
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}
@@ -74,7 +74,10 @@ Gem::Specification.new do |s|
74
74
  "lib/backports/1.9.1/string.rb",
75
75
  "lib/backports/1.9.1/symbol.rb",
76
76
  "lib/backports/1.9.2.rb",
77
+ "lib/backports/1.9.2/array.rb",
77
78
  "lib/backports/1.9.2/enumerable.rb",
79
+ "lib/backports/1.9.2/float.rb",
80
+ "lib/backports/1.9.2/match_data.rb",
78
81
  "lib/backports/1.9.2/method.rb",
79
82
  "lib/backports/1.9.rb",
80
83
  "lib/backports/basic_object.rb",
@@ -15,7 +15,7 @@ module Kernel
15
15
  raise LoadError, "require_relative is called in #{$1}"
16
16
  end
17
17
  require File.expand_path(relative_feature, File.dirname(file))
18
- end unless method_defined? :require_relative
18
+ end unless private_method_defined? :require_relative
19
19
  private :require_relative
20
20
 
21
21
  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
@@ -0,0 +1,28 @@
1
+ class Array
2
+ # Standard in Ruby 1.9.2 See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
3
+ def keep_if
4
+ return to_enum :keep_if unless block_given?
5
+ delete_if{|elem| !yield elem}
6
+ end unless method_defined? :keep_if
7
+
8
+ def rotate(n=1)
9
+ dup.rotate!(n)
10
+ end unless method_defined? :rotate
11
+
12
+ def rotate!(n=1)
13
+ return self if empty?
14
+ n %= size
15
+ concat(slice!(0, n))
16
+ end unless method_defined? :rotate!
17
+
18
+ def select!(&block)
19
+ return to_enum :select! unless block_given?
20
+ reject!{|elem| ! yield elem}
21
+ end unless method_defined? :select!
22
+
23
+ def sort_by!(&block)
24
+ return to_enum :sort_by! unless block_given?
25
+ replace sort_by(&block)
26
+ end unless method_defined? :sort_by!
27
+ end
28
+
@@ -34,10 +34,45 @@ module Enumerable
34
34
  end
35
35
  end unless method_defined? :chunk
36
36
 
37
- # Standard in Ruby 1.9.2 See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
37
+ def each_entry(*pass)
38
+ return to_enum :each_entry, *pass unless block_given?
39
+ each(*pass) do |*args|
40
+ yield args.size == 1 ? args[0] : args
41
+ end
42
+ self
43
+ end unless method_defined? :each_entry
44
+
38
45
  def flat_map(&block)
39
46
  return to_enum(:flat_map) unless block_given?
40
47
  map(&block).flatten(1)
41
48
  end unless method_defined? :flat_map
42
49
  Backports.alias_method self, :collect_concat, :flat_map
50
+
51
+ def join(*args)
52
+ to_a.join(*args)
53
+ end unless method_defined? :join
54
+
55
+ def slice_before(arg = Backports::Undefined, &block)
56
+ if block_given?
57
+ has_init = not(arg.equal? Backports::Undefined)
58
+ else
59
+ raise ArgumentError, "wrong number of arguments (0 for 1)" if arg.equal? Backports::Undefined
60
+ block = Proc.new{|elem| arg === elem }
61
+ end
62
+ Enumerator.new do |yielder|
63
+ init = arg.dup if has_init
64
+ accumulator = nil
65
+ each do |elem|
66
+ start_new = has_init ? block.yield(elem, init) : block.yield(elem)
67
+ if start_new
68
+ yielder.yield accumulator if accumulator
69
+ accumulator = [elem]
70
+ else
71
+ accumulator ||= []
72
+ accumulator << elem
73
+ end
74
+ end
75
+ yielder.yield accumulator if accumulator
76
+ end
77
+ end unless method_defined? :slice_before
43
78
  end
@@ -0,0 +1,4 @@
1
+ class Float
2
+ INFINITY = 1.0/0.0 unless const_defined? :INFINITY
3
+ NAN = 0.0/0.0 unless const_defined? :NAN
4
+ end
@@ -0,0 +1,3 @@
1
+ class MatchData
2
+ Backports.alias_method self, :==, :eql?
3
+ 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.13.3
4
+ version: 1.14.0
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-02-26 00:00:00 -05:00
12
+ date: 2010-03-04 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -79,7 +79,10 @@ files:
79
79
  - lib/backports/1.9.1/string.rb
80
80
  - lib/backports/1.9.1/symbol.rb
81
81
  - lib/backports/1.9.2.rb
82
+ - lib/backports/1.9.2/array.rb
82
83
  - lib/backports/1.9.2/enumerable.rb
84
+ - lib/backports/1.9.2/float.rb
85
+ - lib/backports/1.9.2/match_data.rb
83
86
  - lib/backports/1.9.2/method.rb
84
87
  - lib/backports/1.9.rb
85
88
  - lib/backports/basic_object.rb