Class: Dotenv::Init::CommentAwareParser
- Inherits:
-
Parser
- Object
- Parser
- Dotenv::Init::CommentAwareParser
- Defined in:
- lib/dotenv/init/comment_aware_parser.rb
Constant Summary collapse
- LINE =
/ \A (?: # optional variable setting (?:export\s+)? # optional export ([\w\.]+) # key (?:\s*(=)\s*|:\s+?) # separator ( # optional value '(?:\'|[^'])*' # single quoted value | # or "(?:\"|[^"])*" # double quoted value | # or [^#\n\s]+ # unquoted value )? # )? # (?:\s*\#\s*(.*))? # optional comment \z /x
- COMMENT_OR_BLANK_LINE =
‘
/\A\s*(?:#.*)?\z/
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(*args) ⇒ CommentAwareParser
constructor
A new instance of CommentAwareParser.
Constructor Details
#initialize(*args) ⇒ CommentAwareParser
31 32 33 34 35 |
# File 'lib/dotenv/init/comment_aware_parser.rb', line 31 def initialize(*args) @line_number = 0 @comments = [] super end |
Instance Method Details
#call ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/dotenv/init/comment_aware_parser.rb', line 37 def call @string.split(/[\n\r]/).each do |line| parse_line(line) @line_number += 1 end @hash end |