Class: Inspec::Feature
- Inherits:
-
Object
- Object
- Inspec::Feature
- Defined in:
- lib/inspec/feature.rb,
lib/inspec/feature/config.rb,
lib/inspec/feature/runner.rb
Defined Under Namespace
Constant Summary collapse
- @@features_invoked =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#env_preview ⇒ Object
readonly
Returns the value of attribute env_preview.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #env_preview_value ⇒ Object
-
#initialize(feature_name, feature_yaml_opts) ⇒ Feature
constructor
A new instance of Feature.
- #no_preview? ⇒ Boolean
- #previewable? ⇒ Boolean
Constructor Details
#initialize(feature_name, feature_yaml_opts) ⇒ Feature
Returns a new instance of Feature.
14 15 16 17 18 19 20 |
# File 'lib/inspec/feature.rb', line 14 def initialize(feature_name, feature_yaml_opts) @name = feature_name feature_yaml_opts ||= {} @description = feature_yaml_opts["description"] @env_preview = feature_yaml_opts["env_preview"] @@features_invoked << feature_name end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/inspec/feature.rb', line 10 def description @description end |
#env_preview ⇒ Object (readonly)
Returns the value of attribute env_preview.
10 11 12 |
# File 'lib/inspec/feature.rb', line 10 def env_preview @env_preview end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/inspec/feature.rb', line 10 def name @name end |
Class Method Details
.list_all_invoked_features ⇒ Object
38 39 40 |
# File 'lib/inspec/feature.rb', line 38 def self.list_all_invoked_features @@features_invoked.uniq end |
Instance Method Details
#env_preview_value ⇒ Object
31 32 33 34 35 36 |
# File 'lib/inspec/feature.rb', line 31 def env_preview_value # Examples: If feature name is "inspec-test-feature" # ENV used for this feature preview would be CHEF_PREVIEW_TEST_FEATURE env_preview_feature_name = name.to_s.split("inspec-")[-1] ENV["CHEF_PREVIEW_#{env_preview_feature_name.gsub("-", "_").upcase}"] end |
#no_preview? ⇒ Boolean
27 28 29 |
# File 'lib/inspec/feature.rb', line 27 def no_preview? env_preview.nil? end |
#previewable? ⇒ Boolean
22 23 24 25 |
# File 'lib/inspec/feature.rb', line 22 def previewable? # If the feature is previewable in config (features.yaml) & has an environment value set to use previewed feature !!env_preview && !env_preview_value.nil? end |