backports 3.11.1 → 3.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a53e840dd9649161f1c89c30dc591a1086a6faf
4
- data.tar.gz: fe88e1c4304bc7c2f24bc68bdf18838ca49d72e7
3
+ metadata.gz: 544fc0fdfde45e2f7545c55cc240f9ea59d66107
4
+ data.tar.gz: 62f0dbfd4df084022ab983e17ab040647e906ef2
5
5
  SHA512:
6
- metadata.gz: bd11c4daa9fd6d95afeb22a6260a0cab569ac277522e47b32f5b1dd41b2395eb8f914e80a2a40feb862d42c964d3b2289ef1acfeb69e46f1ff65913839305ffc
7
- data.tar.gz: 0fe9ec5fc708360fe0178c59e7bac01ab28cbd61d3dee8b188420fab6cbbf2017a2288035a08b07d71f3d16b5fa5affbb140be93e5719f9f3c1718bf9f41ac3e
6
+ metadata.gz: b9659fda7635ff3b7c9949a72394ce390c52cb077f9ce46143cc89ad8d599c8653edc8b800a88a07581a3f562433bae32a4ff64b3ea9ed5b971f830173363fcb
7
+ data.tar.gz: 4c88602d22577ab20dd5fe704a0b043f76353856f6e52274159f575c6233386e27c1e27561e47aedccf78b4130b32b685b3f0bf781c90e2899733dfe2ebcc778
@@ -1,8 +1,6 @@
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]
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]
2
2
 
3
- * Yearning to use some of the new cool features in Ruby 2.0.0 while using 1.8.6?
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
- * Can't remember if you can use Array#sample or String#each_char on a friend's box?
3
+ Yearning to use some of the new cool features in Ruby 2.5 while using 2.3.x? Have some legacy code in Ruby 1.8 but can't live without `flat_map`?
6
4
 
7
5
  This gem is for you!
8
6
 
@@ -12,12 +10,12 @@ The goal of 'backports' is to make it easier to write ruby code that runs across
12
10
 
13
11
  === Explicitly (recommended)
14
12
 
15
- For example, if you want to use flat_map, even in Ruby implementations that don't include it, as well as the new bsearch method:
13
+ For example, if you want to use transform_values and transform_keys, even in Ruby implementations that don't include it:
16
14
 
17
- require 'backports/1.9.2/enumerable/flat_map'
18
- require 'backports/2.0.0/array/bsearch'
15
+ require 'backports/2.4.0/hash/transform_values'
16
+ require 'backports/2.5.0/hash/transform_keys'
19
17
 
20
- This will enable Enumerable#flat_map and Array#bsearch, using the native versions if available or otherwise provide a pure Ruby version.
18
+ This will enable Hash#transform_values and Hash#transform_keys, using the native versions if available or otherwise provide a pure Ruby version.
21
19
 
22
20
  === By Module
23
21
 
@@ -52,9 +50,9 @@ For Ruby < 2.0, there are some real incompatibilities. For example, <tt>Module::
52
50
 
53
51
  == Installation & compatibility
54
52
 
55
- +backports+ is can be installed with:
53
+ +backports+ can be installed with:
56
54
 
57
- (sudo) gem install backports
55
+ gem install backports
58
56
 
59
57
  To use:
60
58
 
@@ -1,6 +1,16 @@
1
- class Object
2
- # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/Object.html]
3
- def try(method_id, *args, &block)
4
- send(method_id, *args, &block) unless self.nil?
5
- end unless method_defined? :try
1
+ # frozen_string_literal: true
2
+
3
+ # From ActiveSupport
4
+ unless Object.method_defined? :try
5
+ class Object
6
+ def try(*a, &b)
7
+ try!(*a, &b) if a.empty? || respond_to?(a.first)
8
+ end
9
+ end
10
+
11
+ class NilClass
12
+ def try(*args)
13
+ nil
14
+ end
15
+ end
6
16
  end
@@ -14,12 +14,12 @@ module Backports
14
14
  alias_method target, with_method
15
15
 
16
16
  case
17
- when public_method_defined?(without_method)
18
- public target
19
- when protected_method_defined?(without_method)
20
- protected target
21
- when private_method_defined?(without_method)
22
- private target
17
+ when public_method_defined?(without_method)
18
+ public target
19
+ when protected_method_defined?(without_method)
20
+ protected target
21
+ when private_method_defined?(without_method)
22
+ private target
23
23
  end
24
24
  end
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module Backports
2
- VERSION = "3.11.1" unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
2
+ VERSION = "3.11.2" unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backports
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.1
4
+ version: 3.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-André Lafortune
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Essential backports that enable many of the nice features of Ruby 1.8.7
14
14
  up to 2.1.0 for earlier versions.