Class: SpecForge::Attribute::Environment
- Inherits:
-
Attribute
- Object
- Attribute
- SpecForge::Attribute::Environment
- Defined in:
- lib/spec_forge/attribute/environment.rb
Overview
Represents an attribute that retrieves its value from an environment variable. This allows specs to reference environment variables dynamically.
Constant Summary collapse
- KEYWORD_REGEX =
Regular expression pattern that matches attribute keywords with this prefix. Used for identifying this attribute type during parsing. Matches case-insensitively (env., ENV., Env., etc.)
/^env\./i
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
Creates a new environment attribute by extracting the variable name.
-
#value ⇒ String?
Returns the value of the referenced environment variable.
Constructor Details
#initialize ⇒ Environment
Creates a new environment attribute by extracting the variable name
29 30 31 32 33 |
# File 'lib/spec_forge/attribute/environment.rb', line 29 def initialize(...) super @variable_name = input.sub(KEYWORD_REGEX, "") end |
Instance Method Details
#value ⇒ String?
Returns the value of the referenced environment variable
40 41 42 |
# File 'lib/spec_forge/attribute/environment.rb', line 40 def value ENV[@variable_name] end |