Class: Dotenv::Merge::FreezeNode
- Inherits:
-
Ast::Merge::FreezeNodeBase
- Object
- Ast::Merge::FreezeNodeBase
- Dotenv::Merge::FreezeNode
- Defined in:
- lib/dotenv/merge/freeze_node.rb
Overview
Represents a freeze block in a dotenv file. Freeze blocks protect sections from being overwritten during merge.
Constant Summary collapse
- InvalidStructureError =
Make InvalidStructureError available as Dotenv::Merge::FreezeNode::InvalidStructureError
Ast::Merge::FreezeNodeBase::InvalidStructureError
- Location =
Make Location available as Dotenv::Merge::FreezeNode::Location
Ast::Merge::FreezeNodeBase::Location
Instance Method Summary collapse
-
#content ⇒ String
Get the content of this freeze block.
-
#env_lines ⇒ Array<EnvLine>
Get environment variable lines within the freeze block.
-
#initialize(start_line:, end_line:, analysis:, reason: nil) ⇒ FreezeNode
constructor
Initialize a new FreezeNode for dotenv.
-
#inspect ⇒ String
String representation for debugging.
-
#signature ⇒ Array
Get a signature for this freeze block.
Constructor Details
#initialize(start_line:, end_line:, analysis:, reason: nil) ⇒ FreezeNode
Initialize a new FreezeNode for dotenv
28 29 30 31 32 33 34 35 |
# File 'lib/dotenv/merge/freeze_node.rb', line 28 def initialize(start_line:, end_line:, analysis:, reason: nil) super( start_line: start_line, end_line: end_line, analysis: analysis, reason: reason ) end |
Instance Method Details
#content ⇒ String
Get the content of this freeze block
39 40 41 |
# File 'lib/dotenv/merge/freeze_node.rb', line 39 def content @lines&.map { |l| l.respond_to?(:raw) ? l.raw : l.to_s }&.join("\n") end |
#env_lines ⇒ Array<EnvLine>
Get environment variable lines within the freeze block
51 52 53 |
# File 'lib/dotenv/merge/freeze_node.rb', line 51 def env_lines @lines&.select { |l| l.respond_to?(:assignment?) && l.assignment? } || [] end |
#inspect ⇒ String
String representation for debugging
57 58 59 |
# File 'lib/dotenv/merge/freeze_node.rb', line 57 def inspect "#<#{self.class.name} lines=#{@start_line}..#{@end_line} env_vars=#{env_lines.size}>" end |
#signature ⇒ Array
Get a signature for this freeze block
45 46 47 |
# File 'lib/dotenv/merge/freeze_node.rb', line 45 def signature [:FreezeNode, content.gsub(/\s+/, " ").strip] end |