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
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.
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.
11 12 13 14 15 16 |
# File 'lib/inspec/feature.rb', line 11 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"] 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 |
Instance Method Details
#env_preview_value ⇒ Object
27 28 29 30 31 32 |
# File 'lib/inspec/feature.rb', line 27 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
23 24 25 |
# File 'lib/inspec/feature.rb', line 23 def no_preview? env_preview.nil? end |
#previewable? ⇒ Boolean
18 19 20 21 |
# File 'lib/inspec/feature.rb', line 18 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 |