backports 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -12,7 +12,6 @@ rvm:
12
12
 
13
13
  matrix:
14
14
  allow_failures:
15
- - rvm: "2.0.0" # Must wait for 2.0.0p0...
16
15
  - rvm: jruby-18mode
17
16
  - rvm: jruby-19mode
18
17
  - rvm: rbx-18mode
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,11 @@
1
1
  = Backports --- History
2
2
 
3
+ == Version 3.2.0 - April 2nd, 2013
4
+
5
+ * Moved `Dir.mktmpdir` to the stdlib 'tmpdir' for Ruby 1.8.7
6
+
7
+ * Removed `returning` as it is no longer part of Rails.
8
+
3
9
  == Version 3.1.0 - March 5th, 2013
4
10
 
5
11
  * Backports can now be loaded separately!
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ gemspec
9
9
  group :test do
10
10
  gem "rake"
11
11
  gem 'mspec', :git => 'git://github.com/rubyspec/mspec.git'
12
+ gem 'activesupport'
12
13
  end
13
14
 
14
15
  # Declare any dependencies that are still in development here instead of in
data/Gemfile.lock CHANGED
@@ -7,11 +7,16 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- backports (3.1.1)
10
+ backports (3.2.0)
11
11
 
12
12
  GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
+ activesupport (3.2.13)
16
+ i18n (= 0.6.1)
17
+ multi_json (~> 1.0)
18
+ i18n (0.6.1)
19
+ multi_json (1.7.2)
15
20
  rake (10.0.3)
16
21
 
17
22
  PLATFORMS
@@ -19,6 +24,7 @@ PLATFORMS
19
24
  ruby
20
25
 
21
26
  DEPENDENCIES
27
+ activesupport
22
28
  backports!
23
29
  mspec!
24
30
  rake
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Backports Library {<img src="https://travis-ci.org/marcandre/backports.png?branch=master">}[https://travis-ci.org/marcandre/backports]
1
+ = Backports Library {<img src="https://travis-ci.org/marcandre/backports.png?branch=master">}[https://travis-ci.org/marcandre/backports] {<img src="https://badge.fury.io/rb/backports.png" alt="Gem Version" />}[http://badge.fury.io/rb/backports] {<img alt='Click here to lend your support to: Ruby Backports and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/19510.png?skin_name=chrome' border='0'}[http://www.pledgie.com/campaigns/19510]
2
2
 
3
3
  * Yearning to use some of the new cool features in Ruby 2.0.0 while using 1.8.6?
4
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?
@@ -255,7 +255,6 @@ Some generic methods from Rails methods have been copied:
255
255
 
256
256
  * Object
257
257
  * +try+
258
- * +returning+
259
258
 
260
259
  * String
261
260
  * +camelize+, +underscore+
@@ -0,0 +1 @@
1
+ Backports::StdLib.extend_relative
@@ -1,5 +1,5 @@
1
- unless Dir.method_defined? :mktmpdir
2
- class Dir
1
+ unless Dir.respond_to? :mktmpdir
2
+ class << Dir
3
3
  def mktmpdir(prefix_suffix=nil, tmpdir=nil)
4
4
  raise NoMethodError, "undefined method `mktmpdir' for Dir:Class; you must require 'tmpdir'" unless respond_to? :tmpdir
5
5
 
@@ -2,12 +2,12 @@ class Hash
2
2
  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
3
3
  def reverse_merge(other_hash)
4
4
  other_hash.merge(self)
5
- end
5
+ end unless method_defined? :reverse_merge
6
6
 
7
7
  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
8
8
  def reverse_merge!(other_hash)
9
9
  replace(reverse_merge(other_hash))
10
- end
10
+ end unless method_defined? :reverse_merge!
11
11
 
12
12
  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html]
13
13
  def symbolize_keys
@@ -1,12 +1,6 @@
1
- module Kernel
1
+ class Object
2
2
  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/Object.html]
3
3
  def try(method_id, *args, &block)
4
4
  send(method_id, *args, &block) unless self.nil?
5
5
  end unless method_defined? :try
6
-
7
- # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/Object.html]
8
- def returning(obj)
9
- yield obj
10
- obj
11
- end unless method_defined? :returning
12
6
  end
@@ -1,6 +1,6 @@
1
1
  class Module
2
2
  # Standard in rails... See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Module.html]
3
- def alias_method_chain(target, feature)
4
- Backports.alias_method_chain(self, target, feature)
3
+ def alias_method_chain(target, feature, &block)
4
+ Backports.alias_method_chain(self, target, feature, &block)
5
5
  end unless method_defined? :alias_method_chain
6
6
  end
@@ -256,8 +256,8 @@ module Backports
256
256
  # Safe alias_method that will only alias if the source exists and destination doesn't
257
257
  def self.alias_method(mod, new_name, old_name)
258
258
  mod.instance_eval do
259
- alias_method new_name, old_name if method_defined?(old_name) and not method_defined?(new_name)
260
- end
259
+ alias_method new_name, old_name
260
+ end if mod.method_defined?(old_name) && !mod.method_defined?(new_name)
261
261
  end
262
262
 
263
263
  # Used internally to combine {IO|File} options hash into mode (String or Integer)
@@ -1,3 +1,3 @@
1
1
  module Backports
2
- VERSION = "3.1.1" unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
2
+ VERSION = "3.2.0" unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
3
3
  end
@@ -31,7 +31,7 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
31
31
  $stderr = @prev
32
32
  end
33
33
 
34
- EXCLUDE = %w[require] # Overriden in all circumstances to load the std-lib
34
+ EXCLUDE = %w[require require_with_backports require_without_backports] # Overriden in all circumstances to load the std-lib
35
35
  EXCLUDE.map!(&:to_sym) if instance_methods.first.is_a?(Symbol)
36
36
 
37
37
  # For some very strange reason, Hash[kvp.flatten] doesn't always work in 1.8.6??
@@ -73,7 +73,7 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
73
73
  compare = after[klass]
74
74
  d = methods.map do |name, unbound|
75
75
  name unless unbound == compare[name]
76
- end
76
+ end + (compare.map(&:first) - methods.map(&:first))
77
77
  d.compact!
78
78
  delta[klass] = d unless d.empty?
79
79
  end
@@ -89,12 +89,13 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
89
89
  # Order super important!
90
90
  def test__2_backports_wont_override_unnecessarily
91
91
  before = digest
92
+ latest = "2.0.0"
92
93
  unless RUBY_VERSION <= '1.8.6'
93
- require "backports/#{RUBY_VERSION}"
94
+ require "backports/#{[RUBY_VERSION, latest].min}"
94
95
  after = digest
95
96
  assert_nil digest_delta(before, after)
96
97
  end
97
- unless RUBY_VERSION == "2.0.0"
98
+ unless RUBY_VERSION >= latest
98
99
  require "backports"
99
100
  after = digest
100
101
  assert !digest_delta(before, after).nil?
@@ -137,4 +138,13 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
137
138
  require 'backports/1.8.7/enumerator/next'
138
139
  assert_equal 1, [1,2,3].each.next # [Bug #70]
139
140
  end
141
+
142
+ def test_rails
143
+ require 'active_support/all'
144
+ $stderr.string = '' # disregard warnings by Rails
145
+ before = digest
146
+ require "backports/rails"
147
+ after = digest
148
+ assert_nil digest_delta(before, after)
149
+ end
140
150
  end
data/test/lazy_test.rb CHANGED
@@ -388,10 +388,10 @@ class TestLazyEnumerator < Test::Unit::TestCase
388
388
  (1..10).lazy.cycle.inspect)
389
389
  assert_equal("#<Enumerator::Lazy: #<Enumerator::Lazy: 1..10>:cycle(3)>",
390
390
  (1..10).lazy.cycle(3).inspect)
391
- l = (1..10).lazy.map {}.collect {}.flat_map {}.collect_concat {}.select {}.find_all {}.reject {}.grep(1).zip(?a..?c).take(10).take_while {}.drop(3).drop_while {}.cycle(3)
391
+ l = (1..10).lazy.map {}.flat_map {}.select {}.reject {}.grep(1).zip(?a..?c).take(10).take_while {}.drop(3).drop_while {}.cycle(3)
392
392
  ### Backport: Modified because I don't think the actual name we were called under in case of aliases is important enough to care
393
393
  assert_equal(<<EOS.chomp, l.inspect)
394
- #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 1..10>:map>:map>:flat_map>:flat_map>:select>:select>:reject>:grep(1)>:zip("a".."c")>:take(10)>:take_while>:drop(3)>:drop_while>:cycle(3)>
394
+ #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 1..10>:map>:flat_map>:select>:reject>:grep(1)>:zip(\"a\"..\"c\")>:take(10)>:take_while>:drop(3)>:drop_while>:cycle(3)>
395
395
  EOS
396
396
  end if [].respond_to?(:flat_map)
397
397
 
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: 3.1.1
4
+ version: 3.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-08 00:00:00.000000000 Z
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Essential backports that enable many of the nice features of Ruby 1.8.7
15
15
  up to 2.0.0 for earlier versions.
@@ -69,7 +69,6 @@ files:
69
69
  - lib/backports/1.8.7/dir.rb
70
70
  - lib/backports/1.8.7/dir/each.rb
71
71
  - lib/backports/1.8.7/dir/foreach.rb
72
- - lib/backports/1.8.7/dir/mktmpdir.rb
73
72
  - lib/backports/1.8.7/enumerable.rb
74
73
  - lib/backports/1.8.7/enumerable/count.rb
75
74
  - lib/backports/1.8.7/enumerable/cycle.rb
@@ -174,6 +173,8 @@ files:
174
173
  - lib/backports/1.8.7/range/step.rb
175
174
  - lib/backports/1.8.7/regexp.rb
176
175
  - lib/backports/1.8.7/regexp/union.rb
176
+ - lib/backports/1.8.7/stdlib.rb
177
+ - lib/backports/1.8.7/stdlib/tmpdir.rb
177
178
  - lib/backports/1.8.7/stop_iteration.rb
178
179
  - lib/backports/1.8.7/string.rb
179
180
  - lib/backports/1.8.7/string/bytes.rb
@@ -519,18 +520,24 @@ require_paths:
519
520
  required_ruby_version: !ruby/object:Gem::Requirement
520
521
  none: false
521
522
  requirements:
522
- - - ! '>='
523
+ - - '>='
523
524
  - !ruby/object:Gem::Version
524
525
  version: '0'
526
+ segments:
527
+ - 0
528
+ hash: -2299400734931840914
525
529
  required_rubygems_version: !ruby/object:Gem::Requirement
526
530
  none: false
527
531
  requirements:
528
- - - ! '>='
532
+ - - '>='
529
533
  - !ruby/object:Gem::Version
530
534
  version: '0'
535
+ segments:
536
+ - 0
537
+ hash: -2299400734931840914
531
538
  requirements: []
532
539
  rubyforge_project:
533
- rubygems_version: 1.8.24
540
+ rubygems_version: 1.8.25
534
541
  signing_key:
535
542
  specification_version: 3
536
543
  summary: Backports of Ruby features for older Ruby.
@@ -540,4 +547,3 @@ test_files:
540
547
  - test/lazy_test.rb
541
548
  - test/socket_interaction_test.rb
542
549
  - test/test_helper.rb
543
- has_rdoc: