Set 2.6 as minimum ruby version for Sinatra 3 (#1699)
* Run tests for Ruby versions >= 2.6 * Remove not needed checks for methods defined * Set required_ruby_version to >= 2.6 * Update READMEs with new Ruby versions
This commit is contained in:
parent
9dede30f5d
commit
9a924aa894
|
@ -15,7 +15,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
||||||
# TODO: Add jruby if something like allow_failures will be implemented on Actions.
|
# TODO: Add jruby if something like allow_failures will be implemented on Actions.
|
||||||
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0']
|
ruby: [2.6, 2.7, '3.0']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: ruby/setup-ruby@v1
|
- uses: ruby/setup-ruby@v1
|
||||||
|
|
|
@ -3082,9 +3082,9 @@ thin --threaded start
|
||||||
Die folgenden Versionen werden offiziell unterstützt:
|
Die folgenden Versionen werden offiziell unterstützt:
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Ruby 2.3</dt>
|
<dt>Ruby 2.6</dt>
|
||||||
<dd>
|
<dd>
|
||||||
2.3 wird vollständig unterstützt. Es gibt derzeit keine Pläne die
|
2.6 wird vollständig unterstützt. Es gibt derzeit keine Pläne die
|
||||||
offizielle Unterstützung zu beenden
|
offizielle Unterstützung zu beenden
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
@ -3103,7 +3103,7 @@ Die folgenden Versionen werden offiziell unterstützt:
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
Versionen vor Ruby 2.2.2 werden ab Sinatra 2.0 nicht länger unterstützt.
|
Versionen vor Ruby 2.6 werden ab Sinatra 3.0 nicht länger unterstützt.
|
||||||
|
|
||||||
Nachfolgende Ruby-Versionen werden regelmäßig auf Unterstützung geprüft.
|
Nachfolgende Ruby-Versionen werden regelmäßig auf Unterstützung geprüft.
|
||||||
|
|
||||||
|
|
|
@ -3075,9 +3075,9 @@ rainbows -c rainbows.conf
|
||||||
Las siguientes versiones de Ruby son soportadas oficialmente:
|
Las siguientes versiones de Ruby son soportadas oficialmente:
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Ruby 2.3</dt>
|
<dt>Ruby 2.6</dt>
|
||||||
<dd>
|
<dd>
|
||||||
2.3 Es totalmente compatible y recomendado. Actualmente no hay planes
|
2.6 Es totalmente compatible y recomendado. Actualmente no hay planes
|
||||||
soltar el apoyo oficial para ello.
|
soltar el apoyo oficial para ello.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
@ -3095,7 +3095,7 @@ Las siguientes versiones de Ruby son soportadas oficialmente:
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
Las versiones de Ruby anteriores a 2.2.2 ya no son compatibles con Sinatra 2.0 .
|
Las versiones de Ruby anteriores a 2.6 ya no son compatibles con Sinatra 3.0 .
|
||||||
|
|
||||||
Siempre le prestamos atención a las nuevas versiones de Ruby.
|
Siempre le prestamos atención a las nuevas versiones de Ruby.
|
||||||
|
|
||||||
|
|
|
@ -3047,9 +3047,9 @@ rainbows -c rainbows.conf
|
||||||
|
|
||||||
The following Ruby versions are officially supported:
|
The following Ruby versions are officially supported:
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Ruby 2.3</dt>
|
<dt>Ruby 2.6</dt>
|
||||||
<dd>
|
<dd>
|
||||||
2.3 is fully supported and recommended. There are currently no plans to
|
2.6 is fully supported and recommended. There are currently no plans to
|
||||||
drop official support for it.
|
drop official support for it.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
@ -3067,7 +3067,7 @@ The following Ruby versions are officially supported:
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
Versions of Ruby before 2.3 are no longer supported as of Sinatra 2.1.0.
|
Versions of Ruby before 2.6 are no longer supported as of Sinatra 3.0.0.
|
||||||
|
|
||||||
We also keep an eye on upcoming Ruby versions.
|
We also keep an eye on upcoming Ruby versions.
|
||||||
|
|
||||||
|
|
|
@ -3051,9 +3051,9 @@ thin --threaded start
|
||||||
|
|
||||||
Следующие версии Ruby официально поддерживаются:
|
Следующие версии Ruby официально поддерживаются:
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Ruby 2.3</dt>
|
<dt>Ruby 2.6</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Версия 2.3 полностью поддерживается и рекомендуется. В настоящее время нет
|
Версия 2.6 полностью поддерживается и рекомендуется. В настоящее время нет
|
||||||
планов отказаться от официальной поддержки.
|
планов отказаться от официальной поддержки.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
@ -3071,7 +3071,7 @@ thin --threaded start
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
Версии Ruby ниже 2.2.2 более не поддерживаются в Sinatra 2.0.
|
Версии Ruby ниже 2.6 более не поддерживаются в Sinatra 3.0.
|
||||||
|
|
||||||
Мы также следим за предстоящими к выходу версиями Ruby.
|
Мы также следим за предстоящими к выходу версиями Ruby.
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
$stderr.puts <<EOF if !Hash.method_defined?(:slice) && !$LOAD_PATH.grep(%r{gems/activesupport}).empty? && ENV['SINATRA_ACTIVESUPPORT_WARNING'] != 'false'
|
|
||||||
WARNING: If you plan to load any of ActiveSupport's core extensions to Hash, be
|
|
||||||
sure to do so *before* loading Sinatra::Application or Sinatra::Base. If not,
|
|
||||||
you may disregard this warning.
|
|
||||||
|
|
||||||
Set SINATRA_ACTIVESUPPORT_WARNING=false in the environment to hide this warning.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
module Sinatra
|
module Sinatra
|
||||||
# A poor man's ActiveSupport::HashWithIndifferentAccess, with all the Rails-y
|
# A poor man's ActiveSupport::HashWithIndifferentAccess, with all the Rails-y
|
||||||
|
@ -112,19 +105,19 @@ module Sinatra
|
||||||
|
|
||||||
def dig(key, *other_keys)
|
def dig(key, *other_keys)
|
||||||
super(convert_key(key), *other_keys)
|
super(convert_key(key), *other_keys)
|
||||||
end if method_defined?(:dig) # Added in Ruby 2.3
|
end
|
||||||
|
|
||||||
def fetch_values(*keys)
|
def fetch_values(*keys)
|
||||||
keys.map!(&method(:convert_key))
|
keys.map!(&method(:convert_key))
|
||||||
|
|
||||||
super(*keys)
|
super(*keys)
|
||||||
end if method_defined?(:fetch_values) # Added in Ruby 2.3
|
end
|
||||||
|
|
||||||
def slice(*keys)
|
def slice(*keys)
|
||||||
keys.map!(&method(:convert_key))
|
keys.map!(&method(:convert_key))
|
||||||
|
|
||||||
self.class[super(*keys)]
|
self.class[super(*keys)]
|
||||||
end if method_defined?(:slice) # Added in Ruby 2.5
|
end
|
||||||
|
|
||||||
def values_at(*keys)
|
def values_at(*keys)
|
||||||
keys.map!(&method(:convert_key))
|
keys.map!(&method(:convert_key))
|
||||||
|
@ -158,7 +151,6 @@ module Sinatra
|
||||||
super(other_hash.is_a?(self.class) ? other_hash : self.class[other_hash])
|
super(other_hash.is_a?(self.class) ? other_hash : self.class[other_hash])
|
||||||
end
|
end
|
||||||
|
|
||||||
if method_defined?(:transform_values!) # Added in Ruby 2.4
|
|
||||||
def transform_values(&block)
|
def transform_values(&block)
|
||||||
dup.transform_values!(&block)
|
dup.transform_values!(&block)
|
||||||
end
|
end
|
||||||
|
@ -167,9 +159,7 @@ module Sinatra
|
||||||
super
|
super
|
||||||
super(&method(:convert_value))
|
super(&method(:convert_value))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if method_defined?(:transform_keys!) # Added in Ruby 2.5
|
|
||||||
def transform_keys(&block)
|
def transform_keys(&block)
|
||||||
dup.transform_keys!(&block)
|
dup.transform_keys!(&block)
|
||||||
end
|
end
|
||||||
|
@ -178,7 +168,6 @@ module Sinatra
|
||||||
super
|
super
|
||||||
super(&method(:convert_key))
|
super(&method(:convert_key))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def select(*args, &block)
|
def select(*args, &block)
|
||||||
return to_enum(:select) unless block_given?
|
return to_enum(:select) unless block_given?
|
||||||
|
|
|
@ -34,7 +34,7 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
s.required_ruby_version = '>= 2.3.0'
|
s.required_ruby_version = '>= 2.6.0'
|
||||||
|
|
||||||
s.add_dependency "sinatra", version
|
s.add_dependency "sinatra", version
|
||||||
s.add_dependency "mustermann", "~> 1.0"
|
s.add_dependency "mustermann", "~> 1.0"
|
||||||
|
|
|
@ -40,7 +40,7 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
s.required_ruby_version = '>= 2.3.0'
|
s.required_ruby_version = '>= 2.6.0'
|
||||||
|
|
||||||
s.add_dependency 'rack', '~> 2.2'
|
s.add_dependency 'rack', '~> 2.2'
|
||||||
s.add_dependency 'tilt', '~> 2.0'
|
s.add_dependency 'tilt', '~> 2.0'
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
#
|
#
|
||||||
require 'minitest/autorun' unless defined?(Minitest)
|
require 'minitest/autorun' unless defined?(Minitest)
|
||||||
|
|
||||||
# Suppress the ActiveSupport warning when this test is executed independently,
|
|
||||||
# outside of the full suite, on older Rubies.
|
|
||||||
ENV['SINATRA_ACTIVESUPPORT_WARNING'] = 'false'
|
|
||||||
|
|
||||||
require_relative '../lib/sinatra/indifferent_hash'
|
require_relative '../lib/sinatra/indifferent_hash'
|
||||||
|
|
||||||
class TestIndifferentHashBasics < Minitest::Test
|
class TestIndifferentHashBasics < Minitest::Test
|
||||||
|
@ -69,10 +65,6 @@ class TestIndifferentHashBasics < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestIndifferentHash < Minitest::Test
|
class TestIndifferentHash < Minitest::Test
|
||||||
def skip_if_lacking(meth)
|
|
||||||
skip "Hash##{meth} not supported on this Ruby" unless Hash.method_defined?(meth)
|
|
||||||
end
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@hash = Sinatra::IndifferentHash[:a=>:a, ?b=>:b, 3=>3,
|
@hash = Sinatra::IndifferentHash[:a=>:a, ?b=>:b, 3=>3,
|
||||||
:simple_nested=>{ :a=>:a, ?b=>:b },
|
:simple_nested=>{ :a=>:a, ?b=>:b },
|
||||||
|
@ -158,8 +150,6 @@ class TestIndifferentHash < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dig
|
def test_dig
|
||||||
skip_if_lacking :dig
|
|
||||||
|
|
||||||
assert_equal :a, @hash.dig(:a)
|
assert_equal :a, @hash.dig(:a)
|
||||||
assert_equal :b, @hash.dig(?b)
|
assert_equal :b, @hash.dig(?b)
|
||||||
assert_nil @hash.dig(:d)
|
assert_nil @hash.dig(:d)
|
||||||
|
@ -174,8 +164,6 @@ class TestIndifferentHash < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_slice
|
def test_slice
|
||||||
skip_if_lacking :slice
|
|
||||||
|
|
||||||
assert_equal Sinatra::IndifferentHash[a: :a], @hash.slice(:a)
|
assert_equal Sinatra::IndifferentHash[a: :a], @hash.slice(:a)
|
||||||
assert_equal Sinatra::IndifferentHash[b: :b], @hash.slice(?b)
|
assert_equal Sinatra::IndifferentHash[b: :b], @hash.slice(?b)
|
||||||
assert_equal Sinatra::IndifferentHash[3 => 3], @hash.slice(3)
|
assert_equal Sinatra::IndifferentHash[3 => 3], @hash.slice(3)
|
||||||
|
@ -186,8 +174,6 @@ class TestIndifferentHash < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_values
|
def test_fetch_values
|
||||||
skip_if_lacking :fetch_values
|
|
||||||
|
|
||||||
assert_raises(KeyError) { @hash.fetch_values(3, :d) }
|
assert_raises(KeyError) { @hash.fetch_values(3, :d) }
|
||||||
assert_equal [:a, :b, 3, ?D], @hash.fetch_values(:a, ?b, 3, :d) { |k| k.upcase }
|
assert_equal [:a, :b, 3, ?D], @hash.fetch_values(:a, ?b, 3, :d) { |k| k.upcase }
|
||||||
end
|
end
|
||||||
|
@ -225,16 +211,12 @@ class TestIndifferentHash < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_transform_values!
|
def test_transform_values!
|
||||||
skip_if_lacking :transform_values!
|
|
||||||
|
|
||||||
@hash.transform_values! { |v| v.is_a?(Hash) ? Hash[v.to_a] : v }
|
@hash.transform_values! { |v| v.is_a?(Hash) ? Hash[v.to_a] : v }
|
||||||
|
|
||||||
assert_instance_of Sinatra::IndifferentHash, @hash[:simple_nested]
|
assert_instance_of Sinatra::IndifferentHash, @hash[:simple_nested]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_transform_values
|
def test_transform_values
|
||||||
skip_if_lacking :transform_values
|
|
||||||
|
|
||||||
hash2 = @hash.transform_values { |v| v.respond_to?(:upcase) ? v.upcase : v }
|
hash2 = @hash.transform_values { |v| v.respond_to?(:upcase) ? v.upcase : v }
|
||||||
|
|
||||||
refute_equal @hash, hash2
|
refute_equal @hash, hash2
|
||||||
|
@ -243,8 +225,6 @@ class TestIndifferentHash < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_transform_keys!
|
def test_transform_keys!
|
||||||
skip_if_lacking :transform_keys!
|
|
||||||
|
|
||||||
@hash.transform_keys! { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
|
@hash.transform_keys! { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
|
||||||
|
|
||||||
assert_equal :a, @hash[:a]
|
assert_equal :a, @hash[:a]
|
||||||
|
@ -252,8 +232,6 @@ class TestIndifferentHash < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_transform_keys
|
def test_transform_keys
|
||||||
skip_if_lacking :transform_keys
|
|
||||||
|
|
||||||
hash2 = @hash.transform_keys { |k| k.respond_to?(:upcase) ? k.upcase : k }
|
hash2 = @hash.transform_keys { |k| k.respond_to?(:upcase) ? k.upcase : k }
|
||||||
|
|
||||||
refute_equal @hash, hash2
|
refute_equal @hash, hash2
|
||||||
|
@ -300,8 +278,6 @@ class TestIndifferentHash < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_compact
|
def test_compact
|
||||||
skip_if_lacking :compact
|
|
||||||
|
|
||||||
hash_with_nil_values = @hash.merge({?z => nil})
|
hash_with_nil_values = @hash.merge({?z => nil})
|
||||||
compacted_hash = hash_with_nil_values.compact
|
compacted_hash = hash_with_nil_values.compact
|
||||||
assert_equal @hash, compacted_hash
|
assert_equal @hash, compacted_hash
|
||||||
|
|
Loading…
Reference in New Issue