Skip to content

Commit

Permalink
(PUP-7038) deprecate ruby 2.0
Browse files Browse the repository at this point in the history
This commit adds a deprecation warning for users running puppet under a version
older than 2.1.0. This is accomplished by adding a new constant,
Puppet::OLDEST_RECOMMENDED_RUBY_VERSION, which we later test for in issuing a
deprecation warning.

Signed-off-by: Moses Mendoza <moses@puppet.com>
  • Loading branch information
Moses Mendoza committed Jan 11, 2017
1 parent e4866ac commit e9eda7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
raise LoadError, "Puppet #{Puppet.version} requires ruby 1.9.3 or greater."
end

Puppet::OLDEST_RECOMMENDED_RUBY_VERSION = '2.1.0'

# see the bottom of the file for further inclusions
# Also see the new Vendor support - towards the end
#
Expand Down Expand Up @@ -141,6 +143,12 @@ def self.run_mode
# Load all of the settings.
require 'puppet/defaults'

# Now that settings are loaded we have the code loaded to be able to issue
# deprecation warnings. Warn if we're on a deprecated ruby version.
if RUBY_VERSION < Puppet::OLDEST_RECOMMENDED_RUBY_VERSION
Puppet.deprecation_warning("Support for ruby version #{RUBY_VERSION} is deprecated and will be removed in a future release. See https://docs.puppet.com/puppet/latest/system_requirements.html#ruby for a list of supported ruby versions.")
end

# Initialize puppet's settings. This is intended only for use by external tools that are not
# built off of the Faces API or the Puppet::Util::Application class. It may also be used
# to initialize state so that a Face may be used programatically, rather than as a stand-alone
Expand Down
14 changes: 14 additions & 0 deletions spec/unit/puppet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@
expect($LOAD_PATH).to include two
end

context "Puppet::OLDEST_RECOMMENDED_RUBY_VERSION" do
it "should have an oldest recommended ruby version constant" do
expect(Puppet::OLDEST_RECOMMENDED_RUBY_VERSION).not_to be_nil
end

it "should be a string" do
expect(Puppet::OLDEST_RECOMMENDED_RUBY_VERSION).to be_a_kind_of(String)
end

it "should match a semver version" do
expect(SemVer).to be_valid(Puppet::OLDEST_RECOMMENDED_RUBY_VERSION)
end
end

context "newtype" do
it "should issue a deprecation warning" do
subject.expects(:deprecation_warning).with("Creating sometype via Puppet.newtype is deprecated and will be removed in a future release. Use Puppet::Type.newtype instead.")
Expand Down

0 comments on commit e9eda7e

Please sign in to comment.