Skip to content

Commit

Permalink
API doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Jan 25, 2024
1 parent bd45591 commit ac5bda3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/dotenv/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "optparse"

module Dotenv
# The command line interface
# The `dotenv` command line interface. Run `$ dotenv --help` to see usage.
class CLI < OptionParser
attr_reader :argv, :filenames, :overwrite

Expand Down
7 changes: 5 additions & 2 deletions lib/dotenv/environment.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module Dotenv
# This class inherits from Hash and represents the environment into which
# Dotenv will load key value pairs from a file.
# A `.env` file that will be read and parsed into a Hash
class Environment < Hash
attr_reader :filename, :overwrite

# Create a new Environment
#
# @param filename [String] the path to the file to read
# @param overwrite [Boolean] whether the parser should assume existing values will be overwritten
def initialize(filename, overwrite: false)
super()
@filename = filename
Expand Down
7 changes: 7 additions & 0 deletions lib/dotenv/log_subscriber.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require "active_support/log_subscriber"

module Dotenv
# Logs instrumented events
#
# Usage:
# require "active_support/notifications"
# require "dotenv/log_subscriber"
# Dotenv.instrumenter = ActiveSupport::Notifications
#
class LogSubscriber < ActiveSupport::LogSubscriber
attach_to :dotenv

Expand Down
6 changes: 3 additions & 3 deletions lib/dotenv/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
require "dotenv/substitutions/command" if RUBY_VERSION > "1.8.7"

module Dotenv
# Error raised when encountering a syntax error while parsing a .env file.
class FormatError < SyntaxError; end

# This class enables parsing of a string for key value pairs to be returned
# and stored in the Environment. It allows for variable substitutions and
# exporting of variables.
# Parses the `.env` file format into key/value pairs.
# It allows for variable substitutions, command substitutions, and exporting of variables.
class Parser
@substitutions =
[Dotenv::Substitutions::Variable, Dotenv::Substitutions::Command]
Expand Down

0 comments on commit ac5bda3

Please sign in to comment.