backports 3.11.4 → 3.12.0
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 +13 -5
- data/.travis.yml +2 -0
- data/CHANGELOG.rdoc +2 -0
- data/README.rdoc +28 -7
- data/Rakefile +15 -3
- data/backports.gemspec +7 -1
- data/default.mspec +6 -1
- data/lib/backports/1.9.1/string/codepoints.rb +1 -0
- data/lib/backports/2.1.0/enumerable/to_h.rb +2 -0
- data/lib/backports/2.5.0/string/undump.rb +65 -0
- data/lib/backports/2.6.0.rb +3 -0
- data/lib/backports/2.6.0/array.rb +3 -0
- data/lib/backports/2.6.0/array/difference.rb +5 -0
- data/lib/backports/2.6.0/array/to_h.rb +13 -0
- data/lib/backports/2.6.0/array/union.rb +5 -0
- data/lib/backports/2.6.0/enumerable.rb +3 -0
- data/lib/backports/2.6.0/enumerable/chain.rb +47 -0
- data/lib/backports/2.6.0/enumerable/to_h.rb +13 -0
- data/lib/backports/2.6.0/kernel.rb +3 -0
- data/lib/backports/2.6.0/kernel/then.rb +7 -0
- data/lib/backports/2.6.rb +2 -0
- data/lib/backports/version.rb +1 -1
- data/set_version/2.6.0.rb +1 -0
- data/spec/tags/1.8.7/core/array/to_h_spec.rb +3 -0
- data/spec/tags/1.8.7/core/enumerable/to_h_spec.rb +2 -0
- data/spec/tags/1.8.7/core/module/attr_spec.rb +1 -0
- data/spec/tags/1.9.1/core/hash/slice_spec.rb +1 -0
- data/spec/tags/1.9.1/core/module/attr_spec.rb +1 -0
- data/spec/tags/1.9.2/core/array/to_h_spec.rb +3 -0
- data/spec/tags/1.9.2/core/enumerable/to_h_spec.rb +2 -0
- data/spec/tags/1.9.2/core/hash/slice_spec.rb +1 -0
- data/spec/tags/1.9.2/core/kernel/then_spec.rb +1 -0
- data/spec/tags/1.9.3/core/hash/slice_spec.rb +1 -0
- data/spec/tags/2.0.0/core/array/to_h_spec.rb +3 -0
- data/spec/tags/2.0.0/core/enumerable/to_h_spec.rb +2 -0
- data/spec/tags/2.0.0/core/hash/slice_spec.rb +1 -0
- data/spec/tags/2.0.0/core/module/attr_spec.rb +1 -0
- data/spec/tags/2.1.0/core/array/union_spec.rb +1 -0
- data/spec/tags/2.1.0/core/hash/slice_spec.rb +1 -0
- data/spec/tags/2.1.0/core/module/attr_spec.rb +1 -0
- data/spec/tags/2.2.0/core/hash/slice_spec.rb +1 -0
- data/spec/tags/2.2.0/core/module/attr_spec.rb +1 -0
- data/spec/tags/2.3.0/core/hash/slice_spec.rb +1 -0
- data/spec/tags/2.3.0/core/module/attr_spec.rb +1 -0
- data/spec/tags/2.4.0/core/hash/slice_spec.rb +1 -0
- data/spec/tags/2.4.0/core/module/attr_spec.rb +1 -0
- data/test/_backport_guards_test.rb +5 -1
- metadata +75 -239
- data/spec/tags/1.8.6/core/argf/each_line_spec.rb +0 -6
- data/spec/tags/1.8.6/core/argf/each_spec.rb +0 -6
- data/spec/tags/1.8.6/core/argf/lines_spec.rb +0 -6
- data/spec/tags/1.8.6/core/array/bsearch_index_spec.rb +0 -1
- data/spec/tags/1.8.6/core/array/collect_spec.rb +0 -7
- data/spec/tags/1.8.6/core/array/rotate_spec.rb +0 -2
- data/spec/tags/1.8.6/core/array/uniq_spec.rb +0 -3
- data/spec/tags/1.8.6/core/complex/to_r_spec.rb +0 -3
- data/spec/tags/1.8.6/core/enumerable/each_entry_spec.rb +0 -1
- data/spec/tags/1.8.6/core/enumerator/next_spec.rb +0 -1
- data/spec/tags/1.8.6/core/env/to_h_spec.rb +0 -2
- data/spec/tags/1.8.6/core/file/join_spec.rb +0 -3
- data/spec/tags/1.8.6/core/file/lchmod_spec.rb +0 -2
- data/spec/tags/1.8.6/core/file/new_spec.rb +0 -2
- data/spec/tags/1.8.6/core/file/open_spec.rb +0 -13
- data/spec/tags/1.8.6/core/file/to_path_spec.rb +0 -1
- data/spec/tags/1.8.6/core/fixnum/fdiv_spec.rb +0 -1
- data/spec/tags/1.8.6/core/gc/stress_spec.rb +0 -2
- data/spec/tags/1.8.6/core/hash/assoc_spec.rb +0 -1
- data/spec/tags/1.8.6/core/hash/constructor_spec.rb +0 -3
- data/spec/tags/1.8.6/core/hash/default_proc_spec.rb +0 -3
- data/spec/tags/1.8.6/core/hash/delete_if_spec.rb +0 -1
- data/spec/tags/1.8.6/core/hash/each_pair_spec.rb +0 -1
- data/spec/tags/1.8.6/core/hash/eql_spec.rb +0 -3
- data/spec/tags/1.8.6/core/hash/hash_spec.rb +0 -3
- data/spec/tags/1.8.6/core/hash/keep_if_spec.rb +0 -2
- data/spec/tags/1.8.6/core/hash/rassoc_spec.rb +0 -1
- data/spec/tags/1.8.6/core/hash/reject_spec.rb +0 -2
- data/spec/tags/1.8.6/core/hash/select_spec.rb +0 -8
- data/spec/tags/1.8.6/core/hash/transform_values_spec.rb +0 -2
- data/spec/tags/1.8.6/core/integer/round_spec.rb +0 -2
- data/spec/tags/1.8.6/core/io/binread_spec.rb +0 -7
- data/spec/tags/1.8.6/core/io/chars_spec.rb +0 -1
- data/spec/tags/1.8.6/core/io/each_char_spec.rb +0 -1
- data/spec/tags/1.8.6/core/io/lines_spec.rb +0 -1
- data/spec/tags/1.8.6/core/io/open_spec.rb +0 -24
- data/spec/tags/1.8.6/core/io/ungetbyte_spec.rb +0 -4
- data/spec/tags/1.8.6/core/io/write_spec.rb +0 -5
- data/spec/tags/1.8.6/core/kernel/__callee___spec.rb +0 -6
- data/spec/tags/1.8.6/core/kernel/__method___spec.rb +0 -1
- data/spec/tags/1.8.6/core/kernel/define_singleton_method_spec.rb +0 -2
- data/spec/tags/1.8.6/core/kernel/public_method_spec.rb +0 -2
- data/spec/tags/1.8.6/core/kernel/require_relative_spec.rb +0 -3
- data/spec/tags/1.8.6/core/math/log2_spec.rb +0 -6
- data/spec/tags/1.8.6/core/math/log_spec.rb +0 -3
- data/spec/tags/1.8.6/core/module/class_exec_spec.rb +0 -2
- data/spec/tags/1.8.6/core/module/module_exec_spec.rb +0 -2
- data/spec/tags/1.8.6/core/numeric/step_spec.rb +0 -12
- data/spec/tags/1.8.6/core/proc/curry_spec.rb +0 -4
- data/spec/tags/1.8.6/core/range/step_spec.rb +0 -12
- data/spec/tags/1.8.6/core/string/getbyte_spec.rb +0 -6
- data/spec/tags/1.8.6/core/string/partition_spec.rb +0 -1
- data/spec/tags/1.8.6/core/string/prepend_spec.rb +0 -1
- data/spec/tags/1.8.6/core/string/rpartition_spec.rb +0 -1
- data/spec/tags/1.8.6/core/string/setbyte_spec.rb +0 -5
- data/spec/tags/1.8.6/core/string/uplus_spec.rb +0 -1
- data/spec/tags/1.8.6/core/string/upto_spec.rb +0 -1
- data/spec/tags/1.8.6/core/symbol/capitalize_spec.rb +0 -3
- data/spec/tags/1.8.6/core/symbol/comparison_spec.rb +0 -1
- data/spec/tags/1.8.6/core/symbol/downcase_spec.rb +0 -2
- data/spec/tags/1.8.6/core/symbol/element_reference_spec.rb +0 -4
- data/spec/tags/1.8.6/core/symbol/empty_spec.rb +0 -1
- data/spec/tags/1.8.6/core/symbol/match_spec.rb +0 -2
- data/spec/tags/1.8.6/core/symbol/swapcase_spec.rb +0 -2
- data/spec/tags/1.8.6/core/symbol/to_proc_spec.rb +0 -1
- data/spec/tags/1.8.6/core/symbol/upcase_spec.rb +0 -1
- data/spec/tags/1.8.7/core/array/bsearch_index_spec.rb +0 -1
- data/spec/tags/1.8.7/core/array/keep_if_spec.rb +0 -2
- data/spec/tags/1.8.7/core/array/rotate_spec.rb +0 -2
- data/spec/tags/1.8.7/core/array/select_spec.rb +0 -2
- data/spec/tags/1.8.7/core/array/uniq_spec.rb +0 -3
- data/spec/tags/1.8.7/core/complex/to_r_spec.rb +0 -3
- data/spec/tags/1.8.7/core/enumerable/collect_concat_spec.rb +0 -1
- data/spec/tags/1.8.7/core/enumerable/flat_map_spec.rb +0 -1
- data/spec/tags/1.8.7/core/env/to_h_spec.rb +0 -2
- data/spec/tags/1.8.7/core/file/lchmod_spec.rb +0 -2
- data/spec/tags/1.8.7/core/file/new_spec.rb +0 -1
- data/spec/tags/1.8.7/core/file/open_spec.rb +0 -5
- data/spec/tags/1.8.7/core/file/readlink_spec.rb +0 -6
- data/spec/tags/1.8.7/core/file/to_path_spec.rb +0 -1
- data/spec/tags/1.8.7/core/hash/assoc_spec.rb +0 -1
- data/spec/tags/1.8.7/core/hash/default_proc_spec.rb +0 -3
- data/spec/tags/1.8.7/core/hash/keep_if_spec.rb +0 -2
- data/spec/tags/1.8.7/core/hash/rassoc_spec.rb +0 -1
- data/spec/tags/1.8.7/core/hash/select_spec.rb +0 -1
- data/spec/tags/1.8.7/core/hash/transform_values_spec.rb +0 -2
- data/spec/tags/1.8.7/core/integer/round_spec.rb +0 -2
- data/spec/tags/1.8.7/core/io/binread_spec.rb +0 -7
- data/spec/tags/1.8.7/core/io/open_spec.rb +0 -32
- data/spec/tags/1.8.7/core/io/ungetbyte_spec.rb +0 -4
- data/spec/tags/1.8.7/core/io/write_spec.rb +0 -5
- data/spec/tags/1.8.7/core/kernel/__callee___spec.rb +0 -6
- data/spec/tags/1.8.7/core/kernel/define_singleton_method_spec.rb +0 -2
- data/spec/tags/1.8.7/core/kernel/public_method_spec.rb +0 -1
- data/spec/tags/1.8.7/core/kernel/require_relative_spec.rb +0 -3
- data/spec/tags/1.8.7/core/math/log2_spec.rb +0 -6
- data/spec/tags/1.8.7/core/math/log_spec.rb +0 -3
- data/spec/tags/1.8.7/core/module/include_spec.rb +0 -3
- data/spec/tags/1.8.7/core/proc/curry_spec.rb +0 -3
- data/spec/tags/1.8.7/core/proc/yield_spec.rb +0 -4
- data/spec/tags/1.8.7/core/range/size_spec.rb +0 -1
- data/spec/tags/1.8.7/core/string/getbyte_spec.rb +0 -5
- data/spec/tags/1.8.7/core/string/prepend_spec.rb +0 -1
- data/spec/tags/1.8.7/core/string/setbyte_spec.rb +0 -5
- data/spec/tags/1.8.7/core/string/uplus_spec.rb +0 -1
- data/spec/tags/1.8.7/core/symbol/capitalize_spec.rb +0 -3
- data/spec/tags/1.8.7/core/symbol/comparison_spec.rb +0 -1
- data/spec/tags/1.8.7/core/symbol/downcase_spec.rb +0 -2
- data/spec/tags/1.8.7/core/symbol/element_reference_spec.rb +0 -4
- data/spec/tags/1.8.7/core/symbol/empty_spec.rb +0 -1
- data/spec/tags/1.8.7/core/symbol/match_spec.rb +0 -2
- data/spec/tags/1.8.7/core/symbol/swapcase_spec.rb +0 -2
- data/spec/tags/1.8.7/core/symbol/upcase_spec.rb +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
ODRmY2Q4YmY5NzU5YTM0NzM3NjgwYTBkZWNiNTczM2JiM2FmNWZhYw==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
OWFjNjgyNDQ5ZWM4MDMwYjUyYTUxYWI2MjJlZGQ2NWI1ZmMxOTI1Yg==
|
|
5
7
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
ZTY4N2YzYzYzY2YzNTkxOWYzNTJmOWQ5ZmU5ZjZjYzA4ZWExNWMwOTMzODI5
|
|
10
|
+
ZmExMGEwNTdmZjk5OTRhMjhmNzMwNzMzYjViYjhhMzg3YWI3MjU5NzNlN2I2
|
|
11
|
+
YTZiZWRiYzVlZTFkNDJmM2FiMjIwZjEwODFmZGUwNzZkMjRlODQ=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
NjI2ZjkzODNhNDZlMTRhYWVhYTkxYjNhYTVjMDQ2NTk0YjI0NzY0Yzg4OTky
|
|
14
|
+
MjRkM2VjNzgxZmUxYzQ4YmMyNWE2MTJiNmM1Njg4MTU1MmQ1YWExMzkyZmU1
|
|
15
|
+
Mzc4MmNmZDE1OTVmZmUzMGE5ODkwOGZmYjAyMWMxZDNmYmQyYjU=
|
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
= Backports Library {<img src="https://travis-ci.org/marcandre/backports.svg?branch=master">}[https://travis-ci.org/marcandre/backports] {<img src="https://badge.fury.io/rb/backports.svg" alt="Gem Version" />}[http://badge.fury.io/rb/backports]
|
|
2
2
|
|
|
3
|
-
Yearning to use some of the new cool features in Ruby 2.
|
|
3
|
+
Yearning to use some of the new cool features in Ruby 2.6 while using 2.3.x? Have some legacy code in Ruby 1.8 but can't live without `flat_map`?
|
|
4
4
|
|
|
5
5
|
This gem is for you!
|
|
6
6
|
|
|
@@ -75,6 +75,21 @@ Compatible with Ruby itself, JRuby and Rubinius.
|
|
|
75
75
|
|
|
76
76
|
= Complete List of backports
|
|
77
77
|
|
|
78
|
+
== Ruby 2.6 backports
|
|
79
|
+
|
|
80
|
+
* Array
|
|
81
|
+
* +difference+, +union+
|
|
82
|
+
* +to_h+ (with block)
|
|
83
|
+
|
|
84
|
+
* Enumerable
|
|
85
|
+
* +chain+
|
|
86
|
+
* +to_h+ (with block)
|
|
87
|
+
|
|
88
|
+
* Enumerator::Chain (use Enumerable#chain)
|
|
89
|
+
|
|
90
|
+
* Kernel
|
|
91
|
+
* +then+
|
|
92
|
+
|
|
78
93
|
== Ruby 2.5 backports
|
|
79
94
|
|
|
80
95
|
* Array
|
|
@@ -97,6 +112,7 @@ Compatible with Ruby itself, JRuby and Rubinius.
|
|
|
97
112
|
* String
|
|
98
113
|
* +delete_prefix+, +delete_prefix!+
|
|
99
114
|
* +delete_suffix+, +delete_suffix!+
|
|
115
|
+
* +undump+
|
|
100
116
|
* Struct
|
|
101
117
|
* +new+ (with <code>keyword_init: true</code>)
|
|
102
118
|
|
|
@@ -111,9 +127,9 @@ Compatible with Ruby itself, JRuby and Rubinius.
|
|
|
111
127
|
* +compact+, +compact!+
|
|
112
128
|
* +transform_values+, +transform_values!+
|
|
113
129
|
* Regexp
|
|
114
|
-
* +match?+
|
|
130
|
+
* +match?+
|
|
115
131
|
* String
|
|
116
|
-
* +match?+
|
|
132
|
+
* +match?+
|
|
117
133
|
* FalseClass, Fixnum, Float, NilClass, TrueClass
|
|
118
134
|
* +dup+
|
|
119
135
|
|
|
@@ -375,12 +391,17 @@ Thanks for the bug reports and patches, in particular the repeat offenders:
|
|
|
375
391
|
* Konstantin Haase ( rkh[https://github.com/rkh])
|
|
376
392
|
* Roger Pack ( rdp[http://github.com/rdp] )
|
|
377
393
|
|
|
378
|
-
|
|
394
|
+
== Contributing
|
|
395
|
+
|
|
396
|
+
The best way to submit a patch is to also submit a patch to ruby/spec[https://github.com/ruby/spec] and then a patch to backports that make it pass the spec.
|
|
397
|
+
|
|
398
|
+
See below to test rubyspec. Note that only features missing from your Ruby version are tested.
|
|
379
399
|
|
|
380
400
|
git submodule init && git submodule update # => pulls rubyspecs
|
|
381
|
-
|
|
382
|
-
rake spec[
|
|
383
|
-
|
|
401
|
+
bundle install
|
|
402
|
+
bundle exec rake spec[hash/slice] # => tests Hash#slice (must be in Ruby 2.4 or less)
|
|
403
|
+
bundle exec rake spec[hash/*] # => tests all backported Hash methods
|
|
404
|
+
bundle exec rake spec (or rake spec[*/*]) # => all rubyspecs for backported methods
|
|
384
405
|
|
|
385
406
|
Failures that are acceptable are added the to `tags` file.
|
|
386
407
|
|
data/Rakefile
CHANGED
|
@@ -62,9 +62,15 @@ desc "Run specs, where path can be '*/*' (default), 'class/*' or 'class/method'.
|
|
|
62
62
|
task :spec, :path, :action do |t, args|
|
|
63
63
|
args.with_defaults(:path => '*/*', :action => 'ci')
|
|
64
64
|
specs = SpecRunner.new
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
# Avoid unclear error message by checking if at least one spec exists in the old specs
|
|
67
|
+
has_frozen_spec = !Dir.glob('frozen_old_spec/rubyspec/core/#{path}_spec.rb')
|
|
68
|
+
if has_frozen_spec || RUBY_VERSION < '1.9'
|
|
69
|
+
mspec_cmds(args[:path], 'frozen_old_spec', args[:action]) do |cmd, path|
|
|
70
|
+
specs.run(cmd, path)
|
|
71
|
+
end
|
|
67
72
|
end
|
|
73
|
+
|
|
68
74
|
unless RUBY_VERSION < '1.9' # Give up entirely on running new specs in 1.8.x, mainly because of {hash: 'syntax'}
|
|
69
75
|
mspec_cmds(args[:path], 'spec', args[:action]) do |cmd, path|
|
|
70
76
|
specs.run(cmd, path)
|
|
@@ -128,6 +134,7 @@ IGNORE_IN_19 = %w[
|
|
|
128
134
|
2.1.0/enumerable/to_h
|
|
129
135
|
2.1.0/array/to_h
|
|
130
136
|
2.1.0/module/include
|
|
137
|
+
2.2.0/kernel/itself
|
|
131
138
|
2.5.0/module/define_method
|
|
132
139
|
2.5.0/module/alias_method
|
|
133
140
|
2.5.0/module/undef_method
|
|
@@ -150,6 +157,10 @@ CLASS_MAP = Hash.new{|k, v| k[v] = v}.merge!(
|
|
|
150
157
|
'nil_class' => 'nil'
|
|
151
158
|
)
|
|
152
159
|
|
|
160
|
+
EXTRA_SPECS = {
|
|
161
|
+
'enumerable/chain' => %w[enumerator/chain/*]
|
|
162
|
+
}
|
|
163
|
+
|
|
153
164
|
def mspec_cmds(pattern, spec_folder, action='ci')
|
|
154
165
|
pattern = "lib/backports/*.*.*/#{pattern}.rb"
|
|
155
166
|
Dir.glob(pattern) do |lib_path|
|
|
@@ -166,12 +177,13 @@ def mspec_cmds(pattern, spec_folder, action='ci')
|
|
|
166
177
|
deps = [*DEPENDENCIES[version_path]].map{|p| "-r #{p}"}.join(' ')
|
|
167
178
|
klass, method = path.split('/')
|
|
168
179
|
path = [CLASS_MAP[klass], method].join('/')
|
|
180
|
+
spec_paths = [path, *EXTRA_SPECS[path]].map {|p| "#{spec_folder}/rubyspec/core/#{p}_spec.rb" }
|
|
169
181
|
yield %W[mspec #{action}
|
|
170
182
|
-I lib
|
|
171
183
|
-r ./set_version/#{version}
|
|
172
184
|
#{deps}
|
|
173
185
|
-r backports/#{version_path}
|
|
174
|
-
#{
|
|
186
|
+
#{spec_paths.join(' ')}
|
|
175
187
|
].join(' '), path
|
|
176
188
|
end
|
|
177
189
|
end
|
data/backports.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
|
8
8
|
gem.version = Backports::VERSION
|
|
9
9
|
gem.authors = ["Marc-André Lafortune"]
|
|
10
10
|
gem.email = ["github@marc-andre.ca"]
|
|
11
|
-
gem.description = %q{Essential backports that enable many of the nice features of Ruby
|
|
11
|
+
gem.description = %q{Essential backports that enable many of the nice features of Ruby for earlier versions.}
|
|
12
12
|
gem.summary = %q{Backports of Ruby features for older Ruby.}
|
|
13
13
|
gem.homepage = "http://github.com/marcandre/backports"
|
|
14
14
|
gem.license = "MIT"
|
|
@@ -17,4 +17,10 @@ Gem::Specification.new do |gem|
|
|
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
gem.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
if gem.respond_to?(:metadata)
|
|
22
|
+
gem.metadata['changelog_uri'] = 'https://github.com/marcandre/backports/blob/master/CHANGELOG.rdoc'
|
|
23
|
+
gem.metadata['source_code_uri'] = 'https://github.com/marcandre/backports'
|
|
24
|
+
gem.metadata['bug_tracker_uri'] = 'https://github.com/marcandre/backports/issues'
|
|
25
|
+
end
|
|
20
26
|
end
|
data/default.mspec
CHANGED
|
@@ -2,7 +2,12 @@ if (Backports::TARGET_VERSION rescue false) # Conf loaded at different times, no
|
|
|
2
2
|
class MSpecScript
|
|
3
3
|
# The set of substitutions to transform a spec filename
|
|
4
4
|
# into a tag filename.
|
|
5
|
-
|
|
5
|
+
main_version = RUBY_VERSION
|
|
6
|
+
unless File.exist?(File.expand_path("../lib/backports/#{main_version}.rb", __FILE__))
|
|
7
|
+
main_version = main_version.sub(/\.\d+$/, '.0')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
set :tags_patterns, [ [%r(rubyspec/), "tags/#{main_version}/"] ]
|
|
6
11
|
end
|
|
7
12
|
|
|
8
13
|
SpecGuard.ruby_version_override = Backports::TARGET_VERSION if Backports::TARGET_VERSION > RUBY_VERSION
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
unless String.method_defined? :undump
|
|
2
|
+
class String
|
|
3
|
+
def undump
|
|
4
|
+
# Making sure to return a String and not a subclass
|
|
5
|
+
string = to_s
|
|
6
|
+
raise 'string contains null byte' if string["\0"]
|
|
7
|
+
raise 'non-ASCII character detected' unless string.ascii_only?
|
|
8
|
+
|
|
9
|
+
#raise '.force_encoding("...") format is not supported by backports' if string.match(/\A".*"\.force_encoding\("[^"]*"\)\z/)
|
|
10
|
+
match = string.match(/\A(".*?"?)(?:\.force_encoding\("([^"]*)"\))?\z/)
|
|
11
|
+
if match
|
|
12
|
+
string = match[1]
|
|
13
|
+
encoding = match[2]
|
|
14
|
+
else
|
|
15
|
+
raise %(invalid dumped string; not wrapped with '"' nor '"...".force_encoding("...")' form)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Ruby 1.9.3 does weird things to encoding during gsub
|
|
19
|
+
encoding ||= string.encoding.to_s
|
|
20
|
+
|
|
21
|
+
# Unescaped have an even number of backslashes in front of them
|
|
22
|
+
# because the double-quote is included, the unescaped quotes are where the size is odd
|
|
23
|
+
nb_unescaped_quote = string.scan(/\\*"/).select { |s| s.size.odd? }.size
|
|
24
|
+
|
|
25
|
+
raise 'unterminated dumped string' if nb_unescaped_quote == 1
|
|
26
|
+
|
|
27
|
+
if string[-1] != '"' || nb_unescaped_quote > 2
|
|
28
|
+
raise %(invalid dumped string; not wrapped with '"' nor '"...".force_encoding("...")' form)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
string = string[1...-1]
|
|
32
|
+
|
|
33
|
+
if RUBY_VERSION >= '1.9'
|
|
34
|
+
# Look-arounds are not supported in ruby 1.8. Using a string with Regexp avoids the SyntaxError in 1.8.7
|
|
35
|
+
# \xY, \x3Y and finishing with \x
|
|
36
|
+
regex = Regexp.new("(?<!\\)(?:\\\\)*\\x(?![0-9a-f]{2})".gsub('\\', '\\\\\\\\'), Regexp::IGNORECASE)
|
|
37
|
+
raise 'invalid hex escape' if string[regex]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# The real #undump ignores the \C, \c and \M escapes
|
|
41
|
+
# Code injection is avoided by:
|
|
42
|
+
# * only allowing \u to have {}, so \\\\#{injection} will not eval the injection
|
|
43
|
+
# * only allowing the first character after the \\ to not be alpha/num/space, so \\\\#@inst_var_access is ignored
|
|
44
|
+
# To reduce the number of calls to eval a little, we wrap everything in a (...)+ so that consecutive escapes are
|
|
45
|
+
# handled at the same time.
|
|
46
|
+
result = string.gsub(/(\\+(u\{[\w ]+\}|[^cCM][\w]*))+/) do |s|
|
|
47
|
+
begin
|
|
48
|
+
eval("\"#{s}\"")
|
|
49
|
+
rescue SyntaxError => e
|
|
50
|
+
raise RuntimeError, e.message, e.backtrace
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
if encoding
|
|
55
|
+
begin
|
|
56
|
+
Encoding.find(encoding)
|
|
57
|
+
rescue ArgumentError
|
|
58
|
+
raise "dumped string has unknown encoding name"
|
|
59
|
+
end
|
|
60
|
+
result = result.force_encoding(encoding)
|
|
61
|
+
end
|
|
62
|
+
result
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'backports/2.1.0/array/to_h' unless Array.method_defined? :to_h
|
|
2
|
+
|
|
3
|
+
if [[:need, true]].to_h { [:need, false] } [:need]
|
|
4
|
+
require 'backports/tools/alias_method_chain'
|
|
5
|
+
|
|
6
|
+
class Array
|
|
7
|
+
def to_h_with_block(&block)
|
|
8
|
+
receiver = block ? map(&block) : self
|
|
9
|
+
receiver.to_h_without_block
|
|
10
|
+
end
|
|
11
|
+
Backports.alias_method_chain self, :to_h, :block
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
unless Enumerable.method_defined? :chain
|
|
2
|
+
module Enumerable
|
|
3
|
+
def chain(*enums)
|
|
4
|
+
Enumerator::Chain.new(self, *enums)
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
Enumerator = Enumerable::Enumerator unless Object.const_defined? :Enumerator # For 1.8.x
|
|
9
|
+
|
|
10
|
+
class Enumerator::Chain < Enumerator
|
|
11
|
+
def initialize(*enums)
|
|
12
|
+
@enums = enums
|
|
13
|
+
@rewindable = -1
|
|
14
|
+
self
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def each(*args, &block)
|
|
18
|
+
@enums.each_with_index do |enum, i|
|
|
19
|
+
@rewindable = i
|
|
20
|
+
enum.each(*args, &block)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def size
|
|
25
|
+
sum = 0
|
|
26
|
+
@enums.each do |enum|
|
|
27
|
+
s = enum.size
|
|
28
|
+
return s if s == nil || s == Float::INFINITY
|
|
29
|
+
sum += s
|
|
30
|
+
end
|
|
31
|
+
sum
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def inspect
|
|
35
|
+
detail = @enums.map(&:inspect).join(', ')
|
|
36
|
+
"#<Enumerator::Chain: [#{detail}]>"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def rewind
|
|
40
|
+
@rewindable.downto(0) do |i|
|
|
41
|
+
enum = @enums[i]
|
|
42
|
+
enum.rewind if enum.respond_to? :rewind
|
|
43
|
+
end
|
|
44
|
+
self
|
|
45
|
+
end
|
|
46
|
+
end unless Enumerator.const_defined? :Chain
|
|
47
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'backports/2.1.0/enumerable/to_h' unless Enumerable.method_defined? :to_h
|
|
2
|
+
|
|
3
|
+
if Enumerable.instance_method(:to_h).bind([[:need, true]]).call { [:need, false] } [:need]
|
|
4
|
+
require 'backports/tools/alias_method_chain'
|
|
5
|
+
|
|
6
|
+
module Enumerable
|
|
7
|
+
def to_h_with_block(*args, &block)
|
|
8
|
+
return to_h_without_block(*args) unless block
|
|
9
|
+
map(*args, &block).to_h_without_block
|
|
10
|
+
end
|
|
11
|
+
Backports.alias_method_chain self, :to_h, :block
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/backports/version.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/setter")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fails:Module#attr with a boolean argument emits a warning when $VERBOSE is true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fails:Hash#slice uses the regular Hash#[] method, even on subclasses that override it
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fails:Module#attr with a boolean argument emits a warning when $VERBOSE is true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fails:Hash#slice uses the regular Hash#[] method, even on subclasses that override it
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fails:Kernel#then returns a sized Enumerator when no block given
|