Class: DotenvSecrets
- Inherits:
-
Object
- Object
- DotenvSecrets
- Defined in:
- lib/dotenv_secrets.rb,
lib/dotenv_secrets/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(path:) ⇒ DotenvSecrets
constructor
A new instance of DotenvSecrets.
Constructor Details
#initialize(path:) ⇒ DotenvSecrets
Returns a new instance of DotenvSecrets.
4 5 6 |
# File 'lib/dotenv_secrets.rb', line 4 def initialize(path:) @path = path end |
Instance Method Details
#[](key) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dotenv_secrets.rb', line 8 def [](key) # We only want to keep the file contents in memory # until the next GC, so we don't store the lines in # an instance variable. key_line = Pathname.new(path).each_line.find do |line| line.start_with?("#{key}=") end if key_line key_line[(key.size + 1)..-1].chomp else raise EOFError, "#{key}= not found in #{path}" end end |