Merge pull request #4680 from inspec/btm/warn-objects

Deprecate inspec/object/* classes
This commit is contained in:
Bryan McLellan 2019-11-12 15:30:45 -05:00 committed by GitHub
commit e4a096ba83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 58 additions and 1 deletions

View file

@ -116,6 +116,10 @@
"wmi_non_hash_usage": {
"action": "fail_control",
"suffix": "This property was removed in InSpec 4.0."
},
"object_classes": {
"action": "warn",
"suffix": "These classes will be removed in InSpec 5.0."
}
}
}

View file

@ -1,3 +1,8 @@
# This class is deprecated and will be removed in the next major release of InSpec.
# Use the Inspec::Object classes from the inspec-objects rubygem instead.
require "inspec/utils/deprecation"
module Inspec
class Control
attr_accessor :id, :title, :descriptions, :impact, :tests, :tags, :refs, :only_if
@ -6,6 +11,8 @@ module Inspec
@tags = []
@refs = []
@descriptions = {}
Inspec.deprecate(:object_classes, "The Inspec::Control class is deprecated. Use the Inspec::Object::Control class from the inspec-objects Ruby library.")
end
def add_test(t)

View file

@ -1,3 +1,8 @@
# This class is deprecated and will be removed in the next major release of InSpec.
# Use the Inspec::Object classes from the inspec-objects rubygem instead.
require "inspec/utils/deprecation"
module Inspec
class Describe
# Internal helper to structure test objects.
@ -53,6 +58,8 @@ module Inspec
@qualifier = []
@tests = []
@variables = []
Inspec.deprecate(:object_classes, "The Inspec::Describe class is deprecated. Use the Inspec::Object::Describe class from the inspec-objects Ruby library.")
end
def add_test(its, matcher, expectation, opts = {})

View file

@ -1,3 +1,8 @@
# This class is deprecated and will be removed in the next major release of InSpec.
# Use the Inspec::Object classes from the inspec-objects rubygem instead.
require "inspec/utils/deprecation"
module Inspec
class EachLoop < List
attr_reader :variables
@ -6,6 +11,8 @@ module Inspec
super
@tests = []
@variables = []
Inspec.deprecate(:object_classes, "The Inspec::EachLoop class is deprecated. Use the Inspec::Object::EachLoop class from the inspec-objects Ruby library.")
end
def add_test(t = nil)

View file

@ -1,3 +1,7 @@
# This file is deprecated and will be removed in the next major release of InSpec.
# The Inspec::Input class will remain but these methods will be removed.
# Use the Inspec::Object::Input class from the inspec-objects rubygem instead.
require "inspec/input"
module Inspec

View file

@ -1,9 +1,16 @@
# This class is deprecated and will be removed in the next major release of InSpec.
# Use the Inspec::Object classes from the inspec-objects rubygem instead.
require "inspec/utils/deprecation"
module Inspec
class OrTest
attr_reader :tests
def initialize(tests)
@tests = tests
@negated = false
Inspec.deprecate(:object_classes, "The Inspec::OrTest class is deprecated. Use the Inspec::Object::OrTest class from the inspec-objects Ruby library.")
end
def skip

View file

@ -1,3 +1,8 @@
# This class is deprecated and will be removed in the next major release of InSpec.
# Use the Inspec::Object classes from the inspec-objects rubygem instead.
require "inspec/utils/deprecation"
module Inspec
class Tag
attr_accessor :key, :value
@ -5,6 +10,8 @@ module Inspec
def initialize(key, value)
@key = key
@value = value
Inspec.deprecate(:object_classes, "The Inspec::Tag class is deprecated. Use the Inspec::Object::Tag class from the inspec-objects Ruby library.")
end
def to_hash

View file

@ -1,3 +1,8 @@
# This class is deprecated and will be removed in the next major release of InSpec.
# Use the Inspec::Object classes from the inspec-objects rubygem instead.
require "inspec/utils/deprecation"
module Inspec
class Test
attr_accessor :qualifier, :matcher, :expectation, :skip, :negated, :variables, :only_if
@ -7,6 +12,8 @@ module Inspec
@qualifier = []
@negated = false
@variables = []
Inspec.deprecate(:object_classes, "The Inspec::Test class is deprecated. Use the Inspec::Object::Test class from the inspec-objects Ruby library.")
end
def negate!

View file

@ -1,3 +1,8 @@
# This class is deprecated and will be removed in the next major release of InSpec.
# Use the Inspec::Object classes from the inspec-objects rubygem instead.
require "inspec/utils/deprecation"
module Inspec
class Value
include ::Inspec::RubyHelper
@ -9,6 +14,8 @@ module Inspec
def initialize(qualifiers = [])
@qualifier = qualifiers
@variable = nil
Inspec.deprecate(:object_classes, "The Inspec::Value class is deprecated. Use the Inspec::Object::Value class from the inspec-objects Ruby library.")
end
def to_ruby

View file

@ -105,7 +105,7 @@ def handle_deprecations(opts_in, &block)
expectations[group_name] = expectations[:all_others]
end
# Wire up Insepc.deprecator accordingly using mocha stubbing
# Wire up Inspec.deprecator accordingly using mocha stubbing
expectations.each do |group_name, expectation|
inst = Inspec::Deprecation::Deprecator.any_instance
case expectation